-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Dependency Changes | ||
|
||
# Trigger on PRs. | ||
on: | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
# Compare dependencies before and after this PR. | ||
dependencies: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
strategy: | ||
fail-fast: true | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
cache-dependency-path: "**/*go.sum" | ||
|
||
# Run the commands to generate dependencies before and after and compare. | ||
- name: Compare dependencies | ||
run: | | ||
BEFORE="$(mktemp -d)" | ||
AFTER="$(mktemp -d)" | ||
scripts/gen-deps.sh "${AFTER}" | ||
git checkout origin/master | ||
scripts/gen-deps.sh "${BEFORE}" | ||
echo "Comparing dependencies..." | ||
# 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 "@@"' | ||
echo "No changes detected." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -e # Exit on error | ||
set -o pipefail # Fail a pipe if any sub-command fails. | ||
|
||
if [[ "$#" -ne 1 || ! -d "$1" ]]; then | ||
echo "Specify a valid output directory as the first parameter." | ||
exit 1 | ||
fi | ||
|
||
SCRIPTS_DIR="$(dirname "$0")" | ||
OUTPUT_DIR="$1" | ||
|
||
cd "${SCRIPTS_DIR}/.." | ||
|
||
git ls-files -- '*.go' | grep -v '\(^\|/\)\(internal\|examples\|benchmark\|interop\|test\|testdata\)\(/\|$\)' | xargs dirname | sort -u | while read d; do | ||
pushd "$d" > /dev/null | ||
pkg="$(echo "$d" | sed 's;\.;grpc;' | sed 's;/;_;g')" | ||
go list -deps . | sort >| "${OUTPUT_DIR}/$pkg" | ||
popd > /dev/null | ||
done |