@@ -58,16 +58,31 @@ jobs:
5858
5959 - name : Set environment variables based on Haskell setup
6060 run : |
61- export STACK_VER=$(stack --numeric-version)
62- echo "STACK_VER=${STACK_VER}" >> ${GITHUB_ENV}
61+ STACK_VER=$(stack --numeric-version)
62+ echo "STACK_VER=${STACK_VER}" >> " ${GITHUB_ENV}"
6363
64- - uses : actions/cache@v3
65- name : Cache dependencies
64+ - name : Cache dependencies (restore)
65+ uses : actions/cache/restore@v3
6666 id : cache
6767 with :
6868 path : ${{ steps.haskell-setup.outputs.stack-root }}
69- # A unique cache is used for each stack.yaml.
70- key : ${{ runner.os }}-stack-${{ env.STACK_VER }}-${{ hashFiles(format('stack-{0}.yaml', matrix.ghc-ver)) }}
69+ key : ${{ runner.os }}-stack-${{ env.STACK_VER }}-ghc-${{ matrix.ghc-ver }}-${{ hashFiles(format('stack-{0}.yaml', matrix.ghc-ver)) }}
70+ restore-keys : ${{ runner.os }}-stack-${{ env.STACK_VER }}-ghc-${{ matrix.ghc-ver }}-
71+
72+ - name : Install dependencies
73+ if : ${{ !steps.cache.outputs.cache-hit }}
74+ run : |
75+ stack build ${{ env.ARGS }} --test --only-dependencies
76+
77+ - name : Cache dependencies (save)
78+ uses : actions/cache/save@v3
79+ env :
80+ key : ${{ steps.cache.outputs.cache-primary-key }}
81+ # Will fail if we already have a cache with this key.
82+ if : ${{ !(steps.cache.outputs.cache-hit && env.key == steps.cache.outputs.cache-matched-key) }}
83+ with :
84+ path : ${{ steps.haskell-setup.outputs.stack-root }}
85+ key : ${{ env.key }}
7186
7287 - name : Build hackage-cli
7388 run : |
0 commit comments