Skip to content

Commit 1e913aa

Browse files
committed
feat: adds auth-react test workflow
1 parent 48b8f63 commit 1e913aa

File tree

5 files changed

+255
-109
lines changed

5 files changed

+255
-109
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
jobs:
14+
define-versions:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
fdiVersions: ${{ steps.versions.outputs.fdiVersions }}
18+
webJsInterfaceVersion: ${{ steps.versions.outputs.webJsInterfaceVersion }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: supertokens/get-supported-versions-action@main
23+
id: versions
24+
with:
25+
has-fdi: true
26+
has-web-js: true
27+
28+
setup-auth-react:
29+
runs-on: ubuntu-latest
30+
needs: define-versions
31+
strategy:
32+
fail-fast: true
33+
matrix:
34+
fdi-version: ${{ fromJSON(needs.define-versions.outputs.fdiVersions) }}
35+
36+
outputs:
37+
AUTH_REACT__LOG_DIR: ${{ steps.envs.outputs.AUTH_REACT__LOG_DIR }}
38+
AUTH_REACT__SCREENSHOT_DIR: ${{ steps.envs.outputs.AUTH_REACT__SCREENSHOT_DIR }}
39+
AUTH_REACT__NODE_PORT: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
40+
AUTH_REACT__APP_SERVER: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
41+
AUTH_REACT__TEST_MODE: ${{ steps.envs.outputs.AUTH_REACT__TEST_MODE }}
42+
AUTH_REACT__PORT: ${{ steps.envs.outputs.AUTH_REACT__PORT }}
43+
specs: ${{ steps.envs.outputs.specs }}
44+
fdiVersions: ${{ needs.define-versions.outputs.fdiVersions }}
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
path: supertokens-web-js
50+
51+
- uses: supertokens/get-versions-action@main
52+
id: versions
53+
with:
54+
driver-name: node
55+
fdi-version: ${{ matrix.fdi-version }}
56+
web-js-interface-version: ${{ needs.define-versions.outputs.webJsInterfaceVersion }}
57+
env:
58+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
59+
60+
- uses: supertokens/auth-react-testing-action/setup@main
61+
id: envs
62+
with:
63+
auth-react-version: ${{ steps.versions.outputs.webJsReactTag }}
64+
node-sdk-version: ${{ steps.versions.outputs.nodeTag }}
65+
fdi-version: ${{ matrix.fdi-version }}
66+
use-common-app-and-test-server: "true"
67+
persist-workspace: "false"
68+
69+
# We will use this in the test run to get the core version
70+
- uses: actions/checkout@v4
71+
with:
72+
repository: supertokens/supertokens-node
73+
ref: ${{ steps.versions.outputs.nodeTag }}
74+
path: supertokens-node
75+
76+
- name: Copy over required dependencies
77+
run: |
78+
cd supertokens-web-js
79+
# Create a tarball of the web-js package
80+
npm pack
81+
82+
cd ../supertokens-auth-react
83+
# Extract the tarball to the auth-react package
84+
tar -xf ../supertokens-web-js/supertokens-web-js-*.tgz --strip-components=1 -C node_modules/supertokens-web-js
85+
# Remove existing website package and link to the one from web-js
86+
rm -rf node_modules/supertokens-website
87+
ln -s "$PWD/../supertokens-web-js/node_modules/supertokens-website" node_modules
88+
89+
# - name: Set up auth-react with new dependencies
90+
# working-directory: supertokens-auth-react/examples/for-tests
91+
# env:
92+
# # Common
93+
# APP_SERVER: ${{ steps.envs.outputs.AUTH_REACT__APP_SERVER }}
94+
# NODE_PORT: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
95+
# TEST_MODE: ${{ steps.envs.outputs.AUTH_REACT__TEST_MODE }}
96+
# # Step-specific
97+
# CI: true
98+
# BROWSER: none
99+
# PORT: ${{ steps.envs.outputs.AUTH_REACT__PORT }}
100+
# REACT_APP_API_PORT: ${{ steps.envs.outputs.AUTH_REACT__APP_SERVER }}
101+
# run: |
102+
# npm i
103+
# npm run prep
104+
105+
- uses: bissolli/gh-action-persist-workspace@v2
106+
with:
107+
action: persist
108+
artifactName: auth-react-${{ matrix.fdi-version }}
109+
110+
launch-test-workflow:
111+
uses: ./.github/workflows/auth-react-test-2.yml
112+
needs: setup-auth-react
113+
name: FDI ${{ matrix.fdi-version }}
114+
strategy:
115+
max-parallel: 1 # This is important to avoid ddos GHA API
116+
fail-fast: false # Don't fail fast to avoid locking TF State
117+
matrix:
118+
fdi-version: ${{ fromJSON(needs.setup-auth-react.outputs.fdiVersions) }}
119+
with:
120+
fdi-version: ${{ matrix.fdi-version }}
121+
specs: ${{ needs.setup-auth-react.outputs.specs }}
122+
AUTH_REACT__LOG_DIR: ${{ needs.setup-auth-react.outputs.AUTH_REACT__LOG_DIR }}
123+
AUTH_REACT__SCREENSHOT_DIR: ${{ needs.setup-auth-react.outputs.AUTH_REACT__SCREENSHOT_DIR }}
124+
AUTH_REACT__APP_SERVER: ${{ needs.setup-auth-react.outputs.AUTH_REACT__APP_SERVER }}
125+
AUTH_REACT__NODE_PORT: ${{ needs.setup-auth-react.outputs.AUTH_REACT__NODE_PORT }}
126+
AUTH_REACT__TEST_MODE: ${{ needs.setup-auth-react.outputs.AUTH_REACT__TEST_MODE }}
127+
AUTH_REACT__PORT: ${{ needs.setup-auth-react.outputs.AUTH_REACT__PORT }}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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: bissolli/gh-action-persist-workspace@v2
69+
with:
70+
action: retrieve
71+
artifactName: auth-react-${{ inputs.fdi-version }}
72+
73+
- name: Get Node CDI versions
74+
id: node-cdi-versions
75+
uses: supertokens/get-supported-versions-action@main
76+
with:
77+
has-cdi: true
78+
working-directory: supertokens-node
79+
80+
- name: Get last Node CDI version
81+
id: last-node-cdi-version
82+
run: echo "lastNodeCdiVersion=$(echo '${{ steps.node-cdi-versions.outputs.cdiVersions }}' | jq -r '.[-1]')" >> $GITHUB_OUTPUT $GITHUB_ENV
83+
84+
- name: Get Core version
85+
id: core-version
86+
uses: supertokens/get-versions-action@main
87+
with:
88+
driver-name: node
89+
cdi-version: ${{ steps.last-node-cdi-version.outputs.lastNodeCdiVersion }}
90+
env:
91+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
92+
93+
- name: Start core
94+
run: docker compose up --wait
95+
working-directory: supertokens-web-js
96+
env:
97+
SUPERTOKENS_CORE_VERSION: ${{ steps.core-version.outputs.coreVersionXy }}
98+
99+
- uses: supertokens/auth-react-testing-action@main
100+
name: test ${{ matrix.spec }} for ${{ inputs.fdi-version }}
101+
with:
102+
fdi-version: ${{ inputs.fdi-version }}
103+
check-name-suffix: "[FDI=${{ inputs.fdi-version }}][Spec=${{ matrix.spec }}]"
104+
path: supertokens-auth-react
105+
spec: ${{ matrix.spec }}

.github/workflows/tests-pass-check-pr.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 0 additions & 85 deletions
This file was deleted.

compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
core:
3+
# Uses `$SUPERTOKENS_CORE_VERSION` when available, else latest
4+
image: supertokens/supertokens-core:dev-branch-${SUPERTOKENS_CORE_VERSION:-master}
5+
ports:
6+
# Uses `$SUPERTOKENS_CORE_PORT` when available, else 3567 for local port
7+
- ${SUPERTOKENS_CORE_PORT:-3567}:3567
8+
platform: linux/amd64
9+
depends_on: [oauth]
10+
environment:
11+
OAUTH_PROVIDER_PUBLIC_SERVICE_URL: http://oauth:4444
12+
OAUTH_PROVIDER_ADMIN_SERVICE_URL: http://oauth:4445
13+
OAUTH_PROVIDER_CONSENT_LOGIN_BASE_URL: http://localhost:3001/auth
14+
OAUTH_CLIENT_SECRET_ENCRYPTION_KEY: asdfasdfasdfasdfasdf
15+
healthcheck:
16+
test: bash -c 'curl -s "http://127.0.0.1:3567/hello" | grep "Hello"'
17+
interval: 10s
18+
timeout: 5s
19+
retries: 5
20+
21+
oauth:
22+
image: supertokens/oauth2-test:latest
23+
platform: linux/amd64

0 commit comments

Comments
 (0)