Skip to content

Commit 77ccbb0

Browse files
authored
minimal CI checks (#2)
Example output: ``` > ./scripts/validate-proposals.sh OK: 0001-init.md ERROR: Invalid filename: 0002.md Expected format: NNNN-name.md (e.g., 0007-my-proposal.md) OK: 0003-example.md OK: 0003-example2.md ERROR: Invalid filename: lol.txt Expected format: NNNN-name.md (e.g., 0007-my-proposal.md) ERROR: Duplicate ID 0003 found in: 0003-example.md 0003-example2.md ``` --------- Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent 4d601dd commit 77ccbb0

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Validate Proposals
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
validate-naming:
10+
name: Validate proposal naming convention
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Validate proposal file names
17+
run: ./scripts/validate-proposals.sh

scripts/validate-proposals.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
validate_file() {
5+
local filename="$1"
6+
7+
# Check if file matches the expected pattern: NNNN-*.md
8+
if ! echo "$filename" | grep -qE '^[0-9]{4}-[a-zA-Z0-9_-]+\.md$'; then
9+
echo "ERROR: Invalid filename: $filename"
10+
echo " Expected format: NNNN-name.md (e.g., 0007-my-proposal.md)"
11+
return 1
12+
fi
13+
14+
return 0
15+
}
16+
17+
exit_code=0
18+
valid_ids=""
19+
20+
# Find all files in proposals/ directory (if it exists)
21+
if [ -d "proposals" ]; then
22+
for file in $(ls proposals/ | sort); do
23+
file="proposals/$file"
24+
# Skip if no files match (glob returns literal pattern)
25+
[ -e "$file" ] || continue
26+
27+
filename=$(basename "$file")
28+
29+
if validate_file "$filename"; then
30+
echo "OK: $filename"
31+
# Collect ID and filename for duplicate checking
32+
id="${filename:0:4}"
33+
valid_ids="${valid_ids}${id} ${filename}"$'\n'
34+
else
35+
exit_code=1
36+
fi
37+
done
38+
39+
# Check for duplicate IDs
40+
duplicate_ids=$(echo "$valid_ids" | awk '{print $1}' | sort | uniq -d)
41+
if [ -n "$duplicate_ids" ]; then
42+
for dup_id in $duplicate_ids; do
43+
files=$(echo "$valid_ids" | grep "^$dup_id " | awk '{print $2}' | tr '\n' ' ')
44+
echo "ERROR: Duplicate ID $dup_id found in: $files"
45+
done
46+
exit_code=1
47+
fi
48+
fi
49+
50+
exit $exit_code

0 commit comments

Comments
 (0)