|
| 1 | +# Copyright 2026 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Check Agent Skills |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: [ main, master, gh-pages ] |
| 20 | + pull_request: |
| 21 | + branches: [ main, master, gh-pages ] |
| 22 | + |
| 23 | +jobs: |
| 24 | + check-skills: |
| 25 | + # Run the checks on the latest Ubuntu environment |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + # Step 1: Checkout the repository code to access the files locally |
| 29 | + - name: Checkout Code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + # Step 2: Extract the list of style guide URLs from the README.md references block |
| 33 | + - name: Extract Style Guide URLs from README.md |
| 34 | + run: | |
| 35 | + # Extract all style guide reference URLs defined between the START/END markers, |
| 36 | + # remove the reference tag prefix, map local relative references (like objc/go) |
| 37 | + # to their online published equivalents, and sort the list alphabetically. |
| 38 | + echo "Extracting style guides from README.md..." |
| 39 | + README_URLS=$(sed -n '/<!-- START_STYLEGUIDES -->/,/<!-- END_STYLEGUIDES -->/p' README.md \ |
| 40 | + | grep -E '^\[[a-zA-Z0-9_-]+\]:' \ |
| 41 | + | sed -E 's/^\[[^]]+\]:[[:space:]]+//' \ |
| 42 | + | sed -E 's|^objcguide\.md$|https://google.github.io/styleguide/objcguide.html|' \ |
| 43 | + | sed -E 's|^go/$|https://google.github.io/styleguide/go/|' \ |
| 44 | + | sort) |
| 45 | + |
| 46 | + # Write the list to a temporary file for differential comparison in a later step |
| 47 | + echo "$README_URLS" > readme_urls.tmp |
| 48 | +
|
| 49 | + # Step 3: Extract the list of style guide URLs defined in the SKILL.md table |
| 50 | + - name: Extract Style Guide URLs from SKILL.md |
| 51 | + run: | |
| 52 | + # Extract all URL targets from markdown links in the SKILL.md table |
| 53 | + # and sort the list alphabetically. |
| 54 | + echo "Extracting style guides from SKILL.md..." |
| 55 | + SKILL_URLS=$(grep '|' skills/google-styleguide/SKILL.md \ |
| 56 | + | grep -o -E 'https?://[a-zA-Z0-9./_-]+' \ |
| 57 | + | sort) |
| 58 | + |
| 59 | + # Write the list to a temporary file for differential comparison in a later step |
| 60 | + echo "$SKILL_URLS" > skill_urls.tmp |
| 61 | +
|
| 62 | + # Step 4: Compare the two lists and fail if they have diverged |
| 63 | + - name: Verify README.md and SKILL.md style guides are in sync |
| 64 | + run: | |
| 65 | + # Perform a differential comparison between the extracted URL list files |
| 66 | + DIFF_OUT=$(diff readme_urls.tmp skill_urls.tmp || true) |
| 67 | +
|
| 68 | + # Clean up temporary files |
| 69 | + rm -f readme_urls.tmp skill_urls.tmp |
| 70 | +
|
| 71 | + # Fail the build if any divergence is found |
| 72 | + if [[ -n "$DIFF_OUT" ]]; then |
| 73 | + echo "Error: README.md style guides and skills/google-styleguide/SKILL.md are OUT OF SYNC!" >&2 |
| 74 | + echo "Differences (- README.md, + SKILL.md):" >&2 |
| 75 | + echo "$DIFF_OUT" >&2 |
| 76 | + exit 1 |
| 77 | + else |
| 78 | + echo "Success: README.md and skills/google-styleguide/SKILL.md are in sync!" |
| 79 | + exit 0 |
| 80 | + fi |
| 81 | +
|
| 82 | + # Step 5: Setup Node.js runtime environment to run markdown-link-check tool |
| 83 | + - name: Set up Node.js |
| 84 | + uses: actions/setup-node@v4 |
| 85 | + with: |
| 86 | + node-version: '20' |
| 87 | + |
| 88 | + # Step 6: Validate that there are no broken links inside README.md or SKILL.md |
| 89 | + - name: Check Markdown Links |
| 90 | + run: | |
| 91 | + # Validate README.md links using the custom JSON config to bypass flaky domains |
| 92 | + npx markdown-link-check -c .github/workflows/mlc_config.json README.md |
| 93 | + # Validate SKILL.md links using the custom JSON config to bypass flaky domains |
| 94 | + npx markdown-link-check -c .github/workflows/mlc_config.json skills/google-styleguide/SKILL.md |
0 commit comments