Skip to content

Commit 25fc2cc

Browse files
authored
Merge branch 'master' into feat/selection-range
2 parents beb94e8 + e622744 commit 25fc2cc

File tree

11 files changed

+255
-383
lines changed

11 files changed

+255
-383
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: "Cached build"
2+
description: "Setup the build using cache"
3+
inputs:
4+
ghc:
5+
description: "Ghc version"
6+
required: true
7+
cabal:
8+
description: "Cabal version"
9+
required: false
10+
default: "3.6"
11+
os:
12+
description: "Operating system: Linux, Windows or macOS"
13+
required: true
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: haskell/actions/setup@v1
18+
id: HaskEnvSetup
19+
with:
20+
ghc-version : ${{ inputs.ghc }}
21+
cabal-version: ${{ inputs.cabal }}
22+
enable-stack: false
23+
24+
- if: inputs.os == 'Windows'
25+
name: (Windows) Platform config
26+
run: |
27+
echo "CABAL_PKGS_DIR=C:\\cabal\\packages" >> $GITHUB_ENV
28+
shell: bash
29+
- if: ( inputs.os == 'Linux' ) || ( inputs.os == 'macOS' )
30+
name: (Linux,macOS) Platform config
31+
run: |
32+
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
33+
shell: bash
34+
35+
# This copy an alternative cabal-ghc${GHCVER}.project (for example cabal-ghc921.project)
36+
# as main cabal-project, for not fully supported ghc versions
37+
# Needs to be before the caching step so that the cache can detect changes to the modified cabal.project file
38+
- name: Use possible modified `cabal.project`
39+
env:
40+
GHCVER: ${{ inputs.ghc }}
41+
run: |
42+
# File has some protections preventing regular `rm`.
43+
# (most probably sticky bit is set on $HOME)
44+
# `&&` insures `rm -f` return is positive.
45+
# Many platforms aslo have `alias cp='cp -i'`.
46+
ALT_PROJECT_FILE=cabal-ghc${GHCVER//./}.project
47+
if [[ -f "$ALT_PROJECT_FILE" ]]; then
48+
rm -f -v cabal.project && cp -v "$ALT_PROJECT_FILE" cabal.project
49+
fi
50+
shell: bash
51+
52+
- if: inputs.os == 'Windows' && inputs.ghc == '8.8.4'
53+
name: (Windows,GHC 8.8) Modify `cabal.project` to workaround segfaults
54+
run: |
55+
echo "package floskell" >> cabal.project
56+
echo " ghc-options: -O0" >> cabal.project
57+
shell: bash
58+
59+
# Shorten binary names as a workaround for filepath length limits in Windows,
60+
# but since tests are hardcoded on this workaround -
61+
# all platforms (in 2021-12-07) need it.
62+
# All workflows which distinquishes cache on `cabal.project` needs this.
63+
- name: Workaround shorten binary names
64+
run: |
65+
sed -i.bak -e 's/haskell-language-server/hls/g' \
66+
-e 's/haskell_language_server/hls/g' \
67+
haskell-language-server.cabal cabal.project
68+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
69+
src/**/*.hs exe/*.hs
70+
shell: bash
71+
72+
- name: Retrieving `cabal.project` Hackage timestamp
73+
run: |
74+
# Form: index-state: 2021-11-29T08:11:08Z
75+
INDEX_STATE_ENTRY=$(grep index-state cabal.project)
76+
# Form: 2021-11-29T08-11-08Z
77+
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
78+
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
79+
shell: bash
80+
81+
# We have to restore package sources before `cabal update`
82+
# because it overwrites the hackage index with the cached one
83+
- name: Hackage sources cache
84+
uses: actions/cache@v2
85+
env:
86+
cache-name: hackage-sources
87+
with:
88+
path: ${{ env.CABAL_PKGS_DIR }}
89+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
90+
restore-keys: ${{ env.cache-name }}-
91+
92+
# To ensure we get the latest hackage index without relying on the haskell action logic
93+
# It has to be done before `cabal freeze` to make it aware of the new index
94+
- run: cabal update
95+
shell: bash
96+
97+
- name: Form the package list ('cabal.project.freeze')
98+
run: |
99+
cabal v2-freeze && \
100+
echo "" && \
101+
echo 'Output:' && \
102+
echo "" && \
103+
cat 'cabal.project.freeze'
104+
shell: bash
105+
106+
- name: Compiled deps cache
107+
id: compiled-deps
108+
uses: actions/cache@v2
109+
env:
110+
cache-name: compiled-deps
111+
with:
112+
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
113+
key: ${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
114+
restore-keys: |
115+
${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-
116+
${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-
117+
${{ env.cache-name }}-${{ inputs.os }}-
118+
119+
# We remove the freeze file because it could interfere with the build
120+
- name: "Remove freeze file"
121+
run: rm -f cabal.project.freeze
122+
shell: bash

.github/workflows/bench.yml

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747
matrix:
4848
ghc: ['8.10.7']
4949
os: [ubuntu-latest]
50-
cabal: ['3.6']
5150

5251
# This code is fitted to the strategy: assumes Linux is used ... etc,
5352
# change of the strategy may require changing the bootstrapping/run code
@@ -57,72 +56,10 @@ jobs:
5756

5857
- run: git fetch origin master # check the master branch for benchmarking
5958

60-
- uses: haskell/actions/setup@v1
61-
id: HaskEnvSetup
62-
with:
63-
ghc-version : ${{ matrix.ghc }}
64-
cabal-version: ${{ matrix.cabal }}
65-
enable-stack: false
66-
67-
- name: Linux 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-
id: compute-cache-key
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-
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
99-
# Removing freeze file as it can break builds using allow-newer
100-
rm -f cabal.project.freeze
101-
102-
- name: Hackage sources cache
103-
uses: actions/cache@v2
104-
env:
105-
cache-name: hackage-sources
106-
with:
107-
path: ${{ env.CABAL_PKGS_DIR }}
108-
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
109-
restore-keys: ${{ env.cache-name }}-
110-
111-
- name: Compiled deps cache
112-
id: compiled-deps
113-
uses: actions/cache@v2
114-
env:
115-
cache-name: compiled-deps
59+
- uses: ./.github/actions/setup-build
11660
with:
117-
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
118-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
119-
restore-keys: |
120-
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
121-
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
122-
${{ env.cache-name }}-${{ runner.os }}-
123-
124-
# To ensure we get the lastest hackage index and not relying on haskell action logic
125-
- run: cabal update
61+
ghc: ${{ matrix.ghc }}
62+
os: ${{ runner.os }}
12663

12764
# max-backjumps is increased as a temporary solution
12865
# for dependency resolution failure

.github/workflows/caching.yml

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -86,106 +86,14 @@ jobs:
8686
, "macOS-latest"
8787
, "windows-latest"
8888
]
89-
cabal: ['3.6']
9089

9190
steps:
9291
- uses: actions/checkout@v2
9392

94-
- uses: haskell/actions/setup@v1
95-
id: HaskEnvSetup
93+
- uses: ./.github/actions/setup-build
9694
with:
97-
ghc-version : ${{ matrix.ghc }}
98-
cabal-version: ${{ matrix.cabal }}
99-
enable-stack: false
100-
101-
- if: runner.os == 'Windows'
102-
name: (Windows) Platform config
103-
run: |
104-
echo "CABAL_PKGS_DIR=C:\\cabal\\packages" >> $GITHUB_ENV
105-
- if: ( runner.os == 'Linux' ) || ( runner.os == 'macOS' )
106-
name: (Linux,macOS) Platform config
107-
run: |
108-
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
109-
110-
# Needs to be before Cache Cabal so the cache can detect changes to the modified cabal.project file
111-
- if: matrix.ghc == '9.0.1'
112-
name: (GHC 9.0.1) Use modified `cabal.project`
113-
run: |
114-
# File has some protections preventing regular `rm`.
115-
# (most probably sticky bit is set on $HOME)
116-
# `&&` insures `rm -f` return is positive.
117-
# Many platforms also have `alias cp='cp -i'`.
118-
rm -f -v cabal.project && cp -v cabal-ghc901.project cabal.project
119-
- if: runner.os == 'Windows' && matrix.ghc == '8.8.4'
120-
name: (Windows,GHC 8.8) Modify `cabal.project` to workaround segfaults
121-
run: |
122-
echo "package floskell" >> cabal.project
123-
echo " ghc-options: -O0" >> cabal.project
124-
125-
# Shorten binary names as a workaround for filepath length limits in Windows,
126-
# but since tests are hardcoded on this workaround -
127-
# all platforms (in 2021-12-07) need it.
128-
# All workflows which distinquishes cache on `cabal.project` needs this.
129-
- name: Workaround shorten binary names
130-
run: |
131-
sed -i.bak -e 's/haskell-language-server/hls/g' \
132-
-e 's/haskell_language_server/hls/g' \
133-
haskell-language-server.cabal cabal.project
134-
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
135-
src/**/*.hs exe/*.hs
136-
137-
- name: Retrieving `cabal.project` Hackage timestamp
138-
run: |
139-
# Form: index-state: 2021-11-29T08:11:08Z
140-
INDEX_STATE_ENTRY=$(grep index-state cabal.project)
141-
# Form: 2021-11-29T08-11-08Z
142-
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
143-
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
144-
145-
- name: Form the package list ('cabal.project.freeze')
146-
id: compute-cache-key
147-
run: |
148-
cabal v2-freeze && \
149-
echo "" && \
150-
echo 'Output:' && \
151-
echo "" && \
152-
cat 'cabal.project.freeze' && \
153-
echo '' || \
154-
echo 'WARNING: Could not produce the `freeze`.'
155-
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
156-
# Removing freeze file as it can break builds using allow-newer
157-
rm -f cabal.project.freeze
158-
159-
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
160-
# but can depend on `base`.
161-
# But this caching is happens only inside `master` for `master` purposes of compiling the deps
162-
# so having a shared pool here that depends only on Hackage pin & does not depend on `base` is "good enough"
163-
# & used such because it preserves 10% of a global cache storage pool.
164-
- name: Hackage sources cache
165-
uses: actions/cache@v2
166-
env:
167-
cache-name: hackage-sources
168-
with:
169-
path: ${{ env.CABAL_PKGS_DIR }}
170-
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
171-
restore-keys: ${{ env.cache-name }}-
172-
173-
- name: Compiled deps cache
174-
id: compiled-deps
175-
uses: actions/cache@v2
176-
env:
177-
cache-name: compiled-deps
178-
with:
179-
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
180-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
181-
restore-keys: |
182-
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
183-
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
184-
${{ env.cache-name }}-${{ runner.os }}-
185-
186-
# To ensure we get the lastest hackage index and not relying on haskell action logic
187-
- if: steps.compiled-deps.outputs.cache-hit != 'true'
188-
run: cabal update
95+
ghc: ${{ matrix.ghc }}
96+
os: ${{ runner.os }}
18997

19098
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '8.10.7'
19199
name: Download sources for bench

0 commit comments

Comments
 (0)