From 83761518615871b29656f1208e7457cc025ce66b Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Mon, 27 Dec 2021 18:27:38 +0000 Subject: [PATCH 01/10] restore TemplateHaskell pragma not 9.2 specific, but required for file_embed flag --- hls-graph/src/Development/IDE/Graph/Internal/Profile.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Profile.hs b/hls-graph/src/Development/IDE/Graph/Internal/Profile.hs index 78db2e5f05..0823070216 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Profile.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Profile.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE ViewPatterns #-} {- HLINT ignore "Redundant bracket" -} -- a result of CPP expansion From c4153981a83c276b639de90a10220293d9cd22f9 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Tue, 28 Dec 2021 14:39:58 +0200 Subject: [PATCH 02/10] CI: add flags workflow --- .github/workflows/flags.yml | 165 ++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 .github/workflows/flags.yml diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml new file mode 100644 index 0000000000..e35783cd86 --- /dev/null +++ b/.github/workflows/flags.yml @@ -0,0 +1,165 @@ +name: Flags + +defaults: + run: + shell: bash + +# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency. +concurrency: + group: ${{ github.head_ref }}-${{ github.workflow }} + cancel-in-progress: true + +on: + pull_request: + branches: + - '**' + +jobs: + pre_job: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + should_skip_ghcide: ${{ steps.skip_ghcide_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@v3.4.1 + with: + cancel_others: false + paths_ignore: '[ "**/docs/**" + , "**.md" + , "**/LICENSE" + , "install/**" + , "**.nix" + , "flake.lock" + , "**/README.md" + , "FUNDING.yml" + , ".circleci/**" + , "**/stack*.yaml" + ]' + # If we only change ghcide downstream packages we have not test ghcide itself + - id: skip_ghcide_check + uses: fkirc/skip-duplicate-actions@v3.4.1 + with: + cancel_others: false + paths_ignore: '[ "hls-test-utils/**" + , "plugins/**" + , "src/**" + , "exe/**" + , "test/**" + , "shake-bench/**" + ]' + + flags: + if: needs.pre_job.outputs.should_skip != 'true' + needs: pre_job + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + ghc: [ "8.10.7" + ] + os: [ "ubuntu-latest" + ] + cabal: ['3.6'] + + steps: + - uses: actions/checkout@v2 + + - uses: haskell/actions/setup@v1 + id: HaskEnvSetup + with: + ghc-version : ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + enable-stack: false + + - if: runner.os == 'Windows' + name: (Windows) Platform config + run: | + echo "CABAL_PKGS_DIR=C:\\cabal\\packages" >> $GITHUB_ENV + - if: ( runner.os == 'Linux' ) || ( runner.os == 'macOS' ) + name: (Linux,macOS) Platform config + run: | + echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV + + # All workflows which distinquishes cache on `cabal.project` needs this. + - name: Workaround shorten binary names + run: | + sed -i.bak -e 's/haskell-language-server/hls/g' \ + -e 's/haskell_language_server/hls/g' \ + haskell-language-server.cabal cabal.project + sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \ + src/**/*.hs exe/*.hs + + - name: Retrieving `cabal.project` Hackage timestamp + run: | + # Form: index-state: 2021-11-29T08:11:08Z + INDEX_STATE_ENTRY=$(grep index-state cabal.project) + # Form: 2021-11-29T08-11-08Z + INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-') + echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV + + - name: Form the package list ('cabal.project.freeze') + continue-on-error: true + run: | + cabal v2-freeze && \ + echo '' && \ + echo 'Output:' && \ + echo '' && \ + cat 'cabal.project.freeze' && \ + echo '' || \ + echo 'WARNING: Could not produce the `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 + 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.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 }}- + + - if: needs.pre_job.outputs.should_skip != 'true' + name: Build `hls-graph` with flags + run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats" + + - if: needs.pre_job.outputs.should_skip != 'true' + name: Build `hie-compat` with flags + run: cabal v2-build hie-compat --flags="ghc-lib" + + - if: needs.pre_job.outputs.should_skip != 'true' + name: Build `hls-plugin-api` with flags + run: cabal v2-build hls-plugin-api --flags="pedantic" + + - if: needs.pre_job.outputs.should_skip != 'true' + name: Build `hls-test-utils` with flags + run: cabal v2-build hls-test-utils --flags="pedantic" + + # repeating builds to workaround segfaults in windows and ghc-8.8.4 + - if: needs.pre_job.outputs.should_skip_ghcide != 'true' + name: Build + run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" || cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" || cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" + + flags_post_job: + if: always() + runs-on: ubuntu-latest + needs: [pre_job, flags] + steps: + - run: | + echo "jobs info: ${{ toJSON(needs) }}" + - if: contains(needs.*.result, 'failure') + run: exit 1 + - if: contains(needs.*.result, 'cancelled') && needs.pre_job.outputs.should_skip != 'true' + run: exit 1 From ca30ee9c2ebca170de3f31861ea38ef63535d943 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Tue, 28 Dec 2021 16:38:19 +0200 Subject: [PATCH 03/10] hls-graph: STM.Stats: fx stm-stats build --- hls-graph/src/Control/Concurrent/STM/Stats.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hls-graph/src/Control/Concurrent/STM/Stats.hs b/hls-graph/src/Control/Concurrent/STM/Stats.hs index f8ca99bf04..295b5d58f0 100644 --- a/hls-graph/src/Control/Concurrent/STM/Stats.hs +++ b/hls-graph/src/Control/Concurrent/STM/Stats.hs @@ -1,5 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} +#ifdef STM_STATS +{-# LANGUAGE RecordWildCards #-} +#endif module Control.Concurrent.STM.Stats ( atomicallyNamed , atomically @@ -180,4 +183,3 @@ dumpSTMStats = do #endif - From 45b29b4248f03e1cf356c10ac7abacb83f97ffa8 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Tue, 28 Dec 2021 16:50:01 +0200 Subject: [PATCH 04/10] hls-graph: Internal.Types: mk 8.6.5 code as such --- hls-graph/src/Development/IDE/Graph/Internal/Types.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs index 13c4359f2b..5026202433 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs @@ -8,13 +8,16 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE CPP #-} module Development.IDE.Graph.Internal.Types where import Control.Applicative import Control.Monad.Catch +#if __GLASGOW_HASKELL__ < 870 -- Needed in GHC 8.6.5 import Control.Concurrent.STM.Stats (TVar, atomically) +#endif import Control.Monad.Fail import Control.Monad.IO.Class import Control.Monad.Trans.Reader From 01959d5f5f26d7709ab1b6dc4b3b4ed01880fd77 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Tue, 28 Dec 2021 16:51:19 +0200 Subject: [PATCH 05/10] hls-graph: Internal.Types: treat MonadFail --- hls-graph/src/Development/IDE/Graph/Internal/Types.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs index 5026202433..f35b4bb939 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs @@ -18,7 +18,10 @@ import Control.Monad.Catch -- Needed in GHC 8.6.5 import Control.Concurrent.STM.Stats (TVar, atomically) #endif +#if __GLASGOW_HASKELL__ < 880 +import Prelude hiding (MonadFail) import Control.Monad.Fail +#endif import Control.Monad.IO.Class import Control.Monad.Trans.Reader import Data.Aeson (FromJSON, ToJSON) From a3504a52c13664e77f0a8376e89e09964e2a7c69 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Tue, 28 Dec 2021 16:56:49 +0200 Subject: [PATCH 06/10] CI: {caching, test, bench, flags}: fx freeze phase --- .github/workflows/bench.yml | 2 +- .github/workflows/caching.yml | 2 +- .github/workflows/flags.yml | 2 +- .github/workflows/test.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index e3185c56de..2f652d826d 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -94,7 +94,7 @@ jobs: echo '' && \ cat 'cabal.project.freeze' && \ echo '' || \ - echo 'WARNING: Could not produce the `freeze`. + echo 'WARNING: Could not produce the `freeze`.' - name: Hackage sources cache uses: actions/cache@v2 diff --git a/.github/workflows/caching.yml b/.github/workflows/caching.yml index 0f91111971..718c14246f 100644 --- a/.github/workflows/caching.yml +++ b/.github/workflows/caching.yml @@ -151,7 +151,7 @@ jobs: echo '' && \ cat 'cabal.project.freeze' && \ echo '' || \ - echo 'WARNING: Could not produce the `freeze`. + echo 'WARNING: Could not produce the `freeze`.' # 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really, # but can depend on `base`. diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index e35783cd86..3be243fcec 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -107,7 +107,7 @@ jobs: echo '' && \ cat 'cabal.project.freeze' && \ echo '' || \ - echo 'WARNING: Could not produce the `freeze`. + echo 'WARNING: Could not produce the `freeze`.' - name: Hackage sources cache uses: actions/cache@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d52f515ea..f26a337e8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -155,7 +155,7 @@ jobs: echo '' && \ cat 'cabal.project.freeze' && \ echo '' || \ - echo 'WARNING: Could not produce the `freeze`. + echo 'WARNING: Could not produce the `freeze`.' - name: Hackage sources cache uses: actions/cache@v2 From 9b199edcadabdff645acc978af54e2634b03112f Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Tue, 28 Dec 2021 17:49:42 +0200 Subject: [PATCH 07/10] hls-graph: Internal.Types: fx TVar import --- hls-graph/src/Development/IDE/Graph/Internal/Types.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs index f35b4bb939..6f75b1a809 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs @@ -17,6 +17,8 @@ import Control.Monad.Catch #if __GLASGOW_HASKELL__ < 870 -- Needed in GHC 8.6.5 import Control.Concurrent.STM.Stats (TVar, atomically) +#else +import GHC.Conc (TVar, atomically) #endif #if __GLASGOW_HASKELL__ < 880 import Prelude hiding (MonadFail) From 3f0a641304623b6bd91c9c43051cc3af2a01886f Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Wed, 29 Dec 2021 02:01:27 +0200 Subject: [PATCH 08/10] CI: {caching, test, bench, flags}: ('' -> "") Tripped-over the syntax highlighting & the DHall work (which uses `''` for QuasiQuoting stuff) --- .github/workflows/bench.yml | 6 +++--- .github/workflows/caching.yml | 6 +++--- .github/workflows/flags.yml | 6 +++--- .github/workflows/test.yml | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 2f652d826d..eb58e31b24 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -89,11 +89,11 @@ jobs: continue-on-error: true run: | cabal v2-freeze && \ - echo '' && \ + echo "" && \ echo 'Output:' && \ - echo '' && \ + echo "" && \ cat 'cabal.project.freeze' && \ - echo '' || \ + echo "" || \ echo 'WARNING: Could not produce the `freeze`.' - name: Hackage sources cache diff --git a/.github/workflows/caching.yml b/.github/workflows/caching.yml index 718c14246f..34812b6544 100644 --- a/.github/workflows/caching.yml +++ b/.github/workflows/caching.yml @@ -146,11 +146,11 @@ jobs: continue-on-error: true run: | cabal v2-freeze && \ - echo '' && \ + echo "" && \ echo 'Output:' && \ - echo '' && \ + echo "" && \ cat 'cabal.project.freeze' && \ - echo '' || \ + echo "" || \ echo 'WARNING: Could not produce the `freeze`.' # 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really, diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index 3be243fcec..852fcddb75 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -102,11 +102,11 @@ jobs: continue-on-error: true run: | cabal v2-freeze && \ - echo '' && \ + echo "" && \ echo 'Output:' && \ - echo '' && \ + echo "" && \ cat 'cabal.project.freeze' && \ - echo '' || \ + echo "" || \ echo 'WARNING: Could not produce the `freeze`.' - name: Hackage sources cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f26a337e8f..03305dd6f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -150,11 +150,11 @@ jobs: continue-on-error: true run: | cabal v2-freeze && \ - echo '' && \ + echo "" && \ echo 'Output:' && \ - echo '' && \ + echo "" && \ cat 'cabal.project.freeze' && \ - echo '' || \ + echo "" || \ echo 'WARNING: Could not produce the `freeze`.' - name: Hackage sources cache From dc5c389cf8fb1e364203ceeaa399a738a99b8d4f Mon Sep 17 00:00:00 2001 From: Anton Latukha Date: Thu, 30 Dec 2021 00:24:44 +0200 Subject: [PATCH 09/10] Apply suggestions from code review Co-authored-by: Javier Neira --- .github/workflows/flags.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index 852fcddb75..8cb859df5b 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -131,25 +131,20 @@ jobs: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}- ${{ env.cache-name }}-${{ runner.os }}- - - if: needs.pre_job.outputs.should_skip != 'true' - name: Build `hls-graph` with flags + - name: Build `hls-graph` with flags run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats" - - if: needs.pre_job.outputs.should_skip != 'true' - name: Build `hie-compat` with flags + - name: Build `hie-compat` with flags run: cabal v2-build hie-compat --flags="ghc-lib" - - if: needs.pre_job.outputs.should_skip != 'true' - name: Build `hls-plugin-api` with flags + - name: Build `hls-plugin-api` with flags run: cabal v2-build hls-plugin-api --flags="pedantic" - - if: needs.pre_job.outputs.should_skip != 'true' - name: Build `hls-test-utils` with flags + - name: Build `hls-test-utils` with flags run: cabal v2-build hls-test-utils --flags="pedantic" # repeating builds to workaround segfaults in windows and ghc-8.8.4 - - if: needs.pre_job.outputs.should_skip_ghcide != 'true' - name: Build + - name: Build run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" || cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" || cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" flags_post_job: From 219e511c712c4070a9e8e7331d6ebea935aed175 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Thu, 30 Dec 2021 00:28:31 +0200 Subject: [PATCH 10/10] CI: flags: post-review fxs --- .github/workflows/flags.yml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index 8cb859df5b..3fe0ac69d2 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -19,7 +19,6 @@ jobs: runs-on: ubuntu-latest outputs: should_skip: ${{ steps.skip_check.outputs.should_skip }} - should_skip_ghcide: ${{ steps.skip_ghcide_check.outputs.should_skip }} steps: - id: skip_check uses: fkirc/skip-duplicate-actions@v3.4.1 @@ -36,18 +35,6 @@ jobs: , ".circleci/**" , "**/stack*.yaml" ]' - # If we only change ghcide downstream packages we have not test ghcide itself - - id: skip_ghcide_check - uses: fkirc/skip-duplicate-actions@v3.4.1 - with: - cancel_others: false - paths_ignore: '[ "hls-test-utils/**" - , "plugins/**" - , "src/**" - , "exe/**" - , "test/**" - , "shake-bench/**" - ]' flags: if: needs.pre_job.outputs.should_skip != 'true' @@ -131,6 +118,10 @@ jobs: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}- ${{ env.cache-name }}-${{ runner.os }}- + # To ensure we get the lastest hackage index and not relying on haskell action logic + - if: steps.compiled-deps.outputs.cache-hit != 'true' + run: cabal update + - name: Build `hls-graph` with flags run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats" @@ -143,9 +134,8 @@ jobs: - name: Build `hls-test-utils` with flags run: cabal v2-build hls-test-utils --flags="pedantic" - # repeating builds to workaround segfaults in windows and ghc-8.8.4 - name: Build - run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" || cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" || cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" + run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" flags_post_job: if: always()