Skip to content

Commit 46dfbd1

Browse files
pepeiborraAnton-Latukhajneira
authored
Restore TemplateHaskell pragma in hls-graph (#2549)
* restore TemplateHaskell pragma not 9.2 specific, but required for file_embed flag * CI: add flags workflow * hls-graph: STM.Stats: fx stm-stats build * hls-graph: Internal.Types: mk 8.6.5 code as such * hls-graph: Internal.Types: treat MonadFail * CI: {caching, test, bench, flags}: fx freeze phase * hls-graph: Internal.Types: fx TVar import * CI: {caching, test, bench, flags}: ('' -> "") Tripped-over the syntax highlighting & the DHall work (which uses `''` for QuasiQuoting stuff) * Apply suggestions from code review Co-authored-by: Javier Neira <atreyu.bbb@gmail.com> * CI: flags: post-review fxs Co-authored-by: Anton-Latukha <anton.latukha@gmail.com> Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
1 parent 2eaa2a4 commit 46dfbd1

File tree

7 files changed

+168
-7
lines changed

7 files changed

+168
-7
lines changed

.github/workflows/bench.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ jobs:
8989
id: compute-cache-key
9090
run: |
9191
cabal v2-freeze && \
92-
echo '' && \
92+
echo "" && \
9393
echo 'Output:' && \
94-
echo '' && \
94+
echo "" && \
9595
cat 'cabal.project.freeze' && \
9696
echo '' || \
9797
echo 'WARNING: Could not produce the `freeze`.'

.github/workflows/caching.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ jobs:
146146
id: compute-cache-key
147147
run: |
148148
cabal v2-freeze && \
149-
echo '' && \
149+
echo "" && \
150150
echo 'Output:' && \
151-
echo '' && \
151+
echo "" && \
152152
cat 'cabal.project.freeze' && \
153153
echo '' || \
154154
echo 'WARNING: Could not produce the `freeze`.'

.github/workflows/flags.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Flags
2+
3+
defaults:
4+
run:
5+
shell: bash
6+
7+
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
8+
concurrency:
9+
group: ${{ github.head_ref }}-${{ github.workflow }}
10+
cancel-in-progress: true
11+
12+
on:
13+
pull_request:
14+
branches:
15+
- '**'
16+
17+
jobs:
18+
pre_job:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
22+
steps:
23+
- id: skip_check
24+
uses: fkirc/skip-duplicate-actions@v3.4.1
25+
with:
26+
cancel_others: false
27+
paths_ignore: '[ "**/docs/**"
28+
, "**.md"
29+
, "**/LICENSE"
30+
, "install/**"
31+
, "**.nix"
32+
, "flake.lock"
33+
, "**/README.md"
34+
, "FUNDING.yml"
35+
, ".circleci/**"
36+
, "**/stack*.yaml"
37+
]'
38+
39+
flags:
40+
if: needs.pre_job.outputs.should_skip != 'true'
41+
needs: pre_job
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
fail-fast: true
45+
matrix:
46+
ghc: [ "8.10.7"
47+
]
48+
os: [ "ubuntu-latest"
49+
]
50+
cabal: ['3.6']
51+
52+
steps:
53+
- uses: actions/checkout@v2
54+
55+
- uses: haskell/actions/setup@v1
56+
id: HaskEnvSetup
57+
with:
58+
ghc-version : ${{ matrix.ghc }}
59+
cabal-version: ${{ matrix.cabal }}
60+
enable-stack: false
61+
62+
- if: runner.os == 'Windows'
63+
name: (Windows) Platform config
64+
run: |
65+
echo "CABAL_PKGS_DIR=C:\\cabal\\packages" >> $GITHUB_ENV
66+
- if: ( runner.os == 'Linux' ) || ( runner.os == 'macOS' )
67+
name: (Linux,macOS) Platform config
68+
run: |
69+
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
70+
71+
# All workflows which distinquishes cache on `cabal.project` needs this.
72+
- name: Workaround shorten binary names
73+
run: |
74+
sed -i.bak -e 's/haskell-language-server/hls/g' \
75+
-e 's/haskell_language_server/hls/g' \
76+
haskell-language-server.cabal cabal.project
77+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
78+
src/**/*.hs exe/*.hs
79+
80+
- name: Retrieving `cabal.project` Hackage timestamp
81+
run: |
82+
# Form: index-state: 2021-11-29T08:11:08Z
83+
INDEX_STATE_ENTRY=$(grep index-state cabal.project)
84+
# Form: 2021-11-29T08-11-08Z
85+
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
86+
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
87+
88+
- name: Form the package list ('cabal.project.freeze')
89+
continue-on-error: true
90+
run: |
91+
cabal v2-freeze && \
92+
echo "" && \
93+
echo 'Output:' && \
94+
echo "" && \
95+
cat 'cabal.project.freeze' && \
96+
echo "" || \
97+
echo 'WARNING: Could not produce the `freeze`.'
98+
99+
- name: Hackage sources cache
100+
uses: actions/cache@v2
101+
env:
102+
cache-name: hackage-sources
103+
with:
104+
path: ${{ env.CABAL_PKGS_DIR }}
105+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
106+
restore-keys: ${{ env.cache-name }}-
107+
108+
- name: Compiled deps cache
109+
id: compiled-deps
110+
uses: actions/cache@v2
111+
env:
112+
cache-name: compiled-deps
113+
with:
114+
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
115+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
116+
restore-keys: |
117+
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
118+
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
119+
${{ env.cache-name }}-${{ runner.os }}-
120+
121+
# To ensure we get the lastest hackage index and not relying on haskell action logic
122+
- if: steps.compiled-deps.outputs.cache-hit != 'true'
123+
run: cabal update
124+
125+
- name: Build `hls-graph` with flags
126+
run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats"
127+
128+
- name: Build `hie-compat` with flags
129+
run: cabal v2-build hie-compat --flags="ghc-lib"
130+
131+
- name: Build `hls-plugin-api` with flags
132+
run: cabal v2-build hls-plugin-api --flags="pedantic"
133+
134+
- name: Build `hls-test-utils` with flags
135+
run: cabal v2-build hls-test-utils --flags="pedantic"
136+
137+
- name: Build
138+
run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe"
139+
140+
flags_post_job:
141+
if: always()
142+
runs-on: ubuntu-latest
143+
needs: [pre_job, flags]
144+
steps:
145+
- run: |
146+
echo "jobs info: ${{ toJSON(needs) }}"
147+
- if: contains(needs.*.result, 'failure')
148+
run: exit 1
149+
- if: contains(needs.*.result, 'cancelled') && needs.pre_job.outputs.should_skip != 'true'
150+
run: exit 1

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ jobs:
150150
id: compute-cache-key
151151
run: |
152152
cabal v2-freeze && \
153-
echo '' && \
153+
echo "" && \
154154
echo 'Output:' && \
155-
echo '' && \
155+
echo "" && \
156156
cat 'cabal.project.freeze' && \
157157
echo '' || \
158158
echo 'WARNING: Could not produce the `freeze`.'

hls-graph/src/Control/Concurrent/STM/Stats.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE ScopedTypeVariables #-}
3+
#ifdef STM_STATS
4+
{-# LANGUAGE RecordWildCards #-}
5+
#endif
36
module Control.Concurrent.STM.Stats
47
( atomicallyNamed
58
, atomically
@@ -180,4 +183,3 @@ dumpSTMStats = do
180183

181184

182185
#endif
183-

hls-graph/src/Development/IDE/Graph/Internal/Profile.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE RecordWildCards #-}
3+
{-# LANGUAGE TemplateHaskell #-}
34
{-# LANGUAGE ViewPatterns #-}
45

56
{- HLINT ignore "Redundant bracket" -} -- a result of CPP expansion

hls-graph/src/Development/IDE/Graph/Internal/Types.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@
88
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
99
{-# LANGUAGE RecordWildCards #-}
1010
{-# LANGUAGE ScopedTypeVariables #-}
11+
{-# LANGUAGE CPP #-}
1112

1213
module Development.IDE.Graph.Internal.Types where
1314

1415
import Control.Applicative
1516
import Control.Monad.Catch
17+
#if __GLASGOW_HASKELL__ < 870
1618
-- Needed in GHC 8.6.5
1719
import Control.Concurrent.STM.Stats (TVar, atomically)
20+
#else
21+
import GHC.Conc (TVar, atomically)
22+
#endif
23+
#if __GLASGOW_HASKELL__ < 880
24+
import Prelude hiding (MonadFail)
1825
import Control.Monad.Fail
26+
#endif
1927
import Control.Monad.IO.Class
2028
import Control.Monad.Trans.Reader
2129
import Data.Aeson (FromJSON, ToJSON)

0 commit comments

Comments
 (0)