From 32f9b1a231b895e9b5148d487a1606ad72f09ff3 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Fri, 1 Mar 2024 16:06:54 +0000 Subject: [PATCH] ci: gate coverage analysis on whether source code changed --- .github/workflows/coveralls.yml | 13 +++++++++++++ contrib/classify-pr.sh | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index a3d37cd3..25d98c28 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -5,7 +5,20 @@ on: name: Code coverage with llvm-cov jobs: + Prepare: + runs-on: ubuntu-latest + outputs: + pr_changed_source: ${{ steps.classify_pr.outputs.pr_changed_source }} + steps: + - name: Checkout Crate + uses: actions/checkout@v4 + - name: Determine what files the PR changes. + id: classify_pr + run: contrib/classify-pr.sh ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }} + Coveralls: + needs: Prepare + if: needs.Prepare.outputs.pr_changed_source == 'true' name: Code coverage - stable toolchain runs-on: ubuntu-latest strategy: diff --git a/contrib/classify-pr.sh b/contrib/classify-pr.sh index 0cab8cce..e72fba5d 100755 --- a/contrib/classify-pr.sh +++ b/contrib/classify-pr.sh @@ -16,6 +16,10 @@ git fetch origin "$pr_tip":pr_tip pr_base=$(git merge-base master_tip pr_tip) +echo "Using master $master_tip" +echo "Using PR tip $pr_tip" +echo "Using PR base $pr_base" + # If something modifies any non-markdown file, it's considered a source code change. if git diff --name-only "$pr_base" "$pr_tip" | grep -qv "^.md$"; then echo "pr_changed_source=true" >> "$GITHUB_OUTPUT"