From 3b2cc63c4af24cc8e5eadbb083cb0e4d98eb0fa8 Mon Sep 17 00:00:00 2001 From: aehnh Date: Wed, 5 Feb 2025 12:14:13 +0100 Subject: [PATCH 1/5] combine deploy and test workflow --- ...tly.yml => deploy-playground-and-test.yml} | 108 ++++++++++++++++-- .github/workflows/deploy-playground.yml | 101 ---------------- .../{e2e-test-nightly.yml => test-all.yml} | 4 +- 3 files changed, 101 insertions(+), 112 deletions(-) rename .github/workflows/{e2e-test-commitly.yml => deploy-playground-and-test.yml} (65%) delete mode 100644 .github/workflows/deploy-playground.yml rename .github/workflows/{e2e-test-nightly.yml => test-all.yml} (99%) diff --git a/.github/workflows/e2e-test-commitly.yml b/.github/workflows/deploy-playground-and-test.yml similarity index 65% rename from .github/workflows/e2e-test-commitly.yml rename to .github/workflows/deploy-playground-and-test.yml index ea360b445..0cd1147a9 100644 --- a/.github/workflows/e2e-test-commitly.yml +++ b/.github/workflows/deploy-playground-and-test.yml @@ -1,19 +1,109 @@ -name: Commitly End-to-End testing check for Playground Apps +name: Deploy Playground Apps to Vercel and Test on React env: - BRANCH_NAME_RAW: ${{ github.event.workflow_run.head_branch || github.ref_name }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + BRANCH_NAME_RAW: ${{ github.head_ref || github.ref_name }} on: - workflow_dispatch: - workflow_run: - workflows: ["Deploy Playground Apps to Vercel"] - types: - - completed - conclusion: success + pull_request: + push: + branches: + - develop jobs: - e2e-tests: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + + - name: Cache node modules + id: cache-npm + uses: actions/cache@v3 + env: + cache-name: cache-node-modules + with: + path: | + ~/.npm + ./node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-force-1 + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + name: Install Dependencies + run: | + npm i + npm install lerna + npm install vercel@33.2.0 + npm list + + - name: Check ESLint Errors + run: npm run lint + + - name: Check Prettier Formatting + run: npm run prettier:check + + - name: Build SDKs + run: | + npm run build + npm run build:bundler:local + + - name: Normalize branch name + run: | + echo "BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-')" >> "$GITHUB_ENV" + shell: bash + + - name: Deploy react playground to Vercel + run: | + npx vercel link --yes --project react-playground --scope corbado -t $VERCEL_TOKEN + npx vercel pull -t $VERCEL_TOKEN + npx vercel build -t $VERCEL_TOKEN + url="$(npx vercel deploy --prebuilt -t ${{ secrets.VERCEL_TOKEN }})" + npx vercel alias -S corbado -t ${{ secrets.VERCEL_TOKEN }} "$url" $BRANCH_NAME.react.playground.corbado.io + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_REACT_PLAYGROUND }} + + - name: Deploy connect next playground to Vercel + run: | + npx vercel link --yes --project connect-next-playground --scope corbado -t $VERCEL_TOKEN + npx vercel pull --environment=preview -t $VERCEL_TOKEN + npx vercel build -t $VERCEL_TOKEN + url="$(npx vercel deploy --prebuilt -t ${{ secrets.VERCEL_TOKEN }})" + npx vercel alias -S corbado -t ${{ secrets.VERCEL_TOKEN }} "$url" $BRANCH_NAME.connect-next.playground.corbado.io + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_CONNECT_NEXT_PLAYGROUND }} + + - name: Deploy web-js playground to Vercel + run: | + npx vercel link --yes --project web-js-playground --scope corbado -t $VERCEL_TOKEN + npx vercel pull -t $VERCEL_TOKEN + npx vercel build -t $VERCEL_TOKEN + url="$(npx vercel deploy --prebuilt -t ${{ secrets.VERCEL_TOKEN }})" + npx vercel alias -S corbado -t ${{ secrets.VERCEL_TOKEN }} "$url" $BRANCH_NAME.web-js.playground.corbado.io + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_WEB_JS_PLAYGROUND }} + + - name: Deploy web-js-script playground to Vercel + run: | + npx vercel link --yes --project web-js-script-playground --scope corbado -t $VERCEL_TOKEN + npx vercel pull -t $VERCEL_TOKEN + npx vercel build -t $VERCEL_TOKEN + url="$(npx vercel deploy --prebuilt -t ${{ secrets.VERCEL_TOKEN }})" + npx vercel alias -S corbado -t ${{ secrets.VERCEL_TOKEN }} "$url" $BRANCH_NAME.web-js-script.playground.corbado.io + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_WEB_JS_SCRIPT_PLAYGROUND }} + + test: timeout-minutes: 60 runs-on: ubuntu-20.04 + steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/deploy-playground.yml b/.github/workflows/deploy-playground.yml deleted file mode 100644 index 6bd5137cd..000000000 --- a/.github/workflows/deploy-playground.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Deploy Playground Apps to Vercel -env: - VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - BRANCH_NAME_RAW: ${{ github.head_ref || github.ref_name }} - -on: - pull_request: - push: - branches: - - develop - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - - - name: Cache node modules - id: cache-npm - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - with: - path: | - ~/.npm - ./node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-force-1 - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - name: Install Dependencies - run: | - npm i - npm install lerna - npm install vercel@33.2.0 - npm list - - - name: Check ESLint Errors - run: npm run lint - - - name: Check Prettier Formatting - run: npm run prettier:check - - - name: Build SDKs - run: | - npm run build - npm run build:bundler:local - - - name: Normalize branch name - run: | - echo "BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-')" >> "$GITHUB_ENV" - shell: bash - - - name: Deploy react playground to Vercel - run: | - npx vercel link --yes --project react-playground --scope corbado -t $VERCEL_TOKEN - npx vercel pull -t $VERCEL_TOKEN - npx vercel build -t $VERCEL_TOKEN - url="$(npx vercel deploy --prebuilt -t ${{ secrets.VERCEL_TOKEN }})" - npx vercel alias -S corbado -t ${{ secrets.VERCEL_TOKEN }} "$url" $BRANCH_NAME.react.playground.corbado.io - env: - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_REACT_PLAYGROUND }} - - - name: Deploy connect next playground to Vercel - run: | - npx vercel link --yes --project connect-next-playground --scope corbado -t $VERCEL_TOKEN - npx vercel pull --environment=preview -t $VERCEL_TOKEN - npx vercel build -t $VERCEL_TOKEN - url="$(npx vercel deploy --prebuilt -t ${{ secrets.VERCEL_TOKEN }})" - npx vercel alias -S corbado -t ${{ secrets.VERCEL_TOKEN }} "$url" $BRANCH_NAME.connect-next.playground.corbado.io - env: - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_CONNECT_NEXT_PLAYGROUND }} - - - name: Deploy web-js playground to Vercel - run: | - npx vercel link --yes --project web-js-playground --scope corbado -t $VERCEL_TOKEN - npx vercel pull -t $VERCEL_TOKEN - npx vercel build -t $VERCEL_TOKEN - url="$(npx vercel deploy --prebuilt -t ${{ secrets.VERCEL_TOKEN }})" - npx vercel alias -S corbado -t ${{ secrets.VERCEL_TOKEN }} "$url" $BRANCH_NAME.web-js.playground.corbado.io - env: - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_WEB_JS_PLAYGROUND }} - - - name: Deploy web-js-script playground to Vercel - run: | - npx vercel link --yes --project web-js-script-playground --scope corbado -t $VERCEL_TOKEN - npx vercel pull -t $VERCEL_TOKEN - npx vercel build -t $VERCEL_TOKEN - url="$(npx vercel deploy --prebuilt -t ${{ secrets.VERCEL_TOKEN }})" - npx vercel alias -S corbado -t ${{ secrets.VERCEL_TOKEN }} "$url" $BRANCH_NAME.web-js-script.playground.corbado.io - env: - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_WEB_JS_SCRIPT_PLAYGROUND }} diff --git a/.github/workflows/e2e-test-nightly.yml b/.github/workflows/test-all.yml similarity index 99% rename from .github/workflows/e2e-test-nightly.yml rename to .github/workflows/test-all.yml index 6ba95ca47..193ff9163 100644 --- a/.github/workflows/e2e-test-nightly.yml +++ b/.github/workflows/test-all.yml @@ -1,4 +1,4 @@ -name: Nightly End-to-End testing check for Playground Apps +name: Test on All Platforms env: BRANCH_NAME_RAW: ${{ github.head_ref || github.ref_name }} @@ -10,7 +10,7 @@ on: - cron: '30 18 * * *' # 7:30 PM CET / 8:30 PM CEST jobs: - prepare: + test: timeout-minutes: 60 runs-on: ubuntu-20.04 steps: From 60cf21dbbb6571f306a5856745133bffe73950c5 Mon Sep 17 00:00:00 2001 From: aehnh Date: Wed, 5 Feb 2025 12:41:05 +0100 Subject: [PATCH 2/5] fail github action if any of the tests failed --- .../workflows/deploy-playground-and-test.yml | 37 +++++++++++++- .github/workflows/test-all.yml | 51 +++++++++++++++++-- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-playground-and-test.yml b/.github/workflows/deploy-playground-and-test.yml index 0cd1147a9..1ece7a14c 100644 --- a/.github/workflows/deploy-playground-and-test.yml +++ b/.github/workflows/deploy-playground-and-test.yml @@ -172,7 +172,12 @@ jobs: cd packages/tests-e2e BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-') export PLAYWRIGHT_TEST_URL="https://$BRANCH_NAME.react.playground.corbado.io" - PLAYWRIGHT_TEST_URL=$PLAYWRIGHT_TEST_URL npx playwright test --config=playwright.config.complete.ts + set +e + npx playwright test --config=playwright.config.complete.ts + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + echo "COMPLETE_REACT_FAILED=true" >> $GITHUB_ENV + fi env: PLAYWRIGHT_NUM_CORES: 4 PLAYWRIGHT_JWT_TOKEN: ${{ secrets.PLAYWRIGHT_JWT_TOKEN }} @@ -215,7 +220,12 @@ jobs: cd packages/tests-e2e BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-') export PLAYWRIGHT_TEST_URL="https://$BRANCH_NAME.connect-next.playground.corbado.io" - PLAYWRIGHT_TEST_URL=$PLAYWRIGHT_TEST_URL npx playwright test --config=playwright.config.connect.ts + set +e + npx playwright test --config=playwright.config.complete.ts + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + echo "CONNECT_REACT_FAILED=true" >> $GITHUB_ENV + fi env: PLAYWRIGHT_NUM_CORES: 4 BACKEND_API_BASIC_AUTH: ${{ secrets.BACKEND_API_BASIC_AUTH }} @@ -250,3 +260,26 @@ jobs: TIMESTAMP=$(date +%s000) LOG_EVENT_JSON="[{\"timestamp\":$TIMESTAMP,\"message\":\"$SUMMARY\"}]" aws logs put-log-events --log-group-name "test-results-board" --log-stream-name "$LOG_STREAM_NAME" --log-events "$LOG_EVENT_JSON" + + - name: Aggregate results + run: | + FAILED_STEPS="" + if [ "${COMPLETE_REACT_FAILED}" = "true" ]; then + FAILED_STEPS="${FAILED_STEPS} Complete-React" + fi + if [ "${COMPLETE_WEBJS_FAILED}" = "true" ]; then + FAILED_STEPS="${FAILED_STEPS} Complete-WebJs" + fi + if [ "${COMPLETE_WEBJSSCRIPT_FAILED}" = "true" ]; then + FAILED_STEPS="${FAILED_STEPS} Complete-WebJsScript" + fi + if [ "${CONNECT_REACT_FAILED}" = "true" ]; then + FAILED_STEPS="${FAILED_STEPS} Connect-React" + fi + + if [ -n "$FAILED_STEPS" ]; then + echo "The following test steps have failed: $FAILED_STEPS" + exit 1 + else + echo "All tests passed." + fi diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index 193ff9163..52941c765 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -81,7 +81,12 @@ jobs: cd packages/tests-e2e BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-') export PLAYWRIGHT_TEST_URL="https://$BRANCH_NAME.react.playground.corbado.io" - PLAYWRIGHT_TEST_URL=$PLAYWRIGHT_TEST_URL npx playwright test --config=playwright.config.complete.ts + set +e + npx playwright test --config=playwright.config.complete.ts + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + echo "COMPLETE_REACT_FAILED=true" >> $GITHUB_ENV + fi env: PLAYWRIGHT_NUM_CORES: 4 PLAYWRIGHT_JWT_TOKEN: ${{ secrets.PLAYWRIGHT_JWT_TOKEN }} @@ -124,7 +129,12 @@ jobs: cd packages/tests-e2e BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-') export PLAYWRIGHT_TEST_URL="https://$BRANCH_NAME.web-js.playground.corbado.io" - PLAYWRIGHT_TEST_URL=$PLAYWRIGHT_TEST_URL npx playwright test --config=playwright.config.complete.ts + set +e + npx playwright test --config=playwright.config.complete.ts + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + echo "COMPLETE_WEBJS_FAILED=true" >> $GITHUB_ENV + fi env: PLAYWRIGHT_NUM_CORES: 4 PLAYWRIGHT_JWT_TOKEN: ${{ secrets.PLAYWRIGHT_JWT_TOKEN }} @@ -167,7 +177,12 @@ jobs: cd packages/tests-e2e BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-') export PLAYWRIGHT_TEST_URL="https://$BRANCH_NAME.web-js-script.playground.corbado.io" - PLAYWRIGHT_TEST_URL=$PLAYWRIGHT_TEST_URL npx playwright test --config=playwright.config.complete.ts + set +e + npx playwright test --config=playwright.config.complete.ts + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + echo "COMPLETE_WEBJSSCRIPT_FAILED=true" >> $GITHUB_ENV + fi env: PLAYWRIGHT_NUM_CORES: 4 PLAYWRIGHT_JWT_TOKEN: ${{ secrets.PLAYWRIGHT_JWT_TOKEN }} @@ -210,7 +225,12 @@ jobs: cd packages/tests-e2e BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-') export PLAYWRIGHT_TEST_URL="https://$BRANCH_NAME.connect-next.playground.corbado.io" - PLAYWRIGHT_TEST_URL=$PLAYWRIGHT_TEST_URL npx playwright test --config=playwright.config.connect.ts + set +e + npx playwright test --config=playwright.config.connect.ts + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + echo "CONNECT_REACT_FAILED=true" >> $GITHUB_ENV + fi env: PLAYWRIGHT_NUM_CORES: 4 BACKEND_API_BASIC_AUTH: ${{ secrets.BACKEND_API_BASIC_AUTH }} @@ -245,3 +265,26 @@ jobs: TIMESTAMP=$(date +%s000) LOG_EVENT_JSON="[{\"timestamp\":$TIMESTAMP,\"message\":\"$SUMMARY\"}]" aws logs put-log-events --log-group-name "test-results-board" --log-stream-name "$LOG_STREAM_NAME" --log-events "$LOG_EVENT_JSON" + + - name: Aggregate results + run: | + FAILED_STEPS="" + if [ "${COMPLETE_REACT_FAILED}" = "true" ]; then + FAILED_STEPS="${FAILED_STEPS} Complete-React" + fi + if [ "${COMPLETE_WEBJS_FAILED}" = "true" ]; then + FAILED_STEPS="${FAILED_STEPS} Complete-WebJs" + fi + if [ "${COMPLETE_WEBJSSCRIPT_FAILED}" = "true" ]; then + FAILED_STEPS="${FAILED_STEPS} Complete-WebJsScript" + fi + if [ "${CONNECT_REACT_FAILED}" = "true" ]; then + FAILED_STEPS="${FAILED_STEPS} Connect-React" + fi + + if [ -n "$FAILED_STEPS" ]; then + echo "The following test steps have failed: $FAILED_STEPS" + exit 1 + else + echo "All tests passed." + fi From 812fd688e30298842a18816cd4269b6ee58d2ff1 Mon Sep 17 00:00:00 2001 From: aehnh Date: Wed, 5 Feb 2025 12:43:13 +0100 Subject: [PATCH 3/5] enforce sequential execution of deploy and test jobs --- .github/workflows/deploy-playground-and-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-playground-and-test.yml b/.github/workflows/deploy-playground-and-test.yml index 1ece7a14c..0924d5e32 100644 --- a/.github/workflows/deploy-playground-and-test.yml +++ b/.github/workflows/deploy-playground-and-test.yml @@ -101,6 +101,7 @@ jobs: VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_WEB_JS_SCRIPT_PLAYGROUND }} test: + needs: deploy timeout-minutes: 60 runs-on: ubuntu-20.04 From 4278fbba4de5c3499dc3cebbf411edb664821400 Mon Sep 17 00:00:00 2001 From: aehnh Date: Wed, 5 Feb 2025 13:25:28 +0100 Subject: [PATCH 4/5] fix configuraiton file for commitly connect tests --- .github/workflows/deploy-playground-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-playground-and-test.yml b/.github/workflows/deploy-playground-and-test.yml index 0924d5e32..d88c8bd94 100644 --- a/.github/workflows/deploy-playground-and-test.yml +++ b/.github/workflows/deploy-playground-and-test.yml @@ -222,7 +222,7 @@ jobs: BRANCH_NAME=$(echo $BRANCH_NAME_RAW | tr '/_' '-') export PLAYWRIGHT_TEST_URL="https://$BRANCH_NAME.connect-next.playground.corbado.io" set +e - npx playwright test --config=playwright.config.complete.ts + npx playwright test --config=playwright.config.connect.ts EXIT_CODE=$? if [ $EXIT_CODE -ne 0 ]; then echo "CONNECT_REACT_FAILED=true" >> $GITHUB_ENV From 973ecbfb73bdba1d56df20bf699101149caa0323 Mon Sep 17 00:00:00 2001 From: aehnh Date: Wed, 5 Feb 2025 14:03:36 +0100 Subject: [PATCH 5/5] remove incorrect test --- .../tests-e2e/src/connect/scenarios/login.spec.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/packages/tests-e2e/src/connect/scenarios/login.spec.ts b/packages/tests-e2e/src/connect/scenarios/login.spec.ts index b27092e9d..a90f528c9 100644 --- a/packages/tests-e2e/src/connect/scenarios/login.spec.ts +++ b/packages/tests-e2e/src/connect/scenarios/login.spec.ts @@ -77,19 +77,6 @@ test.describe('login component (with invitation token, with passkeys)', () => { await model.login.repeatedlyFailPasskeyInput(); }); - test('inaccessible passkey on login', async ({ model }) => { - await model.home.logout(); - await model.expectScreen(ScreenNames.InitLoginOneTap); - - await model.authenticator.clearCredentials(); - await model.storage.clearLocalStorageAndCookies(); - await model.storage.loadInvitationToken(); - await model.expectScreen(ScreenNames.InitLogin); - - await model.login.submitEmail(model.email, false); - await model.expectScreen(ScreenNames.InitLoginFallback); - }); - test('Corbado FAPI unavailable after authentication', async ({ model }) => { await model.home.logout(); await model.expectScreen(ScreenNames.InitLoginOneTap);