-
Notifications
You must be signed in to change notification settings - Fork 9
121 lines (106 loc) · 4.4 KB
/
Copy path_checks.yml
File metadata and controls
121 lines (106 loc) · 4.4 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
118
119
120
121
name: Checks
on:
workflow_call:
jobs:
validate:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
cache: npm
- name: Install skill-validator
env:
SKILL_VALIDATOR_VERSION: "1.5.1"
run: |
curl -sL "https://github.com/agent-ecosystem/skill-validator/releases/download/v${SKILL_VALIDATOR_VERSION}/skill-validator_${SKILL_VALIDATOR_VERSION}_linux_amd64.tar.gz" | tar xz -C /usr/local/bin skill-validator
- name: Detect changed skills
id: changed
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
dirs=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- 'skills/' \
| grep -oP '^skills/\K[^/]+(?=/)' \
| sort -u \
| grep -v '^_' \
| while read -r d; do [ -f "skills/$d/SKILL.md" ] && echo "$d" || true; done)
if [ -n "$dirs" ]; then
# Build space-separated paths for skill-validator
paths=$(echo "$dirs" | sed 's|^|skills/|' | tr '\n' ' ')
echo "paths=$paths" >> "$GITHUB_OUTPUT"
echo "names=$(echo "$dirs" | tr '\n' ' ')" >> "$GITHUB_OUTPUT"
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
else
echo "paths=skills/" >> "$GITHUB_OUTPUT"
echo "names=" >> "$GITHUB_OUTPUT"
echo "found=true" >> "$GITHUB_OUTPUT"
fi
- run: npm ci
- name: Run skill-validator checks
id: skill-validator
if: steps.changed.outputs.found == 'true'
run: |
set +e
# TODO: re-enable link checks once https://github.com/agent-ecosystem/skill-validator/issues/45 is resolved
report=$(skill-validator check ${{ steps.changed.outputs.paths }} --skip links -o markdown 2>/dev/null)
exit_code=$?
echo "$report" >> "$GITHUB_STEP_SUMMARY"
delimiter=$(openssl rand -hex 8)
{
echo "report<<${delimiter}"
echo "$report"
echo "${delimiter}"
} >> "$GITHUB_OUTPUT"
echo "exit_code=$exit_code" >> "$GITHUB_OUTPUT"
# Re-run with annotations sent to stdout/stderr for GitHub to process
skill-validator check ${{ steps.changed.outputs.paths }} --skip links --emit-annotations > /dev/null
exit 0
- name: Run project-specific checks
id: check-project
if: steps.changed.outputs.found == 'true'
run: |
set +e
output=$(node scripts/check-project.js ${{ steps.changed.outputs.names }} 2>&1)
exit_code=$?
echo "$output"
delimiter=$(openssl rand -hex 8)
{
echo "report<<${delimiter}"
echo "$output"
echo "${delimiter}"
} >> "$GITHUB_OUTPUT"
echo "exit_code=$exit_code" >> "$GITHUB_OUTPUT"
- name: Post PR comment
if: github.event_name == 'pull_request' && steps.changed.outputs.found == 'true' && always()
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
header: skill-validator
message: |
## Skill Validation Report
${{ steps.skill-validator.outputs.report }}
### Project Checks
```
${{ steps.check-project.outputs.report }}
```
- name: Post PR comment (no skills changed)
if: github.event_name == 'pull_request' && steps.changed.outputs.found == 'false'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
header: skill-validator
recreate: true
message: |
## Skill Validation Report
No skill files were changed in this PR — validation skipped.
- name: Fail on validation errors
if: steps.changed.outputs.found == 'true' && (steps.skill-validator.outputs.exit_code == '1' || steps.check-project.outputs.exit_code == '1')
run: |
echo "::error::Validation found errors"
exit 1