-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (155 loc) · 5.75 KB
/
tests.yml
File metadata and controls
196 lines (155 loc) · 5.75 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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: Tests
on:
push:
branches:
- '**'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pr-check:
runs-on: ubuntu-latest
outputs:
has_open_pr: ${{ steps.detect.outputs.has_open_pr }}
steps:
- name: Detect open pull request for current branch
id: detect
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" != "push" || "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
exit 0
fi
branch="${GITHUB_REF#refs/heads/}"
head="${GITHUB_REPOSITORY_OWNER}:${branch}"
api_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls"
count="$(
curl -fsSL \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
--get "${api_url}" \
--data-urlencode "state=open" \
--data-urlencode "head=${head}" \
--data-urlencode "per_page=1" \
| python3 -c 'import json,sys; print(len(json.load(sys.stdin)))'
)"
if [[ "${count}" -gt 0 ]]; then
echo "has_open_pr=true" >> "$GITHUB_OUTPUT"
else
echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
fi
eslint:
needs: pr-check
if: github.event_name != 'push' || github.ref == 'refs/heads/main' || needs.pr-check.outputs.has_open_pr != 'true'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 22.x, 24.x ]
steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4
- name: Setup Node and dependencies
uses: ./.github/actions/setup-env
with:
node-version: ${{ matrix.node-version }}
- name: Run eslint
run: yarn eslint
tests:
needs: eslint
timeout-minutes: 90
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 22.x, 24.x ]
steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4
- name: Setup Node and dependencies
uses: ./.github/actions/setup-env
with:
node-version: ${{ matrix.node-version }}
- name: Run test type checks
if: matrix.node-version == '24.x'
run: yarn tsc:tests
- name: Run tests
if: matrix.node-version != '24.x'
run: yarn test
- name: Install Playwright Chromium
if: matrix.node-version == '24.x'
run: yarn playwright install --with-deps chromium
- name: Run merged coverage
if: matrix.node-version == '24.x'
run: |
rm -rf coverage .nyc_output artifacts
mkdir -p coverage/.parts .nyc_output artifacts
yarn test --coverage --coverage.provider=istanbul --coverage.reporter=json --coverage.reportsDirectory=coverage/unit
yarn test:e2e:coverage
cp coverage/unit/coverage-final.json coverage/.parts/unit.json
cp coverage/e2e-react/coverage-final.json coverage/.parts/e2e-react.json
cp coverage/e2e-vue/coverage-final.json coverage/.parts/e2e-vue.json
yarn nyc merge coverage/.parts .nyc_output/coverage-final.json >/dev/null
yarn nyc report
yarn nyc report --reporter=json-summary >/dev/null
yarn node --experimental-strip-types scripts/show-total-coverage.ts
- name: Upload Playwright/Vitest artifacts on failure
if: failure() && matrix.node-version == '24.x'
uses: actions/upload-artifact@v4
with:
name: playwright-vitest-artifacts-node-24
path: artifacts
if-no-files-found: ignore
- name: Upload merged coverage artifacts
if: matrix.node-version == '24.x' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: coverage-node-24
path: |
coverage/lcov.info
coverage/coverage-summary.json
if-no-files-found: error
codecov:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: tests
runs-on: ubuntu-latest
steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4
- name: Download merged coverage artifacts
uses: actions/download-artifact@v4
with:
name: coverage-node-24
path: coverage
- name: Upload merged coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info
flags: combined
name: combined-coverage
fail_ci_if_error: true
verbose: true
storybook-tests:
needs: eslint
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 22.x, 24.x ]
steps:
- name: Using branch ${{ github.ref }} for repository ${{ github.repository }}.
uses: actions/checkout@v4
- name: Setup Node and dependencies
uses: ./.github/actions/setup-env
with:
node-version: ${{ matrix.node-version }}
- name: Build React Storybook
run: yarn workspace @modulify/m3-react storybook:build --test --quiet
- name: Build Vue Storybook
run: yarn workspace @modulify/m3-vue storybook:build --test --quiet
- name: Run React Storybook smoke tests
run: yarn workspace @modulify/m3-react test:smoke
- name: Run Vue Storybook smoke tests
run: yarn workspace @modulify/m3-vue test:smoke