|
| 1 | +name: Run supertokens-auth-react tests |
| 2 | +description: |
| 3 | + Will clone the `supertokens-auth-react` repo in it's own folder in the workspace directory. |
| 4 | + Expects `node` to be installed. The test-server and core need to be running before this action. |
| 5 | + |
| 6 | +inputs: |
| 7 | + auth-react-version: |
| 8 | + description: The git ref to clone, usually a version tag |
| 9 | + required: true |
| 10 | + |
| 11 | + node-version: |
| 12 | + description: The git ref to use for `supertokens-node`, usually a version tag |
| 13 | + required: true |
| 14 | + |
| 15 | + check-name-suffix: |
| 16 | + description: Suffix to append to check names (usually matrix values) |
| 17 | + required: true |
| 18 | + |
| 19 | + path: |
| 20 | + description: Relative path where the repo will be cloned |
| 21 | + required: false |
| 22 | + default: supertokens-auth-react |
| 23 | + |
| 24 | + should-clone: |
| 25 | + description: Whether the `supertokens-auth-react` repo should be cloned |
| 26 | + required: false |
| 27 | + default: 'true' |
| 28 | + |
| 29 | +runs: |
| 30 | + using: composite |
| 31 | + |
| 32 | + steps: |
| 33 | + - if: ${{ inputs.should-clone }} |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + repository: supertokens/supertokens-auth-react |
| 37 | + ref: ${{ inputs.auth-react-version }} |
| 38 | + path: ${{ inputs.path }} |
| 39 | + |
| 40 | + - name: Setup auth-react test servers |
| 41 | + working-directory: ${{ inputs.path }} |
| 42 | + env: |
| 43 | + CI: true |
| 44 | + BROWSER: none |
| 45 | + PORT: 3031 |
| 46 | + REACT_APP_API_PORT: 8083 |
| 47 | + TEST_MODE: testing |
| 48 | + NODE_PORT: 8082 |
| 49 | + NODE_TAG: ${{ inputs.node-version }} |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + npm init |
| 53 | + (cd ./examples/for-tests && npm run link) # this is there because in linux machine, postinstall in npm doesn't work.. |
| 54 | + cd ./test/server/ |
| 55 | + npm i git+https://github.com:supertokens/supertokens-node.git#$NODE_TAG |
| 56 | + npm i |
| 57 | +
|
| 58 | + (cd test/server/ && node . >> ~/test_report/react-logs/backend.log 2>&1 &) |
| 59 | + (cd ./examples/for-tests/ && cat | npm run start >> ~/test_report/react-logs/frontend.log 2>&1 &) |
| 60 | +
|
| 61 | + - name: Run tests |
| 62 | + working-directory: ${{ inputs.path }} |
| 63 | + env: |
| 64 | + CI: true |
| 65 | + BROWSER: none |
| 66 | + PORT: 3031 |
| 67 | + REACT_APP_API_PORT: 8083 |
| 68 | + TEST_MODE: testing |
| 69 | + NODE_PORT: 8082 |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + npm test-e2e |
| 73 | +
|
| 74 | + - if: always() |
| 75 | + name: Fix paths |
| 76 | + working-directory: ${{ inputs.path }} |
| 77 | + shell: bash |
| 78 | + # Doing it in the shell since the Reporter's `transformers` don't seem to work |
| 79 | + run: sed -i "s|${{ github.workspace }}/${{ inputs.path }}/test||g" test-report/test-results.xml |
| 80 | + |
| 81 | + - if: always() |
| 82 | + name: Reporter |
| 83 | + # Alternative: dorny/test-reporter@v1 - does not create a summary |
| 84 | + uses: mikepenz/action-junit-report@v5 |
| 85 | + with: |
| 86 | + report_paths: ${{ inputs.path }}/test-results.xml |
| 87 | + check_name: Auth React Tests ${{ inputs.check-name-suffix }} |
| 88 | + # Include table with all test results in the summary |
| 89 | + detailed_summary: true |
| 90 | + # Group the testcases by test suite in the detailed_summary |
| 91 | + group_suite: true |
| 92 | + # Fail if no test are found. |
| 93 | + require_tests: true |
| 94 | + # Fail the build in case of a test failure. |
| 95 | + fail_on_failure: true |
0 commit comments