From e0ebc311d6d284dcd33c6f858fa15896219832d1 Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Mon, 9 Sep 2024 06:01:46 +0530 Subject: [PATCH] fix: Repository for Surface Tests Picks the repository from where the PR branch exists. --- .github/workflows/ci.yml | 15 ++++++++++++++- test/surface/docker/server/Dockerfile | 3 ++- test/surface/run-solid-test-suite.sh | 8 ++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d513c28c4..7df9e1371 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,12 +22,25 @@ jobs: steps: - uses: actions/checkout@v4 + + # extract repository name + - if: github.event_name == 'pull_request' + run: echo "REPO_NAME=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV + + - if: github.event_name != 'pull_request' + run: echo "REPO_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_ENV + # extract branch name - if: github.event_name == 'pull_request' run: echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV + - if: github.event_name != 'pull_request' run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + # print repository name + - name: Get repository name + run: echo 'The repository name is' $REPO_NAME + # print branch name - name: Get branch name run: echo 'The branch name is' $BRANCH_NAME @@ -45,7 +58,7 @@ jobs: - run: npm pack . - run: npm install -g solid-server-*.tgz # Run the Solid test-suite - - run: bash test/surface/run-solid-test-suite.sh $BRANCH_NAME + - run: bash test/surface/run-solid-test-suite.sh $BRANCH_NAME $REPO_NAME # TODO: The pipeline should automate publication to npm, so that the docker build gets the correct version # This job will only dockerize solid-server@latest / solid-server@ from npmjs.com! diff --git a/test/surface/docker/server/Dockerfile b/test/surface/docker/server/Dockerfile index 300739334..293be8ac3 100644 --- a/test/surface/docker/server/Dockerfile +++ b/test/surface/docker/server/Dockerfile @@ -1,7 +1,8 @@ FROM node:latest ARG BRANCH=main +ARG REPO=nodeSolidServer/node-solid-server RUN echo Testing branch ${BRANCH} of NSS -RUN git clone https://github.com/nodeSolidServer/node-solid-server +RUN git clone https://github.com/${REPO} WORKDIR node-solid-server RUN git checkout ${BRANCH} RUN git status diff --git a/test/surface/run-solid-test-suite.sh b/test/surface/run-solid-test-suite.sh index d55540bcc..1e385dc5f 100755 --- a/test/surface/run-solid-test-suite.sh +++ b/test/surface/run-solid-test-suite.sh @@ -3,8 +3,9 @@ set -e function setup { echo Branch name: $1 + echo Repoitory: $2 docker network create testnet - docker build -t server --build-arg BRANCH=$1 test/surface/docker/server + docker build -t server --build-arg BRANCH=$1 --build-arg REPO=$2 test/surface/docker/server docker build -t cookie test/surface/docker/cookie docker run -d --env-file test/surface/server-env.list --name server --network=testnet -v `pwd`:/travis -w /node-solid-server server /travis/bin/solid-test start --config-file /node-solid-server/config.json docker run -d --env-file test/surface/thirdparty-env.list --name thirdparty --network=testnet -v `pwd`/test/surface:/surface server /node-solid-server/bin/solid-test start --config-file /surface/thirdparty-config.json @@ -32,7 +33,7 @@ function waitForNss { function runTests { docker pull solidtestsuite/$1:$2 - + echo "Running $1 against server with cookie $COOKIE_server" docker run --rm --network=testnet \ --env COOKIE="$COOKIE_server" \ @@ -54,7 +55,7 @@ function runTestsFromGit { # ... teardown || true -setup $1 +setup $1 $2 waitForNss server runTests webid-provider-tests v2.0.3 runTestsFromGit solid-crud-tests v6.0.0-issue#1743 @@ -72,4 +73,3 @@ teardown # --env COOKIE_BOB="$COOKIE_thirdparty" \ # --env-file test/surface/web-access-control-tests-env.list \ # solidtestsuite/web-access-control-tests:latest /bin/bash -