Skip to content

Commit 312fd9c

Browse files
committed
ci: backend-sdk-testing
1 parent f78e62d commit 312fd9c

File tree

3 files changed

+106
-1
lines changed

3 files changed

+106
-1
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: "Backend SDK Tests"
2+
3+
on:
4+
pull_request:
5+
types:
6+
- synchronize
7+
push:
8+
tags:
9+
- "(dev-)?v[0-9]+.[0-9]+.[0-9]+"
10+
11+
jobs:
12+
define-versions:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
fdiVersions: ${{ steps.versions.outputs.fdiVersions }}
16+
cdiVersions: ${{ steps.versions.outputs.cdiVersions }}
17+
pyVersions: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]'
18+
nodeVersions: '["20"]'
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: supertokens/get-supported-versions-action@main
22+
id: versions
23+
with:
24+
has-fdi: true
25+
has-cdi: true
26+
27+
test:
28+
runs-on: ubuntu-latest
29+
needs: define-versions
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
cdi-version: ${{ fromJSON(needs.define-versions.outputs.cdiVersions) }}
35+
fdi-version: ${{ fromJSON(needs.define-versions.outputs.fdiVersions) }}
36+
py-version: ${{ fromJson(needs.define-versions.outputs.pyVersions) }}
37+
node-version: ${{ fromJson(needs.define-versions.outputs.nodeVersions) }}
38+
39+
env:
40+
API_PORT: 3030
41+
SUPERTOKENS_CORE_PORT: 3567
42+
SUPERTOKENS_CORE_HOST: localhost
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
# Checking out to a custom path since the test repo will also be cloned
48+
path: supertokens-python
49+
50+
- uses: supertokens/get-versions-action@main
51+
id: versions
52+
with:
53+
driver-name: python
54+
cdi-version: ${{ matrix.cdi-version }}
55+
fdi-version: ${{ matrix.fdi-version }}
56+
env:
57+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
58+
59+
- uses: actions/setup-node@v4
60+
with:
61+
node-version: ${{ matrix.node-version }}
62+
63+
- name: Create virtual environment and install dependencies
64+
working-directory: supertokens-python
65+
# Upgrade `pip` and `setuptools` to have the latest versions before further installs
66+
run: |
67+
python3 -m venv venv
68+
source venv/bin/activate
69+
python3 -m pip install pip setuptools --upgrade
70+
make dev-install && rm -rf src
71+
- name: Start core and server
72+
working-directory: supertokens-python
73+
env:
74+
SUPERTOKENS_ENV: testing
75+
SUPERTOKENS_CORE_VERSION: ${{ steps.versions.outputs.coreVersionXy }}
76+
run: |
77+
source venv/bin/activate
78+
docker compose up --build --wait
79+
python3 tests/test-server/app.py &
80+
- uses: supertokens/backend-sdk-testing-action@main
81+
with:
82+
# version: ${{ matrix.fdi-version }}
83+
version: ci/github-actions/containerized-core/${{ matrix.fdi-version }}
84+
check-name-suffix: '[CDI=${{ matrix.cdi-version }}][Core=${{ steps.versions.outputs.coreVersionXy }}][FDI=${{ matrix.fdi-version }}][Py=${{ matrix.py-version }}][Node=${{ matrix.node-version }}]'
85+
path: backend-sdk-testing

compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,18 @@ services:
66
# Uses `$SUPERTOKENS_CORE_PORT` when available, else 3567 for local port
77
- ${SUPERTOKENS_CORE_PORT:-3567}:3567
88
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
915
healthcheck:
1016
test: bash -c 'curl -s "http://127.0.0.1:3567/hello" | grep "Hello"'
1117
interval: 10s
1218
timeout: 5s
1319
retries: 5
20+
21+
oauth:
22+
image: supertokens/oauth2-test:latest
23+
platform: linux/amd64

tests/test-server/app.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@ def origin_func( # pylint: disable=unused-argument, dangerous-default-value
9494
return origin
9595
return "http://localhost:8080"
9696

97+
core_host: str = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost")
98+
core_port: str = os.environ.get("SUPERTOKENS_CORE_PORT", "3567")
99+
core_url = f"http://{core_host}:{core_port}"
100+
97101
init(
98102
app_info=InputAppInfo(
99103
app_name="SuperTokens",
100104
api_domain="http://api.supertokens.io",
101105
origin=origin_func,
102106
),
103-
supertokens_config=SupertokensConfig(connection_uri="http://localhost:3567"),
107+
supertokens_config=SupertokensConfig(connection_uri=core_url),
104108
framework="flask",
105109
recipe_list=[emailpassword.init(), session.init()],
106110
)
@@ -739,6 +743,12 @@ def reset_override_params_api():
739743
return jsonify({"ok": True})
740744

741745

746+
@app.route("/test/resetoverridelogs", methods=["GET"]) # type: ignore
747+
def reset_override_logs():
748+
override_logging.reset_override_logs()
749+
return jsonify({"ok": True})
750+
751+
742752
@app.route("/test/getoverridelogs", methods=["GET"]) # type: ignore
743753
def get_override_logs():
744754
return jsonify({"logs": override_logging.override_logs})

0 commit comments

Comments
 (0)