@@ -85,31 +85,30 @@ jobs:
8585 INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
8686 echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
8787
88+ # We have to restore package sources before `cabal update`
89+ # cause it overwrites the hackage index with the cached one
90+ - name : Hackage sources cache
91+ uses : actions/cache@v2
92+ env :
93+ cache-name : hackage-sources
94+ with :
95+ path : ${{ env.CABAL_PKGS_DIR }}
96+ key : ${{ env.cache-name }}-${{ env.INDEX_STATE }}
97+ restore-keys : ${{ env.cache-name }}-
98+
8899 # To ensure we get the lastest hackage index and not relying on haskell action logic
100+ # It has to be done before `cabal freeze` to make it aware of the new index
89101 - run : cabal update
90102
91103 - name : Form the package list ('cabal.project.freeze')
92- id : compute-cache-key
93104 run : |
94105 cabal v2-freeze && \
95106 echo "" && \
96107 echo 'Output:' && \
97108 echo "" && \
98109 cat 'cabal.project.freeze' && \
99- echo "" || \
110+ echo '' || \
100111 echo 'WARNING: Could not produce the `freeze`.'
101- echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
102- # Removing freeze file as it breaks builds with alternative flags
103- rm -rf cabal.project.freeze
104-
105- - name : Hackage sources cache
106- uses : actions/cache@v2
107- env :
108- cache-name : hackage-sources
109- with :
110- path : ${{ env.CABAL_PKGS_DIR }}
111- key : ${{ env.cache-name }}-${{ env.INDEX_STATE }}
112- restore-keys : ${{ env.cache-name }}-
113112
114113 - name : Compiled deps cache
115114 id : compiled-deps
@@ -118,12 +117,16 @@ jobs:
118117 cache-name : compiled-deps
119118 with :
120119 path : ${{ steps.HaskEnvSetup.outputs.cabal-store }}
121- key : ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
120+ key : ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
122121 restore-keys : |
123122 ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
124123 ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
125124 ${{ env.cache-name }}-${{ runner.os }}-
126125
126+ # Removing freeze file cause it breaks builds with alternative flags
127+ - name : Remove freeze file
128+ run : rm -f cabal.project.freeze
129+
127130 - name : Build `hls-graph` with flags
128131 run : cabal v2-build hls-graph --flags="pedantic embed-files stm-stats"
129132
0 commit comments