Skip to content

Commit

Permalink
Use stack ls dependencies for cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed May 30, 2024
1 parent 6623777 commit fb907b6
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions .github/workflows/stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,34 @@ jobs:

- name: Setup Stack
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.vers.ghc }}
cabal-version: ${{ matrix.cabal }}
enable-stack: true
stack-version: "latest"
stack-version: '2.15.7'

- name: Cache ~/.stack and .stack-work
uses: actions/cache@v3
- name: Configure stack
run: |
stack config set system-ghc --global true
stack config set install-ghc --global false
- name: List dependencies
run: stack ls dependencies json | jq > stack-deps.json

- name: Restore cached dependency of Pantry (Stackage package index)
uses: actions/cache/restore@v4
id: pantry
env:
key: ghc-${{ steps.setup.outputs.ghc-version }}-stack-${{ steps.setup.outputs.stack-version }}
with:
path: |
~/.stack
.stack-work
key: ${{ runner.os }}-${{ matrix.ghc }}-stack-${{ hashFiles('**/*.cabal', './stack.yaml', './stack.yaml.lock') }}
path: ${{ steps.setup.outputs.stack-root }}/pantry
key: ${{ env.key }}-plan-${{ hashFiles('stack-deps.json') }}
restore-keys: ${{ env.key }}-

- name: Recompute Stackage package index (~/.stack/pantry)
if: steps.pantry.outputs.cache-hit != 'true'
run: stack update

- name: Stack resolver check
if: ${{ matrix.vers.ghc == matrix.ghc-default }}
Expand All @@ -63,7 +78,14 @@ jobs:
run: stack test --no-run-tests --dry-run --lock-file=error-on-write

- name: Build
run: stack test --no-run-tests $STACK_FLAGS --resolver ${{ matrix.vers.stackage }}
run: stack test --no-run-tests $STACK_FLAGS --resolver ${{ matrix.vers.stackage }} --lock-file=ignore

- name: Test
run: stack test --test-arguments "--color=always" $STACK_FLAGS --resolver ${{ matrix.vers.stackage }}
run: stack test --test-arguments "--color=always" $STACK_FLAGS --resolver ${{ matrix.vers.stackage }} --lock-file=ignore

- name: Save cached dependencies of Pantry
uses: actions/cache/save@v4
if: steps.pantry.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.stack-root }}/pantry
key: ${{ steps.cache.outputs.cache-primary-key }}

0 comments on commit fb907b6

Please sign in to comment.