-
-
Notifications
You must be signed in to change notification settings - Fork 26
152 lines (137 loc) · 4.13 KB
/
ci.yml
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: ci
on: push
permissions:
contents: write
issues: write
pull-requests: write
jobs:
# example splitting all tests across GitHub machines
prepare:
runs-on: ubuntu-22.04
# explicitly set the output of this job
# so that other jobs can use it
outputs:
matrix: ${{ steps.prepare.outputs.matrix }}
steps:
# generate the list using a bash script
- name: Create matrix ⊹
id: prepare
# for reusable workflow, must use the full action reference
uses: bahmutov/[email protected]
with:
n: 3 # number of containers to output
- name: Print result 🖨
run: echo '${{ steps.prepare.outputs.matrix }}'
# two jobs that split 2 explicit specs
test-spec:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
containers: [1, 2]
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run split Cypress E2E tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v5
with:
build: npm run test-names
# using operating system process environment variables
env:
SPEC: 'cypress/e2e/spec-b.cy.js,cypress/e2e/spec-e.cy.js'
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
test-split:
needs: prepare
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Print GitHub variables 🖨
run: npx @bahmutov/print-env GITHUB
- name: Print GitHub strategy context 🖨
run: echo '${{ toJSON(strategy) }}'
- name: Run split Cypress tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v5
with:
build: npm run test-names
# using operating system process environment variables
env:
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
test-no-summary:
needs: prepare
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run some Cypress tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v5
# run half of all specs
env:
SPLIT: 2
# run the second part of the list of specs
SPLIT_INDEX: 1
# do not write summary to github
SPLIT_SUMMARY: false
test-empty:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Run an empty Cypress split 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v5
with:
build: npm run deps
command: npm run empty
test-user-spec-list:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Split explicit user list of specs 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v5
with:
command: npm run user-specs
test-workflow-e2e:
# https://github.com/bahmutov/cypress-workflows
uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v1
with:
n: 3
test-workflow-component:
# https://github.com/bahmutov/cypress-workflows
uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v1
with:
component: true
n: 2
release:
if: github.ref == 'refs/heads/main'
needs:
[
test-empty,
test-split,
test-spec,
test-workflow-e2e,
test-workflow-component,
test-no-summary,
test-user-spec-list,
]
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Semantic Release 🚀
uses: cycjimmy/semantic-release-action@v3
with:
branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}