|
| 1 | +name: Next.js appdir test suite |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + setup: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + test-files: ${{ steps['set-test-files'].outputs['test-files'] }} |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + - run: npm install |
| 17 | + - id: set-test-files |
| 18 | + name: Get test files |
| 19 | + # Extracts the list of all test files as JSON and trims to be relative to the test dir to be easier to read |
| 20 | + run: |
| 21 | + echo "test-files=$(npx jest -c test/e2e/jest.config.appdir.js --listTests --json | jq -cM 'map(.[env.PWD | |
| 22 | + length + 10:])')" >> $GITHUB_OUTPUT |
| 23 | + # echo "test-files=$(npx jest -c test/e2e/jest.config.all.js --listTests --json | jq -cM 'map(.[env.PWD | length |
| 24 | + # + 10:])')" >> $GITHUB_OUTPUT |
| 25 | + |
| 26 | + test: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + name: test (${{ matrix.test-file }}) |
| 29 | + needs: |
| 30 | + - setup |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + # Creates a job for each chunk ID. This will be assigned one or more test files to run |
| 35 | + test-file: ${{ fromJson(needs.setup.outputs['test-files']) }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v3 |
| 38 | + - run: npm install |
| 39 | + - name: Run tests |
| 40 | + run: npx jest --reporters=jest-junit --reporters=default -c test/e2e/jest.config.all.js ${{ matrix.test-file }} |
| 41 | + env: |
| 42 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_BOT_AUTH_TOKEN }} |
| 43 | + NETLIFY_SITE_ID: 1d5a5c76-d445-4ae5-b694-b0d3f2e2c395 |
| 44 | + NEXT_TEST_VERSION: canary |
| 45 | + - uses: actions/upload-artifact@v3 |
| 46 | + if: ${{ always() }} |
| 47 | + name: Upload test results |
| 48 | + with: |
| 49 | + name: test-results |
| 50 | + path: reports/jest-*.xml |
| 51 | + report: |
| 52 | + name: Report appDir e2e test results |
| 53 | + runs-on: ubuntu-latest |
| 54 | + if: ${{ always() }} |
| 55 | + needs: |
| 56 | + - test |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v3 |
| 59 | + - uses: actions/download-artifact@v3 |
| 60 | + with: |
| 61 | + path: reports |
| 62 | + - name: Combine reports |
| 63 | + # The test reporter can handle multiple files, but these have random filenames so the output is better when combined |
| 64 | + run: npx junit-report-merger test-results.xml reports/**/*.xml |
| 65 | + - uses: phoenix-actions/test-reporting@v10 |
| 66 | + with: |
| 67 | + name: Jest Tests |
| 68 | + output-to: 'step-summary' |
| 69 | + path: 'test-results.xml' |
| 70 | + max-annotations: 49 |
| 71 | + reporter: jest-junit |
0 commit comments