|
| 1 | +name: Validate Package Catalog |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 9 * * 1' # Every Monday 9am UTC |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + validate: |
| 10 | + runs-on: macos-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: Check packages exist in Homebrew |
| 15 | + run: | |
| 16 | + python3 - << 'EOF' |
| 17 | + import subprocess, sys, yaml |
| 18 | +
|
| 19 | + with open("internal/config/data/packages.yaml") as f: |
| 20 | + data = yaml.safe_load(f) |
| 21 | +
|
| 22 | + formulae, casks, taps_needed = [], [], set() |
| 23 | +
|
| 24 | + for category in data.get("categories", []): |
| 25 | + for pkg in category.get("packages", []): |
| 26 | + name = pkg["name"] |
| 27 | + if pkg.get("npm"): |
| 28 | + continue # npm packages not validated here |
| 29 | + if pkg.get("cask"): |
| 30 | + casks.append(name) |
| 31 | + else: |
| 32 | + formulae.append(name) |
| 33 | + # tap-qualified: owner/repo/formula |
| 34 | + parts = name.split("/") |
| 35 | + if len(parts) == 3: |
| 36 | + taps_needed.add(f"{parts[0]}/{parts[1]}") |
| 37 | +
|
| 38 | + # Add required taps |
| 39 | + for tap in taps_needed: |
| 40 | + subprocess.run(["brew", "tap", tap], capture_output=True) |
| 41 | +
|
| 42 | + failed = [] |
| 43 | +
|
| 44 | + print(f"Checking {len(formulae)} formulae and {len(casks)} casks...\n") |
| 45 | +
|
| 46 | + for name in formulae: |
| 47 | + result = subprocess.run(["brew", "info", name], capture_output=True) |
| 48 | + if result.returncode != 0: |
| 49 | + print(f" MISSING formula: {name}") |
| 50 | + failed.append(name) |
| 51 | +
|
| 52 | + for name in casks: |
| 53 | + result = subprocess.run(["brew", "info", "--cask", name], capture_output=True) |
| 54 | + if result.returncode != 0: |
| 55 | + print(f" MISSING cask: {name}") |
| 56 | + failed.append(name) |
| 57 | +
|
| 58 | + if failed: |
| 59 | + print(f"\n{len(failed)} package(s) not found in Homebrew:") |
| 60 | + for name in failed: |
| 61 | + print(f" - {name}") |
| 62 | + print("\nUpdate packages.yaml to fix or remove these entries.") |
| 63 | + sys.exit(1) |
| 64 | + else: |
| 65 | + print(f"All packages validated OK.") |
| 66 | + EOF |
0 commit comments