From 4789ce3d523975fb10f736d3180e576d03e176e8 Mon Sep 17 00:00:00 2001 From: make-github-pseudonymous-again <5165674+make-github-pseudonymous-again@users.noreply.github.com> Date: Sat, 8 Feb 2025 20:40:16 +0100 Subject: [PATCH] :building_construction: config(cd): Do `ci:test:deploy` in `ci:build:image:. This fixes #900 and fixes #1110. --- .github/workflows/ci:build:image.yml | 76 ++++++++++++++++++++ .github/workflows/ci:test:deploy.yml | 104 --------------------------- 2 files changed, 76 insertions(+), 104 deletions(-) delete mode 100644 .github/workflows/ci:test:deploy.yml diff --git a/.github/workflows/ci:build:image.yml b/.github/workflows/ci:build:image.yml index c4862e20e..01e9e35d0 100644 --- a/.github/workflows/ci:build:image.yml +++ b/.github/workflows/ci:build:image.yml @@ -365,3 +365,79 @@ jobs: - name: Stop run: | docker compose down + + + test-deploy: + name: Continuous integration (test deploy) + + needs: + - build + + strategy: + matrix: + platform: + - ubuntu-latest + port: + - 3000 + - 3123 + + runs-on: ${{ matrix.platform }} + + timeout-minutes: 15 + + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4 + + - name: Start + env: + ROOT_URL: http://localhost:${{ matrix.port }} + PORT: ${{ matrix.port }} + IMAGE_TAG: sha-${{ github.sha }} + run: | + docker compose \ + --env-file .env -f compose.yaml \ + --env-file .deploy/ghcr.io/.env -f .deploy/ghcr.io/compose.yaml \ + up --no-build --detach + + - id: patient-db-container + uses: ./.github/actions/docker/compose/container + with: + service: patient-db + + - name: Wait for database container to be healthy + uses: ./.github/actions/docker/container/is-healthy + with: + container: ${{ steps.patient-db-container.outputs.id }} + timeout: 60 + + - name: Wait for web port to be available + uses: ./.github/actions/network/is-reachable + with: + timeout: 60 + port: ${{ matrix.port }} + + - id: patient-web-container + uses: ./.github/actions/docker/compose/container + with: + service: patient-web + + - name: Wait for web container to be healthy + uses: ./.github/actions/docker/container/is-healthy + with: + container: ${{ steps.patient-web-container.outputs.id }} + timeout: 60 + + - name: Call healthcheck endpoint + run: | + timeout 60 bash -c \ + 'curl -f http://localhost:${{ matrix.port }}/api/healthcheck' + + - name: Run healthcheck script + run: | + timeout 60 bash -c \ + 'node scripts/healthcheck.cjs http://localhost:${{ matrix.port }}/api/healthcheck' + + - name: Stop + run: | + docker compose down diff --git a/.github/workflows/ci:test:deploy.yml b/.github/workflows/ci:test:deploy.yml deleted file mode 100644 index df32cec29..000000000 --- a/.github/workflows/ci:test:deploy.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: ci:test:deploy - -on: - push: - branches: - - main - pull_request: - merge_group: - workflow_run: - workflows: - - ci:build:image - types: - - completed - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - - build: - name: Continuous integration (test deploy) - strategy: - matrix: - platform: - - ubuntu-latest - port: - - 3000 - - 3123 - - runs-on: ${{ matrix.platform }} - - timeout-minutes: 30 - - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v4 - - - name: Fail job if triggering workflow did not succeed - if: github.event_name == 'workflow_run' && github.event.workflow_run.conclusion != 'success' - uses: actions/github-script@v7 - with: - script: | - core.setFailed('ci:build:image did not succeed') - - - name: Wait for image build workflow to succeed - if: github.event_name != 'workflow_run' - uses: ArcticLampyrid/action-wait-for-workflow@v1.2.0 - with: - workflow: ci:build:image.yml - sha: auto - - - name: Start - env: - ROOT_URL: http://localhost:${{ matrix.port }} - PORT: ${{ matrix.port }} - IMAGE_TAG: sha-${{ github.sha }} - run: | - docker compose \ - --env-file .env -f compose.yaml \ - --env-file .deploy/ghcr.io/.env -f .deploy/ghcr.io/compose.yaml \ - up --no-build --detach - - - id: patient-db-container - uses: ./.github/actions/docker/compose/container - with: - service: patient-db - - - name: Wait for database container to be healthy - uses: ./.github/actions/docker/container/is-healthy - with: - container: ${{ steps.patient-db-container.outputs.id }} - timeout: 60 - - - name: Wait for web port to be available - uses: ./.github/actions/network/is-reachable - with: - timeout: 60 - port: ${{ matrix.port }} - - - id: patient-web-container - uses: ./.github/actions/docker/compose/container - with: - service: patient-web - - - name: Wait for web container to be healthy - uses: ./.github/actions/docker/container/is-healthy - with: - container: ${{ steps.patient-web-container.outputs.id }} - timeout: 60 - - - name: Call healthcheck endpoint - run: | - timeout 60 bash -c \ - 'curl -f http://localhost:${{ matrix.port }}/api/healthcheck' - - - name: Run healthcheck script - run: | - timeout 60 bash -c \ - 'node scripts/healthcheck.cjs http://localhost:${{ matrix.port }}/api/healthcheck' - - - name: Stop - run: | - docker compose down