From 265b01ef7569f5f6ec2047a4199f8add55458f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20Mart=C3=ADnez?= Date: Wed, 23 Oct 2024 21:02:26 -0700 Subject: [PATCH] actions: adding a workflow to check for stale hints --- .github/workflows/stale_hints.yml | 19 +++++++++++++++++++ .scripts/remove_stale_hints.sh | 13 +++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/stale_hints.yml diff --git a/.github/workflows/stale_hints.yml b/.github/workflows/stale_hints.yml new file mode 100644 index 00000000000..41522524f5f --- /dev/null +++ b/.github/workflows/stale_hints.yml @@ -0,0 +1,19 @@ +name: Check for stale hints +on: + pull_request: + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + - run: | + L=$(.scripts/remove_stale_hints.sh list) + if [ "$L" != "" ]; then + echo "There are stale hints:" + echo "$L" + false + fi diff --git a/.scripts/remove_stale_hints.sh b/.scripts/remove_stale_hints.sh index e8e8f20570c..db029f17465 100755 --- a/.scripts/remove_stale_hints.sh +++ b/.scripts/remove_stale_hints.sh @@ -2,6 +2,11 @@ set -eu +list=false +if [ $# -gt 0 ] && [ $1 == "list" ]; then + list=true +fi + declare -A files # Store all basenames in repo declare -A hints # Store all paths of hints in repo @@ -27,7 +32,11 @@ for h0 in "${!hints[@]}"; do # Given a/b/c/Foo.Bar.fst.hints, if there is no Foo.Bar.fst # anywhere, then delete the hint file. if ! [ -v "files[$h]" ]; then - echo "DELETING HINT $h0" - rm -f "${h0}" + if $list; then + echo "$h0" + else + echo "DELETING HINT $h0" + rm -f "${h0}" + fi fi done