google.golang.org/grpc@v1.74.2/.github/workflows/deps.yml (about)

     1  name: Dependency Changes
     2  
     3  # Trigger on PRs.
     4  on:
     5    pull_request:
     6  
     7  permissions:
     8    contents: read
     9  
    10  jobs:
    11    # Compare dependencies before and after this PR.
    12    dependencies:
    13      runs-on: ubuntu-latest
    14      timeout-minutes: 10
    15      strategy:
    16        fail-fast: true
    17  
    18      steps:
    19        - name: Checkout repo
    20          uses: actions/checkout@v4
    21          with:
    22            fetch-depth: 0
    23  
    24        - name: Setup Go
    25          uses: actions/setup-go@v5
    26          with:
    27            go-version: stable
    28            cache-dependency-path: "**/*go.sum"
    29  
    30        # Run the commands to generate dependencies before and after and compare.
    31        - name: Compare dependencies
    32          run: |
    33            set -eu
    34            TEMP_DIR="$(mktemp -d)"
    35            # GITHUB_BASE_REF is set when the job is triggered by a PR.
    36            TARGET_REF="${GITHUB_BASE_REF:-master}"
    37  
    38            mkdir "${TEMP_DIR}/after"
    39            scripts/gen-deps.sh "${TEMP_DIR}/after"
    40  
    41            git checkout "origin/${TARGET_REF}"
    42            mkdir "${TEMP_DIR}/before"
    43            scripts/gen-deps.sh "${TEMP_DIR}/before"
    44  
    45            echo -e " \nComparing dependencies..."
    46            cd "${TEMP_DIR}"
    47            # Run grep in a sub-shell since bash does not support ! in the middle of a pipe.
    48            if diff -u0 -r "before" "after" | bash -c '! grep -v "@@"'; then
    49              echo "No changes detected."
    50              exit 0
    51            fi
    52  
    53            # Print packages in `after` but not `before`.
    54            for x in $(ls -1 after | grep -vF "$(ls -1 before)"); do
    55              echo -e " \nDependencies of new package $x:"
    56              cat "after/$x"
    57            done
    58  
    59            echo -e " \nChanges detected; exiting with error."
    60            exit 1