diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 90d0d05ada..37cb975a9b 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -85,11 +85,22 @@ jobs: INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-') echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV + # We have to restore package sources before `cabal update` + # cause it overwrites the hackage index with the cached one + - name: Hackage sources cache + uses: actions/cache@v2 + env: + cache-name: hackage-sources + with: + path: ${{ env.CABAL_PKGS_DIR }} + key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} + restore-keys: ${{ env.cache-name }}- + # To ensure we get the lastest hackage index and not relying on haskell action logic + # It has to be done before `cabal freeze` to make it aware of the new index - run: cabal update - name: Form the package list ('cabal.project.freeze') - id: compute-cache-key run: | cabal v2-freeze && \ echo "" && \ @@ -98,16 +109,6 @@ jobs: cat 'cabal.project.freeze' && \ echo '' || \ echo 'WARNING: Could not produce the `freeze`.' - echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }} - - - name: Hackage sources cache - uses: actions/cache@v2 - env: - cache-name: hackage-sources - with: - path: ${{ env.CABAL_PKGS_DIR }} - key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} - restore-keys: ${{ env.cache-name }}- - name: Compiled deps cache id: compiled-deps @@ -116,7 +117,7 @@ jobs: cache-name: compiled-deps with: path: ${{ steps.HaskEnvSetup.outputs.cabal-store }} - key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }} + key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }} restore-keys: | ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}- ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}- diff --git a/.github/workflows/caching.yml b/.github/workflows/caching.yml index 789ec0ff46..6e9a7306c7 100644 --- a/.github/workflows/caching.yml +++ b/.github/workflows/caching.yml @@ -142,26 +142,13 @@ jobs: INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-') echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV - # To ensure we get the lastest hackage index and not relying on haskell action logic - - run: cabal update - - - name: Form the package list ('cabal.project.freeze') - id: compute-cache-key - run: | - cabal v2-freeze && \ - echo "" && \ - echo 'Output:' && \ - echo "" && \ - cat 'cabal.project.freeze' && \ - echo '' || \ - echo 'WARNING: Could not produce the `freeze`.' - echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }} - # 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really, # but can depend on `base`. # But this caching is happens only inside `master` for `master` purposes of compiling the deps # so having a shared pool here that depends only on Hackage pin & does not depend on `base` is "good enough" # & used such because it preserves 10% of a global cache storage pool. + # We have to restore package sources before `cabal update` + # cause it overwrites the hackage index with the cached one - name: Hackage sources cache uses: actions/cache@v2 env: @@ -171,6 +158,20 @@ jobs: key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} restore-keys: ${{ env.cache-name }}- + # To ensure we get the lastest hackage index and not relying on haskell action logic + # It has to be done before `cabal freeze` to make it aware of the new index + - run: cabal update + + - name: Form the package list ('cabal.project.freeze') + run: | + cabal v2-freeze && \ + echo "" && \ + echo 'Output:' && \ + echo "" && \ + cat 'cabal.project.freeze' && \ + echo '' || \ + echo 'WARNING: Could not produce the `freeze`.' + - name: Compiled deps cache id: compiled-deps uses: actions/cache@v2 @@ -178,7 +179,7 @@ jobs: cache-name: compiled-deps with: path: ${{ steps.HaskEnvSetup.outputs.cabal-store }} - key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }} + key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }} restore-keys: | ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}- ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}- diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index 608d9ed544..ac95aeac80 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -85,31 +85,30 @@ jobs: INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-') echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV + # We have to restore package sources before `cabal update` + # cause it overwrites the hackage index with the cached one + - name: Hackage sources cache + uses: actions/cache@v2 + env: + cache-name: hackage-sources + with: + path: ${{ env.CABAL_PKGS_DIR }} + key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} + restore-keys: ${{ env.cache-name }}- + # To ensure we get the lastest hackage index and not relying on haskell action logic + # It has to be done before `cabal freeze` to make it aware of the new index - run: cabal update - name: Form the package list ('cabal.project.freeze') - id: compute-cache-key run: | cabal v2-freeze && \ echo "" && \ echo 'Output:' && \ echo "" && \ cat 'cabal.project.freeze' && \ - echo "" || \ + echo '' || \ echo 'WARNING: Could not produce the `freeze`.' - echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }} - # Removing freeze file as it breaks builds with alternative flags - rm -rf cabal.project.freeze - - - name: Hackage sources cache - uses: actions/cache@v2 - env: - cache-name: hackage-sources - with: - path: ${{ env.CABAL_PKGS_DIR }} - key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} - restore-keys: ${{ env.cache-name }}- - name: Compiled deps cache id: compiled-deps @@ -118,12 +117,16 @@ jobs: cache-name: compiled-deps with: path: ${{ steps.HaskEnvSetup.outputs.cabal-store }} - key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }} + key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }} restore-keys: | ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}- ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}- ${{ env.cache-name }}-${{ runner.os }}- + # Removing freeze file cause it breaks builds with alternative flags + - name: Remove freeze file + run: rm -f cabal.project.freeze + - name: Build `hls-graph` with flags run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats" diff --git a/.github/workflows/hackage.yml b/.github/workflows/hackage.yml index 7fa7714afd..0c16b40cfd 100644 --- a/.github/workflows/hackage.yml +++ b/.github/workflows/hackage.yml @@ -78,16 +78,32 @@ jobs: cache-name: hackage-sources with: path: ${{ env.CABAL_PKGS_DIR }} - key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} + key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} restore-keys: ${{ env.cache-name }}- + # To ensure we get the lastest hackage index and not relying on haskell action logic + # It has to be done before `cabal freeze` to make it aware of the new index + - name: "Ensure we will use hackage head" + run: cabal update + + - name: Form the package list ('cabal.project.freeze') + run: | + cabal v2-freeze && \ + echo "" && \ + echo 'Output:' && \ + echo "" && \ + cat 'cabal.project.freeze' && \ + echo '' || \ + echo 'WARNING: Could not produce the `freeze`.' + - name: Compiled deps cache + id: compiled-deps uses: actions/cache@v2 env: cache-name: compiled-deps with: path: ${{ steps.HaskEnvSetup.outputs.cabal-store }} - key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project') }} + key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }} restore-keys: | ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}- ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}- @@ -116,9 +132,6 @@ jobs: - name: "Unpack package source in an isolated location" run: cabal unpack ${{ steps.generate-dist-tarball.outputs.path }} --destdir=./incoming - - name: "Ensure we will use hackage head" - run: cabal update - - name: "Try to get the current hackage version" id: get-hackage-version run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7ed443d518..f83653a0be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -146,11 +146,22 @@ jobs: INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-') echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV + # We have to restore package sources before `cabal update` + # cause it overwrites the hackage index with the cached one + - name: Hackage sources cache + uses: actions/cache@v2 + env: + cache-name: hackage-sources + with: + path: ${{ env.CABAL_PKGS_DIR }} + key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} + restore-keys: ${{ env.cache-name }}- + # To ensure we get the lastest hackage index and not relying on haskell action logic + # It has to be done before `cabal freeze` to make it aware of the new index - run: cabal update - - name: Compute the cache key - id: compute-cache-key + - name: Form the package list ('cabal.project.freeze') run: | cabal v2-freeze && \ echo "" && \ @@ -159,16 +170,6 @@ jobs: cat 'cabal.project.freeze' && \ echo '' || \ echo 'WARNING: Could not produce the `freeze`.' - echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }} - - - name: Hackage sources cache - uses: actions/cache@v2 - env: - cache-name: hackage-sources - with: - path: ${{ env.CABAL_PKGS_DIR }} - key: ${{ env.cache-name }}-${{ env.INDEX_STATE }} - restore-keys: ${{ env.cache-name }}- - name: Compiled deps cache id: compiled-deps @@ -177,7 +178,7 @@ jobs: cache-name: compiled-deps with: path: ${{ steps.HaskEnvSetup.outputs.cabal-store }} - key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }} + key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }} restore-keys: | ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}- ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-