Validate Package Catalog #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate Package Catalog | |
| on: | |
| schedule: | |
| - cron: '0 9 * * *' # Every day 9am UTC | |
| workflow_dispatch: | |
| jobs: | |
| validate: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check packages exist in Homebrew | |
| run: | | |
| CATALOG="internal/config/data/packages.yaml" | |
| failed=() | |
| # Extract all package names (lines matching " - name: <value>") | |
| # then pair with their type by reading surrounding context | |
| while IFS= read -r line; do | |
| name=$(echo "$line" | sed 's/.*- name: //' | tr -d ' ') | |
| [[ -z "$name" ]] && continue | |
| # Skip category names (they appear as " - name: Category") | |
| # Package names are indented with 6 spaces | |
| indent=$(echo "$line" | sed 's/[^ ].*//' | wc -c) | |
| [[ $indent -lt 7 ]] && continue | |
| # Check if this package is a cask (look ahead in file) | |
| is_cask=$(awk "/- name: ${name}$/,/- name:/" "$CATALOG" | grep -c "cask: true" || true) | |
| is_npm=$(awk "/- name: ${name}$/,/- name:/" "$CATALOG" | grep -c "npm: true" || true) | |
| [[ $is_npm -gt 0 ]] && continue # skip npm packages | |
| # For tap-qualified names (owner/repo/formula), add tap first | |
| slash_count=$(echo "$name" | tr -cd '/' | wc -c) | |
| if [[ $slash_count -eq 2 ]]; then | |
| tap=$(echo "$name" | cut -d'/' -f1-2) | |
| brew tap "$tap" --quiet 2>/dev/null || true | |
| fi | |
| if [[ $is_cask -gt 0 ]]; then | |
| if ! brew info --cask "$name" &>/dev/null; then | |
| echo " MISSING cask: $name" | |
| failed+=("$name") | |
| fi | |
| else | |
| if ! brew info "$name" &>/dev/null; then | |
| echo " MISSING formula: $name" | |
| failed+=("$name") | |
| fi | |
| fi | |
| done < <(grep -n " - name: " "$CATALOG") | |
| echo "" | |
| if [[ ${#failed[@]} -gt 0 ]]; then | |
| echo "${#failed[@]} package(s) not found in Homebrew:" | |
| for p in "${failed[@]}"; do echo " - $p"; done | |
| echo "" | |
| echo "Update packages.yaml to fix or remove these entries." | |
| exit 1 | |
| else | |
| echo "All packages validated OK." | |
| fi |