Skip to content

Commit 29134e0

Browse files
[CI] Fix third-party actions validation: fix peter-evans comment with self-collected runner info, fix verify step, add permissions, add ascend-upload fallback
1 parent 5d7831c commit 29134e0

1 file changed

Lines changed: 113 additions & 28 deletions

File tree

.github/workflows/validate_third_party_actions.yaml

Lines changed: 113 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@ defaults:
3636
run:
3737
shell: bash -el {0}
3838

39+
permissions:
40+
contents: read
41+
pull-requests: write
42+
issues: write
43+
actions: read
44+
3945
concurrency:
4046
group: ${{ github.workflow }}-${{ github.ref }}
4147
cancel-in-progress: true
4248

4349
jobs:
50+
# ─── Job 1: dorny/paths-filter 验证 ───
4451
validate-paths-filter:
4552
name: validate-dorny-paths-filter
4653
runs-on: linux-amd64-cpu-4-hk
@@ -59,11 +66,11 @@ jobs:
5966
workflows:
6067
- '.github/workflows/**'
6168
source:
62-
- 'vllm_ascend/**'
63-
- 'csrc/**'
69+
- 'vllm_ascend/**
70+
- 'csrc/**
6471
- 'setup.py'
6572
docs:
66-
- 'docs/**'
73+
- 'docs/**
6774
- '*.md'
6875
tests:
6976
- 'tests/**'
@@ -76,6 +83,7 @@ jobs:
7683
echo "tests changed: ${{ steps.filter.outputs.tests }}"
7784
echo "dorny/paths-filter validation OK"
7885
86+
# ─── Job 2: tj-actions/changed-files 验证 (含安全提醒) ───
7987
validate-changed-files:
8088
name: validate-tj-actions-changed-files
8189
runs-on: linux-amd64-cpu-4-hk
@@ -103,10 +111,11 @@ jobs:
103111
104112
- name: Security note
105113
run: |
106-
echo "::notice title=Security Reminder::tj-actions/changed-files@v47 has had supply chain security incidents. Consider replacing with dorny/paths-filter@v4 or native git diff commands."
114+
echo "::notice title=Security Reminder::tj-actions/changed-files@v47 had supply chain security incidents in March 2025. Consider replacing with dorny/paths-filter@v4 or native 'git diff --name-only'."
107115
116+
# ─── Job 3: ascend-gha-runners/artifact/upload 验证 ───
108117
validate-ascend-artifact-upload:
109-
name: validate-ascend-gha-runners-artifact-upload
118+
name: validate-ascend-gha-upload
110119
runs-on: linux-amd64-cpu-4-hk
111120

112121
steps:
@@ -117,8 +126,10 @@ jobs:
117126
run: |
118127
mkdir -p /tmp/ascend-artifact-test
119128
echo "ascend-gha-runners/artifact/upload validation test" > /tmp/ascend-artifact-test/test.txt
120-
echo "runner=$(uname -m)" >> /tmp/ascend-artifact-test/test.txt
129+
echo "arch=$(uname -m)" >> /tmp/ascend-artifact-test/test.txt
121130
echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> /tmp/ascend-artifact-test/test.txt
131+
ls -la /tmp/ascend-artifact-test/
132+
echo "Test content created at /tmp/ascend-artifact-test/"
122133
123134
- name: Upload via ascend-gha-runners/artifact/upload
124135
id: ascend-upload
@@ -131,6 +142,7 @@ jobs:
131142
retention-days: 1
132143

133144
- name: Upload via standard actions/upload-artifact (fallback)
145+
if: steps.ascend-upload.outcome != 'success'
134146
uses: actions/upload-artifact@v7
135147
with:
136148
name: validate-ascend-artifact-${{ github.run_id }}
@@ -140,15 +152,20 @@ jobs:
140152

141153
- name: Report ascend-gha-runners result
142154
run: |
143-
if [ "${{ steps.ascend-upload.outcome }}" == "success" ]; then
144-
echo "ascend-gha-runners/artifact/upload@v0.3 works on self-hosted"
145-
elif [ "${{ steps.ascend-upload.outcome }}" == "skipped" ]; then
146-
echo "::notice::ascend-gha-runners/artifact/upload skipped (missing OBS credentials)"
147-
else
148-
echo "::warning::ascend-gha-runners/artifact/upload failed - check OBS credentials and network"
149-
fi
150-
151-
validate-pr-context-actions:
155+
case "${{ steps.ascend-upload.outcome }}" in
156+
success)
157+
echo "::notice::ascend-gha-runners/artifact/upload@v0.3 works on self-hosted"
158+
;;
159+
skipped)
160+
echo "::notice::ascend-gha-runners/artifact/upload@v0.3 skipped (likely missing OBS credentials)"
161+
;;
162+
*)
163+
echo "::warning::ascend-gha-runners/artifact/upload@v0.3 failed (outcome=${{ steps.ascend-upload.outcome }}). Check OBS credentials and network."
164+
;;
165+
esac
166+
167+
# ─── Job 4: peter-evans/create-or-update-comment 验证 ───
168+
validate-pr-comment:
152169
name: validate-peter-evans-comment
153170
runs-on: linux-amd64-cpu-4-hk
154171
if: github.event_name == 'pull_request'
@@ -157,26 +174,55 @@ jobs:
157174
- name: Checkout repo
158175
uses: actions/checkout@v7
159176

177+
# 获取 runner 信息用于评论 (自行获取,不依赖 runner.name/runner.arch)
178+
- name: Collect runner info
179+
id: runner-info
180+
run: |
181+
echo "hostname=$(hostname)" >> $GITHUB_OUTPUT
182+
echo "arch=$(uname -m)" >> $GITHUB_OUTPUT
183+
echo "os=$(uname -s)" >> $GITHUB_OUTPUT
184+
echo "docker-version=$(docker --version 2>/dev/null || echo 'not-available')" >> $GITHUB_OUTPUT
185+
echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
186+
160187
- name: peter-evans/create-or-update-comment
188+
id: comment
161189
uses: peter-evans/create-or-update-comment@v5
162190
with:
163191
issue-number: ${{ github.event.pull_request.number }}
164192
body: |
165193
## Third-Party Actions Validation
166194
167-
✅ `peter-evans/create-or-update-comment@v5` works on self-hosted runner `${{ runner.name }}`
195+
✅ `peter-evans/create-or-update-comment@v5` works on self-hosted runner.
196+
197+
| Field | Value |
198+
|-------|-------|
199+
| Runner label | `linux-amd64-cpu-4-hk` |
200+
| Hostname | `${{ steps.runner-info.outputs.hostname }}` |
201+
| Arch | `${{ steps.runner-info.outputs.arch }}` |
202+
| OS | `${{ steps.runner-info.outputs.os }}` |
203+
| Docker | `${{ steps.runner-info.outputs.docker-version }}` |
204+
| Timestamp | `${{ steps.runner-info.outputs.timestamp }}` |
168205
169-
- Runner: `${{ runner.name }}`
170-
- Arch: `${{ runner.arch }}`
171-
- OS: `${{ runner.os }}`
206+
> This comment was posted by the self-hosted runner validation workflow.
172207
173208
- name: Verify comment posted
174-
run: echo "peter-evans/create-or-update-comment@v5 validation OK"
209+
if: steps.comment.outputs.comment-id != ''
210+
run: |
211+
echo "Comment posted successfully!"
212+
echo "Comment ID: ${{ steps.comment.outputs.comment-id }}"
213+
echo "Comment URL: ${{ steps.comment.outputs.comment-url }}"
214+
215+
- name: Comment post failed notification
216+
if: steps.comment.outputs.comment-id == ''
217+
run: |
218+
echo "::warning::peter-evans/create-or-update-comment did not return a comment-id. Check if this is a fork PR (GITHUB_TOKEN may lack write permission)."
219+
echo "Outcome: ${{ steps.comment.outcome }}"
175220
221+
# ─── Job 5: push 事件触发的文档化 (workflow 修改时自动运行) ───
176222
documentation:
177223
name: actions-validation-documentation
178224
runs-on: linux-amd64-cpu-4-hk
179-
if: github.event_name == 'workflow_dispatch'
225+
if: github.event_name != 'pull_request'
180226

181227
steps:
182228
- name: Print validation documentation
@@ -188,23 +234,21 @@ jobs:
188234
189235
The following actions require a PR/issue context and **cannot be validated** via \`workflow_dispatch\`:
190236
191-
| Action | Context | Validation Method |
192-
|--------|---------|-------------------|
237+
| Action | Context | How to Validate |
238+
|--------|---------|-----------------|
193239
| \`peter-evans/create-or-update-comment@v5\` | PR/Issue | Trigger via PR event |
194240
| \`peter-evans/slash-command-dispatch@v5\` | Issue Comment | Use slash command in PR |
195241
| \`actions/stale@v10\` | Issue/PR | Schedule or manual trigger |
196242
| \`actions/labeler@v6\` | PR | Trigger via PR event |
197243
| \`github/issue-labeler@v3.4\` | Issue | Trigger via issue event |
198244
| \`eps1lon/actions-label-merge-conflict@v3\` | PR | Trigger via PR event |
199245
200-
**Recommended**: Create a test PR with the \`pull_request\` trigger to validate these actions.
201-
202246
## Actions with Security Concerns
203247
204248
| Action | Concern | Recommendation |
205249
|--------|---------|----------------|
206-
| \`tj-actions/changed-files@v47\` | Past supply chain security incidents | Replace with \`dorny/paths-filter@v4\` or native \`git diff\` |
207-
| \`jlumbroso/free-disk-space\` | Destructive on self-hosted runners (removes system packages) | **Remove entirely** from self-hosted workflows |
250+
| \`tj-actions/changed-files@v47\` | Past supply chain security incidents (March 2025) | Replace with \`dorny/paths-filter@v4\` or native \`git diff --name-only\` |
251+
| \`jlumbroso/free-disk-space\` | Destructive on self-hosted (removes system packages) | **Remove entirely** from self-hosted workflows |
208252
209253
## Actions Requiring Special Credentials
210254
@@ -214,4 +258,45 @@ jobs:
214258
| \`docker/login-action@v4\` (to Quay) | Quay username/password | Must be configured in repo/organization secrets |
215259
`;
216260
console.log(summary);
217-
return summary;
261+
return summary;
262+
263+
- name: Write summary to step summary
264+
run: |
265+
echo "## Actions Requiring Special Context" >> $GITHUB_STEP_SUMMARY
266+
echo "" >> $GITHUB_STEP_SUMMARY
267+
echo "The following actions require PR/issue context and can only be validated by creating a test PR:" >> $GITHUB_STEP_SUMMARY
268+
echo "" >> $GITHUB_STEP_SUMMARY
269+
echo "- \`peter-evans/create-or-update-comment@v5\` (7 usages)" >> $GITHUB_STEP_SUMMARY
270+
echo "- \`peter-evans/slash-command-dispatch@v5\` (1 usage)" >> $GITHUB_STEP_SUMMARY
271+
echo "- \`actions/stale@v10\` (2 usages)" >> $GITHUB_STEP_SUMMARY
272+
echo "- \`actions/labeler@v6\` (1 usage)" >> $GITHUB_STEP_SUMMARY
273+
echo "- \`github/issue-labeler@v3.4\` (1 usage)" >> $GITHUB_STEP_SUMMARY
274+
echo "- \`eps1lon/actions-label-merge-conflict@v3\` (1 usage)" >> $GITHUB_STEP_SUMMARY
275+
276+
# ─── Job 6: 汇总 ───
277+
summary:
278+
name: third-party-validation-summary
279+
runs-on: linux-amd64-cpu-4-hk
280+
needs:
281+
- validate-paths-filter
282+
- validate-changed-files
283+
- validate-ascend-artifact-upload
284+
if: always()
285+
steps:
286+
- name: Generate summary
287+
run: |
288+
echo "## Third-Party Actions Validation Summary" >> $GITHUB_STEP_SUMMARY
289+
echo "" >> $GITHUB_STEP_SUMMARY
290+
echo "| Job | Result | Action |" >> $GITHUB_STEP_SUMMARY
291+
echo "|-----|--------|--------|" >> $GITHUB_STEP_SUMMARY
292+
echo "| validate-dorny-paths-filter | ${{ needs.validate-paths-filter.result }} | dorny/paths-filter@v4 |" >> $GITHUB_STEP_SUMMARY
293+
echo "| validate-tj-actions-changed-files | ${{ needs.validate-changed-files.result }} | tj-actions/changed-files@v47 |" >> $GITHUB_STEP_SUMMARY
294+
echo "| validate-ascend-gha-upload | ${{ needs.validate-ascend-artifact-upload.result }} | ascend-gha-runners/artifact/upload@v0.3 |" >> $GITHUB_STEP_SUMMARY
295+
echo "" >> $GITHUB_STEP_SUMMARY
296+
echo "### Key Changes from Original PR #11619" >> $GITHUB_STEP_SUMMARY
297+
echo "" >> $GITHUB_STEP_SUMMARY
298+
echo "1. **Fixed peter-evans comment** — 不再依赖 \`runner.name\`/\`runner.arch\`(self-hosted 上可能为空),改用 \`hostname\`/\`uname -m\` 自行收集" >> $GITHUB_STEP_SUMMARY
299+
echo "2. **Fixed verify step** — 检查 \`comment-id\` 实际输出来验证评论是否发布成功" >> $GITHUB_STEP_SUMMARY
300+
echo "3. **Added fallback** — ascend-gha-runners/upload 失败时自动用标准 actions/upload-artifact 兜底" >> $GITHUB_STEP_SUMMARY
301+
echo "4. **Explicit permissions** — 添加 \`pull-requests: write\` 和 \`issues: write\` 权限" >> $GITHUB_STEP_SUMMARY
302+
echo "5. **Fork PR 兼容** — 当评论因 fork PR 无写权限失败时,输出 warning 而非 fail" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)