test/nginx: prefix test-specific server endpoints #424
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test, Build, Publish | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| publish_image: | |
| description: 'Publish image to registry?' | |
| required: true | |
| type: boolean | |
| default: false | |
| jobs: | |
| test-misc: # quick, simple checks | |
| timeout-minutes: 2 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: docker --version | |
| - run: docker compose version | |
| - uses: actions/checkout@v5 | |
| - run: ./test/check-submodules.sh | |
| - run: ./test/test-with-pgenvblock.sh | |
| - run: sudo apt-get install shellcheck | |
| - run: ./test/check-scripts.sh | |
| - run: ./test/check-for-large-files.sh | |
| - run: ./test/check-dockerfiles.sh | |
| - run: cd test && npm clean-install | |
| - run: cd test && npm run lint | |
| - run: cd test && npm run test:github-actions | |
| test-envsub: | |
| timeout-minutes: 2 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - run: cd test/envsub && ./run-tests.sh | |
| test-nginx: | |
| timeout-minutes: 4 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version-file: test/package.json | |
| - run: cd test/nginx && npm clean-install | |
| - run: cd test/nginx && ./setup-tests.sh | |
| - run: cd test/nginx && npm run test:nginx:mocha | |
| - run: cd test/nginx && ./lint-config.sh | |
| - run: cd test/nginx && npx playwright install --with-deps chromium-headless-shell | |
| - run: cd test/nginx && npm run test:nginx:playwright | |
| - if: always() | |
| run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix nginx-ssl-selfsign | |
| - if: always() | |
| run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix nginx-ssl-upstream | |
| - if: always() | |
| run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix service | |
| - if: always() | |
| run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix enketo | |
| - if: always() | |
| run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix sentry-mock | |
| test-secrets: | |
| timeout-minutes: 2 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - run: ./test/test-secrets.sh | |
| test-service: | |
| timeout-minutes: 5 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version-file: test/package.json | |
| - run: cd test/nginx && npm clean-install | |
| - run: cd test/nginx && npm run test:service | |
| test-images: | |
| timeout-minutes: 10 | |
| needs: | |
| - test-misc | |
| - test-envsub | |
| - test-nginx | |
| - test-secrets | |
| - test-service | |
| runs-on: ubuntu-latest # TODO matrix to run on all expected versions? | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| submodules: recursive | |
| - run: ./test/check-docker-context.sh --min-size 5000 --max-size 10000 --min-count 600 --max-count 700 | |
| - name: Extract FRONTEND_VERSION | |
| run: | | |
| touch .env | |
| echo "FRONTEND_VERSION=$( | |
| docker compose config --format json | jq -r .services.nginx.build.args.FRONTEND_VERSION | |
| )" >> "$GITHUB_ENV" | |
| - run: FRONTEND_BUILD_MODE=fetch ./test/test-images.sh | |
| # Check out the current frontend version referenced by docker-compose, as it should build OK. | |
| - run: | | |
| git clone \ | |
| --depth 1 \ | |
| --branch "$FRONTEND_VERSION" \ | |
| https://github.com/getodk/central-frontend.git \ | |
| client | |
| - run: FRONTEND_BUILD_MODE=source ./test/test-images.sh | |
| - if: always() | |
| run: docker compose logs | |
| build-push-image: | |
| if: | | |
| (github.event_name == 'workflow_dispatch' && inputs.publish_image == true) || | |
| (github.event_name != 'workflow_dispatch' && ( | |
| github.ref == 'refs/heads/master' || | |
| startsWith(github.ref, 'refs/tags/v') | |
| )) | |
| needs: | |
| - test-images | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| image: [nginx, service] | |
| env: | |
| REGISTRY: ghcr.io | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| submodules: recursive | |
| - name: Log into registry ${{ env.REGISTRY }} | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Show Docker Context | |
| run: ./test/check-docker-context.sh --report | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/central-${{ matrix.image }} | |
| - name: Set up QEMU emulator for multi-arch images | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Extract FRONTEND_VERSION | |
| run: | | |
| touch .env | |
| echo "FRONTEND_VERSION=$( | |
| docker compose config --format json | jq -r .services.nginx.build.args.FRONTEND_VERSION | |
| )" >> "$GITHUB_ENV" | |
| - name: Build and push ${{ matrix.image }} Docker image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| file: ${{ matrix.image }}.dockerfile | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: 'linux/amd64,linux/arm64' | |
| build-args: | | |
| FRONTEND_BUILD_MODE=fetch | |
| FRONTEND_VERSION=${{ env.FRONTEND_VERSION }} |