diff --git a/.github/workflows/auth-react-test-1-django.yml b/.github/workflows/auth-react-test-1-django.yml index bef6b3c4a..ad74b1bcc 100644 --- a/.github/workflows/auth-react-test-1-django.yml +++ b/.github/workflows/auth-react-test-1-django.yml @@ -7,11 +7,14 @@ on: - reopened - synchronize push: - branches: - - master - - "v[0-9]+.[0-9]+" tags: - - "(dev-)?v[0-9]+.[0-9]+.[0-9]+" + - 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: @@ -22,6 +25,7 @@ jobs: pyVersions: '["3.8", "3.13"]' steps: - uses: actions/checkout@v4 + - uses: supertokens/get-supported-versions-action@main id: versions with: diff --git a/.github/workflows/auth-react-test-1-fastapi.yml b/.github/workflows/auth-react-test-1-fastapi.yml index ac4cc1de3..5f0e08cc9 100644 --- a/.github/workflows/auth-react-test-1-fastapi.yml +++ b/.github/workflows/auth-react-test-1-fastapi.yml @@ -7,11 +7,14 @@ on: - reopened - synchronize push: - branches: - - master - - "v[0-9]+.[0-9]+" tags: - - "(dev-)?v[0-9]+.[0-9]+.[0-9]+" + - 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: @@ -22,6 +25,7 @@ jobs: pyVersions: '["3.8", "3.13"]' steps: - uses: actions/checkout@v4 + - uses: supertokens/get-supported-versions-action@main id: versions with: diff --git a/.github/workflows/auth-react-test-1-flask.yml b/.github/workflows/auth-react-test-1-flask.yml index b0a104000..991381bb7 100644 --- a/.github/workflows/auth-react-test-1-flask.yml +++ b/.github/workflows/auth-react-test-1-flask.yml @@ -7,11 +7,14 @@ on: - reopened - synchronize push: - branches: - - master - - "v[0-9]+.[0-9]+" tags: - - "(dev-)?v[0-9]+.[0-9]+.[0-9]+" + - 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: @@ -22,6 +25,7 @@ jobs: pyVersions: '["3.8", "3.13"]' steps: - uses: actions/checkout@v4 + - uses: supertokens/get-supported-versions-action@main id: versions with: diff --git a/.github/workflows/auth-react-test-3.yml b/.github/workflows/auth-react-test-3.yml index d7c8b9564..23a5b108d 100644 --- a/.github/workflows/auth-react-test-3.yml +++ b/.github/workflows/auth-react-test-3.yml @@ -67,6 +67,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + # Checking out to a custom path since the test repo will also be cloned path: supertokens-python - uses: actions/setup-python@v5 diff --git a/.github/workflows/backend-sdk-testing.yml b/.github/workflows/backend-sdk-testing.yml index 08212eed2..94798d06c 100644 --- a/.github/workflows/backend-sdk-testing.yml +++ b/.github/workflows/backend-sdk-testing.yml @@ -7,11 +7,14 @@ on: - reopened - synchronize push: - branches: - - master - - "v[0-9]+.[0-9]+" tags: - - "(dev-)?v[0-9]+.[0-9]+.[0-9]+" + - 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: @@ -23,6 +26,7 @@ jobs: nodeVersions: '["20"]' steps: - uses: actions/checkout@v4 + - uses: supertokens/get-supported-versions-action@main id: versions with: @@ -82,10 +86,11 @@ jobs: run: | source venv/bin/activate docker compose up --build --wait - python3 tests/test-server/app.py & + python3 tests/test-server/app.py &> python.log & - uses: supertokens/backend-sdk-testing-action@main with: version: ${{ matrix.fdi-version }} check-name-suffix: '[CDI=${{ matrix.cdi-version }}][Core=${{ steps.versions.outputs.coreVersionXy }}][FDI=${{ matrix.fdi-version }}][Py=${{ matrix.py-version }}][Node=${{ matrix.node-version }}]' path: backend-sdk-testing + app-server-logs: ${{ github.workspace }}/supertokens-python/python.log diff --git a/.github/workflows/lint-code.yml b/.github/workflows/lint-code.yml index af902ce40..7f78aff05 100644 --- a/.github/workflows/lint-code.yml +++ b/.github/workflows/lint-code.yml @@ -7,11 +7,14 @@ on: - reopened - synchronize push: - branches: - - master - - "v[0-9]+.[0-9]+" tags: - - "(dev-)?v[0-9]+.[0-9]+.[0-9]+" + - 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: @@ -19,6 +22,11 @@ jobs: outputs: pyVersions: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]' + steps: + # Required to avoid errors in runs due to no steps + - name: Placeholder + run: echo "Placeholder" + lint-format: name: Check linting and formatting runs-on: ubuntu-latest @@ -28,15 +36,18 @@ jobs: py-version: ${{ fromJSON(needs.define-versions.outputs.pyVersions) }} steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.py-version }} + - name: Create virtual environment and install dependencies run: | python3 -m venv venv source venv/bin/activate python3 -m pip install pip setuptools --upgrade make dev-install && rm -rf src + - name: Run checks # New steps require sourcing the venv again run: | diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml index 3dd31354a..72175a5aa 100644 --- a/.github/workflows/lint-pr.yml +++ b/.github/workflows/lint-pr.yml @@ -8,6 +8,12 @@ on: - edited - synchronize +# 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: lint-pr-title: name: Lint PR Title diff --git a/.github/workflows/pipeline-dev-tag.yml b/.github/workflows/pipeline-dev-tag.yml new file mode 100644 index 000000000..494933f83 --- /dev/null +++ b/.github/workflows/pipeline-dev-tag.yml @@ -0,0 +1,140 @@ +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: + constantsVersion: ${{ steps.versions.outputs.constantsVersion }} + constantsVersionXy: ${{ steps.versions.outputs.constantsVersionXy }} + setupVersion: ${{ steps.versions.outputs.setupVersion }} + setupVersionXy: ${{ steps.versions.outputs.setupVersionXy }} + 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 "constantsVersion=$constantsVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "constantsVersionXy=$constantsVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "setupVersion=$setupVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "setupVersionXy=$setupVersionXy" | 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$setupVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "releaseTag=v$setupVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + + - name: Check tag and branch correctness + run: | + if [[ "${{ steps.versions.outputs.setupVersion }}" != ${{ 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: make dev-install + + - name: Build docs + run: make 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: true + has-fdi: true + + - run: | + ./hooks/populate-hook-constants.sh + + curl --fail-with-body -X PUT \ + https://api.supertokens.io/0/driver \ + -H 'Content-Type: application/json' \ + -H 'api-version: 0' \ + -d "{ + \"password\": \"${{ secrets.SUPERTOKENS_API_KEY }}\", + \"version\":\"${{ needs.setup.outputs.setupVersion }}\", + \"name\": \"python\", + \"frontendDriverInterfaces\": ${{ steps.versions.outputs.fdiVersions }}, + \"coreDriverInterfaces\": ${{ steps.versions.outputs.cdiVersions }} + }" diff --git a/.github/workflows/pipeline-release-tag.yml b/.github/workflows/pipeline-release-tag.yml new file mode 100644 index 000000000..1f8d3ca9a --- /dev/null +++ b/.github/workflows/pipeline-release-tag.yml @@ -0,0 +1,325 @@ +name: "Release Pipeline" + +on: + workflow_dispatch: + inputs: + branch: + description: The branch to create the release tag on + type: string + required: true + + skip-test-checks: + description: Skip tests passed checks + type: boolean + default: false + required: false + + skip-other-version-checks: + description: Skip server checks for core and frontend versions + type: boolean + default: false + required: false + +permissions: + contents: write + + +jobs: + setup: + runs-on: ubuntu-latest + + outputs: + constantsVersion: ${{ steps.versions.outputs.constantsVersion }} + constantsVersionXy: ${{ steps.versions.outputs.constantsVersionXy }} + setupVersion: ${{ steps.versions.outputs.setupVersion }} + setupVersionXy: ${{ steps.versions.outputs.setupVersionXy }} + newestVersion: ${{ steps.versions.outputs.newestVersion }} + targetBranch: ${{ steps.versions.outputs.targetBranch }} + devTag: ${{ steps.versions.outputs.devTag }} + releaseTag: ${{ steps.versions.outputs.releaseTag }} + versionFolder: ${{ steps.versions.outputs.versionFolder }} + artifactName: ${{ steps.versions.outputs.artifactName }} + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + fetch-tags: true + token: ${{ secrets.ALL_REPO_PAT }} + + - name: Populate variables + id: versions + run: | + . ./hooks/populate-hook-constants.sh + + echo "constantsVersion=$constantsVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "constantsVersionXy=$constantsVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "setupVersion=$setupVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "setupVersionXy=$setupVersionXy" | 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$setupVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "releaseTag=v$setupVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + + echo "versionFolder=$setupVersionXy.X" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + echo "artifactName=python-docs-$setupVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + + mark-as-success: + runs-on: ubuntu-latest + + needs: + - setup + + steps: + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Install dependencies + run: | + pip install httpx + + - if: ${{ inputs.skip-test-checks == 'false' }} + name: Get commit status + run: | + python3 -c "$(cat << EOF + + from collections import defaultdict + import httpx + import sys + + url = "https://api.github.com/repos/${{ github.repository }}/commits/tags/${{ needs.setup.outputs.devTag }}/check-runs?per_page=100&page={page}" + page = 1 + total = 0 + + status_map = defaultdict(int) + conclusion_map = defaultdict(int) + + while True: + response = httpx.get(url.format(page=page)).json() + + if len(response["check_runs"]) == 0: + break + + for run_info in response["check_runs"]: + status_map[run_info["status"]] += 1 + conclusion_map[run_info["conclusion"]] += 1 + total += 1 + + page += 1 + + print(f"{total=}") + print(dict(status_map)) + print(dict(conclusion_map)) + + if status_map["completed"] < total: + print("Some checks not completed.") + print(dict(status_map)) + sys.exit(1) + + if conclusion_map["success"] < total: + print("Some checks not successful.") + print(dict(conclusion_map)) + sys.exit(1) + + EOF + )" + + - run: | + curl --fail-with-body -X PATCH \ + https://api.supertokens.io/0/driver \ + -H 'Content-Type: application/json' \ + -H 'api-version: 0' \ + -d "{ + \"password\": \"${{ secrets.SUPERTOKENS_API_KEY }}\", + \"version\":\"${{ needs.setup.outputs.setupVersion }}\", + \"name\": \"python\", + \"testPassed\": true + }" + + release: + runs-on: ubuntu-latest + + # This job marks the version as a release version and creates tags. + # Binding this to the publish env to require approvals before run. + # Further jobs are follow-ups to the release and are not required to be approved once release is approved. + environment: publish + + needs: + - setup + - mark-as-success + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + 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" + + - name: Check tests passed + run: | + testsPassed=`curl -s -X GET "https://api.supertokens.io/0/driver?password=${{ secrets.SUPERTOKENS_API_KEY }}&version=${{ needs.setup.outputs.setupVersion }}&name=python" -H 'api-version: 0'` + + if [[ $(echo $testsPassed | jq .testPassed) != "true" ]] + then + echo "All tests have not passed. Exiting." + exit 1 + fi + + - if: ${{ inputs.skip-other-version-checks == 'false' }} + name: Check if core and frontend released + run: | + canReleaseSafelyResponse=`curl -s -X GET "https://api.supertokens.io/0/driver/release/check?password=${{ secrets.SUPERTOKENS_API_KEY }}&version=${{ needs.setup.outputs.setupVersion }}&name=python" -H 'api-version: 0'` + + if [[ $(echo $canReleaseSafelyResponse | jq .canRelease) != "true" ]] + then + echo "Cannot release. Have you released corresponding core and frontend?" + exit 1 + fi + + - name: Check if current commit is dev-tagged + run: | + currentCommit=$(git log --format="%H" -n 1) + currentTag=`git tag -l --points-at $currentCommit` + expectedTag="${{ needs.setup.outputs.devTag }}" + + if [[ $currentTag != $expectedTag ]] + then + echo "Commit does not have the correct dev tag for this release" + echo "Current: $currentTag" + echo "Expected: $expectedTag" + exit 1 + fi + + - name: Mark for release + run: | + curl --fail-with-body -X PUT \ + https://api.supertokens.io/0/driver \ + -H 'Content-Type: application/json' \ + -H 'api-version: 0' \ + -d "{ + \"password\": \"${{ secrets.SUPERTOKENS_RELEASE_API_KEY }}\", + \"name\":\"python\", + \"version\":\"${{ needs.setup.outputs.setupVersion }}\", + \"release\": true + }" + + - name: Create release tag, delete dev tag + run: | + # Add new release tag + git tag ${{ needs.setup.outputs.releaseTag }} + git push --tags + + # Delete current dev tag + git tag --delete ${{ needs.setup.outputs.devTag }} + git push --delete origin ${{ needs.setup.outputs.devTag }} + + + merge: + runs-on: ubuntu-latest + needs: + - setup + - release + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + # Need a complete fetch to make the master merge 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" + + - name: Check API and merge to master + run: | + response=$(curl -s\ + -X GET\ + "https://api.supertokens.io/0/driver/latest/check?\ + password=${{ secrets.SUPERTOKENS_API_KEY }}&\ + version=${{ needs.setup.outputs.setupVersion }}&\ + name=python" \ + -H 'api-version: 0' + ) + + if [[ $response == "true" ]] + then + git checkout master + git checkout ${{ inputs.branch }} + + git merge master + git checkout master + git merge ${{ inputs.branch }} + git push + git checkout ${{ inputs.branch }} + fi + + publish-docs: + runs-on: ubuntu-latest + needs: + - setup + - release + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.setup.outputs.releaseTag }} + fetch-tags: true + + - uses: actions/upload-artifact@v4 + with: + name: ${{ needs.setup.outputs.artifactName }} + path: html/supertokens_python + + - name: Trigger the backend website CI + uses: actions/github-script@v7 + with: + # NOTE: We should use a better scoped PAT here. + github-token: ${{ secrets.ALL_REPO_PAT }} + script: | + github.rest.actions.createWorkflowDispatch({ + owner: 'supertokens', + repo: 'supertokens-backend-website', + workflow_id: 'release-python-documentation-changes.yml', + ref: 'master', + inputs: { + "version": `${{ needs.setup.outputs.setupVersion }}`, + "artifact-name": `${{ needs.setup.outputs.artifactName }}`, + "version-folder": `${{ needs.setup.outputs.versionFolder }}`, + "run-id": `${{ github.run_id }}`, + "stage": "production", + } + }) + + publish: + runs-on: ubuntu-latest + needs: + - setup + - release + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.setup.outputs.releaseTag }} + fetch-tags: true + + - run: | + # python3 -m pip install pip setuptools packaging poetry clikit --upgrade + # make dev-install + # pip install setuptools wheels twine + # python setup.py sdist bdist_wheel + # twine upload -u ${{ secrets.TWINE_USERNAME }} -p ${{ secrets.TWINE_PASSWORD }} dist/* diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 9f8ee912e..a74f9ec51 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -7,21 +7,27 @@ on: - reopened - synchronize push: - branches: - - master - - "v[0-9]+.[0-9]+" tags: - - "(dev-)?v[0-9]+.[0-9]+.[0-9]+" + - 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 }} 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: @@ -31,13 +37,16 @@ jobs: 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: @@ -45,9 +54,11 @@ jobs: 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: | @@ -55,12 +66,14 @@ jobs: 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() diff --git a/.github/workflows/website-test.yml b/.github/workflows/website-test.yml index 315a9666c..f63530500 100644 --- a/.github/workflows/website-test.yml +++ b/.github/workflows/website-test.yml @@ -7,11 +7,14 @@ on: - reopened - synchronize push: - branches: - - master - - "v[0-9]+.[0-9]+" tags: - - "(dev-)?v[0-9]+.[0-9]+.[0-9]+" + - 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: @@ -22,6 +25,7 @@ jobs: pyVersions: '["3.8", "3.13"]' steps: - uses: actions/checkout@v4 + - uses: supertokens/get-supported-versions-action@main id: versions with: @@ -46,8 +50,17 @@ jobs: - flask-nest-asyncio steps: + - name: Setup ENVs + id: envs + run: | + APP_SERVER_LOG_DIR=${{ github.workspace }}/logs + echo "APP_SERVER_LOG_DIR=$APP_SERVER_LOG_DIR" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" + + mkdir -p $APP_SERVER_LOG_DIR + - uses: actions/checkout@v4 with: + # Checking out to a custom path since the test repo will also be cloned path: supertokens-python - uses: actions/setup-python@v5 @@ -88,8 +101,8 @@ jobs: export PYTHONPATH="${PYTHONPATH}:$(pwd)" cd tests/frontendIntegration/django2x - gunicorn mysite.wsgi --bind 0.0.0.0:8080 &> app-server.log & - gunicorn mysite.wsgi --bind 0.0.0.0:8082 &> app-server-cross-domain.log & + gunicorn mysite.wsgi --bind 0.0.0.0:8080 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server.log & + gunicorn mysite.wsgi --bind 0.0.0.0:8082 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server-cross-domain.log & - name: Install dependencies and start servers (django3x) if: matrix.framework == 'django3x' @@ -101,8 +114,8 @@ jobs: export PYTHONPATH="${PYTHONPATH}:$(pwd)" cd tests/frontendIntegration/django3x - uvicorn mysite.asgi:application --port 8080 &> app-server.log & - uvicorn mysite.asgi:application --port 8082 &> app-server-cross-domain.log & + uvicorn mysite.asgi:application --port 8080 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server.log & + uvicorn mysite.asgi:application --port 8082 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server-cross-domain.log & - name: Install dependencies and start servers (drf_sync) if: matrix.framework == 'drf_sync' @@ -114,8 +127,8 @@ jobs: export PYTHONPATH="${PYTHONPATH}:$(pwd)" cd tests/frontendIntegration/drf_sync - gunicorn mysite.wsgi --bind 0.0.0.0:8080 &> app-server.log & - gunicorn mysite.wsgi --bind 0.0.0.0:8082 &> app-server-cross-domain.log & + gunicorn mysite.wsgi --bind 0.0.0.0:8080 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server.log & + gunicorn mysite.wsgi --bind 0.0.0.0:8082 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server-cross-domain.log & - name: Install dependencies and start servers (drf_async) if: matrix.framework == 'drf_async' @@ -127,8 +140,8 @@ jobs: export PYTHONPATH="${PYTHONPATH}:$(pwd)" cd tests/frontendIntegration/drf_async - uvicorn mysite.asgi:application --port 8080 &> app-server.log & - uvicorn mysite.asgi:application --port 8082 &> app-server-cross-domain.log & + uvicorn mysite.asgi:application --port 8080 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server.log & + uvicorn mysite.asgi:application --port 8082 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server-cross-domain.log & - name: Install dependencies and start servers (fastapi) if: matrix.framework == 'fastapi' @@ -140,8 +153,8 @@ jobs: export PYTHONPATH="${PYTHONPATH}:$(pwd)" cd tests/frontendIntegration/fastapi-server - uvicorn app:app --host 0.0.0.0 --port 8080 &> app-server.log & - uvicorn app:app --host 0.0.0.0 --port 8082 &> app-server-cross-domain.log & + uvicorn app:app --host 0.0.0.0 --port 8080 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server.log & + uvicorn app:app --host 0.0.0.0 --port 8082 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server-cross-domain.log & - name: Install dependencies and start servers (flask) if: matrix.framework == 'flask' @@ -153,8 +166,8 @@ jobs: export PYTHONPATH="${PYTHONPATH}:$(pwd)" cd tests/frontendIntegration/flask-server - python3 app.py --port 8080 &> app-server.log & - python3 app.py --port 8082 &> app-server-cross-domain.log & + python3 app.py --port 8080 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server.log & + python3 app.py --port 8082 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server-cross-domain.log & - name: Install dependencies and start servers (flask-nest-asyncio) if: matrix.framework == 'flask-nest-asyncio' @@ -167,8 +180,8 @@ jobs: export PYTHONPATH="${PYTHONPATH}:$(pwd)" cd tests/frontendIntegration/flask-server - python3 app.py --port 8080 &> app-server.log & - python3 app.py --port 8082 &> app-server-cross-domain.log & + python3 app.py --port 8080 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server.log & + python3 app.py --port 8082 &> ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }}/app-server-cross-domain.log & - uses: supertokens/website-testing-action@main with: @@ -176,3 +189,4 @@ jobs: node-sdk-version: ${{ steps.versions.outputs.nodeTag }} path: supertokens-website check-name-suffix: '[Py=${{ matrix.py-version }}][FDI=${{ matrix.fdi-version }}][Framework=${{ matrix.framework }}]' + app-server-logs: ${{ steps.envs.outputs.APP_SERVER_LOG_DIR }} diff --git a/hooks/populate-hook-constants.sh b/hooks/populate-hook-constants.sh index e5da15fea..ab53cf320 100755 --- a/hooks/populate-hook-constants.sh +++ b/hooks/populate-hook-constants.sh @@ -4,17 +4,19 @@ # - Abitrary Spaces: ` *` # - Extracting the version into a match group: `(...)` # - Substituting the matched string with the match group: `/\1/` -constantsVersion=$(sed -n 's/^ *VERSION *= *["]\([0-9\.]*\).*/\1/p' supertokens_python/constants.py) -setupVersion=$(sed -n 's/ *version *= *["]\([0-9\.]*\).*/\1/p' setup.py ) +export constantsVersion=$(sed -n 's/^ *VERSION *= *["]\([0-9\.]*\).*/\1/p' supertokens_python/constants.py) +export constantsVersionXy=$(sed -n 's/^ *VERSION *= *["]\([0-9]*\.[0-9]*\).*/\1/p' supertokens_python/constants.py) +export setupVersion=$(sed -n 's/ *version *= *["]\([0-9\.]*\).*/\1/p' setup.py ) +export setupVersionXy=$(sed -n 's/ *version *= *["]\([0-9]*\.[0-9]*\).*/\1/p' setup.py ) -newestVersion=$( if [[ "$constantsVersion" > "$setupVersion" ]]; then echo "$constantsVersion"; else echo "$setupVersion"; fi ) +export newestVersion=$( if [[ "$constantsVersion" > "$setupVersion" ]]; then echo "$constantsVersion"; else echo "$setupVersion"; fi ) # Target branch of the PR. # Ideally, this is all we want to check. if [[ "$GITHUB_BASE_REF" != "" ]] then - targetBranch="$GITHUB_BASE_REF" + export targetBranch="$GITHUB_BASE_REF" else # Fallback to current branch if not in a PR - targetBranch=$(git branch --show-current 2> /dev/null) || targetBranch="(unnamed branch)" # Get current branch + export targetBranch=$(git branch --show-current 2> /dev/null) || export targetBranch="(unnamed branch)" # Get current branch fi -targetBranch=${targetBranch##refs/heads/} # Remove refs/heads/ if present +export targetBranch=${targetBranch##refs/heads/} # Remove refs/heads/ if present