-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
162 lines (128 loc) · 4.58 KB
/
ci.yml
File metadata and controls
162 lines (128 loc) · 4.58 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
name: CI
on:
push:
branches: [next]
pull_request:
types: [opened, synchronize, reopened, closed]
branches: [next]
merge_group:
permissions:
id-token: write
actions: write
jobs:
cancel-on-pr-close:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'closed'
steps:
- name: Cancel running workflows on PR close/merge
uses: actions/github-script@v8
with:
script: |
const { owner, repo } = context.repo;
const pr_number = context.payload.pull_request.number;
const head_sha = context.payload.pull_request.head.sha;
console.log(`PR #${pr_number} was ${context.payload.pull_request.merged ? 'merged' : 'closed'}`);
console.log(`Cancelling workflows for SHA: ${head_sha}`);
// Get all workflow runs for this PR's head SHA
const { data: runs } = await github.rest.actions.listWorkflowRunsForRepo({
owner,
repo,
head_sha,
status: 'in_progress'
});
console.log(`Found ${runs.workflow_runs.length} in-progress workflow runs`);
// Cancel each running workflow
for (const run of runs.workflow_runs) {
if (run.status === 'in_progress') {
console.log(`Cancelling workflow run ${run.id} (${run.name})`);
await github.rest.actions.cancelWorkflowRun({
owner,
repo,
run_id: run.id
});
}
}
console.log('All running workflows have been cancelled');
typecheck:
runs-on: ubuntu-latest
concurrency:
group: typecheck-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: '22'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run lint
run: pnpm run lint
- name: Run typecheck
run: pnpm run typecheck
test-packages:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
node: ['22', '24']
name: Test packages (${{ matrix.os }}, ${{ matrix.node }})
runs-on: ${{ matrix.os }}
concurrency:
group: test-packages-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }})
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm run ci
- name: Code Coverage
# skip on windows, it will hangup on codecov
if: ${{ matrix.os != 'windows-latest' }}
uses: codecov/codecov-action@v5
with:
use_oidc: true
test-egg-bin:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
node: ['22', '24']
name: Test egg-bin (${{ matrix.os }}, ${{ matrix.node }})
runs-on: ${{ matrix.os }}
concurrency:
group: test-egg-bin-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }})
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm run --filter="@eggjs/bin" ci
- name: Code Coverage
# skip on windows, it will hangup on codecov https://github.com/codecov/codecov-action/issues/1787
if: ${{ matrix.os != 'windows-latest' }}
uses: codecov/codecov-action@v5
with:
use_oidc: true