Skip to content

Commit d762b8d

Browse files
committed
Port THV-0597
1 parent 310baf3 commit d762b8d

3 files changed

Lines changed: 503 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Validate Proposal Naming
2+
permissions:
3+
contents: read
4+
5+
on:
6+
pull_request:
7+
paths:
8+
- '**'
9+
types: [opened, synchronize]
10+
workflow_dispatch:
11+
inputs:
12+
pr_number:
13+
description: 'The PR number to validate the naming convention for'
14+
required: true
15+
type: string
16+
17+
jobs:
18+
validate-proposal-naming:
19+
runs-on: ubuntu-slim
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set PR number
27+
run: |
28+
# Set PR_NUMBER based on context: use inputs.pr_number for manual dispatch,
29+
# otherwise use github.event.number for pull request events
30+
if [ -n "${{ inputs.pr_number }}" ]; then
31+
echo "PR_NUMBER=printf \"%04d\n\" ${{ inputs.pr_number }}" >> $GITHUB_ENV
32+
echo "Using PR number from manual input: ${{ inputs.pr_number }}"
33+
else
34+
echo "PR_NUMBER=printf \"%04d\n\" ${{ github.event.number }}" >> $GITHUB_ENV
35+
echo "Using PR number from event: ${{ github.event.number }}"
36+
fi
37+
38+
- name: Validate proposal naming
39+
run: |
40+
# Get the list of NEW files added (not modifications to existing files)
41+
CHANGED_FILES=$(git diff --name-only --diff-filter=A origin/${{ github.base_ref }}...HEAD | grep '^THV-' || true)
42+
43+
# Skip validation if no new proposal files are being added
44+
# (modifications to existing proposals don't need naming validation)
45+
if [ -z "$CHANGED_FILES" ]; then
46+
echo "ℹ️ No new proposal files added in this PR (only modifications to existing proposals or manual trigger)"
47+
exit 0
48+
fi
49+
50+
echo "Checking proposal file naming convention..."
51+
echo "Files to check:"
52+
echo "$CHANGED_FILES"
53+
54+
VALIDATION_FAILED=false
55+
56+
# Check each changed file
57+
while IFS= read -r file; do
58+
if [ -n "$file" ] && [ -f "$file" ]; then
59+
filename=$(basename "$file")
60+
echo "Checking file: $filename"
61+
62+
# Check if the filename follows the THV-####-name pattern with the current PR number
63+
if echo "$filename" | grep -qE "^THV-${PR_NUMBER}-.*\.md$"; then
64+
echo "✅ $filename follows the correct naming convention"
65+
else
66+
echo "❌ $filename does not follow the correct naming convention"
67+
echo " Expected format: THV-${PR_NUMBER}-name-of-your-proposal.md"
68+
echo " Where ${PR_NUMBER} is the current PR number"
69+
VALIDATION_FAILED=true
70+
fi
71+
fi
72+
done <<< "$CHANGED_FILES"
73+
74+
# Check if any validation failed
75+
if [ "$VALIDATION_FAILED" = "true" ]; then
76+
echo ""
77+
echo "❌ Validation failed! Some proposal files do not follow the naming convention."
78+
echo ""
79+
echo "Proposal files must follow this naming pattern:"
80+
echo " THV-${PR_NUMBER}-name-of-your-proposal.md"
81+
echo ""
82+
echo "Where:"
83+
echo " - THV- is the prefix"
84+
echo " - ${PR_NUMBER} is the current PR number"
85+
echo " - name-of-your-proposal is a descriptive name in kebab-case"
86+
echo " - .md is the file extension"
87+
echo ""
88+
echo "Example of valid name for this PR:"
89+
echo " - THV-${PR_NUMBER}-new-feature-proposal.md"
90+
echo ""
91+
exit 1
92+
else
93+
echo ""
94+
echo "✅ All proposal files follow the correct naming convention!"
95+
fi

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Dependency directories (remove the comment below to include it)
15+
# vendor/
16+
17+
# Go workspace file
18+
go.work
19+
20+
# IDE specific files
21+
.idea/
22+
.vscode/
23+
*.swp
24+
*.swo
25+
26+
# Build output
27+
/bin/
28+
/dist/
29+
/coverage/
30+
31+
.roo/
32+
^thv$
33+
34+
.claude/settings.local.json
35+
kconfig.yaml
36+
37+
.DS_Store
38+
39+
cmd/thv-operator/.task/checksum/crdref-gen
40+
.task/checksum/crdref-gen
41+
42+
# Test coverage
43+
coverage*
44+
45+
crd-helm-wrapper

0 commit comments

Comments
 (0)