-
Notifications
You must be signed in to change notification settings - Fork 1
185 lines (162 loc) · 5.46 KB
/
Copy pathtest.yml
File metadata and controls
185 lines (162 loc) · 5.46 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
name: Test
on:
push:
branches:
- dev
pull_request:
branches:
- main
- dev
schedule:
- cron: "0 17 * * 1-5" # UTC 17:00 = JST 02:00, weekdays
workflow_dispatch:
inputs:
full_matrix:
description: "Run build-test on the full multi-OS matrix (like nightly)"
type: boolean
default: false
concurrency:
group: test-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Detect docs-only changes
id: filter
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
with:
filters: |
code:
- '!**/*.md'
- '!LICENSE'
- '!.github/ISSUE_TEMPLATE/**'
- '!.github/CODEOWNERS'
- '!.claude/**'
- '!.cursor/**'
- '!.vscode/**'
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set.outputs.matrix }}
steps:
- name: Compute OS matrix
id: set
shell: bash
run: |
if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event.inputs.full_matrix }}" = "true" ]; then
echo 'matrix={"os":["ubuntu-latest","macOS-latest","windows-latest"]}' >> "$GITHUB_OUTPUT"
else
echo 'matrix={"os":["ubuntu-latest"]}' >> "$GITHUB_OUTPUT"
fi
lint:
needs: [changes]
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 24
- name: Enable Corepack and setup Yarn v4
run: |
corepack enable
yarn --version
- name: Cache dependencies
id: cache-depends
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: "**/node_modules"
key: os-ubuntu-latest-node24-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
if: steps.cache-depends.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Lint
run: yarn lint
build-test:
needs: [changes, setup-matrix, lint]
if: needs.changes.outputs.code == 'true'
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 24
- name: Enable Corepack and setup Yarn v4
run: |
corepack enable
yarn --version
- name: Cache dependencies
id: cache-depends
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: "**/node_modules"
key: os-${{ matrix.os }}-node24-${{ hashFiles('yarn.lock') }}
- name: Create .yarnrc for Windows
if: runner.os == 'Windows' && steps.cache-depends.outputs.cache-hit != 'true'
run: echo "network-timeout 600000" > .yarnrc
- name: Install dependencies
if: steps.cache-depends.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Build
run: yarn build
- name: Test
run: yarn test
ci-required:
needs: [changes, lint, build-test]
if: always()
runs-on: ubuntu-latest
steps:
- name: Aggregate job results
shell: bash
env:
NEEDS: ${{ toJSON(needs) }}
run: |
echo "$NEEDS"
failed=$(echo "$NEEDS" | jq -r 'to_entries[] | select(.value.result == "failure" or .value.result == "cancelled") | .key')
if [ -n "$failed" ]; then
echo "Failed jobs: $failed"
exit 1
fi
nightly-report:
needs: [build-test]
if: failure() && github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Ensure ci-failure label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh label create ci-failure --color d73a4a --description "Nightly CI failure" --force
- name: Open or update failure issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MARKER: "[nightly-ci-failure]"
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
shell: bash
run: |
existing=$(gh issue list --search "in:title $MARKER" --state open --json number --jq '.[0].number' || echo "")
title="$MARKER Nightly CI failure ($(date -u +%Y-%m-%d))"
body="Nightly build-test failed. See: $RUN_URL"
if [ -n "$existing" ]; then
gh issue comment "$existing" --body "$body"
else
gh issue create --title "$title" --body "$body" --label "ci-failure"
fi