From 56907ec166e7fce15f652c5d7af10c1f5a38e5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szil=C3=A1rd=20D=C3=B3r=C3=B3?= Date: Mon, 19 Jun 2023 12:17:34 +0200 Subject: [PATCH 1/8] chore: use the same testing method for local and CI --- .github/workflows/test.yaml | 50 +------------------------------------ 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 168de7072..be8e01d26 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,52 +19,6 @@ jobs: test: name: Service tests runs-on: ubuntu-latest - services: - postgres: - # TODO bump - image: nhost/postgres:12-v0.0.6 - env: - POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} - options: >- - --restart always - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - graphql-engine: - image: hasura/graphql-engine:v2.15.2 - env: - HASURA_GRAPHQL_ENABLE_TELEMETRY: 'false' - HASURA_GRAPHQL_ADMIN_SECRET: ${{ env.HASURA_GRAPHQL_ADMIN_SECRET }} - HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:${{ env.POSTGRES_PASSWORD }}@postgres:5432/postgres - HASURA_GRAPHQL_JWT_SECRET: '{"type": "${{ env.JWT_ALGORITHM }}", "key": "${{ env.JWT_KEY }}"}' - options: >- - --restart always - mailhog: - image: mailhog/mailhog - env: - SMTP_HOST: mailhog - SMTP_PORT: 1025 - SMTP_PASS: password - SMTP_USER: user - SMTP_SECURE: 'false' - SMTP_SENDER: hbp@hbp.com - container: - image: node:16 - env: - AUTH_PORT: 4000 - HASURA_GRAPHQL_ADMIN_SECRET: ${{ env.HASURA_GRAPHQL_ADMIN_SECRET }} - HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:${{env.POSTGRES_PASSWORD }}@postgres:5432/postgres - HASURA_GRAPHQL_GRAPHQL_URL: 'http://graphql-engine:8080/v1/graphql' - HASURA_GRAPHQL_JWT_SECRET: '{"type": "${{ env.JWT_ALGORITHM }}", "key": "${{ env.JWT_KEY }}"}' - AUTH_SMTP_HOST: mailhog - AUTH_SMTP_PORT: 1025 - AUTH_SMTP_USER: user - AUTH_SMTP_PASS: password - AUTH_SMTP_SENDER: hasura-auth@example.com - AUTH_SMTP_SECURE: false - AUTH_CLIENT_URL: http://localhost:3000 - options: --hostname hasura-auth steps: - uses: actions/checkout@v3 @@ -72,9 +26,7 @@ jobs: uses: ./.github/actions/install-dependencies - name: Run Jest tests - # env: - # AUTH_LOCALE_ALLOWED_LOCALES: en,fr - run: pnpm run test --coverage + run: make test - name: Upload test results uses: actions/upload-artifact@v1 with: From 8409a86d1984faf6d38d09999c4cef673f810f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szil=C3=A1rd=20D=C3=B3r=C3=B3?= Date: Mon, 19 Jun 2023 12:25:04 +0200 Subject: [PATCH 2/8] fix: don't break CI --- .github/workflows/test.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index be8e01d26..e9fa60250 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,8 +25,10 @@ jobs: - name: Install Node and dependencies uses: ./.github/actions/install-dependencies - - name: Run Jest tests + - name: Run tests + shell: bash run: make test + - name: Upload test results uses: actions/upload-artifact@v1 with: From 42c94e3c2a784a6bdadeb4189cf93e69c201675e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szil=C3=A1rd=20D=C3=B3r=C3=B3?= Date: Mon, 19 Jun 2023 12:51:53 +0200 Subject: [PATCH 3/8] fix: don't break CI --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 910a15913..50ab6031d 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ test: check-port install dev-env-up ## Run end-to-end tests. .PHONY: check-port check-port: - [[ -z $$(lsof -t -i tcp:$(PORT)) ]] || (echo "The port $(PORT) is already in use"; exit 1;) + [ -z $$(lsof -t -i tcp:$(PORT)) ] || (echo "The port $(PORT) is already in use"; exit 1;) .PHONY: docgen docgen: check-port install dev-env-up ## Generate the openapi.json file. From b70a8b86145fb8b2c59f35f1748cf2db1810550f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szil=C3=A1rd=20D=C3=B3r=C3=B3?= Date: Mon, 19 Jun 2023 12:58:06 +0200 Subject: [PATCH 4/8] fix: use correct env vars --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e9fa60250..ca4326832 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,9 +11,9 @@ on: env: HASURA_GRAPHQL_ADMIN_SECRET: test_secret_key - JWT_ALGORITHM: HS256 - JWT_KEY: never_use_this_secret_key_in_production_this_is_only_for_CI_testing_098hu32r4389ufb4n38994321 + HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256", "key":"never_use_this_secret_key_in_production_this_is_only_for_CI_testing_098hu32r4389ufb4n38994321","issuer":"hasura-auth"}' POSTGRES_PASSWORD: postgrespassword + HASURA_GRAPHQL_GRAPHQL_URL: http://localhost:8080/v1/graphql jobs: test: From 8bfe6261b39f453b4d1c4a819a6b82e0336add26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szil=C3=A1rd=20D=C3=B3r=C3=B3?= Date: Mon, 19 Jun 2023 13:10:11 +0200 Subject: [PATCH 5/8] fix: don't break CI --- .github/workflows/test.yaml | 3 ++- Makefile | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ca4326832..9bfd29808 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,9 +10,10 @@ on: - '!*.md' env: + POSTGRES_PASSWORD: postgrespassword HASURA_GRAPHQL_ADMIN_SECRET: test_secret_key HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256", "key":"never_use_this_secret_key_in_production_this_is_only_for_CI_testing_098hu32r4389ufb4n38994321","issuer":"hasura-auth"}' - POSTGRES_PASSWORD: postgrespassword + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@localhost:5432/postgres HASURA_GRAPHQL_GRAPHQL_URL: http://localhost:8080/v1/graphql jobs: diff --git a/Makefile b/Makefile index 50ab6031d..994a3f8b2 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ check-port: .PHONY: docgen docgen: check-port install dev-env-up ## Generate the openapi.json file. AUTH_CLIENT_URL=https://my-app.com AUTH_LOG_LEVEL=error AUTH_ACCESS_CONTROL_ALLOWED_REDIRECT_URLS= pnpm dev & - while [[ "$$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:$(PORT)/healthz)" != "200" ]]; do sleep 1; done + while [ "$$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:$(PORT)/healthz)" != "200" ]; do sleep 1; done curl http://localhost:$(PORT)/openapi.json | json_pp > docs/openapi.json kill -9 $$(lsof -t -i tcp:$(PORT)) make dev-env-down @@ -57,7 +57,7 @@ build: .PHONY: dev-env-down dev-env-up: ## Start required services (Hasura, Postgres, Mailhog). docker-compose -f docker-compose.yaml up -d - while [[ "$$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/healthz)" != "200" ]]; do sleep 1; done + while [ "$$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/healthz)" != "200" ]; do sleep 1; done @echo "Hasura is ready"; From 4dd912d1c3a56056bea733c12716b9aad77772a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szil=C3=A1rd=20D=C3=B3r=C3=B3?= Date: Mon, 19 Jun 2023 13:12:55 +0200 Subject: [PATCH 6/8] fix: use correct env vars --- .github/workflows/test.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9bfd29808..698578491 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,6 +15,12 @@ env: HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256", "key":"never_use_this_secret_key_in_production_this_is_only_for_CI_testing_098hu32r4389ufb4n38994321","issuer":"hasura-auth"}' HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@localhost:5432/postgres HASURA_GRAPHQL_GRAPHQL_URL: http://localhost:8080/v1/graphql + AUTH_SMTP_HOST: localhost + AUTH_SMTP_PORT: 1025 + AUTH_SMTP_USER: user + AUTH_SMTP_PASS: password + AUTH_SMTP_SENDER: hasura-auth@example.com + AUTH_SMTP_SECURE: false jobs: test: From 712e4b60f9487f41d62f9ad930eaa3be3226032e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szil=C3=A1rd=20D=C3=B3r=C3=B3?= Date: Mon, 19 Jun 2023 13:16:39 +0200 Subject: [PATCH 7/8] fix: use correct env vars --- .github/workflows/test.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 698578491..5f768d007 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,12 +15,16 @@ env: HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256", "key":"never_use_this_secret_key_in_production_this_is_only_for_CI_testing_098hu32r4389ufb4n38994321","issuer":"hasura-auth"}' HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@localhost:5432/postgres HASURA_GRAPHQL_GRAPHQL_URL: http://localhost:8080/v1/graphql + AUTH_SERVER_URL: http://localhost:4000 + AUTH_CLIENT_URL: http://localhost:3000 AUTH_SMTP_HOST: localhost AUTH_SMTP_PORT: 1025 AUTH_SMTP_USER: user AUTH_SMTP_PASS: password AUTH_SMTP_SENDER: hasura-auth@example.com AUTH_SMTP_SECURE: false + AUTH_EMAIL_PASSWORDLESS_ENABLED: true + AUTH_LOG_LEVEL: info jobs: test: From 71f0883b0d488ffe853e9f2209d0fbce394eea55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szil=C3=A1rd=20D=C3=B3r=C3=B3?= Date: Mon, 19 Jun 2023 13:22:34 +0200 Subject: [PATCH 8/8] chore: remove artifact upload step from CI --- .github/workflows/test.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5f768d007..c30bcb64d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -39,9 +39,3 @@ jobs: - name: Run tests shell: bash run: make test - - - name: Upload test results - uses: actions/upload-artifact@v1 - with: - name: coverage - path: coverage