Skip to content

Commit 2efb8d0

Browse files
authored
Merge 40f2457 into sapling-pr-archive-ktf
2 parents 7fa8856 + 40f2457 commit 2efb8d0

File tree

4 files changed

+502
-14
lines changed

4 files changed

+502
-14
lines changed
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
name: Check untested packages
3+
4+
'on':
5+
workflow_call:
6+
inputs:
7+
owner:
8+
type: string
9+
required: true
10+
description: Repository owner or organization
11+
repo:
12+
type: string
13+
required: true
14+
description: Repository name (without owner)
15+
pr:
16+
type: string
17+
required: true
18+
description: Pull request number in the specified repository
19+
max_workers:
20+
type: string
21+
required: false
22+
default: '2'
23+
description: Maximum number of parallel aliDoctor processes
24+
25+
permissions: {}
26+
27+
jobs:
28+
check-untested-packages:
29+
name: Check for untested packages
30+
runs-on: ubuntu-latest
31+
container:
32+
image: registry.cern.ch/alisw/slc9-builder:latest
33+
permissions:
34+
contents: read
35+
pull-requests: write
36+
37+
steps:
38+
- name: Checkout ali-bot
39+
uses: actions/checkout@v4
40+
with:
41+
repository: alisw/ali-bot
42+
path: ali-bot
43+
44+
- name: Checkout target repository
45+
uses: actions/checkout@v4
46+
with:
47+
repository: ${{ inputs.owner }}/${{ inputs.repo }}
48+
path: ali-bot/alidist
49+
fetch-depth: 0
50+
51+
- name: Install GitHub CLI
52+
run: |
53+
dnf install -y 'dnf-command(config-manager)'
54+
dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
55+
dnf install -y gh
56+
57+
- name: Checkout PR branch
58+
run: |
59+
cd ali-bot/alidist
60+
gh pr checkout ${{ inputs.pr }}
61+
env:
62+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Install the latest version of uv
65+
uses: astral-sh/setup-uv@v6
66+
67+
- name: Install aliDoctor
68+
run: |
69+
# We need the python binary for ci/tested_pkgs.py
70+
uv python install
71+
# Install aliBuild which provides aliDoctor
72+
uv tool install alibuild
73+
aliBuild analytics off
74+
75+
- name: Get modified packages
76+
id: modified_packages
77+
run: |
78+
set -e
79+
cd ali-bot/alidist
80+
# Get list of modified .sh files in this PR
81+
git fetch origin master
82+
MODIFIED_FILES=$(git diff --name-only origin/master...HEAD | grep '\.sh$' || true)
83+
84+
MODIFIED_PACKAGES=""
85+
for file in $MODIFIED_FILES; do
86+
if [[ -f "$file" ]]; then
87+
PACKAGE=$(grep '^package:' "$file" | head -1 | cut -d: -f2 | tr -d ' ' || echo "")
88+
if [[ -n "$MODIFIED_PACKAGES" ]]; then
89+
MODIFIED_PACKAGES="$MODIFIED_PACKAGES,$PACKAGE"
90+
else
91+
MODIFIED_PACKAGES="$PACKAGE"
92+
fi
93+
fi
94+
done
95+
96+
echo "modified_packages=$MODIFIED_PACKAGES" >> "$GITHUB_OUTPUT"
97+
echo "Modified packages: $MODIFIED_PACKAGES"
98+
99+
- name: Run package analysis
100+
id: analysis
101+
if: steps.modified_packages.outputs.modified_packages != ''
102+
run: |
103+
cd ali-bot
104+
105+
echo "Analyzing modified packages: ${{ steps.modified_packages.outputs.modified_packages }}"
106+
./ci/tested_pkgs.py --json --max-workers ${{ inputs.max_workers }} --packages "${{ steps.modified_packages.outputs.modified_packages }}" > analysis_results.json
107+
108+
untested_count=$(jq -r '.statistics.untested_packages_count' analysis_results.json)
109+
untested_packages=$(jq -r '.untested_packages | join(",")' analysis_results.json)
110+
111+
echo "untested_count=$untested_count" >> "$GITHUB_OUTPUT"
112+
echo "untested_packages=$untested_packages" >> "$GITHUB_OUTPUT"
113+
114+
- name: Skip analysis - no packages modified
115+
id: no_analysis
116+
if: steps.modified_packages.outputs.modified_packages == ''
117+
run: |
118+
echo "No packages were modified in this PR, skipping analysis"
119+
echo "untested_count=0" >> "$GITHUB_OUTPUT"
120+
echo "untested_packages=" >> "$GITHUB_OUTPUT"
121+
122+
- name: Comment on PR
123+
if: steps.analysis.outputs.untested_count > 0
124+
env:
125+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
run: |
127+
UNTESTED_PACKAGES="${{ steps.analysis.outputs.untested_packages }}"
128+
UNTESTED_COUNT="${{ steps.analysis.outputs.untested_count }}"
129+
130+
if [ "$UNTESTED_COUNT" -gt 0 ]; then
131+
PACKAGE_LIST=$(echo "$UNTESTED_PACKAGES" | tr ',' '\n' | head -20 | sed 's/^/- `/' | sed 's/$/`/')
132+
133+
TOTAL_PACKAGES=$(echo "$UNTESTED_PACKAGES" | tr ',' '\n' | wc -l)
134+
ADDITIONAL_NOTE=""
135+
if [ "$TOTAL_PACKAGES" -gt 20 ]; then
136+
REMAINING=$((TOTAL_PACKAGES - 20))
137+
ADDITIONAL_NOTE="... and $REMAINING more packages"
138+
fi
139+
140+
{
141+
echo "## ⚠️ Untested Packages Found"
142+
echo ""
143+
echo "The following packages modified in this PR are not currently tested by CI:"
144+
echo ""
145+
echo "$PACKAGE_LIST"
146+
if [ -n "$ADDITIONAL_NOTE" ]; then
147+
echo ""
148+
echo "*$ADDITIONAL_NOTE*"
149+
fi
150+
echo ""
151+
echo "**Summary:**"
152+
echo "- **Modified packages analyzed**: $TOTAL_PACKAGES"
153+
echo "- **Untested packages**: $UNTESTED_COUNT"
154+
echo ""
155+
echo "Consider adding CI configurations for these packages if they should be covered by automated testing."
156+
} > /tmp/comment.md
157+
158+
gh pr comment ${{ inputs.pr }} --repo ${{ inputs.owner }}/${{ inputs.repo }} --body-file /tmp/comment.md
159+
fi
160+
161+
- name: Upload analysis results
162+
if: steps.modified_packages.outputs.modified_packages != ''
163+
uses: actions/upload-artifact@v4
164+
with:
165+
name: package-analysis-results
166+
path: ali-bot/analysis_results.json
167+
retention-days: 30
168+
169+
- name: Summary
170+
if: steps.modified_packages.outputs.modified_packages != ''
171+
run: |
172+
COUNT="${{ steps.analysis.outputs.untested_count }}"
173+
{
174+
echo "## Package Analysis Results"
175+
echo "- Modified packages: $MODIFIED_PACKAGES"
176+
echo "- Untested packages found: $COUNT"
177+
if [ "$COUNT" -gt 0 ]; then
178+
echo "- Status: ⚠️ Some modified packages are not tested by CI"
179+
echo "- Untested packages: ${{ steps.analysis.outputs.untested_packages }}"
180+
else
181+
echo "- Status: ✅ All modified packages are covered by CI testing"
182+
fi
183+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)