diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 01821c8444..cf248d8664 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -89,9 +89,9 @@ jobs: id: compute-cache-key run: | cabal v2-freeze && \ - echo '' && \ + echo "" && \ echo 'Output:' && \ - echo '' && \ + echo "" && \ cat 'cabal.project.freeze' && \ echo '' || \ echo 'WARNING: Could not produce the `freeze`.' diff --git a/.github/workflows/caching.yml b/.github/workflows/caching.yml index 34ff476a71..61c05d8936 100644 --- a/.github/workflows/caching.yml +++ b/.github/workflows/caching.yml @@ -146,9 +146,9 @@ jobs: id: compute-cache-key run: | cabal v2-freeze && \ - echo '' && \ + echo "" && \ echo 'Output:' && \ - echo '' && \ + echo "" && \ cat 'cabal.project.freeze' && \ echo '' || \ echo 'WARNING: Could not produce the `freeze`.' diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml new file mode 100644 index 0000000000..3fe0ac69d2 --- /dev/null +++ b/.github/workflows/flags.yml @@ -0,0 +1,150 @@ +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 }} + 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" + ]' + + 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 }}- + + # 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" + + - name: Build `hie-compat` with flags + run: cabal v2-build hie-compat --flags="ghc-lib" + + - name: Build `hls-plugin-api` with flags + run: cabal v2-build hls-plugin-api --flags="pedantic" + + - name: Build `hls-test-utils` with flags + run: cabal v2-build hls-test-utils --flags="pedantic" + + - name: Build + run: 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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bde2e92a50..9430e72156 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -150,9 +150,9 @@ jobs: id: compute-cache-key run: | cabal v2-freeze && \ - echo '' && \ + echo "" && \ echo 'Output:' && \ - echo '' && \ + echo "" && \ cat 'cabal.project.freeze' && \ echo '' || \ echo 'WARNING: Could not produce the `freeze`.' 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 - 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 diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs index 13c4359f2b..6f75b1a809 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs @@ -8,14 +8,22 @@ {-# 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) +#else +import GHC.Conc (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)