feat: sets up workflow to run integration tests #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Web JS Integration 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 }} | |
| wjiVersions: ${{ steps.versions.outputs.webJsInterfaceVersion }} | |
| 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-web-js: true | |
| - 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: | |
| fdi-version: ${{ fromJSON(needs.define-versions.outputs.fdiVersions) }} | |
| node-version: ${{ fromJson(needs.define-versions.outputs.nodeVersions) }} | |
| env: | |
| API_PORT: 3030 | |
| SUPERTOKENS_CORE_PORT: 3567 | |
| SUPERTOKENS_CORE_HOST: localhost | |
| SUPERTOKENS_ENV: testing | |
| TEST_MODE: testing | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| path: supertokens-web-js | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Get Node version from current FDI version | |
| id: node-version | |
| run: | | |
| nodeVersion=$(echo '${{ needs.define-versions.outputs.nodeFdiVersionMap }}' | jq -r '.["${{ matrix.fdi-version }}"]') | |
| echo "nodeVersion=${nodeVersion}" >> $GITHUB_OUTPUT | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: supertokens/supertokens-node | |
| path: supertokens-node | |
| - uses: supertokens/get-supported-versions-action@main | |
| id: node-cdi-versions | |
| 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 CDI version | |
| id: core-version | |
| run: | | |
| lastCdiVersion=$(echo '${{ steps.node-cdi-versions.outputs.cdiVersions }}' | jq -r '.[-1]') | |
| coreVersion=$(echo '${{ steps.core-versions.outputs.cdiVersions }}' | jq -r '.["$lastCdiVersion"]') | |
| echo "coreVersion=${coreVersion}" >> $GITHUB_OUTPUT | |
| - name: Start core | |
| working-directory: supertokens-web-js | |
| env: | |
| SUPERTOKENS_CORE_VERSION: ${{ steps.core-version.outputs.coreVersion }} | |
| run: | | |
| docker compose up --build --wait | |
| - name: Setup server | |
| working-directory: supertokens-web-js/test/server | |
| run: | | |
| npm i | |
| node . | |
| - name: Run tests | |
| working-directory: supertokens-web-js | |
| run: | | |
| npx mocha test/integration |