-
Notifications
You must be signed in to change notification settings - Fork 2
110 lines (95 loc) · 3.62 KB
/
Copy pathsubmodule-tests.yml
File metadata and controls
110 lines (95 loc) · 3.62 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
name: submodule-tests
on:
pull_request:
branches: [dev, master, code-optimization]
types: [opened, synchronize, reopened]
schedule:
- cron: '0 18 * * *' # 每日 UTC 18:00(北京 02:00)
workflow_dispatch:
permissions:
contents: read
jobs:
# Stable summary for every long-lived-branch PR (plan M4 step 3): reports
# "not-applicable" and succeeds when no gitlink/.gitmodules change is present,
# so the check never leaves a PR stuck on "Waiting for status".
submodule-gate:
name: Submodule Gate / Summary
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Detect submodule changes
id: detect
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
CHANGED=$(git diff --name-only "$BASE_SHA..$HEAD_SHA" -- .gitmodules bt_api/ || true)
echo "changed<<EOF" >> "$GITHUB_OUTPUT"
echo "$CHANGED" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
# git diff --raw header is ":oldmode newmode oldsha newsha status";
# gitlinks are marked by mode 160000, which awk sees as $1/$2.
GITLINKS=$(git diff --raw "$BASE_SHA..$HEAD_SHA" | awk '$2 == "160000"' | wc -l | tr -d ' ')
echo "count=$GITLINKS" >> "$GITHUB_OUTPUT"
- name: Full submodule validation
if: steps.detect.outputs.count != '0'
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 1
- uses: actions/setup-python@v6
if: steps.detect.outputs.count != '0'
with:
python-version: '3.11'
- name: Install and test all submodules
if: steps.detect.outputs.count != '0'
run: python bt_api/install_and_test_all.py --parallel 4 --report markdown
- uses: actions/upload-artifact@v7
if: steps.detect.outputs.count != '0' && always()
with:
name: submodule-report-pr-${{ github.event.pull_request.number }}
path: /tmp/submodule_report.md
if-no-files-found: ignore
- name: Publish gate summary
if: always()
run: |
{
echo "## Submodule Gate / Summary"
echo ""
if [ "${{ steps.detect.outputs.count }}" = "0" ]; then
echo "- Result: **not-applicable** (no gitlink or .gitmodules change)"
echo "- Submodule validation not required for this PR."
else
echo "- Result: **validated** (${{ steps.detect.outputs.count }} gitlink change(s))"
echo "- Old/new SHA pairs are listed in the PR template; report artifact attached."
echo ""
echo '```'
echo "${{ steps.detect.outputs.changed }}"
echo '```'
fi
} >> "$GITHUB_STEP_SUMMARY"
submodule-matrix:
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 1
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install and test all submodules
run: python bt_api/install_and_test_all.py --parallel 4 --report markdown
- uses: actions/upload-artifact@v4
with:
name: submodule-report
path: /tmp/submodule_report.md