From 16001a610e2fbc7b491436fb4354c71f1c4bee53 Mon Sep 17 00:00:00 2001 From: cpelley Date: Tue, 2 Jul 2024 12:42:40 +0100 Subject: [PATCH] minor fixes to caching --- .github/workflows/tests.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4218046..779df98 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,14 +2,14 @@ name: Pull Request Tests on: [pull_request] -env: - # ${{ github.base_ref }}: base branch of the pull request (e.g. master/main). - # ${{ github.head_ref }}: branch the pull request targets (e.g. feature branch). - TARGET_REF: ${{ github.base_ref }} jobs: test: if: "!contains(github.event.head_commit.message, '[skip ci]')" + env: + BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || '' }} + HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + runs-on: ubuntu-latest steps: @@ -55,18 +55,20 @@ jobs: uses: actions/cache@v4 with: path: ref/coverage_output.txt - key: ref-${{ env.TARGET_REF }} + key: ref-${{ env.BASE_SHA }} - name: Checkout ref branch if: steps.cache-ref-coverage.outputs.cache-hit != 'true' uses: actions/checkout@v4 with: path: ref - ref: ${{ env.TARGET_REF }} + ref: ${{ github.base_ref }} - name: Run tests with coverage for ref branch if: steps.cache-ref-coverage.outputs.cache-hit != 'true' - run: cd ref; pytest --cov=dagrunner --cov-report=term | tee coverage_output.txt + run: | + cd ref + pytest --cov=dagrunner --cov-report=term | tee coverage_output.txt # TESTS (compare coverage) - name: Compare coverage