Skip to content

Commit

Permalink
Fix wrong version used for cache key (#57)
Browse files Browse the repository at this point in the history
As the hash is always included, this has only cosmetic impact
  • Loading branch information
mosteo authored Jan 30, 2024
1 parent 1ea72ad commit 594462b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/selftest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: alire-project/setup-alire@v2-next
if: matrix.target == 'stable'
with:
cache: false
cache: false
# We test without cache, as caching is tested in a separate workflow.
# This way we make sure the cache isn't hiding any issue.

Expand All @@ -38,7 +38,7 @@ jobs:
version: nightly
cache: false

- name: Setup from source
- name: Setup from source (master)
uses: alire-project/setup-alire@v2-next
if: matrix.target == 'source'
with:
Expand Down
14 changes: 12 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,27 @@ runs:
steps:

- name: Identify hash from which alr was built
# Identifies the version and hash to be used for the cache key
id: find-hash
shell: bash
run: |
if [[ "${{ inputs.branch }}" != "" ]]; then
echo "hash=$(git ls-remote --heads https://github.com/alire-project/alire ${{ inputs.branch }} | cut -f1)" >> $GITHUB_OUTPUT
echo "version=${{ inputs.branch }}" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.version }}" != "nightly" ]]; then
echo "hash=$(git ls-remote --tags https://github.com/alire-project/alire v${{ inputs.version }} | cut -f1)" >> $GITHUB_OUTPUT
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "hash=$(git ls-remote --tags https://github.com/alire-project/alire ${{ inputs.version }} | cut -f1)" >> $GITHUB_OUTPUT
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
fi
- name: Print cache key
id: cache-key
shell: bash
run: |
echo "key=alr[${{ steps.find-hash.outputs.version }}][${{ inputs.toolchain }}][${{ runner.os }}][${{ steps.find-hash.outputs.hash }}]" >> $GITHUB_OUTPUT
- name: Reuse cached installation
if: ${{ inputs.cache == 'true' && inputs.toolchain_dir == '' }}
id: cache-alr
Expand All @@ -55,15 +65,15 @@ runs:
~/.cache/alire
~/.config/alire
./alire_install
key: alr[${{ inputs.version }}][${{ inputs.toolchain }}][${{ runner.os }}][${{ steps.find-hash.outputs.hash }}]
key: ${{steps.cache-key.outputs.key}}
# .cache contains msys64 install on Windows
# .config contains the toolchain at the default location, besides index config
# ./alire_install contains alr itself

- name: Check cache output
shell: bash
run: |
echo Cache hit result: [${{ steps.cache-alr.outputs.cache-hit }}] cache-id: ${{ steps.find-hash.outputs.hash }}
echo Cache hit result: [${{steps.cache-alr.outputs.cache-hit}}] cache-key: ${{steps.cache-key.outputs.key}}
# Ascertain if we need to install a toolchain for building from sources
- name: Find GNAT
Expand Down

0 comments on commit 594462b

Please sign in to comment.