Skip to content

Commit 7fd939b

Browse files
committed
feat: uses containerised core in tests
- 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
1 parent 4b6ac8b commit 7fd939b

File tree

89 files changed

+1149
-2169
lines changed

Some content is hidden

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

89 files changed

+1149
-2169
lines changed

.circleci/config_continue.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
- checkout
2626
- run: apt update && apt install -y bc jq lsof
2727
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
28-
- run: (cd .circleci/ && ./installJava.sh)
2928
- run: python3 -m pip install pip setuptools --upgrade
3029
- run: make dev-install
3130
- run: (cd .circleci/ && ./doUnitTests.sh << parameters.cdi-version >>)
@@ -329,18 +328,18 @@ workflows:
329328
only: /test-cicd\/.*/
330329
- test-unit:
331330
requires:
332-
- test-dev-tag-as-not-passed
331+
- test-dev-tag-as-not-passed
333332
context:
334-
- slack-notification
333+
- slack-notification
335334
filters:
336-
tags:
337-
only: /dev-v[0-9]+(\.[0-9]+)*/
338-
branches:
339-
only: /test-cicd\/.*/
335+
tags:
336+
only: /dev-v[0-9]+(\.[0-9]+)*/
337+
branches:
338+
only: /test-cicd\/.*/
340339
matrix:
341-
parameters:
342-
cdi-version: placeholder
343-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
340+
parameters:
341+
cdi-version: placeholder
342+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
344343
- test-backend-sdk-testing:
345344
requires:
346345
- test-dev-tag-as-not-passed

.circleci/doUnitTests.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ then
1616
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."
1717
exit 1
1818
fi
19-
coreFree=$(echo $coreFree | jq .core | tr -d '"')
2019

21-
./setupAndTestWithFreeCore.sh $coreFree $coreDriverVersion
22-
if [[ $? -ne 0 ]]
23-
then
24-
echo "test failed... exiting!"
25-
exit 1
26-
fi
27-
rm -rf ../../supertokens-root
20+
export SUPERTOKENS_CORE_VERSION=$(echo $coreFree | jq .core | tr -d '"')
21+
22+
make test

.circleci/setupAndTestWithFreeCore.sh

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

.github/helpers/.gitignore

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

.github/helpers/package.json

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

.github/workflows/pre-commit-hook-run.yml renamed to .github/workflows/lint-code.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1-
name: "Lint/Format"
1+
name: "Lint/Format Code"
22

33
on:
44
pull_request:
55
types:
66
- opened
77
- reopened
88
- synchronize
9+
push:
10+
branches:
11+
- master
12+
- "v[0-9]+.[0-9]+"
13+
tags:
14+
- "(dev-)?v[0-9]+.[0-9]+.[0-9]+"
915

1016
jobs:
17+
define-versions:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
pyVersions: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]'
21+
1122
lint-format:
23+
name: Check linting and formatting
1224
runs-on: ubuntu-latest
25+
needs: define-versions
1326
strategy:
1427
matrix:
15-
py_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
28+
py-version: ${{ fromJSON(needs.define-versions.outputs.pyVersions) }}
1629
steps:
1730
- uses: actions/checkout@v4
1831
- uses: actions/setup-python@v5
1932
with:
20-
python-version: ${{ matrix.py_version }}
33+
python-version: ${{ matrix.py-version }}
2134
- name: Create virtual environment and install dependencies
2235
run: |
2336
python3 -m venv venv

.github/workflows/lint-pr.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
name: "Lint PR"
22

33
on:
4-
pull_request:
5-
types:
6-
- opened
7-
- reopened
8-
- edited
9-
- synchronize
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- edited
9+
- synchronize
1010

1111
jobs:
12-
lint-pr-title:
13-
name: Lint PR Title
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: amannn/action-semantic-pull-request@v3
17-
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19-
with:
20-
validateSingleCommit: true
12+
lint-pr-title:
13+
name: Lint PR Title
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: amannn/action-semantic-pull-request@v3
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
with:
20+
validateSingleCommit: true
2121

22-
# Enforces the update of a changelog file on every pull request
23-
lint-changelog:
24-
name: Enforce Changelogs
25-
runs-on: ubuntu-latest
26-
steps:
27-
- uses: actions/checkout@v2
28-
- uses: dangoslen/changelog-enforcer@v2
29-
with:
30-
changeLogPath: "CHANGELOG.md"
31-
skipLabels: "Skip-Changelog"
22+
# Enforces the update of a changelog file on every pull request
23+
lint-changelog:
24+
name: Enforce Changelogs
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: dangoslen/changelog-enforcer@v2
29+
with:
30+
changeLogPath: "CHANGELOG.md"
31+
skipLabels: "Skip-Changelog"

.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 & 60 deletions
This file was deleted.

.github/workflows/unit-test.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "Unit Tests"
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
push:
10+
branches:
11+
- master
12+
- "v[0-9]+.[0-9]+"
13+
tags:
14+
- "(dev-)?v[0-9]+.[0-9]+.[0-9]+"
15+
16+
jobs:
17+
define-versions:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
fdiVersions: ${{ steps.versions.outputs.fdiVersions }}
21+
cdiVersions: ${{ steps.versions.outputs.cdiVersions }}
22+
pyVersions: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]'
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: supertokens/get-supported-versions-action@main
26+
id: versions
27+
with:
28+
has-fdi: true
29+
has-cdi: true
30+
31+
test:
32+
runs-on: ubuntu-latest
33+
needs: define-versions
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
py-version: ${{ fromJSON(needs.define-versions.outputs.pyVersions) }}
38+
cdi-version: ${{ fromJSON(needs.define-versions.outputs.cdiVersions) }}
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: supertokens/get-versions-action@main
42+
id: versions
43+
with:
44+
driver-name: python
45+
cdi-version: ${{ matrix.cdi-version }}
46+
env:
47+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
48+
- uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.py-version }}
51+
- name: Create virtual environment and install dependencies
52+
# Updrade `pip` and `setuptools` to have the latest versions before further installs
53+
run: |
54+
python3 -m venv venv
55+
source venv/bin/activate
56+
python3 -m pip install pip setuptools --upgrade
57+
make dev-install && rm -rf src
58+
- name: Run unit tests
59+
run: |
60+
source venv/bin/activate
61+
make test
62+
env:
63+
SUPERTOKENS_CORE_VERSION: ${{ steps.versions.outputs.coreVersionXy }}
64+
- uses: pmeier/pytest-results-action@main
65+
name: Surface failing tests
66+
if: always()
67+
with:
68+
path: test-results/junit.xml
69+
summary: true
70+
title: "[Core=${{ steps.versions.outputs.coreVersionXy }}][py=${{ matrix.py-version }}] Unit Test Results"

0 commit comments

Comments
 (0)