From a42f1477c787ab717cedc38d7ad604063bc4eac0 Mon Sep 17 00:00:00 2001 From: Jasper Herzberg Date: Wed, 21 Feb 2024 07:39:30 +0100 Subject: [PATCH 1/7] ci: print container logs on e2e fails --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 870d73a2..0731ee09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,9 +63,10 @@ jobs: run: ./tools/db/kordis-db.sh init e2edb - name: Start API and SPA containers run: | - docker run -d -p 3000:3333 -e MONGODB_URI=mongodb://host.docker.internal:27017/e2edb kordis-api:${{ github.sha }} - docker run -d -p 4200:8080 -e API_URL=http://localhost:3000 -e AUTH_PROVIDER=dev kordis-spa:${{ github.sha }} + docker run -d --name kordis-api-container -p 3000:3333 -e MONGODB_URI=mongodb://host.docker.internal:27017/e2edb kordis-api:${{ github.sha }} + docker run -d --name kordis-spa-container -p 4200:8080 -e API_URL=http://localhost:3000 -e AUTH_PROVIDER=dev kordis-spa:${{ github.sha }} - name: Run E2Es + id: e2e-tests run: npx wait-on -t 30s tcp:3000 && npx wait-on -t 30s http://localhost:4200 && npx nx e2e spa-e2e --skipInstall env: E2E_BASE_URL: http://localhost:4200/ @@ -75,6 +76,11 @@ jobs: name: e2e-test-results path: test-results/ if-no-files-found: ignore + - name: Print Container Logs + if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} + run: | + docker logs kordis-api-container + docker logs kordis-spa-container - name: SonarCloud Scan uses: sonarsource/sonarcloud-github-action@master From 422e3d14213007748edffa31c1506bc6bbaeba4c Mon Sep 17 00:00:00 2001 From: Timon Masberg Date: Fri, 16 Feb 2024 14:33:49 +0100 Subject: [PATCH 2/7] ci: make e2e run wait on correctly served api --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0731ee09..37785bf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: docker run -d --name kordis-spa-container -p 4200:8080 -e API_URL=http://localhost:3000 -e AUTH_PROVIDER=dev kordis-spa:${{ github.sha }} - name: Run E2Es id: e2e-tests - run: npx wait-on -t 30s tcp:3000 && npx wait-on -t 30s http://localhost:4200 && npx nx e2e spa-e2e --skipInstall + run: npx wait-on -t 30s http://localhost:3000/health-check && npx wait-on -t 30s http://localhost:4200 && npx nx e2e spa-e2e --skipInstall env: E2E_BASE_URL: http://localhost:4200/ - uses: actions/upload-artifact@v4 From ea679f923d776f42cfe66ff7d80a2291b912ae94 Mon Sep 17 00:00:00 2001 From: Jasper Herzberg Date: Wed, 21 Feb 2024 08:04:42 +0100 Subject: [PATCH 3/7] ci: group container logs --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37785bf3..70d81fcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,8 +79,12 @@ jobs: - name: Print Container Logs if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} run: | + echo "::group::Kordis API Container Logs" docker logs kordis-api-container + echo "::endgroup::" + echo "::group::Kordis SPA Container Logs" docker logs kordis-spa-container + echo "::endgroup::" - name: SonarCloud Scan uses: sonarsource/sonarcloud-github-action@master From 3a59b16a83c772f7841ee4af794e26a738dd06cd Mon Sep 17 00:00:00 2001 From: Jasper Herzberg Date: Thu, 22 Feb 2024 06:52:10 +0100 Subject: [PATCH 4/7] ci: set auth provider to dev for pipeline e2e tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70d81fcf..1a8e81f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: run: ./tools/db/kordis-db.sh init e2edb - name: Start API and SPA containers run: | - docker run -d --name kordis-api-container -p 3000:3333 -e MONGODB_URI=mongodb://host.docker.internal:27017/e2edb kordis-api:${{ github.sha }} + docker run -d --name kordis-api-container -p 3000:3333 -e MONGODB_URI=mongodb://host.docker.internal:27017/e2edb -e AUTH_PROVIDER=dev kordis-api:${{ github.sha }} docker run -d --name kordis-spa-container -p 4200:8080 -e API_URL=http://localhost:3000 -e AUTH_PROVIDER=dev kordis-spa:${{ github.sha }} - name: Run E2Es id: e2e-tests From 26c9343f4e46102e69d058181bada8cd96abcfa6 Mon Sep 17 00:00:00 2001 From: Jasper Herzberg Date: Thu, 22 Feb 2024 06:56:05 +0100 Subject: [PATCH 5/7] ci: increase timeout for e2e container startup --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a8e81f2..78696009 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: docker run -d --name kordis-spa-container -p 4200:8080 -e API_URL=http://localhost:3000 -e AUTH_PROVIDER=dev kordis-spa:${{ github.sha }} - name: Run E2Es id: e2e-tests - run: npx wait-on -t 30s http://localhost:3000/health-check && npx wait-on -t 30s http://localhost:4200 && npx nx e2e spa-e2e --skipInstall + run: npx wait-on -t 90s http://localhost:3000/health-check && npx wait-on -t 30s http://localhost:4200 && npx nx e2e spa-e2e --skipInstall env: E2E_BASE_URL: http://localhost:4200/ - uses: actions/upload-artifact@v4 From f6102067803cfa8d2690afe2e4de2cbce28c69a1 Mon Sep 17 00:00:00 2001 From: Jasper Herzberg Date: Thu, 22 Feb 2024 07:20:46 +0100 Subject: [PATCH 6/7] ci: use host ip to reach the mongodb container in e2e tests See https://stackoverflow.com/questions/65497331/github-actions-is-it-possible-to-call-the-runner-host-from-a-docker-container --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78696009..2969951e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: run: ./tools/db/kordis-db.sh init e2edb - name: Start API and SPA containers run: | - docker run -d --name kordis-api-container -p 3000:3333 -e MONGODB_URI=mongodb://host.docker.internal:27017/e2edb -e AUTH_PROVIDER=dev kordis-api:${{ github.sha }} + docker run -d --name kordis-api-container -p 3000:3333 -e MONGODB_URI=mongodb://172.17.0.1:27017/e2edb -e AUTH_PROVIDER=dev kordis-api:${{ github.sha }} docker run -d --name kordis-spa-container -p 4200:8080 -e API_URL=http://localhost:3000 -e AUTH_PROVIDER=dev kordis-spa:${{ github.sha }} - name: Run E2Es id: e2e-tests From f9f7cc4f7a3ac615315dfff12988a8b28c892abe Mon Sep 17 00:00:00 2001 From: Jasper Herzberg Date: Thu, 22 Feb 2024 10:43:54 +0100 Subject: [PATCH 7/7] ci: remove wrong environment from spa container in e2e tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2969951e..4f178494 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: - name: Start API and SPA containers run: | docker run -d --name kordis-api-container -p 3000:3333 -e MONGODB_URI=mongodb://172.17.0.1:27017/e2edb -e AUTH_PROVIDER=dev kordis-api:${{ github.sha }} - docker run -d --name kordis-spa-container -p 4200:8080 -e API_URL=http://localhost:3000 -e AUTH_PROVIDER=dev kordis-spa:${{ github.sha }} + docker run -d --name kordis-spa-container -p 4200:8080 -e API_URL=http://localhost:3000 kordis-spa:${{ github.sha }} - name: Run E2Es id: e2e-tests run: npx wait-on -t 90s http://localhost:3000/health-check && npx wait-on -t 30s http://localhost:4200 && npx nx e2e spa-e2e --skipInstall