Skip to content

Commit

Permalink
ci(github): isolate container test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Feb 7, 2025
1 parent 989723a commit 8b7d2b8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 22 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 🚥 Container Tests

on:
workflow_call:

jobs:
integration_test:
name: 🚥 Container test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker pull ghcr.io/${{ github.repository }}:${{ github.sha }}
- name: 🚥 Run Container Tests
uses: docker://gcr.io/gcp-runtimes/container-structure-test:v1.15.0
with:
args: test --config container-structure-test.yml --image ghcr.io/${{ github.repository }}:${{ github.sha }} --verbosity debug
18 changes: 3 additions & 15 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Docker Image
name: 🐳 Docker Image

on:
push:
workflow_call:

jobs:
build:
name: 🐳 Build Docker Image
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -41,16 +42,3 @@ jobs:
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max
build-args: |
SOURCE_COMMIT=${{ github.sha }}
integration_test:
name: 🚥 Integration test
needs:
- Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker pull ghcr.io/${{ github.repository }}:${{ github.sha }}
- name: 🚥 Run Container Tests
uses: docker://gcr.io/gcp-runtimes/container-structure-test:v1.15.0
with:
args: test --config container-structure-test.yml --image ghcr.io/${{ github.repository }}:${{ github.sha }} --verbosity debug
40 changes: 33 additions & 7 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: End-to-end tests
name: 🚥 End-to-end tests

on:
push:
Expand All @@ -12,18 +12,27 @@ env:
PGDATABASE: moncomptepro
PGHOST: 127.0.0.1
PGPORT: 5432
BREVO_API_KEY: ${{ secrets.BREVO_API_KEY }}
CYPRESS_BASE_URL: http://172.18.0.1:3000
CYPRESS_MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
CYPRESS_BASE_URL: http://localhost:3000
DATABASE_URL: postgres://moncomptepro:[email protected]:5432/moncomptepro
DEBOUNCE_API_KEY: ${{ secrets.DEBOUNCE_API_KEY }}
FEATURE_SEND_MAIL: "True"
INSEE_CONSUMER_KEY: ${{ secrets.INSEE_CONSUMER_KEY }}
INSEE_CONSUMER_SECRET: ${{ secrets.INSEE_CONSUMER_SECRET }}
HOST: http://172.18.0.1:3000
HOST: http://localhost:3000
ZAMMAD_TOKEN: ${{ secrets.ZAMMAD_TOKEN }}
jobs:
build:
name: 🐳 Build Docker Image
uses: ./.github/workflows/docker.yml

container-tests:
needs: build
name: 🚥 Container
uses: ./.github/workflows/container.yml

test:
needs: build
name: 🚥 End-to-end
strategy:
# don't fail the entire matrix on failure
fail-fast: false
Expand Down Expand Up @@ -118,13 +127,30 @@ jobs:
uses: cypress-io/[email protected]
with:
wait-on: ${{ env.HOST }}/users/start-sign-in
build: npm run build:assets
start: npx dotenvx run -f cypress/e2e/${{ matrix.e2e_test }}/env.conf --overload -- npm start
build: docker pull ghcr.io/${{ github.repository }}:${{ github.sha }}
start: |
docker run \
-d \
--name proconnect \
-p 3000:3000 \
--env-file cypress/e2e/${{ matrix.e2e_test }}/env.conf \
--env INSEE_CONSUMER_KEY=${{ secrets.INSEE_CONSUMER_KEY }} \
--env INSEE_CONSUMER_SECRET=${{ secrets.INSEE_CONSUMER_SECRET }} \
--env DATABASE_URL=postgres://moncomptepro:[email protected]:5432/moncomptepro \
--env DEBOUNCE_API_KEY=${{ secrets.DEBOUNCE_API_KEY }} \
--env FEATURE_SEND_MAIL=True \
--env FEATURE_USE_ANNUAIRE_EMAILS=True \
--env FEATURE_USE_SECURE_COOKIES=True \
--env FEATURE_USE_SECURITY_RESPONSE_HEADERS=True \
ghcr.io/${{ github.repository }}:${{ github.sha }}
install: false
spec: cypress/e2e/${{ matrix.e2e_test }}/index.cy.ts
env:
NODE_ENV: production
# Store tests runs in case of failure
- if: failure()
run: |
docker logs proconnect
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand Down

0 comments on commit 8b7d2b8

Please sign in to comment.