-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (80 loc) Β· 2.84 KB
/
cypress.yml
File metadata and controls
98 lines (80 loc) Β· 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Get Cypress cache
uses: actions/cache@v4
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/github-action@v6
with:
start: yarn start
wait-on: 'http://localhost:3000'
wait-on-timeout: 120
browser: chrome
record: false
- name: Upload Cypress screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: ignore
- name: Upload Cypress videos
uses: actions/upload-artifact@v4
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/github-script@v7
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
});