Skip to content

Commit

Permalink
Use subdirs for before and after
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal committed Jan 16, 2025
1 parent 95c84da commit e482d57
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,26 @@ jobs:
- name: Compare dependencies
run: |
set -eux
BASE_REF="${GITHUB_BASE_REF:-master}"
# Suffixes passed to mktemp must not contain "/".
BEFORE_SUFFIX="${BASE_REF//\//_}"
AFTER_SUFFIX="${GITHUB_HEAD_REF//\//_}"
TEMP_DIR="$(mktemp -d)"
# GITHUB_BASE_REF is set when the job is triggered by a PR.
TARGET_REF="${GITHUB_BASE_REF:-master}"
# GITHUB_HEAD_REF is set when the job is triggered by a PR.
SOURCE_REF="${GITHUB_HEAD_REF:-source}"
BEFORE="$(mktemp -d --suffix="-${BEFORE_SUFFIX}")"
AFTER="$(mktemp -d --suffix="-${AFTER_SUFFIX}")"
# Replace special characters in the branch names.
BEFORE_DIR_NAME="$(echo "${SOURCE_REF}" | sed 's/[^a-zA-Z0-9._-]/_/g')"
AFTER_DIR_NAME="$(echo "${TARGET_REF}" | sed 's/[^a-zA-Z0-9._-]/_/g')"
scripts/gen-deps.sh "${AFTER}"
# GITHUB_BASE_REF is set when the job is triggered by a PR.
git checkout origin/"${BASE_REF}"
scripts/gen-deps.sh "${BEFORE}"
mkdir "${TEMP_DIR}/${AFTER_DIR_NAME}"
scripts/gen-deps.sh "${TEMP_DIR}/${AFTER_DIR_NAME}"
git checkout "origin/${TARGET_REF}"
mkdir "${TEMP_DIR}/${BEFORE_DIR_NAME}"
scripts/gen-deps.sh "${TEMP_DIR}/${BEFORE_DIR_NAME}"
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_DIR_NAME}" "./${AFTER_DIR_NAME}" | bash -c '! grep -v "@@"'
echo "No changes detected."

0 comments on commit e482d57

Please sign in to comment.