Skip to content
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

feat: add CI to detect references #905

Closed
wants to merge 16 commits into from
Closed
39 changes: 39 additions & 0 deletions .github/workflows/check-reference.yml
@@ -0,0 +1,39 @@
name: Check patch references

on:
push:
branches-ignore:
- dependabot/**
schedule:
# Once every day at midnight UTC
- cron: "0 0 * * *"

jobs:
stale:
SMillerDev marked this conversation as resolved.
Show resolved Hide resolved
SMillerDev marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- name: Checkout patches
uses: actions/checkout@v4

- name: Checkout core
uses: actions/checkout@v4
with:
repository: 'homebrew/homebrew-core'
path: homebrew-core

- name: Detect references
SMillerDev marked this conversation as resolved.
Show resolved Hide resolved
run: |
#!/bin/bash

SMillerDev marked this conversation as resolved.
Show resolved Hide resolved
core_patches=$(git -C homebrew-core grep -h "Homebrew/formula-patches" | awk -F/ '{print $NF}' | tr -d '"')
issyl0 marked this conversation as resolved.
Show resolved Hide resolved
all_patches=$(git ls-files | grep -v "LICENSE" | grep -v "README.md" | grep -v ".github/workflows/triage-issues.yml" | grep -v ".github/workflows/check-reference.yml")
issyl0 marked this conversation as resolved.
Show resolved Hide resolved
status=0

for patch in $all_patches; do
if ! grep -q "$core_patches" <<< "$patch"; then
issyl0 marked this conversation as resolved.
Show resolved Hide resolved
echo "Unused patch: $patch."
# TODO: Delete the patch and commit the deletion.
status=1
fi
done
exit $status