Skip to content

Commit 5a59586

Browse files
committed
workflows: add check that models have _nice values
1 parent 981e4db commit 5a59586

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.github/checks/check-model-nice.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
# Check that all model files have brand_nice and model_nice set,
4+
# with the exception of x86 models
5+
6+
if [ "$#" -gt 0 ]; then
7+
model_files=("$@")
8+
else
9+
model_files=(group_vars/model_*.yml)
10+
fi
11+
12+
error_found=0
13+
14+
for file in "${model_files[@]}"; do
15+
if [ ! -f "$file" ]; then
16+
echo "File $file does not exist, skipping."
17+
continue
18+
fi
19+
20+
if [[ "$file" == *"_x86"* ]]; then
21+
continue
22+
fi
23+
24+
brand_nice=$(yq -r '.brand_nice // ""' "$file" 2>/dev/null || true)
25+
model_nice=$(yq -r '.model_nice // ""' "$file" 2>/dev/null || true)
26+
27+
if [ -z "$brand_nice" ]; then
28+
echo "Error: $file missing 'brand_nice'"
29+
error_found=1
30+
fi
31+
32+
if [ -z "$model_nice" ]; then
33+
echo "Error: $file missing 'model_nice'"
34+
error_found=1
35+
fi
36+
done
37+
38+
if [ "$error_found" -eq 1 ]; then
39+
exit 1
40+
else
41+
echo "All model files have brand_nice and model_nice set"
42+
fi
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Check model nice fields
3+
4+
on: [push, pull_request]
5+
6+
permissions:
7+
contents: read
8+
actions: read
9+
10+
jobs:
11+
check-model-nice:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v5
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Run model nice fields check
20+
run: |
21+
git fetch origin main
22+
changed_files=$(git diff --name-only origin/main)
23+
model_files=$(echo "$changed_files" | grep -E '^group_vars/model_.*\.yml$' || true)
24+
if [ -z "$model_files" ]; then
25+
echo "No model files changed, running against all models"
26+
bash ./.github/checks/check-model-nice.sh
27+
else
28+
echo "Running check on changed model files"
29+
bash ./.github/checks/check-model-nice.sh "$model_files"
30+
fi

0 commit comments

Comments
 (0)