|
| 1 | +--- |
| 2 | +name: Solid Test Suites |
| 3 | + |
| 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:b73a2a5c98d2005bb667dfc69d1c859d704366024298b9caa24ea2e182c456c2 |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + pull_request: |
| 13 | + branches: [ main ] |
| 14 | + # Allow manually triggering the workflow. |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +# Cancels all previous workflow runs for the same branch that have not yet completed. |
| 18 | +concurrency: |
| 19 | + # The concurrency group contains the workflow name and the branch name. |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + # @TODO: Instead of building the docker image here, take a pre-build image and mount the code? |
| 25 | + # (only build when the Dockerfile changes) Or only push when tagged/main? |
| 26 | + build-docker: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Create docker tag from git reference |
| 30 | + # A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes. |
| 31 | + run: | |
| 32 | + echo "TAG=$(echo -n "${{ github.ref_name }}" \ |
| 33 | + | tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \ |
| 34 | + >> "${GITHUB_ENV}" |
| 35 | +
|
| 36 | + - uses: actions/cache@v4 |
| 37 | + id: cache-solid-php-docker |
| 38 | + with: |
| 39 | + path: cache/solid-php |
| 40 | + key: solid-php-${{ github.sha }} |
| 41 | + |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - uses: docker/login-action@v3 |
| 45 | + with: |
| 46 | + registry: ghcr.io |
| 47 | + username: ${{ github.actor }} |
| 48 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + - name: Build Solid-PHP |
| 51 | + run: | |
| 52 | + docker build \ |
| 53 | + --tag "solid-php:${{ env.TAG }}" \ |
| 54 | + --tag "ghcr.io/${{ github.repository }}:${{ env.TAG }}" |
| 55 | + . |
| 56 | + docker push "ghcr.io/${{ github.repository }}:${{ env.TAG }}" |
| 57 | + mkdir -p cache/solid-php |
| 58 | + docker image save solid-php:${{ env.TAG }} --output ./cache/solid-php/${{ github.sha }}.tar |
| 59 | +
|
| 60 | + solid-testsuite: |
| 61 | + timeout-minutes: 30 |
| 62 | + needs: |
| 63 | + - build-docker |
| 64 | + |
| 65 | + runs-on: ubuntu-latest |
| 66 | + |
| 67 | + strategy: |
| 68 | + fail-fast: false |
| 69 | + |
| 70 | + steps: |
| 71 | + - name: Create docker tag from git reference |
| 72 | + # A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes. |
| 73 | + run: | |
| 74 | + echo "TAG=$(echo -n "${{ github.ref_name }}" \ |
| 75 | + | tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \ |
| 76 | + >> "${GITHUB_ENV}" |
| 77 | +
|
| 78 | + - uses: actions/checkout@v4 |
| 79 | + |
| 80 | + - uses: actions/cache@v4 |
| 81 | + id: cache-solid-php-docker |
| 82 | + with: |
| 83 | + path: cache/solid-php |
| 84 | + key: solid-php-docker-${{ github.sha }} |
| 85 | + |
| 86 | + - uses: docker/login-action@v3 |
| 87 | + with: |
| 88 | + registry: ghcr.io |
| 89 | + username: ${{ github.actor }} |
| 90 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + |
| 92 | + # FIXME: The `docker pull` should be moved to a previous step and cached |
| 93 | + - name: Pull docker Images |
| 94 | + run: | |
| 95 | + docker image load --input ./cache/solid-php/${{ github.sha }}.tar |
| 96 | + docker pull ${{ matrix.test }} |
| 97 | + docker pull ghcr.io/pdsinterop/php-solid-pubsub-server:${{ env.PUBSUB_TAG }} |
| 98 | +
|
| 99 | + - name: Start Docker Containers |
| 100 | + run: | |
| 101 | + ./tests/testsuite/run-solid-test-suite.sh |
0 commit comments