From 008834eab688add896e70412d8d2da910bf5bc13 Mon Sep 17 00:00:00 2001 From: Maxim Reznik Date: Thu, 11 Jul 2024 14:07:26 +0300 Subject: [PATCH] Make `key` unique using OS arch (#8) * Make `key` unique * Use PR's action version during testing * Log cache usage * Test with and without cache * Remove now pointless branch check --------- Co-authored-by: Alejandro R. Mosteo --- .github/workflows/branch.yml | 15 --------------- .github/workflows/selftest.yml | 9 +++++++-- action.yml | 19 ++++++++++++++++--- 3 files changed, 23 insertions(+), 20 deletions(-) delete mode 100644 .github/workflows/branch.yml diff --git a/.github/workflows/branch.yml b/.github/workflows/branch.yml deleted file mode 100644 index f68eca6..0000000 --- a/.github/workflows/branch.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Source branch -on: [pull_request] -env: - TARGET_HEAD: v1-next - -jobs: - check_pr: - runs-on: ubuntu-latest - steps: - - name: Check on proper branch - if: github.head_ref != env.TARGET_HEAD - uses: actions/github-script@v3 - with: - script: | - core.setFailed(`PRs for latest-stable must come from ${{ env.TARGET_HEAD }}, but branch is ${{ github.head_ref }}`) \ No newline at end of file diff --git a/.github/workflows/selftest.yml b/.github/workflows/selftest.yml index ded4f61..96228d4 100644 --- a/.github/workflows/selftest.yml +++ b/.github/workflows/selftest.yml @@ -7,16 +7,21 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] + cached: [false, true] runs-on: ${{ matrix.os }} steps: - - uses: alire-project/alr-install@v1-next + - name: Checkout + uses: actions/checkout@v2 + + - name: Selftest + uses: ./ # Uses the action code from the PR itself with: crates: gprbuild # This can be changed to a more lightweight crate (hello) # once we can install indexed releases. - cache: false # Don't use cache for testing + cache: ${{ matrix.cached }} - name: Run check shell: bash diff --git a/action.yml b/action.yml index d2d6dd6..45a3985 100644 --- a/action.yml +++ b/action.yml @@ -54,7 +54,7 @@ runs: echo "force=" >> $GITHUB_OUTPUT fi - - name: Prepare cache id + - name: Prepare cache milestones id: find-versions shell: bash run: | @@ -65,14 +65,27 @@ runs: echo Versions are: $versions echo "milestones=$versions" >> $GITHUB_OUTPUT + - name: Prepare cache id + id: cache-key + shell: bash + run: | + echo "key=[alr-install][${{runner.os}}][${{runner.arch}}][${{inputs.prefix}}][${{steps.find-versions.outputs.milestones}}]" >> $GITHUB_OUTPUT + - name: Reuse cached installation if: inputs.cache == 'true' id: cache-install - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ${{inputs.prefix}} - key: '[alr-install][${{runner.os}}][${{inputs.prefix}}][${{steps.find-versions.outputs.milestones}}]' + key: ${{steps.cache-key.outputs.key}} + + - name: Diagnose cache usage + shell: bash + run: | + echo "alr-install cache requested: ${{inputs.cache}}" + echo "alr-install cache hit: ${{steps.cache-install.outputs.cache-hit}}" + echo "alr-install cache key: ${{steps.cache-key.outputs.key}}" - name: Run `alr install` if: inputs.cache != 'true' || steps.cache-install.outputs.cache-hit != 'true'