From 7b5c173543cdc9776d1bf850fd461257dd25b1c8 Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Mon, 11 Mar 2024 17:37:38 -0700 Subject: [PATCH] ci: Improve diagnostics in PR workflows (#2778) --- .github/workflows/coverage.yml | 1 + .github/workflows/pr.yml | 41 +++++++++++++++++----------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bb93ea000b..a3a5f33077 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,6 +23,7 @@ jobs: timeout-minutes: 5 runs-on: ubuntu-latest steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: changed uses: tj-actions/changed-files@800a2825992141ddde1a8bca8ad394cec34d3188 with: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 257ea753dc..36a045f93f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -16,6 +16,7 @@ jobs: timeout-minutes: 5 runs-on: ubuntu-latest steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: build uses: tj-actions/changed-files@800a2825992141ddde1a8bca8ad394cec34d3188 with: @@ -29,22 +30,17 @@ jobs: files_ignore: 'Cargo.toml' files: | **/Cargo.toml + - id: cargo-crates + if: steps.cargo.outputs.any_changed == 'true' + run: ./.github/list-crates.sh ${{ steps.cargo.outputs.all_changed_files }} - id: rust uses: tj-actions/changed-files@800a2825992141ddde1a8bca8ad394cec34d3188 with: files: | **/*.rs Cargo.lock - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - id: cargo-crates - if: steps.cargo.outputs.any_changed - run: ./.github/list-crates.sh ${{ steps.cargo.outputs.all_changed_files }} - - run: | - echo 'build: ${{ steps.build.outputs.all_changed_files }}' - echo 'cargo: ${{ steps.cargo.outputs.all_changed_files }}' - echo 'crates: ${{ steps.cargo-crates.outputs.crates }}' - echo 'rust: ${{ steps.rust.outputs.all_changed_files }}' outputs: + is_dependabot: ${{ github.actor == 'dependabot[bot]' && 'true' || '' }} any_changed: ${{ steps.build.outputs.any_changed || steps.cargo.outputs.any_changed || steps.rust.outputs.any_changed }} build_changed: ${{ steps.build.outputs.any_changed }} cargo_changed: ${{ steps.cargo.outputs.any_changed }} @@ -63,7 +59,7 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - run: git config --global --add safe.directory "$PWD" # actions/runner#2033 - run: just fetch - - name: cargo deny check bans licenses sources + - name: Run cargo deny check bans licenses sources uses: EmbarkStudios/cargo-deny-action@64015a69ee7ee08f6c56455089cdaf6ad974fd15 with: command: check bans licenses sources @@ -114,29 +110,34 @@ jobs: ok: timeout-minutes: 3 - needs: [rust, rust-crates, linkerd-install] + needs: [meta, rust, rust-crates, linkerd-install] if: always() runs-on: ubuntu-latest steps: - name: Info run: | - echo 'Actor: ${{ github.actor }}' - echo 'Event: ${{ github.event_name }}' - echo 'Rust: ${{ needs.rust.result }}' - echo 'Crates: ${{ needs.rust-crates.result }}' - echo 'Install: ${{ needs.linkerd-install.result }}' + echo 'github.actor: ${{ github.actor }}' + echo 'github.event_name: ${{ github.event_name }}' + echo 'github.event.pull_request.number: ${{ github.event.pull_request.number }}' + echo 'needs.rust.result: ${{ needs.rust.result }}' + echo 'needs.rust-crates.result: ${{ needs.rust-crates.result }}' + echo 'needs.linkerd-install.result: ${{ needs.linkerd-install.result }}' + echo 'needs.meta.outputs.is_dependabot: ${{ needs.meta.outputs.is_dependabot }}' + echo 'needs.meta.outputs.any_changed: ${{ needs.meta.outputs.any_changed }}' + echo 'needs.meta.outputs.cargo_changed: ${{ needs.meta.outputs.cargo_changed }}' + echo 'needs.meta.outputs.cargo_crates: ${{ needs.meta.outputs.cargo_crates }}' + echo 'needs.meta.outputs.rust_changed: ${{ needs.meta.outputs.rust_changed }}' - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') run: exit 1 auto-merge: - needs: ok - if: github.actor == 'dependabot[bot]' + needs: [meta, ok] + if: needs.meta.outputs.is_dependabot == 'true' runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - run: gh pr merge '${{ github.event.pull_request.number }}' --auto --merge + - run: gh pr merge '${{ github.event.pull_request.number }}' --auto --squash env: GH_TOKEN: ${{ github.token }}