-
Notifications
You must be signed in to change notification settings - Fork 221
216 lines (197 loc) · 8.06 KB
/
Copy pathbug-server.yml
File metadata and controls
216 lines (197 loc) · 8.06 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Bug Server CI
# 这里业务方根据需求设置
on:
workflow_dispatch:
inputs:
pr_number:
description: '待验证的外部 fork PR 编号'
required: true
type: string
head_sha:
description: '已审查的 PR head commit(完整 40 位 SHA)'
required: true
type: string
push:
branches: ['main']
pull_request:
branches: ['main', 'develop', 'dev/**']
permissions:
contents: read
jobs:
build:
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
runs-on: macos-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: './common/config/rush/pnpm-lock.yaml'
- name: Test manual dispatch validation
run: |
node --test .github/scripts/bug-server-dispatch.test.cjs
python3 -m unittest discover -s .github/scripts -p 'test_extract_bug_server_bundle.py'
- name: Install Python distutils (macOS)
if: runner.os == 'macOS'
run: |
python3 -m pip install setuptools --break-system-packages
- name: Install Python distutils (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y python3-distutils
python3 -m pip install setuptools --break-system-packages
- name: Install latest pnpm
run: npm install -g pnpm@10.7.0
- name: Install native deps for node-canvas (macOS)
if: runner.os == 'macOS'
run: |
brew update
brew install pkg-config cairo pango libpng jpeg giflib librsvg
- name: Install native deps for node-canvas (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev pkg-config
- name: Print All Github Environment Variables
run: env
- name: Install rush
run: node common/scripts/install-run-rush.js install --bypass-policy
- name: Build vutils-extension
working-directory: ./packages/vutils-extension
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: node ../../common/scripts/install-run-rushx.js build:es
- name: Build vchart
working-directory: ./packages/vchart
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: node ../../common/scripts/install-run-rushx.js build:es
- name: Build vchart-extension
working-directory: ./packages/vchart-extension
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: node ../../common/scripts/install-run-rushx.js build:es
- name: Build bugserver-trigger
working-directory: ./tools/bugserver-trigger
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: node ../../common/scripts/install-run-rushx.js build
- name: Run CI
working-directory: ./tools/bugserver-trigger
env:
BUG_SERVER_TOKEN: ${{ secrets.BUG_SERVER_TOKEN }}
run: node ../../common/scripts/install-run-rushx.js ci
resolve-manual-target:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
actions: read
outputs:
sha: ${{ steps.target.outputs.sha }}
pr_number: ${{ steps.target.outputs.pr_number }}
head_ref: ${{ steps.target.outputs.head_ref }}
pr_url: ${{ steps.target.outputs.pr_url }}
artifact_id: ${{ steps.target.outputs.artifact_id }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.workflow_sha }}
persist-credentials: false
sparse-checkout: .github/scripts
- name: Validate reviewed PR head
id: target
uses: actions/github-script@v8
env:
PR_NUMBER: ${{ inputs.pr_number }}
HEAD_SHA: ${{ inputs.head_sha }}
with:
script: |
const { resolveBugServerTarget } = require('./.github/scripts/bug-server-dispatch.cjs');
const target = await resolveBugServerTarget({
github, context,
prNumber: process.env.PR_NUMBER,
headSha: process.env.HEAD_SHA
});
core.setOutput('sha', target.sha);
core.setOutput('pr_number', target.prNumber);
core.setOutput('head_ref', target.headRef);
core.setOutput('pr_url', target.prUrl);
core.setOutput('artifact_id', target.artifactId);
await core.summary
.addHeading('Bug Server 手动验证')
.addLink(`PR #${target.prNumber}`, target.prUrl)
.addLink(`来源构建 ${target.runId}`, target.runUrl)
.addRaw(`\n\n被测 head: \`${target.sha}\`\n`)
.write();
submit-manual-bundle:
needs: resolve-manual-target
runs-on: ubuntu-latest
timeout-minutes: 180
permissions:
contents: read
actions: read
steps:
# 使用默认分支 workflow 的固定提交,仅将 PR bundle 作为文件上传。
- uses: actions/checkout@v4
with:
ref: ${{ github.workflow_sha }}
persist-credentials: false
sparse-checkout: |
.github/scripts
tools/bugserver-trigger/scripts
- uses: actions/setup-node@v4
with:
node-version: 24.x
- name: Install isolated trigger client dependencies
run: |
mkdir -p "$RUNNER_TEMP/bug-server-client"
npm install --prefix "$RUNNER_TEMP/bug-server-client" --ignore-scripts --no-audit --no-fund --package-lock=false \
node-fetch@2.6.7 form-data@4.0.6 ts-node@10.9.0 typescript@4.9.5
- name: Download reviewed PR artifact
uses: actions/github-script@v8
env:
ARTIFACT_ID: ${{ needs.resolve-manual-target.outputs.artifact_id }}
with:
script: |
const archive = await github.rest.actions.downloadArtifact({
...context.repo,
artifact_id: Number(process.env.ARTIFACT_ID),
archive_format: 'zip'
});
const fs = require('node:fs');
const path = require('node:path');
fs.writeFileSync(path.join(process.env.RUNNER_TEMP, 'bug-server-bundle.zip'), Buffer.from(archive.data));
- name: Read bundle as data
run: python3 .github/scripts/extract_bug_server_bundle.py "$RUNNER_TEMP/bug-server-bundle.zip" tools/bugserver-trigger/dist/index.js
- name: Trigger Bug Server for reviewed PR
working-directory: tools/bugserver-trigger
env:
BUG_SERVER_TOKEN: ${{ secrets.BUG_SERVER_TOKEN }}
NODE_PATH: ${{ runner.temp }}/bug-server-client/node_modules
TEST_SHA: ${{ needs.resolve-manual-target.outputs.sha }}
TEST_REF: refs/pull/${{ needs.resolve-manual-target.outputs.pr_number }}/head
TEST_BRANCH: ${{ needs.resolve-manual-target.outputs.head_ref }}
TEST_PR_URL: ${{ needs.resolve-manual-target.outputs.pr_url }}
run: |
if [ -z "$BUG_SERVER_TOKEN" ]; then
echo '::error::BUG_SERVER_TOKEN is not configured for this repository.'
exit 1
fi
test -f dist/index.js
printf 'PR: %s\n被测 head: `%s`\n' "$TEST_PR_URL" "$TEST_SHA" >> "$GITHUB_STEP_SUMMARY"
env GITHUB_SHA="$TEST_SHA" GITHUB_REF="$TEST_REF" GITHUB_HEAD_REF="$TEST_BRANCH" \
node "$RUNNER_TEMP/bug-server-client/node_modules/ts-node/dist/bin.js" \
--transpile-only --skip-project \
--compiler-options '{"module":"CommonJS","moduleResolution":"node","esModuleInterop":true}' \
scripts/trigger-test.ts