Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 185 additions & 0 deletions .github/workflows/app-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: "App Tests"

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 }}
nodeVersions: '["20"]'
nodeFdiVersionMap: ${{ steps.node-versions.outputs.fdiVersions }}
steps:
- uses: actions/checkout@v4

- uses: supertokens/get-supported-versions-action@main
id: versions
with:
has-fdi: true
has-cdi: false

- uses: supertokens/actions/get-versions-from-repo@main
id: node-versions
with:
repo: supertokens-node
github-token: ${{ secrets.GITHUB_TOKEN }}
fdi-versions: ${{ steps.versions.outputs.fdiVersions }}

test:
runs-on: ubuntu-latest
needs:
- define-versions
strategy:
fail-fast: false
matrix:
node-version: ${{ fromJSON(needs.define-versions.outputs.nodeVersions) }}
fdi-version: ${{ fromJSON(needs.define-versions.outputs.fdiVersions) }}

steps:
- name: Setup ENVs
id: envs
run: |
DATA_DIR=${{ github.workspace }}/data
APP_SERVER_LOG_DIR=${{ github.workspace }}/data/logs
echo "DATA_DIR=$DATA_DIR" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "APP_SERVER_LOG_DIR=$APP_SERVER_LOG_DIR" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"

mkdir -p $DATA_DIR
mkdir -p $APP_SERVER_LOG_DIR

- id: repo-versions
run: |
nodeVersion=$( echo '${{ needs.define-versions.outputs.nodeFdiVersionMap }}' | jq -r '.["${{ matrix.fdi-version }}"]' )
echo "nodeVersion=${nodeVersion}" >> $GITHUB_OUTPUT

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- uses: actions/checkout@v4
with:
path: supertokens-react-native

- uses: actions/checkout@v4
with:
repository: supertokens/supertokens-node
path: supertokens-node
ref: ${{ steps.repo-versions.outputs.nodeVersion }}

- name: Get Node CDI versions
id: node-cdi-versions
uses: supertokens/get-supported-versions-action@main
with:
has-cdi: true
working-directory: supertokens-node

- uses: supertokens/actions/get-versions-from-repo@main
id: core-versions
with:
repo: supertokens-core
github-token: ${{ secrets.GITHUB_TOKEN }}
cdi-versions: ${{ steps.node-cdi-versions.outputs.cdiVersions }}

- name: Get core version from latest Node CDI version
id: core-version
run: |
lastNodeCdiVersion=$(echo '${{ steps.node-cdi-versions.outputs.cdiVersions }}' | jq -r '.[-1]') | sed -e 's/"/\\"/g'
coreVersion=$(echo '${{ steps.core-versions.outputs.cdiVersions }}' | jq -r ".[$lastNodeCdiVersion]")

echo "coreVersion=${coreVersion}" >> $GITHUB_OUTPUT

- name: Start core
working-directory: supertokens-react-native
run: docker compose up --wait
env:
SUPERTOKENS_CORE_VERSION: ${{ steps.core-version.outputs.coreVersion }}

- name: Install SDK dependencies
working-directory: supertokens-react-native/TestingApp
run: |
npm i -d
cp -r ./test/tough-cookie ./node_modules/
npm i git+https://github.com:supertokens/supertokens-react-native.git#${{ github.sha }}

- name: Setup test server
working-directory: supertokens-react-native/TestingApp/test/server
env:
TEST_MODE: testing
NODE_PORT: 8080
run: |
npm i -d
npm i git+https://github.com:supertokens/supertokens-node.git#${{ steps.repo-versions.outputs.nodeVersion }}

- name: Run tests
working-directory: supertokens-react-native/TestingApp
env:
TEST_MODE: testing
NODE_PORT: 8080
JEST_JUNIT_OUTPUT_DIR: ${{ steps.envs.outputs.DATA_DIR }}
JEST_JUNIT_ADD_FILE_ATTRIBUTE: true
run: |
set +e

tries=0
max_tries=3

while true; do
tries=$((tries + 1))
echo "Running tests [Try $tries/$max_tries]"

echo "Starting server"
node test/server/index.js &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server-$tries.log &
server_pid=$!

echo "Running tests"
npx jest test/*.spec.js --ci --reporters=default --reporters=jest-junit --runInBand --verbose --split-by=timings
exit_code=$?

if [[ $exit_code -ne 0 && $tries -lt $max_tries ]]; then
echo -e "\n\n\n"
pkill -9 $server_pid
else
exit $exit_code
fi

done

- if: always()
name: Publish test results
uses: mikepenz/action-junit-report@v5
with:
report_paths: ${{ steps.envs.outputs.DATA_DIR }}/junit.xml
check_name: React Native Tests [FDI=${{ matrix.fdi-version }}][Node=${{ matrix.node-version }}][NodeSDK=${{ steps.versions.outputs.nodeTag }}]
# Include table with all test results in the summary
detailed_summary: true
# Skips the summary table if only successful tests were detected.
skip_success_summary: true
# Group the testcases by test suite in the detailed_summary
group_suite: true
# Don't fail if no test are found.
require_tests: false
# Fail the build in case of a test failure.
fail_on_failure: true
# No annotations will be added to the run
skip_annotations: true

- if: failure()
name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: React Native Tests [FDI=${{ matrix.fdi-version }}][Node=${{ matrix.node-version }}][NodeSDK=${{ steps.versions.outputs.nodeTag }}]
path: ${{ steps.envs.outputs.DATA_DIR }}
150 changes: 150 additions & 0 deletions .github/workflows/pipeline-dev-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: "Dev Tag Pipeline"

on:
workflow_dispatch:
inputs:
branch:
description: The branch to create the dev tag on
type: string
required: true

permissions:
contents: write

jobs:
setup:
runs-on: ubuntu-latest

outputs:
packageVersion: ${{ steps.versions.outputs.packageVersion }}
packageVersionXy: ${{ steps.versions.outputs.packageVersionXy }}
packageLockVersion: ${{ steps.versions.outputs.packageLockVersion }}
packageLockVersionXy: ${{ steps.versions.outputs.packageLockVersionXy }}
newestVersion: ${{ steps.versions.outputs.newestVersion }}
targetBranch: ${{ steps.versions.outputs.targetBranch }}
devTag: ${{ steps.versions.outputs.devTag }}
releaseTag: ${{ steps.versions.outputs.releaseTag }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
# Need a complete fetch to make the master merge check work
fetch-depth: 0
fetch-tags: true
token: ${{ secrets.ALL_REPO_PAT }}

- name: Setup git
run: |
# NOTE: The user email is {user.id}+{user.login}@users.noreply.github.com.
# See users API: https://api.github.com/users/github-actions%5Bbot%5D
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git fetch origin master

- name: Check if branch needs master merge
run: |
if [[ $(git log origin/master ^HEAD) != "" ]]; then
echo "You need to merge master into this branch."
exit 1
fi

- name: Populate variables
id: versions
run: |
. ./hooks/populate-hook-constants.sh

echo "packageVersion=$packageVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "packageVersionXy=$packageVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "packageLockVersion=$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "packageLockVersionXy=$packageLockVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "newestVersion=$newestVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "targetBranch=$targetBranch" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"

echo "devTag=dev-v$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "releaseTag=v$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"

- name: Check tag and branch correctness
run: |
if [[ "${{ steps.versions.outputs.packageVersion }}" != "${{ steps.versions.outputs.packageLockVersion }}" ]]
then
echo "The package version and package lock version do not match."
exit 1
fi

if [[ "${{ steps.versions.outputs.packageVersion }}" != ${{ inputs.branch }}* ]]
then
echo "Adding tag to wrong branch"
exit 1
fi

if git rev-parse ${{ steps.versions.outputs.releaseTag }} >/dev/null 2>&1
then
echo "The released version of this tag already exists."
exit 1
fi

- name: Delete tag if already tagged
run: |
git tag --delete ${{ steps.versions.outputs.devTag }} || true
git push --delete origin ${{ steps.versions.outputs.devTag }} || true

- name: Install dependencies
run: npm install

- name: Build docs
run: |
npm run build-pretty
npm run build-docs

- name: Commit doc changes
run: |
git add --all
git commit --allow-empty -nm "doc: update docs for ${{ steps.versions.outputs.releaseTag }} tag"
git push

- name: Create and push tag
run: |
# NOTE: The user email is {user.id}+{user.login}@users.noreply.github.com.
# See users API: https://api.github.com/users/github-actions%5Bbot%5D
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git tag ${{ steps.versions.outputs.devTag }}
git push --tags --follow-tags

mark-dev-tag-as-not-passed:
runs-on: ubuntu-latest
needs:
- setup

steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.setup.outputs.devTag }}
fetch-tags: true

- id: versions
uses: supertokens/get-supported-versions-action@main
with:
has-cdi: false
has-fdi: true

- id: escape-versions
run: |
echo "fdiVersions=$(sed 's/"/\\"/g' <<< '${{ steps.versions.outputs.fdiVersions }}')" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"

- run: |
./hooks/populate-hook-constants.sh

curl --fail-with-body -X PUT \
https://api.supertokens.io/0/frontend \
-H 'Content-Type: application/json' \
-H 'api-version: 0' \
-d "{
\"password\": \"${{ secrets.SUPERTOKENS_API_KEY }}\",
\"version\":\"${{ needs.setup.outputs.packageVersion }}\",
\"name\": \"react-native\",
\"frontendDriverInterfaces\": ${{ steps.escape-versions.outputs.fdiVersions }},
}"
Loading
Loading