Skip to content

Polish ci:build, ci:build:image, and ci:build:compose #103

Polish ci:build, ci:build:image, and ci:build:compose

Polish ci:build, ci:build:image, and ci:build:compose #103

name: ci:build:compose
on:
push:
branches:
- main
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
name: Continuous integration (build compose)
strategy:
matrix:
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}
timeout-minutes: 15
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Wait for image build workflow to succeed
uses: ArcticLampyrid/[email protected]
with:
workflow: ci:build:image.yml
sha: auto
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Bake 🧑‍🍳
uses: docker/bake-action@v4
with:
files: |
compose.yaml
set: |
patient-web.cache-from=type=gha
patient-web.output=type=docker,dest=/tmp/patient-web.tar
patient-web.tags=patients-patient-web
- name: Upload image
uses: actions/upload-artifact@v4
with:
name: images-patient-web
path: /tmp/patient-web.tar
retention-days: 1
test:
name: Continuous integration (build compose test)
needs:
- build
strategy:
matrix:
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}
timeout-minutes: 4
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Download image
uses: actions/download-artifact@v4
with:
name: images-patient-web
path: /tmp/images
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Load image
run: |
docker image load --input /tmp/images/patient-web.tar
- name: Start
run: |
docker compose up --no-build --detach
- name: Wait for database container to be healthy
run: |
timeout 60 bash -c \
'until docker inspect --format "{{json .State.Health }}" "$(docker compose ps -q patient-db)" | jq -e ".Status == \"healthy\"" ; do sleep 1; done'
- name: Wait for web port to be available
uses: ./.github/actions/is-reachable
with:
timeout: 60
port: 3000
- name: Wait for web container to be healthy
run: |
timeout 60 bash -c \
'until docker inspect --format "{{json .State.Health }}" "$(docker compose ps -q patient-web)" | jq -e ".Status == \"healthy\"" ; do sleep 1; done'
- name: Call healthcheck endpoint
run: |
timeout 60 bash -c \
'curl -f http://localhost:3000/api/healthcheck'
- name: Run healthcheck script
run: |
timeout 60 bash -c \
'node scripts/healthcheck.cjs http://localhost:3000/api/healthcheck'
- name: Stop
run: |
docker compose down