-
Notifications
You must be signed in to change notification settings - Fork 25
117 lines (97 loc) · 3.53 KB
/
Copy pathvalidate-examples.yml
File metadata and controls
117 lines (97 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Validate Examples
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# Run weekly to catch dependency issues
- cron: '0 0 * * 0'
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.changes.outputs.examples }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed examples
id: changes
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
# For scheduled runs, test all examples
examples=$(./dev.sh list | grep -E "^ - " | sed 's/^ - //' | jq -R -s -c 'split("\n")[:-1]')
else
# For PR/push, only test changed examples
changed_files=$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} || git diff --name-only HEAD~1)
examples=$(echo "$changed_files" | grep -E "(docker-compose\.ya?ml|Dockerfile|\.sh)$" | xargs dirname 2>/dev/null | sort -u | jq -R -s -c 'split("\n")[:-1]' || echo '[]')
fi
echo "examples=$examples" >> $GITHUB_OUTPUT
validate-examples:
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.examples != '[]'
strategy:
matrix:
example: ${{ fromJson(needs.detect-changes.outputs.examples) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Validate example
run: |
example="${{ matrix.example }}"
echo "Validating: $example"
./dev.sh validate "$example"
lint-and-security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
# Install shellcheck
sudo apt-get update
sudo apt-get install -y shellcheck
# Install yamllint
pip install yamllint
- name: Run lint checks
run: ./dev.sh lint
- name: Run security checks
run: ./dev.sh security
comprehensive-check:
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
# Install shellcheck
sudo apt-get update
sudo apt-get install -y shellcheck
# Install yamllint
pip install yamllint
- name: Run all checks
run: ./dev.sh check-all
summary:
runs-on: ubuntu-latest
needs: [detect-changes, validate-examples, lint-and-security]
if: always()
steps:
- name: Validation Summary
run: |
echo "## Validation Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
examples="${{ needs.detect-changes.outputs.examples }}"
if [ "$examples" == "[]" ] || [ "$examples" == "" ]; then
echo "No examples were modified or detected for validation." >> $GITHUB_STEP_SUMMARY
else
echo "Validated examples: $examples" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Check job results
validation_result="${{ needs.validate-examples.result }}"
lint_security_result="${{ needs.lint-and-security.result }}"
echo "| Check | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Example Validation | $validation_result |" >> $GITHUB_STEP_SUMMARY
echo "| Lint & Security | $lint_security_result |" >> $GITHUB_STEP_SUMMARY
fi