-
Notifications
You must be signed in to change notification settings - Fork 16
Revert "Rework skill validator script (#11)" #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,70 @@ | ||||||||||
| #!/bin/bash | ||||||||||
| # Validates all skill directories changed in a pull request. | ||||||||||
| # | ||||||||||
| # Usage: validate-skills.sh <base-ref> | ||||||||||
| # base-ref The base branch name to diff against (e.g. "main"). | ||||||||||
| # When omitted or when the remote is unavailable, all skills are validated. | ||||||||||
| # | ||||||||||
| # Exit codes: | ||||||||||
| # 0 All validated skills passed. | ||||||||||
| # 1 One or more skills failed validation. | ||||||||||
|
|
||||||||||
| # -e is intentionally omitted: all error paths are handled explicitly, | ||||||||||
| # so abort-on-error would conflict with the || FAILED=1 accumulator pattern. | ||||||||||
| set -uo pipefail | ||||||||||
|
|
||||||||||
| BASE_REF="${1:-}" | ||||||||||
|
|
||||||||||
| # Find unique skill directories containing files changed in this PR. | ||||||||||
| # The three-dot diff requires fetch-depth: 0 and a properly configured remote, | ||||||||||
| # which is always the case on GitHub Actions but may not be in local act runs. | ||||||||||
| changed_skills=() | ||||||||||
| if [ -n "$BASE_REF" ]; then | ||||||||||
| mapfile -t changed_skills < <(git diff --name-only "origin/${BASE_REF}...HEAD" -- skills/ \ | ||||||||||
| 2>/dev/null \ | ||||||||||
| | cut -d'/' -f2 \ | ||||||||||
| | sort -u \ | ||||||||||
| | grep -v '^$') | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if [ "${#changed_skills[@]}" -eq 0 ]; then | ||||||||||
| # Fallback: validate all skill directories (e.g. when git remote is unavailable | ||||||||||
| # in local act testing, or when a PR only deletes files with no remaining dirs). | ||||||||||
| echo "Could not determine changed skills from git diff; validating all skills." | ||||||||||
| mapfile -t changed_skills < <(find skills -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort -u) | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if [ "${#changed_skills[@]}" -eq 0 ]; then | ||||||||||
| echo "No skill directories found, skipping validation." | ||||||||||
| exit 0 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| FAILED=0 | ||||||||||
| for skill in "${changed_skills[@]}"; do | ||||||||||
| # Skip skills whose directories were deleted in this PR. | ||||||||||
| if [ ! -d "skills/$skill" ]; then | ||||||||||
| echo "Skipping deleted skill: $skill" | ||||||||||
| continue | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Run validation with markdown output so the result is written to the job | ||||||||||
| # summary in one pass. --emit-annotations works with any output format, so | ||||||||||
| # inline PR annotations are still emitted alongside the markdown report. | ||||||||||
| # We use process substitution to: | ||||||||||
| # 1. Send all output (including ::error commands) to stdout for GitHub Actions | ||||||||||
| # 2. Filter out ::error/::warning/::notice lines before writing to the summary | ||||||||||
| skill-validator check --strict --emit-annotations -o markdown "skills/$skill/" \ | ||||||||||
| | tee >(grep -v '^::' >> "${GITHUB_STEP_SUMMARY:-/dev/null}") || FAILED=1 | ||||||||||
| done | ||||||||||
|
|
||||||||||
| if [ $FAILED -ne 0 ]; then | ||||||||||
| echo "" | ||||||||||
| echo "❌ Skill validation failed!" | ||||||||||
| echo "" | ||||||||||
| echo "📋 See the Job Summary for detailed validation results:" | ||||||||||
| echo " https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | ||||||||||
|
||||||||||
| echo " https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
| if [ -n "${GITHUB_ACTIONS:-}" ] && [ -n "${GITHUB_REPOSITORY:-}" ] && [ -n "${GITHUB_RUN_ID:-}" ]; then | |
| echo " https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
| fi |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,12 +2,17 @@ name: Validate Skills | |||||||||
|
|
||||||||||
| on: | ||||||||||
| pull_request: | ||||||||||
| paths: | ||||||||||
| - "skills/**" | ||||||||||
|
||||||||||
| - "skills/**" | |
| - "skills/**" | |
| - ".github/workflows/validate-skills.yml" | |
| - ".github/scripts/validate-skills.sh" |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script uses
mapfile, which is not available in the default macOS/bin/bash(3.2). Since the shebang is#!/bin/bashand the comments mention local usage (e.g., act runs), running it locally on macOS will fail. Either avoidmapfile(e.g., use awhile IFS= read -rloop) or explicitly require Bash >= 4 (and consider#!/usr/bin/env bash).