Skip to content

feat: adds dev/release pipelines, auth-react tests #13

feat: adds dev/release pipelines, auth-react tests

feat: adds dev/release pipelines, auth-react tests #13

name: Auth-React Tests - L1
on:
pull_request:
types:
- opened
- reopened
- synchronize
push:
tags:
- dev-v[0-9]+.[0-9]+.[0-9]+
# Only one instance of this workflow will run on the same ref (PR/Branch/Tag)
# Previous runs will be cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
define-versions:
runs-on: ubuntu-latest
outputs:
fdiVersions: ${{ steps.versions.outputs.fdiVersions }}
webJsInterfaceVersion: ${{ steps.versions.outputs.webJsInterfaceVersion }}
steps:
- uses: actions/checkout@v4
- uses: supertokens/get-supported-versions-action@main
id: versions
with:
has-fdi: true
has-web-js: true
setup-auth-react:
runs-on: ubuntu-latest
needs: define-versions
strategy:
fail-fast: true
matrix:
fdi-version: ${{ fromJSON(needs.define-versions.outputs.fdiVersions) }}
outputs:
AUTH_REACT__LOG_DIR: ${{ steps.envs.outputs.AUTH_REACT__LOG_DIR }}
AUTH_REACT__SCREENSHOT_DIR: ${{ steps.envs.outputs.AUTH_REACT__SCREENSHOT_DIR }}
AUTH_REACT__NODE_PORT: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
AUTH_REACT__APP_SERVER: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
AUTH_REACT__TEST_MODE: ${{ steps.envs.outputs.AUTH_REACT__TEST_MODE }}
AUTH_REACT__PORT: ${{ steps.envs.outputs.AUTH_REACT__PORT }}
specs: ${{ steps.envs.outputs.specs }}
fdiVersions: ${{ needs.define-versions.outputs.fdiVersions }}
steps:
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/checkout@v4
with:
path: supertokens-web-js
- uses: supertokens/get-versions-action@main
id: versions
with:
driver-name: node
fdi-version: ${{ matrix.fdi-version }}
fetch-frontend-versions: false
web-js-interface-version: ${{ needs.define-versions.outputs.webJsInterfaceVersion }}
env:
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
- uses: actions/checkout@v4
with:
repository: supertokens/supertokens-auth-react
ref: ${{ steps.versions.outputs.webJsReactTag }}
path: supertokens-auth-react
# We will use this in the test run to get the core version
- uses: actions/checkout@v4
with:
repository: supertokens/supertokens-node
ref: ${{ steps.versions.outputs.nodeTag }}
path: supertokens-node
- name: Setup envs
id: envs
run: |
echo "AUTH_REACT__LOG_DIR=${{ github.workspace }}/supertokens-auth-react/test_report/logs" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "AUTH_REACT__SCREENSHOT_DIR=${{ github.workspace }}/supertokens-auth-react/test_report/screenshots" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "AUTH_REACT__NODE_PORT=8082" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "AUTH_REACT__APP_SERVER=8082" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "AUTH_REACT__TEST_MODE=testing" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "AUTH_REACT__PORT=3031" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
cd supertokens-auth-react
echo "specs=$(find 'test/end-to-end' -name '*.test.js' -type f | sort | jq -Rsc 'split("\n")[:-1]' | jq -r 'tostring')" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
- name: Setup auth-react
working-directory: supertokens-auth-react
env:
ROOT_DIR: supertokens-auth-react
run: |
npm i
mkdir -p ${{ steps.envs.outputs.AUTH_REACT__LOG_DIR }}
mkdir -p ${{ steps.envs.outputs.AUTH_REACT__SCREENSHOT_DIR }}
- name: Setup auth-react test server
working-directory: supertokens-auth-react/test/server/
env:
# Common
APP_SERVER: ${{ steps.envs.outputs.AUTH_REACT__APP_SERVER }}
NODE_PORT: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
TEST_MODE: ${{ steps.envs.outputs.AUTH_REACT__TEST_MODE }}
# Step-specific
NODE_TAG: ${{ steps.versions.outputs.nodeTag }}
run: |
npm i git+https://github.com:supertokens/supertokens-node.git#$NODE_TAG
npm i
- name: Setup auth-react frontend application
working-directory: supertokens-auth-react/examples/for-tests/
env:
# Common
APP_SERVER: ${{ steps.envs.outputs.AUTH_REACT__APP_SERVER }}
NODE_PORT: ${{ steps.envs.outputs.AUTH_REACT__NODE_PORT }}
TEST_MODE: ${{ steps.envs.outputs.AUTH_REACT__TEST_MODE }}
# Step-specific
CI: true
BROWSER: none
PORT: ${{ steps.envs.outputs.AUTH_REACT__PORT }}
REACT_APP_API_PORT: ${{ steps.envs.outputs.AUTH_REACT__APP_SERVER }}
run: |
npm i
npm run prep
- name: Copy over required dependencies
run: |
cd supertokens-web-js
# Create a tarball of the web-js package
npm pack
cd ../supertokens-auth-react
# Extract the tarball to the auth-react package
tar -xf ../supertokens-web-js/supertokens-web-js-*.tgz --strip-components=1 -C node_modules/supertokens-web-js
# Remove existing website package and link to the one from web-js
# rm -rf node_modules/supertokens-website
# ln -s "../supertokens-web-js/node_modules/supertokens-website" node_modules
- uses: bissolli/gh-action-persist-workspace@v2
with:
action: persist
artifactName: auth-react-${{ matrix.fdi-version }}
launch-test-workflow:
uses: ./.github/workflows/auth-react-test-2.yml
needs: setup-auth-react
name: FDI ${{ matrix.fdi-version }}
strategy:
max-parallel: 1 # This is important to avoid ddos GHA API
fail-fast: false # Don't fail fast to avoid locking TF State
matrix:
fdi-version: ${{ fromJSON(needs.setup-auth-react.outputs.fdiVersions) }}
with:
fdi-version: ${{ matrix.fdi-version }}
specs: ${{ needs.setup-auth-react.outputs.specs }}
AUTH_REACT__LOG_DIR: ${{ needs.setup-auth-react.outputs.AUTH_REACT__LOG_DIR }}
AUTH_REACT__SCREENSHOT_DIR: ${{ needs.setup-auth-react.outputs.AUTH_REACT__SCREENSHOT_DIR }}
AUTH_REACT__APP_SERVER: ${{ needs.setup-auth-react.outputs.AUTH_REACT__APP_SERVER }}
AUTH_REACT__NODE_PORT: ${{ needs.setup-auth-react.outputs.AUTH_REACT__NODE_PORT }}
AUTH_REACT__TEST_MODE: ${{ needs.setup-auth-react.outputs.AUTH_REACT__TEST_MODE }}
AUTH_REACT__PORT: ${{ needs.setup-auth-react.outputs.AUTH_REACT__PORT }}
secrets: inherit