|
| 1 | +name: Cypress Component Tests |
| 2 | + |
| 3 | +on: pull_request |
| 4 | + |
| 5 | +env: |
| 6 | + # Adjust APP_NAME if your repository name is different |
| 7 | + APP_NAME: ${{ github.event.repository.name }} |
| 8 | + |
| 9 | + # This represents the server branch to checkout. |
| 10 | + # Usually it's the base branch of the PR, but for pushes it's the branch itself. |
| 11 | + # e.g. 'main', 'stable27' or 'feature/my-feature |
| 12 | + # n.b. server will use head_ref, as we want to test the PR branch. |
| 13 | + BRANCH: ${{ github.base_ref || github.ref_name }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + cypress-component: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout app |
| 21 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 22 | + |
| 23 | + - name: Read package.json node and npm engines version |
| 24 | + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 |
| 25 | + id: versions |
| 26 | + with: |
| 27 | + fallbackNode: "^20" |
| 28 | + fallbackNpm: "^9" |
| 29 | + |
| 30 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 31 | + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 |
| 32 | + with: |
| 33 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 34 | + |
| 35 | + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} |
| 36 | + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" |
| 37 | + |
| 38 | + - name: Install node dependencies & build app |
| 39 | + run: | |
| 40 | + npm ci |
| 41 | + TESTING=true npm run build --if-present |
| 42 | +
|
| 43 | + - name: Cypress component tests |
| 44 | + uses: cypress-io/github-action@ebe8b24c4428922d0f793a5c4c96853a633180e3 # v6.6.0 |
| 45 | + with: |
| 46 | + component: true |
| 47 | + env: |
| 48 | + # Needs to be prefixed with CYPRESS_ |
| 49 | + CYPRESS_BRANCH: ${{ env.BRANCH }} |
| 50 | + # https://github.com/cypress-io/github-action/issues/124 |
| 51 | + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} |
| 52 | + # Needed for some specific code workarounds |
| 53 | + TESTING: true |
| 54 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + CYPRESS_BUILD_ID: ${{ github.sha }}-${{ github.run_number }} |
| 56 | + CYPRESS_GROUP: Run component |
0 commit comments