Skip to content

Commit

Permalink
github: Run deps workflow against PR target branch and improve dir na…
Browse files Browse the repository at this point in the history
…mes (grpc#8010)
  • Loading branch information
arjan-bal committed Jan 22, 2025
1 parent 85f90c0 commit 5a06379
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ jobs:
# Run the commands to generate dependencies before and after and compare.
- name: Compare dependencies
run: |
BEFORE="$(mktemp -d)"
AFTER="$(mktemp -d)"
set -eu
TEMP_DIR="$(mktemp -d)"
# GITHUB_BASE_REF is set when the job is triggered by a PR.
TARGET_REF="${GITHUB_BASE_REF:-master}"
scripts/gen-deps.sh "${AFTER}"
git checkout origin/master
scripts/gen-deps.sh "${BEFORE}"
mkdir "${TEMP_DIR}/after"
scripts/gen-deps.sh "${TEMP_DIR}/after"
git checkout "origin/${TARGET_REF}"
mkdir "${TEMP_DIR}/before"
scripts/gen-deps.sh "${TEMP_DIR}/before"
echo "Comparing dependencies..."
cd "${TEMP_DIR}"
# Run grep in a sub-shell since bash does not support ! in the middle of a pipe
diff -u0 -r "${BEFORE}" "${AFTER}" | bash -c '! grep -v "@@"'
diff -u0 -r "before" "after" | bash -c '! grep -v "@@"'
echo "No changes detected."

0 comments on commit 5a06379

Please sign in to comment.