|
1 | | -# This workflow will do a clean install of node dependencies, build the source |
2 | | -# code and run tests across different versions of node |
3 | | -# For more information see: |
4 | | -# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 1 | +--- |
| 2 | +name: Solid Test Suites |
5 | 3 |
|
6 | | -name: CI |
| 4 | +env: |
| 5 | + # Docker Hub digest (i.e. hash) of the used Docker Images that do not have a version tag. |
| 6 | + PUBSUB_TAG: latest@sha256:35166933e3d30bde801fd156bd2f21ebba9cdeca464ebd574c6be4cdb14d35cd |
| 7 | + COOKIE_TAG: latest@sha256:c71a3947f97d96ce09823743182582e0d919738be0d4ef5c8c55a9c22c615b91 |
7 | 8 |
|
8 | 9 | on: |
9 | 10 | push: |
10 | | - branches: [ main ] |
| 11 | + branches: |
| 12 | + - main |
11 | 13 | pull_request: |
12 | 14 | branches: [ main ] |
13 | 15 |
|
| 16 | +# Cancels all previous workflow runs for the same branch that have not yet completed. |
| 17 | +concurrency: |
| 18 | + # The concurrency group contains the workflow name and the branch name. |
| 19 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
14 | 22 | jobs: |
15 | | - build: |
| 23 | + # @TODO: Instead of building the docker image here, take a pre-build image and mount the code |
| 24 | + # (only build when the Dockerfile changes) |
| 25 | + build-docker-nextcloud: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Create docker tag from git reference |
| 29 | + # A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes. |
| 30 | + run: | |
| 31 | + echo "TAG=$(echo -n "${{ github.ref_name }}" \ |
| 32 | + | tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \ |
| 33 | + >> "${GITHUB_ENV}" |
| 34 | +
|
| 35 | + - uses: actions/cache@v3 |
| 36 | + id: cache-solid-nextcloud-docker |
| 37 | + with: |
| 38 | + path: cache/solid-nextcloud |
| 39 | + key: solid-nextcloud-docker-${{ github.sha }} |
| 40 | + |
| 41 | + - uses: actions/checkout@v3 |
16 | 42 |
|
17 | | - runs-on: ${{ matrix.os }} |
| 43 | + - uses: docker/login-action@v2 |
| 44 | + with: |
| 45 | + registry: ghcr.io |
| 46 | + username: ${{ github.actor }} |
| 47 | + password: ${{ secrets.GITHUB_TOKEN }} |
18 | 48 |
|
| 49 | + - name: Build Solid-Nextcloud Docker image |
| 50 | + run: | |
| 51 | + docker build \ |
| 52 | + --tag "solid-nextcloud:${{ env.TAG }}" \ |
| 53 | + --tag "ghcr.io/pdsinterop/solid-nextcloud:${{ env.TAG }}" \ |
| 54 | + . |
| 55 | + docker push "ghcr.io/pdsinterop/solid-nextcloud:${{ env.TAG }}" |
| 56 | + mkdir -p cache/solid-nextcloud |
| 57 | + docker image save solid-nextcloud:${{ env.TAG }} --output ./cache/solid-nextcloud/${{ github.sha }}.tar |
| 58 | +
|
| 59 | + solid-testsuite: |
19 | 60 | strategy: |
| 61 | + fail-fast: false |
20 | 62 | matrix: |
21 | | - os: [ ubuntu-latest ] |
| 63 | + test: |
| 64 | + - 'solidtestsuite/solid-crud-tests:v7.0.5' |
| 65 | + - 'solidtestsuite/web-access-control-tests:v7.1.0' |
| 66 | + - 'solidtestsuite/webid-provider-tests:v2.1.0' |
| 67 | + |
| 68 | + needs: |
| 69 | + - build-docker-nextcloud |
| 70 | + |
| 71 | + runs-on: ubuntu-latest |
22 | 72 |
|
23 | 73 | steps: |
24 | | - - uses: actions/checkout@v2 |
25 | | - # Run the Solid test-suite |
26 | | - - name: Run the Solid test suite |
27 | | - shell: 'script -q -e -c "bash {0}"' |
| 74 | + - name: Create docker tag from git reference |
| 75 | + # A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes. |
| 76 | + run: | |
| 77 | + echo "TAG=$(echo -n "${{ github.ref_name }}" \ |
| 78 | + | tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \ |
| 79 | + >> "${GITHUB_ENV}" |
| 80 | +
|
| 81 | + - uses: actions/checkout@v3 |
| 82 | + |
| 83 | + - uses: actions/cache@v3 |
| 84 | + id: cache-solid-nextcloud-docker |
| 85 | + with: |
| 86 | + path: cache/solid-nextcloud |
| 87 | + key: solid-nextcloud-docker-${{ github.sha }} |
| 88 | + |
| 89 | + - uses: docker/login-action@v2 |
| 90 | + with: |
| 91 | + registry: ghcr.io |
| 92 | + username: ${{ github.actor }} |
| 93 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + |
| 95 | + - name: Pull docker Images |
| 96 | + run: | |
| 97 | + docker image load --input ./cache/solid-nextcloud/${{ github.sha }}.tar |
| 98 | + docker pull michielbdejong/nextcloud-cookie:${{ env.COOKIE_TAG }} |
| 99 | + docker pull ${{ matrix.test }} |
| 100 | + docker pull ghcr.io/pdsinterop/php-solid-pubsub-server:${{ env.PUBSUB_TAG }} |
| 101 | +
|
| 102 | + - name: Start Docker Containers |
28 | 103 | run: | |
29 | | - bash ./run-solid-test-suite.sh |
| 104 | + docker network create testnet |
| 105 | + docker run \ |
| 106 | + --detach \ |
| 107 | + --interactive \ |
| 108 | + --name 'pubsub' \ |
| 109 | + --network=testnet \ |
| 110 | + "ghcr.io/pdsinterop/php-solid-pubsub-server:${{ env.PUBSUB_TAG }}" |
| 111 | +
|
| 112 | + source ./run-solid-test-suite.sh |
| 113 | + startSolidNextcloud 'server' "solid-nextcloud:${{ env.TAG }}" ${{ matrix.test }} |
| 114 | + startSolidNextcloud 'thirdparty' "solid-nextcloud:${{ env.TAG }}" ${{ matrix.test }} |
| 115 | +
|
| 116 | + echo "COOKIE_server=${COOKIE_server}" >> "${GITHUB_ENV}" |
| 117 | + echo "COOKIE_thirdparty=${COOKIE_thirdparty}" >> "${GITHUB_ENV}" |
| 118 | +
|
| 119 | + - name: Run tests - ${{ matrix.test }} |
| 120 | + run: | |
| 121 | + export COOKIE_server="${{ env.COOKIE_server }}" |
| 122 | + export COOKIE_thirdparty="${{ env.COOKIE_thirdparty }}" |
| 123 | +
|
| 124 | + docker run -i --rm --network=testnet \ |
| 125 | + --name tester \ |
| 126 | + --env COOKIE="$COOKIE_server" \ |
| 127 | + --env COOKIE_ALICE="$COOKIE_server" \ |
| 128 | + --env COOKIE_BOB="$COOKIE_thirdparty" \ |
| 129 | + --env-file ./env-vars-testers.list \ |
| 130 | + ${{ matrix.test }} |
0 commit comments