Skip to content

Commit

Permalink
feat: uses containerised core in tests (#561)
Browse files Browse the repository at this point in the history
- Adds unit test workflow
- Test changes:
  - Removes all instances of start_st, clean_st, setup_st, setup_function, teardown_function
  - Adds per-test setup/teardown to call `reset()`
  - Replaces `start_st` calls and usages of `localhost:3567` with `get_new_core_app_url` equivalents
    - Creates a new application in the core
  - Removes unused constants and functions
  - Adds TODOs for test cleanup
  - Removes `st_common_init_args` constant, prefers use of `get_st_init_args` instead
- Adds actions for common tasks
  - https://github.com/supertokens/get-versions-action
  - https://github.com/supertokens/get-supported-versions-action
- Updates unit test Circle CI scripts
  • Loading branch information
namsnath authored Mar 6, 2025
1 parent 4db27ad commit d00c0a6
Show file tree
Hide file tree
Showing 89 changed files with 1,149 additions and 2,169 deletions.
19 changes: 9 additions & 10 deletions .circleci/config_continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
- checkout
- run: apt update && apt install -y bc jq lsof
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
- run: (cd .circleci/ && ./installJava.sh)
- run: python3 -m pip install pip setuptools --upgrade
- run: make dev-install
- run: (cd .circleci/ && ./doUnitTests.sh << parameters.cdi-version >>)
Expand Down Expand Up @@ -329,18 +328,18 @@ workflows:
only: /test-cicd\/.*/
- test-unit:
requires:
- test-dev-tag-as-not-passed
- test-dev-tag-as-not-passed
context:
- slack-notification
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
matrix:
parameters:
cdi-version: placeholder
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
parameters:
cdi-version: placeholder
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
- test-backend-sdk-testing:
requires:
- test-dev-tag-as-not-passed
Expand Down
11 changes: 3 additions & 8 deletions .circleci/doUnitTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ then
echo "fetching latest X.Y version for core given core-driver-interface X.Y version: $coreDriverVersion, planType: FREE gave response: $coreFree. Please make sure all relevant cores have been pushed."
exit 1
fi
coreFree=$(echo $coreFree | jq .core | tr -d '"')

./setupAndTestWithFreeCore.sh $coreFree $coreDriverVersion
if [[ $? -ne 0 ]]
then
echo "test failed... exiting!"
exit 1
fi
rm -rf ../../supertokens-root
export SUPERTOKENS_CORE_VERSION=$(echo $coreFree | jq .core | tr -d '"')

make test
63 changes: 0 additions & 63 deletions .circleci/setupAndTestWithFreeCore.sh

This file was deleted.

2 changes: 0 additions & 2 deletions .github/helpers/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions .github/helpers/package.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
name: "Lint/Format"
name: "Lint/Format Code"

on:
pull_request:
types:
- opened
- reopened
- synchronize
push:
branches:
- master
- "v[0-9]+.[0-9]+"
tags:
- "(dev-)?v[0-9]+.[0-9]+.[0-9]+"

jobs:
define-versions:
runs-on: ubuntu-latest
outputs:
pyVersions: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]'

lint-format:
name: Check linting and formatting
runs-on: ubuntu-latest
needs: define-versions
strategy:
matrix:
py_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
py-version: ${{ fromJSON(needs.define-versions.outputs.pyVersions) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py_version }}
python-version: ${{ matrix.py-version }}
- name: Create virtual environment and install dependencies
run: |
python3 -m venv venv
Expand Down
50 changes: 25 additions & 25 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
name: "Lint PR"

on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
pull_request:
types:
- opened
- reopened
- edited
- synchronize

jobs:
lint-pr-title:
name: Lint PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: true
lint-pr-title:
name: Lint PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: true

# Enforces the update of a changelog file on every pull request
lint-changelog:
name: Enforce Changelogs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dangoslen/changelog-enforcer@v2
with:
changeLogPath: "CHANGELOG.md"
skipLabels: "Skip-Changelog"
# Enforces the update of a changelog file on every pull request
lint-changelog:
name: Enforce Changelogs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dangoslen/changelog-enforcer@v2
with:
changeLogPath: "CHANGELOG.md"
skipLabels: "Skip-Changelog"
24 changes: 0 additions & 24 deletions .github/workflows/tests-pass-check-pr.yml

This file was deleted.

60 changes: 0 additions & 60 deletions .github/workflows/tests.yml

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Unit Tests"

on:
pull_request:
types:
- opened
- reopened
- synchronize
push:
branches:
- master
- "v[0-9]+.[0-9]+"
tags:
- "(dev-)?v[0-9]+.[0-9]+.[0-9]+"

jobs:
define-versions:
runs-on: ubuntu-latest
outputs:
fdiVersions: ${{ steps.versions.outputs.fdiVersions }}
cdiVersions: ${{ steps.versions.outputs.cdiVersions }}
pyVersions: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]'
steps:
- uses: actions/checkout@v4
- uses: supertokens/get-supported-versions-action@main
id: versions
with:
has-fdi: true
has-cdi: true

test:
runs-on: ubuntu-latest
needs: define-versions
strategy:
fail-fast: false
matrix:
py-version: ${{ fromJSON(needs.define-versions.outputs.pyVersions) }}
cdi-version: ${{ fromJSON(needs.define-versions.outputs.cdiVersions) }}
steps:
- uses: actions/checkout@v4
- uses: supertokens/get-versions-action@main
id: versions
with:
driver-name: python
cdi-version: ${{ matrix.cdi-version }}
env:
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py-version }}
- name: Create virtual environment and install dependencies
# Updrade `pip` and `setuptools` to have the latest versions before further installs
run: |
python3 -m venv venv
source venv/bin/activate
python3 -m pip install pip setuptools --upgrade
make dev-install && rm -rf src
- name: Run unit tests
run: |
source venv/bin/activate
make test
env:
SUPERTOKENS_CORE_VERSION: ${{ steps.versions.outputs.coreVersionXy }}
- uses: pmeier/pytest-results-action@main
name: Surface failing tests
if: always()
with:
path: test-results/junit.xml
summary: true
title: "[Core=${{ steps.versions.outputs.coreVersionXy }}][py=${{ matrix.py-version }}] Unit Test Results"
Loading

0 comments on commit d00c0a6

Please sign in to comment.