Skip to content

Commit bafe941

Browse files
CYFS3Rbb666
authored andcommitted
ci: streamline package validation workflows
1 parent 5f4318b commit bafe941

9 files changed

Lines changed: 1305 additions & 368 deletions

File tree

.github/workflows/aciont_tool.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
11
name: ToolsCI
22
# 这个CI用来检查menuconfig中的warning和错误
33
on:
4-
# Runs at 16:00 UTC (BeiJing 00:00) on the 1st of every month
5-
schedule:
6-
- cron: '0 16 1 * *'
7-
push:
8-
branches:
9-
- master
10-
pull_request:
11-
branches:
12-
- master
4+
workflow_call:
135
workflow_dispatch:
146

157
permissions:
168
contents: read # to fetch code (actions/checkout)
179

1810
jobs:
1911
test:
12+
if: ${{ github.repository == 'RT-Thread/packages' }}
2013
runs-on: ubuntu-22.04
2114
name: Tools
22-
if: github.repository_owner == 'RT-Thread'
23-
strategy:
24-
fail-fast: false
2515
env:
2616
TEST_BSP_ROOT: bsp/stm32/stm32f407-atk-explorer
2717
steps:
28-
- uses: actions/checkout@main
18+
- uses: actions/checkout@v5
2919
with:
3020
repository: RT-Thread/rt-thread
3121

@@ -45,7 +35,7 @@ jobs:
4535
/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version
4636
echo "RTT_EXEC_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin" >> $GITHUB_ENV
4737
- name: Checkout packages
48-
uses: actions/checkout@main
38+
uses: actions/checkout@v5
4939
with:
5040
path: packages
5141
- name: Build Tools

.github/workflows/daily-check.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Packages Daily Check
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
timezone: "Asia/Shanghai"
7+
workflow_dispatch:
8+
inputs:
9+
create_failure_issue:
10+
description: Create or update the failure issue when this manual run fails
11+
required: false
12+
default: false
13+
type: boolean
14+
15+
permissions: {}
16+
17+
concurrency:
18+
group: packages-daily-${{ github.ref }}
19+
cancel-in-progress: false
20+
21+
jobs:
22+
tools-check:
23+
if: ${{ github.repository == 'RT-Thread/packages' }}
24+
permissions:
25+
contents: read
26+
uses: ./.github/workflows/aciont_tool.yml
27+
28+
daily-url-check:
29+
if: ${{ github.repository == 'RT-Thread/packages' }}
30+
name: URL shard ${{ matrix.label }}
31+
runs-on: ubuntu-22.04
32+
timeout-minutes: 45
33+
strategy:
34+
fail-fast: false
35+
max-parallel: 8
36+
matrix:
37+
include:
38+
- shard_index: 0
39+
label: "1/8"
40+
- shard_index: 1
41+
label: "2/8"
42+
- shard_index: 2
43+
label: "3/8"
44+
- shard_index: 3
45+
label: "4/8"
46+
- shard_index: 4
47+
label: "5/8"
48+
- shard_index: 5
49+
label: "6/8"
50+
- shard_index: 6
51+
label: "7/8"
52+
- shard_index: 7
53+
label: "8/8"
54+
permissions:
55+
contents: read
56+
env:
57+
GITHUB_TOKEN: ${{ github.token }}
58+
steps:
59+
- uses: actions/checkout@v5
60+
61+
- name: Set up Python
62+
uses: actions/setup-python@v6
63+
with:
64+
python-version: "3.11"
65+
66+
- name: Install URL checker dependencies
67+
run: python -m pip install requests
68+
69+
- name: Validate package URLs and metadata
70+
run: python ci.py --shard-count 8 --shard-index ${{ matrix.shard_index }}
71+
72+
report-daily-failure:
73+
needs:
74+
- daily-url-check
75+
- tools-check
76+
if: ${{ always() && github.repository == 'RT-Thread/packages' && (github.event_name == 'schedule' || inputs.create_failure_issue) && (needs.daily-url-check.result == 'failure' || needs.tools-check.result == 'failure') }}
77+
runs-on: ubuntu-22.04
78+
permissions:
79+
actions: read
80+
issues: write
81+
steps:
82+
- name: Create or update failure issue
83+
uses: actions/github-script@v8
84+
with:
85+
script: |
86+
const marker = '<!-- daily-packages-check -->';
87+
const title = '[CI] Daily packages check failed';
88+
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
89+
const urlResult = '${{ needs.daily-url-check.result }}';
90+
const toolsResult = '${{ needs.tools-check.result }}';
91+
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, {
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
run_id: context.runId,
95+
filter: 'latest',
96+
per_page: 100,
97+
});
98+
const failedJobs = jobs
99+
.filter((job) => job.conclusion === 'failure')
100+
.slice(0, 20)
101+
.map((job) => ` - [${job.name}](${job.html_url})`);
102+
const details = [
103+
marker,
104+
'@CYFS3 @Rbb666',
105+
'',
106+
'每日软件包 URL/元数据检查失败,请协助处理。',
107+
'',
108+
`- URL/元数据检查:${urlResult}`,
109+
`- ToolsCI:${toolsResult}`,
110+
`- Commit:${context.sha}`,
111+
`- 运行记录:${runUrl}`,
112+
'',
113+
'失败 Jobs:',
114+
...(failedJobs.length ? failedJobs : [' - 请查看运行记录中的失败步骤。']),
115+
].join('\n');
116+
117+
const issues = await github.paginate(github.rest.issues.listForRepo, {
118+
owner: context.repo.owner,
119+
repo: context.repo.repo,
120+
state: 'open',
121+
per_page: 100,
122+
});
123+
const existing = issues.find((issue) =>
124+
!issue.pull_request && issue.title === title && issue.body?.includes(marker)
125+
);
126+
127+
if (existing) {
128+
await github.rest.issues.createComment({
129+
owner: context.repo.owner,
130+
repo: context.repo.repo,
131+
issue_number: existing.number,
132+
body: details,
133+
});
134+
} else {
135+
await github.rest.issues.create({
136+
owner: context.repo.owner,
137+
repo: context.repo.repo,
138+
title,
139+
body: details,
140+
});
141+
}

.github/workflows/pkgs-static-check.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/pkgs-test.yml

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)