Skip to content

Commit 7a28dfd

Browse files
namsnathdeepjyoti30-stsattvikc
authored
feat: adds dev/release tag pipelines (#911)
* feat: add mochawesome reporter * update: makes test utils/server use applications - Removes Start/Stop/Clean/Setup ST functions - Adds a `/test/setup` endpoint to use `setupApp` - Adds generic backend hook endpoints * feat: setup mochawesome - Adds screenshots to report - Adds defaults to `.mocharc.yml` * update: `emailverification` tests use core apps - Each test runs independently - Adds some additional steps to ensure tests are independent - Cleans up test hooks - Fixes verification failure test that relied on core being stopped - Adds intercept to fail verification query * update: `embed` tests use core apps - Each test runs independently - Adds some additional steps to ensure tests are independent - Cleans up test hooks * update: `generalerror` tests use core apps * update: `getRedirectionURL` tests use core apps * update: remove assertion on creating new apps - Same appId can be re-used and will not create new apps * update: `mfa.chooserscreen` tests use core apps * feat: adds mocha envs to test config * lint: format code * update: `accountlinking` tests use core apps - Each test runs independently - Adds some additional steps to ensure tests are independent - Cleans up test hooks * update: `mfa.default_reqs` tests use core apps - Each test runs independently - Cleans up test hooks * refactor: split app creation and ST setup utils * update: `mfa.factorscreen.otp` tests use core apps * refactor: split app creation and ST setup utils * update: `mfa.factorscreen.totp` tests use core apps * update: add missing backend hooks * update: `mfa.firstFactors` tests use core apps * update: `mfa.requirement_handling` tests use core apps * update: `mfa.signin` tests use core apps * update: `multitenancy.dynamic_login_methods` tests use core apps * update: `multitenancy.tenant_interactions` tests use core apps * update: `oauth2provider` tests use core apps * update: `resetpasswordusingtoken` tests use core apps * update: `signin-rrdv5/6` tests use core apps * update: few `thirdparty` tests use core apps * update: removes `visual` tests * removes usages of old helper functions * update: `userContext`/`userroles` tests use core apps * fix: broken tests, update configs * update: remove log * fix: correct setup ST url * test: only run few tests * revert: test: only run few tests * Fix package-lock issues * Add some fixes for userContext and test server * Port all webauthn tests to use updated test structure * update: remove spec config in mocha * Add init workflow for auth-react e2e tests * Whitelist ci branch for tests * Remove cdi version related code * Add support for starting core in the tests * Add compose for starting up core * Explicitly pass APP_SERVER port in envs * Use alternative approach to pass spec files to test action * Parse the spec array into JSON to iterate through it * Make some improvements in the workflow * Add changes to run tests in a different workflow * Update workflow to make it ready for merge * Add workflow for unit tests * Remove current branch from list of allowed branches in unit test * Get rid of using random UUID for appId * Rename Core test to Core Functionality * Get rid of a TODO * Get rid of using timeout in tests * Get rid of setting appId from tests directly * fix: failing auth-react tests [0.49] (#895) * fix: awaits `setupST` calls * fix: `after` hook page close failures * feat: webauthn test flows (#883) ## Summary of change This PR adds e2e test flows for webauthn and accountlinking ## Related issues ## Test Plan All webauthn accountlinking tests should pass ## Documentation changes (If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) ## Checklist for important updates - [ ] Changelog has been updated - [ ] `frontendDriverInterfaceSupported.json` file has been updated (if needed) - [ ] Changes to the version if needed - In `package.json` - In `package-lock.json` - In `lib/ts/version.ts` - [x] Had run `npm run build-pretty` - [x] Had installed and ran the pre-commit hook - [x] Issue this PR against the latest non released version branch. - To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag. - If no such branch exists, then create one from the latest released branch. - [ ] If added a new recipe interface, then make sure that the implementation of it uses NON arrow functions only (like `someFunc: function () {..}`). - [ ] If I added a new recipe, I also added the recipe entry point into the `size-limit` section of `package.json` with the size limit set to the current size rounded up. - [ ] If I added a new recipe, I also added the recipe entry point into the `rollup.config.mjs` - [ ] If I added a new login method, I modified the list in `lib/ts/types.ts` - [ ] If I added a factor id, I modified the list in `lib/ts/recipe/multifactorauth/types.ts` * fix: separate helper method from test file (#900) ## Summary of change This PR removes a util method from the accountlinking test file and moves it to the helper file since it is used in 2 test files (accountlinking and webauthn) and the while running the webauthn tests, the accountlinking ones were also getting triggered because the helper was being imported from that file. ## Related issues ## Test Plan All accountlinking and webauthn accountlinking tests should pass ## Documentation changes (If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) ## Checklist for important updates - [ ] Changelog has been updated - [ ] `frontendDriverInterfaceSupported.json` file has been updated (if needed) - [ ] Changes to the version if needed - In `package.json` - In `package-lock.json` - In `lib/ts/version.ts` - [x] Had run `npm run build-pretty` - [x] Had installed and ran the pre-commit hook - [x] Issue this PR against the latest non released version branch. - To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag. - If no such branch exists, then create one from the latest released branch. - [ ] If added a new recipe interface, then make sure that the implementation of it uses NON arrow functions only (like `someFunc: function () {..}`). - [ ] If I added a new recipe, I also added the recipe entry point into the `size-limit` section of `package.json` with the size limit set to the current size rounded up. - [ ] If I added a new recipe, I also added the recipe entry point into the `rollup.config.mjs` - [ ] If I added a new login method, I modified the list in `lib/ts/types.ts` - [ ] If I added a factor id, I modified the list in `lib/ts/recipe/multifactorauth/types.ts` ## Remaining TODOs for this PR * feat: adds dev/release tag pipelines - Sets up dev/release tag pipelines - Adds script to populate common constants - Updates workflows to run on PRs and dev-tags * update: makes chromatic tests run on dev tag - Ensures chromatic statuses are checked in the release checks * update: web js interface variable to match action output * doc: adds changelog * update: GHA concurrency to cancel runs if new commit pushed --------- Co-authored-by: Deepjyoti Barman <[email protected]> Co-authored-by: Sattvik Chakravarthy <[email protected]>
1 parent 92c7c1e commit 7a28dfd

File tree

66 files changed

+5340
-6202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+5340
-6202
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Auth-React Tests - L1
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
push:
10+
tags:
11+
- dev-v[0-9]+.[0-9]+.[0-9]+
12+
13+
# Only one instance of this workflow will run on the same ref (PR/Branch/Tag)
14+
# Previous runs will be cancelled.
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
define-versions:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
fdiVersions: ${{ steps.versions.outputs.fdiVersions }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: supertokens/get-supported-versions-action@main
27+
id: versions
28+
with:
29+
has-fdi: true
30+
31+
setup-auth-react:
32+
runs-on: ubuntu-latest
33+
needs: define-versions
34+
strategy:
35+
fail-fast: true
36+
matrix:
37+
fdi-version: ${{ fromJSON(needs.define-versions.outputs.fdiVersions) }}
38+
39+
outputs:
40+
AUTH_REACT__LOG_DIR: ${{ steps.envs.outputs.AUTH_REACT__LOG_DIR }}
41+
AUTH_REACT__SCREENSHOT_DIR: ${{ steps.envs.outputs.AUTH_REACT__SCREENSHOT_DIR }}
42+
AUTH_REACT__NODE_PORT: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
43+
AUTH_REACT__APP_SERVER: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
44+
AUTH_REACT__TEST_MODE: ${{ steps.envs.outputs.AUTH_REACT__TEST_MODE }}
45+
AUTH_REACT__PORT: ${{ steps.envs.outputs.AUTH_REACT__PORT }}
46+
specs: ${{ steps.envs.outputs.specs }}
47+
fdiVersions: ${{ needs.define-versions.outputs.fdiVersions }}
48+
49+
steps:
50+
- uses: supertokens/get-versions-action@main
51+
id: versions
52+
with:
53+
driver-name: node
54+
fdi-version: ${{ matrix.fdi-version }}
55+
env:
56+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
57+
58+
- uses: supertokens/auth-react-testing-action/setup@main
59+
id: envs
60+
with:
61+
auth-react-version: ${{ github.sha }}
62+
node-sdk-version: ${{ steps.versions.outputs.nodeTag }}
63+
fdi-version: ${{ matrix.fdi-version }}
64+
use-common-app-and-test-server: "true"
65+
66+
launch-test-workflow:
67+
uses: ./.github/workflows/auth-react-test-2.yml
68+
needs: setup-auth-react
69+
name: FDI ${{ matrix.fdi-version }}
70+
strategy:
71+
max-parallel: 1 # This is important to avoid ddos GHA API
72+
fail-fast: false # Don't fail fast to avoid locking TF State
73+
matrix:
74+
fdi-version: ${{ fromJSON(needs.setup-auth-react.outputs.fdiVersions) }}
75+
with:
76+
fdi-version: ${{ matrix.fdi-version }}
77+
specs: ${{ needs.setup-auth-react.outputs.specs }}
78+
AUTH_REACT__LOG_DIR: ${{ needs.setup-auth-react.outputs.AUTH_REACT__LOG_DIR }}
79+
AUTH_REACT__SCREENSHOT_DIR: ${{ needs.setup-auth-react.outputs.AUTH_REACT__SCREENSHOT_DIR }}
80+
AUTH_REACT__APP_SERVER: ${{ needs.setup-auth-react.outputs.AUTH_REACT__APP_SERVER }}
81+
AUTH_REACT__NODE_PORT: ${{ needs.setup-auth-react.outputs.AUTH_REACT__NODE_PORT }}
82+
AUTH_REACT__TEST_MODE: ${{ needs.setup-auth-react.outputs.AUTH_REACT__TEST_MODE }}
83+
AUTH_REACT__PORT: ${{ needs.setup-auth-react.outputs.AUTH_REACT__PORT }}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Auth-React Tests - L2
2+
on:
3+
workflow_call:
4+
inputs:
5+
fdi-version:
6+
description: "FDI Version"
7+
required: true
8+
type: string
9+
10+
specs:
11+
description: "Spec Files"
12+
required: true
13+
type: string
14+
15+
AUTH_REACT__LOG_DIR:
16+
description: AUTH_REACT__LOG_DIR
17+
required: true
18+
type: string
19+
20+
AUTH_REACT__SCREENSHOT_DIR:
21+
description: AUTH_REACT__SCREENSHOT_DIR
22+
required: true
23+
type: string
24+
25+
AUTH_REACT__APP_SERVER:
26+
description: AUTH_REACT__APP_SERVER
27+
required: true
28+
type: string
29+
30+
AUTH_REACT__NODE_PORT:
31+
description: AUTH_REACT__NODE_PORT
32+
required: true
33+
type: string
34+
35+
AUTH_REACT__TEST_MODE:
36+
description: AUTH_REACT__TEST_MODE
37+
required: true
38+
type: string
39+
40+
AUTH_REACT__PORT:
41+
description: AUTH_REACT__PORT
42+
required: true
43+
type: string
44+
45+
jobs:
46+
test:
47+
runs-on: ubuntu-latest
48+
49+
strategy:
50+
max-parallel: 10
51+
fail-fast: false
52+
matrix:
53+
spec: ${{ fromJSON(inputs.specs) }}
54+
55+
env:
56+
SUPERTOKENS_CORE_PORT: 3567
57+
SUPERTOKENS_CORE_HOST: localhost
58+
TEST_MODE: testing
59+
# Auth react setup envs
60+
AUTH_REACT__LOG_DIR: ${{ inputs.AUTH_REACT__LOG_DIR }}
61+
AUTH_REACT__SCREENSHOT_DIR: ${{ inputs.AUTH_REACT__SCREENSHOT_DIR }}
62+
AUTH_REACT__NODE_PORT: ${{ inputs.AUTH_REACT__NODE_PORT }}
63+
AUTH_REACT__APP_SERVER: ${{ inputs.AUTH_REACT__NODE_PORT }}
64+
AUTH_REACT__TEST_MODE: ${{ inputs.AUTH_REACT__TEST_MODE }}
65+
AUTH_REACT__PORT: ${{ inputs.AUTH_REACT__PORT }}
66+
67+
steps:
68+
- uses: actions/checkout@v4
69+
with:
70+
path: supertokens-auth-react
71+
72+
- name: Start core
73+
run: docker compose up --wait
74+
working-directory: supertokens-auth-react
75+
76+
- uses: supertokens/auth-react-testing-action@main
77+
name: test ${{ matrix.spec }} for ${{ inputs.fdi-version }}
78+
with:
79+
fdi-version: ${{ inputs.fdi-version }}
80+
check-name-suffix: "[FDI=${{ inputs.fdi-version }}][Spec=${{ matrix.spec }}]"
81+
path: supertokens-auth-react
82+
spec: ${{ matrix.spec }}

.github/workflows/chromatic.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ name: "Chromatic"
22

33
on:
44
push:
5-
branches: [master, "[0-9]*.[0-9]*"]
5+
branches:
6+
- master
7+
- "[0-9]*.[0-9]*"
8+
tags:
9+
- dev-v[0-9]+.[0-9]+.[0-9]+
610
workflow_dispatch:
711

12+
# Only one instance of this workflow will run on the same ref (PR/Branch/Tag)
13+
# Previous runs will be cancelled.
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
818
jobs:
919
chromatic:
1020
runs-on: ubuntu-latest
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: "Dev Tag Pipeline"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: The branch to create the dev tag on
8+
type: string
9+
required: true
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
setup:
16+
runs-on: ubuntu-latest
17+
18+
outputs:
19+
packageVersion: ${{ steps.versions.outputs.packageVersion }}
20+
packageVersionXy: ${{ steps.versions.outputs.packageVersionXy }}
21+
packageLockVersion: ${{ steps.versions.outputs.packageLockVersion }}
22+
packageLockVersionXy: ${{ steps.versions.outputs.packageLockVersionXy }}
23+
newestVersion: ${{ steps.versions.outputs.newestVersion }}
24+
targetBranch: ${{ steps.versions.outputs.targetBranch }}
25+
devTag: ${{ steps.versions.outputs.devTag }}
26+
releaseTag: ${{ steps.versions.outputs.releaseTag }}
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
ref: ${{ inputs.branch }}
32+
# Need a complete fetch to make the master merge check work
33+
fetch-depth: 0
34+
fetch-tags: true
35+
token: ${{ secrets.ALL_REPO_PAT }}
36+
37+
- name: Setup git
38+
run: |
39+
# NOTE: The user email is {user.id}+{user.login}@users.noreply.github.com.
40+
# See users API: https://api.github.com/users/github-actions%5Bbot%5D
41+
git config user.name "github-actions[bot]"
42+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
43+
44+
git fetch origin master
45+
46+
- name: Check if branch needs master merge
47+
run: |
48+
if [[ $(git log origin/master ^HEAD) != "" ]]; then
49+
echo "You need to merge master into this branch."
50+
exit 1
51+
fi
52+
53+
- name: Populate variables
54+
id: versions
55+
run: |
56+
. ./hooks/populate-hook-constants.sh
57+
58+
echo "packageVersion=$packageVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
59+
echo "packageVersionXy=$packageVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
60+
echo "packageLockVersion=$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
61+
echo "packageLockVersionXy=$packageLockVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
62+
echo "newestVersion=$newestVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
63+
echo "targetBranch=$targetBranch" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
64+
65+
echo "devTag=dev-v$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
66+
echo "releaseTag=v$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
67+
68+
- name: Check tag and branch correctness
69+
run: |
70+
if [[ "${{ steps.versions.outputs.packageVersion }}" != "${{ steps.versions.outputs.packageLockVersion }}" ]]
71+
then
72+
echo "The package version and package lock version do not match."
73+
exit 1
74+
fi
75+
76+
if [[ "${{ steps.versions.outputs.packageVersion }}" != ${{ inputs.branch }}* ]]
77+
then
78+
echo "Adding tag to wrong branch"
79+
exit 1
80+
fi
81+
82+
if git rev-parse ${{ steps.versions.outputs.releaseTag }} >/dev/null 2>&1
83+
then
84+
echo "The released version of this tag already exists."
85+
exit 1
86+
fi
87+
88+
- name: Delete tag if already tagged
89+
run: |
90+
git tag --delete ${{ steps.versions.outputs.devTag }} || true
91+
git push --delete origin ${{ steps.versions.outputs.devTag }} || true
92+
93+
- name: Install dependencies
94+
run: npm install
95+
96+
- name: Build docs
97+
run: |
98+
npm run build-pretty
99+
npm run build-docs
100+
101+
- name: Commit doc changes
102+
run: |
103+
git add --all
104+
git commit --allow-empty -nm "doc: update docs for ${{ steps.versions.outputs.releaseTag }} tag"
105+
git push
106+
107+
- name: Create and push tag
108+
run: |
109+
# NOTE: The user email is {user.id}+{user.login}@users.noreply.github.com.
110+
# See users API: https://api.github.com/users/github-actions%5Bbot%5D
111+
git config user.name "github-actions[bot]"
112+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
113+
114+
git tag ${{ steps.versions.outputs.devTag }}
115+
git push --tags --follow-tags
116+
117+
mark-dev-tag-as-not-passed:
118+
runs-on: ubuntu-latest
119+
needs:
120+
- setup
121+
122+
steps:
123+
- uses: actions/checkout@v4
124+
with:
125+
ref: ${{ needs.setup.outputs.devTag }}
126+
fetch-tags: true
127+
128+
- id: versions
129+
uses: supertokens/get-supported-versions-action@main
130+
with:
131+
has-cdi: false
132+
has-fdi: true
133+
has-web-js: true
134+
135+
- id: escape-versions
136+
run: |
137+
echo "fdiVersions=$(sed 's/"/\\"/g' <<< '${{ steps.versions.outputs.fdiVersions }}')" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
138+
echo "webJsInterfaceVersion=$(sed 's/"/\\"/g' <<< '${{ steps.versions.outputs.webJsInterfaceVersion }}')" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
139+
140+
- run: |
141+
./hooks/populate-hook-constants.sh
142+
143+
curl --fail-with-body -X PUT \
144+
https://api.supertokens.io/0/frontend \
145+
-H 'Content-Type: application/json' \
146+
-H 'api-version: 1' \
147+
-d "{
148+
\"password\": \"${{ secrets.SUPERTOKENS_API_KEY }}\",
149+
\"version\":\"${{ needs.setup.outputs.packageVersion }}\",
150+
\"name\": \"auth-react\",
151+
\"frontendDriverInterfaces\": ${{ steps.escape-versions.outputs.fdiVersions }},
152+
\"webJsInterface\": \"${{ steps.escape-versions.outputs.webJsInterfaceVersion }}\"
153+
}"

0 commit comments

Comments
 (0)