Skip to content

Commit ec1cc78

Browse files
authored
Merge branch 'haskell:master' into master
2 parents 1663636 + 47f29da commit ec1cc78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+759
-486
lines changed

.circleci/config.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ defaults: &defaults
66
steps:
77
- checkout
88
- run:
9-
name: Write provided stack.yaml with predictable name
10-
command: cp ${STACK_FILE} stack-build.txt
11-
12-
- run:
13-
name: Figure out resolver for better caching
14-
command: grep '^resolver:' stack-build.txt > resolver.txt
9+
name: Save resolver field into file
10+
command: grep '^resolver:' ${STACK_FILE} > resolver.txt
1511

1612
- restore_cache:
1713
keys:

.github/workflows/bench.yml

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Benchmark
22

3+
defaults:
4+
run:
5+
shell: bash
6+
37
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
48
concurrency:
59
group: ${{ github.head_ref }}-${{ github.workflow }}
@@ -34,28 +38,62 @@ jobs:
3438
os: [ubuntu-latest]
3539
cabal: ['3.6']
3640

41+
# This code is fitted to the strategy: assumes Linux is used ... etc,
42+
# change of the strategy may require changing the bootstrapping/run code
43+
3744
steps:
3845
- uses: actions/checkout@v2
3946

4047
- run: git fetch origin master # check the master branch for benchmarking
4148

4249
- uses: haskell/actions/setup@v1
50+
id: HaskEnvSetup
4351
with:
4452
ghc-version : ${{ matrix.ghc }}
4553
cabal-version: ${{ matrix.cabal }}
4654
enable-stack: false
4755

48-
- name: Cache Cabal
56+
- name: Linux Platform config
57+
run: |
58+
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
59+
60+
# All workflows which distinquishes cache on `cabal.project` needs this.
61+
- name: Workaround shorten binary names
62+
run: |
63+
sed -i.bak -e 's/haskell-language-server/hls/g' \
64+
-e 's/haskell_language_server/hls/g' \
65+
haskell-language-server.cabal cabal.project
66+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
67+
src/**/*.hs exe/*.hs
68+
69+
- name: Retrieving `cabal.project` Hackage timestamp
70+
run: |
71+
# Form: index-state: 2021-11-29T08:11:08Z
72+
INDEX_STATE_ENTRY=$(grep index-state cabal.project)
73+
# Form: 2021-11-29T08-11-08Z
74+
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
75+
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
76+
77+
- name: Hackage sources cache
4978
uses: actions/cache@v2
79+
env:
80+
cache-name: hackage-sources
5081
with:
51-
path: |
52-
~/.cabal/packages
53-
~/.cabal/store
54-
key: v2-${{ runner.os }}-${{ matrix.ghc }}-bench-${{ hashFiles('cabal.project') }}
82+
path: ${{ env.CABAL_PKGS_DIR }}
83+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
84+
restore-keys: ${{ env.cache-name }}-
85+
86+
- name: Compiled deps cache
87+
uses: actions/cache@v2
88+
env:
89+
cache-name: compiled-deps
90+
with:
91+
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
92+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project') }}
5593
restore-keys: |
56-
v2-${{ runner.os }}-${{ matrix.ghc }}-build-${{ hashFiles('cabal.project') }}
57-
v2-${{ runner.os }}-${{ matrix.ghc }}-bench-
58-
v2-${{ runner.os }}-${{ matrix.ghc }}
94+
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
95+
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
96+
${{ env.cache-name }}-${{ runner.os }}-
5997
6098
- run: cabal update
6199

@@ -64,17 +102,14 @@ jobs:
64102
- run: cabal configure --enable-benchmarks --max-backjumps 12000
65103

66104
- name: Build
67-
shell: bash
68105
run: cabal build ghcide:benchHist
69106

70107
- name: Bench init
71-
shell: bash
72108
run: cabal bench ghcide:benchHist -j --benchmark-options="all-binaries"
73109

74110
# tar is required to preserve file permissions
75111
# compression speeds up upload/download nicely
76112
- name: tar workspace
77-
shell: bash
78113
run: tar -czf workspace.tar.gz * .git
79114

80115
- name: tar cabal
@@ -105,6 +140,7 @@ jobs:
105140
matrix:
106141
ghc: ['8.10.7']
107142
os: [ubuntu-latest]
143+
cabal: ['3.6']
108144
example: ['cabal', 'lsp-types']
109145

110146
steps:
@@ -133,11 +169,9 @@ jobs:
133169
tar xzf cabal.tar.gz --directory ~/.cabal
134170
135171
- name: Bench
136-
shell: bash
137172
run: cabal bench ghcide:benchHist -j --benchmark-options="${{ matrix.example }}"
138173

139174
- name: Display results
140-
shell: bash
141175
run: |
142176
column -s, -t < ghcide/bench-results/unprofiled/${{ matrix.example }}/results.csv | tee ghcide/bench-results/unprofiled/${{ matrix.example }}/results.txt
143177

.github/workflows/build.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Builds
22

3-
defaults:
4-
run:
5-
shell: bash
6-
73
on:
84
release:
95
types: [created]
@@ -14,7 +10,10 @@ on:
1410
jobs:
1511
build:
1612
runs-on: ${{ matrix.os }}
17-
13+
container: ${{ (matrix.os == 'ubuntu-18.04' && 'alpine:3.12') || '' }}
14+
defaults:
15+
run:
16+
shell: ${{ (matrix.os == 'windows-latest' && 'bash') || 'sh' }}
1817
strategy:
1918
fail-fast: false
2019
matrix:
@@ -23,13 +22,26 @@ jobs:
2322
cabal: ['3.6']
2423

2524
steps:
25+
- name: Install system dependencies
26+
if: matrix.os == 'ubuntu-18.04'
27+
run: |
28+
apk add --no-cache curl gcc g++ gmp-dev ncurses-dev libffi-dev make xz gzip tar perl git bash sudo binutils-gold
29+
apk add --no-cache zlib zlib-dev zlib-static gmp gmp-dev ncurses-static
2630
- uses: actions/checkout@v2
27-
with:
28-
submodules: true
31+
2932
- uses: haskell/actions/setup@v1
3033
with:
3134
ghc-version : ${{ matrix.ghc }}
3235
cabal-version: ${{ matrix.cabal }}
36+
enable-stack: false
37+
38+
# some alpines come with integer-simple instead of integer-gmp
39+
- name: Force integer-simple
40+
if: matrix.os == 'ubuntu-18.04'
41+
run: |
42+
if ghc --info | grep -q integer-simple ; then
43+
echo -e 'package blaze-textual\n flags: +integer-simple' >> cabal.project.local
44+
fi
3345
3446
- name: Use modified cabal.project for ghc9
3547
if: ${{ matrix.ghc == '9.0.1' }}
@@ -75,8 +87,8 @@ jobs:
7587
- name: Build server
7688
# Try building it twice in case of flakey builds on Windows
7789
run: |
78-
cabal build exe:hls -O2 $LINUX_CABAL_ARGS || \
79-
cabal build exe:hls -O2 $LINUX_CABAL_ARGS -j1
90+
cabal build --disable-tests exe:hls -O2 $LINUX_CABAL_ARGS || \
91+
cabal build --disable-tests exe:hls -O2 $LINUX_CABAL_ARGS -j1
8092
8193
- name: Compress server binary
8294
id: compress_server_binary
@@ -115,7 +127,7 @@ jobs:
115127

116128
- name: Build wrapper
117129
if: matrix.ghc == '8.10.7'
118-
run: cabal build exe:hls-wrapper -O2 $LINUX_CABAL_ARGS
130+
run: cabal build --disable-tests exe:hls-wrapper -O2 $LINUX_CABAL_ARGS
119131

120132
- name: Compress wrapper binary
121133
if: matrix.ghc == '8.10.7'
@@ -161,8 +173,6 @@ jobs:
161173

162174
steps:
163175
- uses: actions/checkout@v2
164-
with:
165-
submodules: true
166176

167177
- name: Create source tarball
168178
run: |

.github/workflows/caching.yml

Lines changed: 84 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
name: Caching
22

33
# Docs on the workflow:
4-
# 1. GitHub cache scoping goes: main branch -> PR main branch -> PR. (essentially in a tree fashion). That is why it is useful to build caches on `master` - to generate & keep the main project state & they would be shared to the whole tree.
5-
# 2. GitHub has a 10G default limit of cache pool per repo. HLS is a big project & monorepo of many projects, so to keep cache useful - the main branch state caches should be preserved & their storage preferred to the PRs, since PRs from internal branches - would count into 10G pool, but would be available only inside of the PR scope, which can bork cache fore the whole community. That is short story why `dist-newstyle` (especially full) - is not includded into `master` cache.
4+
# 1. GitHub cache scoping goes:
5+
# [main branch -> PR main branch -> PR. (essentially in a tree fashion)](https://web.archive.org/web/20211125171853/https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache).
6+
# Building & keeping caches on `master` allows
7+
# to share the main project state cache be shared to the whole tree.
8+
# 2. GitHub has a [default 10G cache pool limit](https://web.archive.org/web/20211125171853/https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy) per repo.
9+
# HLS is a big monorepo codebase, which means easy cache pool
10+
# invalidation & exhaustion because of the pool limit.
11+
# To keep caches useful - the main state of the main branch should remain
12+
# & so keep caching in the repo well below the limit.
13+
# that means preferring main branch to the PR caches
14+
# (especially internal branch ones), since PRs from internal branches -
15+
# count into the repo 10G pool, while that cache gets used only inside of the PR,
16+
# while exhausting the pool would bork cache for the rest of the community.
17+
# That is a short story why `dist-newstyle` (especially full) currently is not
18+
# includded into `master` or PR caches.
619

720
defaults:
821
run:
@@ -17,11 +30,12 @@ on:
1730
push:
1831
branches:
1932
- master
20-
schedule:
21-
# Try to save snapshot every day at 08:25 UTC (~00:25 in California)
22-
- cron: "25 8 * * *"
33+
34+
env:
35+
cabalBuild: "v2-build all --enable-tests --enable-benchmarks"
2336

2437
jobs:
38+
2539
pre_job:
2640
runs-on: ubuntu-latest
2741
outputs:
@@ -40,73 +54,105 @@ jobs:
4054
cancel_others: false
4155
paths_ignore: '["hls-test-utils/**", "plugins/**", "src/**", "exe/**", "test/**", "shake-bench/**"]'
4256

43-
deps:
57+
caching:
4458
if: needs.pre_job.outputs.should_skip != 'true'
4559
needs: pre_job
4660
runs-on: ${{ matrix.os }}
4761
strategy:
62+
fail-fast: false
4863
matrix:
4964
ghc: ["9.0.1", '8.10.7', '8.10.6', "8.8.4", "8.6.5"]
5065
os: [ubuntu-latest, macOS-latest, windows-latest]
5166
cabal: ['3.6']
5267

5368
steps:
5469
- uses: actions/checkout@v2
55-
with:
56-
submodules: true
70+
5771
- uses: haskell/actions/setup@v1
72+
id: HaskEnvSetup
5873
with:
5974
ghc-version : ${{ matrix.ghc }}
6075
cabal-version: ${{ matrix.cabal }}
76+
enable-stack: false
6177

62-
- if: matrix.os == 'windows-latest'
63-
name: Set some window specific things
78+
- if: runner.os == 'Windows'
79+
name: (Windows) Platform config
6480
run: |
65-
echo "CABAL_STORE_DIR=$SYSTEMDRIVE\\SR" >> $GITHUB_ENV
6681
echo "CABAL_PKGS_DIR=~\\AppData\\cabal\\packages" >> $GITHUB_ENV
67-
68-
- if: matrix.os != 'windows-latest'
69-
name: Set some linux/macOS specific things
82+
- if: ( runner.os == 'Linux' ) || ( runner.os == 'macOS' )
83+
name: (Linux,macOS) Platform config
7084
run: |
71-
echo "CABAL_STORE_DIR=~/.cabal/store" >> $GITHUB_ENV
7285
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
7386
7487
# Needs to be before Cache Cabal so the cache can detect changes to the modified cabal.project file
7588
- if: matrix.ghc == '9.0.1'
76-
name: Use modified cabal.project for ghc9
77-
run: cp cabal-ghc901.project cabal.project
78-
79-
- if: matrix.ghc == '8.8.4' && matrix.os == 'windows-latest'
80-
name: Modify cabal.project to workaround segfaults for ghc-8.8.4 and windows
89+
name: (GHC 9.0.1) Use modified `cabal.project`
90+
run: |
91+
cp cabal-ghc901.project cabal.project
92+
- if: runner.os == 'Windows' && matrix.ghc == '8.8.4'
93+
name: (Windows,GHC 8.8) Modify `cabal.project` to workaround segfaults
8194
run: |
8295
echo "package floskell" >> cabal.project
8396
echo " ghc-options: -O0" >> cabal.project
8497
85-
- name: Cache Cabal
98+
# Shorten binary names as a workaround for filepath length limits in Windows,
99+
# but since tests are hardcoded on this workaround -
100+
# all platforms (in 2021-12-07) need it.
101+
# All workflows which distinquishes cache on `cabal.project` needs this.
102+
- name: Workaround shorten binary names
103+
run: |
104+
sed -i.bak -e 's/haskell-language-server/hls/g' \
105+
-e 's/haskell_language_server/hls/g' \
106+
haskell-language-server.cabal cabal.project
107+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
108+
src/**/*.hs exe/*.hs
109+
110+
- name: Retrieving `cabal.project` Hackage timestamp
111+
run: |
112+
# Form: index-state: 2021-11-29T08:11:08Z
113+
INDEX_STATE_ENTRY=$(grep index-state cabal.project)
114+
# Form: 2021-11-29T08-11-08Z
115+
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
116+
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
117+
118+
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
119+
# but can depend on `base`.
120+
# But this caching is happens only inside `master` for `master` purposes of compiling the deps
121+
# so having a shared pool here that depends only on Hackage pin & does not depend on `base` is "good enough"
122+
# & used such because it preserves 10% of a global cache storage pool.
123+
- name: Hackage sources cache
124+
uses: actions/cache@v2
125+
env:
126+
cache-name: hackage-sources
127+
with:
128+
path: ${{ env.CABAL_PKGS_DIR }}
129+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
130+
restore-keys: ${{ env.cache-name }}-
131+
132+
- name: Compiled deps cache
86133
uses: actions/cache@v2
87134
env:
88-
cache-name: cache-cabal
135+
cache-name: compiled-deps
89136
with:
90-
path: |
91-
${{ env.CABAL_PKGS_DIR }}
92-
${{ env.CABAL_STORE_DIR }}
93-
key: v2-${{ runner.os }}-${{ matrix.ghc }}-build-${{ hashFiles('cabal.project') }}
137+
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
138+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project') }}
94139
restore-keys: |
95-
v2-${{ runner.os }}-${{ matrix.ghc }}-bench-${{ hashFiles('cabal.project') }}
96-
v2-${{ runner.os }}-${{ matrix.ghc }}-build-
97-
v2-${{ runner.os }}-${{ matrix.ghc }}
140+
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
141+
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
142+
${{ env.cache-name }}-${{ runner.os }}-
98143
99144
- run: cabal update
100145

101-
# Need this to work around filepath length limits in Windows
102-
- name: Shorten binary names
146+
- name: Download all sources
103147
run: |
104-
sed -i.bak -e 's/haskell-language-server/hls/g' \
105-
-e 's/haskell_language_server/hls/g' \
106-
haskell-language-server.cabal cabal.project
107-
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
108-
src/**/*.hs exe/*.hs
148+
cabal $cabalBuild --only-download
109149
110150
# repeating builds to workaround segfaults in windows and ghc-8.8.4
111-
- name: Build
112-
run: cabal build --only-dependencies || cabal build --only-dependencies || cabal build --only-dependencies
151+
# This build agenda in not to have successful code,
152+
# but to cache what can be cached, so step is fault tolerant & would always succseed.
153+
# 2021-12-11: NOTE: Building all targets, since
154+
# current Cabal does not allow `all --enable-tests --enable-benchmarks --only-dependencies`
155+
- name: Build all targets; try 3 times
156+
continue-on-error: true
157+
run: |
158+
cabal $cabalBuild || cabal $cabalBuild || cabal $cabalBuild

0 commit comments

Comments
 (0)