Skip to content

Commit

Permalink
Make key unique using OS arch (#8)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
reznikmm and mosteo authored Jul 11, 2024
1 parent 590c6f7 commit 008834e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/branch.yml

This file was deleted.

9 changes: 7 additions & 2 deletions .github/workflows/selftest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 16 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ runs:
echo "force=" >> $GITHUB_OUTPUT
fi
- name: Prepare cache id
- name: Prepare cache milestones
id: find-versions
shell: bash
run: |
Expand All @@ -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'
Expand Down

0 comments on commit 008834e

Please sign in to comment.