test message #13
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: Cypress Tests | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| cypress: | |
| runs-on: ubuntu-latest | |
| # Add permissions needed for PR comments | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| strategy: | |
| matrix: | |
| node-version: [22.x] # Latest LTS version | |
| # Don't cancel other matrix jobs if one fails | |
| fail-fast: false | |
| steps: | |
| - uses: actions/[email protected] | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/[email protected] | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Get Cypress cache | |
| uses: actions/[email protected] | |
| id: cypress-cache | |
| with: | |
| path: ~/.cache/Cypress | |
| key: cypress-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| cypress-${{ runner.os }}- | |
| - name: Install Cypress | |
| if: steps.cypress-cache.outputs.cache-hit != 'true' | |
| run: yarn cypress install | |
| - name: Run Cypress tests | |
| id: cypress | |
| uses: cypress-io/[email protected] | |
| with: | |
| start: yarn start | |
| wait-on: 'http://localhost:3000' | |
| wait-on-timeout: 120 | |
| browser: chrome | |
| record: false | |
| - name: Upload Cypress screenshots | |
| uses: actions/[email protected] | |
| if: failure() | |
| with: | |
| name: cypress-screenshots | |
| path: cypress/screenshots | |
| if-no-files-found: ignore | |
| - name: Upload Cypress videos | |
| uses: actions/[email protected] | |
| if: always() | |
| with: | |
| name: cypress-videos | |
| path: cypress/videos | |
| if-no-files-found: ignore | |
| # Add test summary to PR | |
| - name: Add PR Comment | |
| if: github.event_name == 'pull_request' && (success() || failure()) | |
| uses: actions/[email protected] | |
| with: | |
| script: | | |
| const testStatus = '${{ steps.cypress.outcome }}' === 'success' ? 'β ' : 'β'; | |
| const artifactsUrl = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; | |
| const comment = `## Cypress Test Results ${testStatus} | |
| **Status:** ${testStatus === 'β ' ? 'All tests passed!' : 'Some tests failed'} | |
| ${testStatus === 'β' ? `### Test Artifacts | |
| - [View Screenshots and Videos](${artifactsUrl})` : ''} | |
| [View Full Test Run](${artifactsUrl})`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); |