Skip to content

Commit 9ea90eb

Browse files
feat: add basic test workflow for YAML validation
Add GitHub Actions workflow to validate YAML syntax and workflow structure before PRs can be merged. Includes yamllint configuration for consistent formatting. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cc624bc commit 9ea90eb

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Test Workflows
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
jobs:
10+
yaml-lint:
11+
name: YAML Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.x'
21+
22+
- name: Install yamllint
23+
run: pip install yamllint
24+
25+
- name: Lint YAML files
26+
run: |
27+
find . -name "*.yml" -o -name "*.yaml" | xargs yamllint -c .yamllint.yml
28+
29+
workflow-validation:
30+
name: Workflow Validation
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
- name: Validate GitHub Actions workflows
37+
run: |
38+
# Check for syntax errors in workflow files
39+
for file in .github/workflows/*.yml .github/workflows/*.yaml; do
40+
if [ -f "$file" ]; then
41+
echo "Validating $file"
42+
# Basic YAML parsing check
43+
python -c "import yaml; yaml.safe_load(open('$file'))" || exit 1
44+
fi
45+
done
46+
47+
- name: Check for required workflow elements
48+
run: |
49+
# Ensure workflows have required elements
50+
for file in .github/workflows/*.yml .github/workflows/*.yaml; do
51+
if [ -f "$file" ]; then
52+
echo "Checking structure of $file"
53+
# Check if workflow has name, on triggers, and jobs
54+
if ! grep -q "^name:" "$file"; then
55+
echo "ERROR: $file missing 'name' field"
56+
exit 1
57+
fi
58+
if ! grep -q "^on:" "$file"; then
59+
echo "ERROR: $file missing 'on' field"
60+
exit 1
61+
fi
62+
if ! grep -q "^jobs:" "$file"; then
63+
echo "ERROR: $file missing 'jobs' field"
64+
exit 1
65+
fi
66+
fi
67+
done

.yamllint.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
extends: default
2+
3+
rules:
4+
line-length:
5+
max: 120
6+
indentation:
7+
spaces: 2
8+
comments:
9+
min-spaces-from-content: 1
10+
comments-indentation: disable
11+
truthy:
12+
allowed-values: ['true', 'false', 'on', 'off']
13+
document-start: disable

0 commit comments

Comments
 (0)