Skip to content

Commit 52118df

Browse files
committed
CI: add workflow to cache build dependencies
1 parent 18633c7 commit 52118df

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

.github/workflows/cache-deps.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Caching of dependencies
2+
3+
# 2021-11-30: NOTE: This workflow currently a trimmed copy of a main `test.yml` workflow. Workflows need further deduplication: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#overview
4+
5+
defaults:
6+
run:
7+
shell: bash
8+
9+
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
10+
concurrency:
11+
group: ${{ github.head_ref }}-${{ github.workflow }}
12+
cancel-in-progress: true
13+
14+
on:
15+
push:
16+
branches:
17+
- master
18+
schedule:
19+
# Try to save snapshot every day at 03:45 UTC (~21:45 in California)
20+
- cron: "45 3 * * *"
21+
22+
jobs:
23+
pre_job:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
27+
should_skip_ghcide: ${{ steps.skip_ghcide_check.outputs.should_skip }}
28+
steps:
29+
- id: skip_check
30+
uses: fkirc/skip-duplicate-actions@v3.4.1
31+
with:
32+
cancel_others: false
33+
paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", "install/**", "**.nix", "flake.lock", "**/README.md", "FUNDING.yml", ".circleci/**"]'
34+
# If we only change ghcide downstream packages we have not test ghcide itself
35+
- id: skip_ghcide_check
36+
uses: fkirc/skip-duplicate-actions@v3.4.1
37+
with:
38+
cancel_others: false
39+
paths_ignore: '["hls-test-utils/**", "plugins/**", "src/**", "exe/**", "test/**", "shake-bench/**"]'
40+
41+
deps:
42+
if: needs.pre_job.outputs.should_skip != 'true'
43+
needs: pre_job
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: true
47+
matrix:
48+
ghc: ["9.0.1", '8.10.7', '8.10.6', "8.10.5", "8.8.4", "8.8.3", "8.6.5"]
49+
os: [ubuntu-latest, macOS-latest]
50+
include:
51+
# only test supported ghc major versions
52+
- os: ubuntu-latest
53+
ghc: '9.0.1'
54+
test: true
55+
- os: ubuntu-latest
56+
ghc: '8.10.7'
57+
test: true
58+
- os: ubuntu-latest
59+
ghc: '8.8.4'
60+
test: true
61+
- os: ubuntu-latest
62+
ghc: '8.6.5'
63+
test: true
64+
- os: windows-latest
65+
ghc: '9.0.1'
66+
test: true
67+
- os: windows-latest
68+
ghc: '8.10.7'
69+
test: true
70+
- os: windows-latest
71+
ghc: '8.6.5'
72+
test: true
73+
# only build rest of supported ghc versions for windows
74+
- os: windows-latest
75+
ghc: '8.10.6'
76+
- os: windows-latest
77+
ghc: '8.10.5'
78+
- os: windows-latest
79+
ghc: '8.8.4'
80+
81+
steps:
82+
- uses: actions/checkout@v2
83+
with:
84+
submodules: true
85+
- uses: haskell/actions/setup@v1
86+
with:
87+
ghc-version: ${{ matrix.ghc }}
88+
cabal-version: "3.4"
89+
90+
- if: matrix.os == 'windows-latest'
91+
name: Set some window specific things
92+
run: |
93+
echo "CABAL_STORE_DIR=$SYSTEMDRIVE\\SR" >> $GITHUB_ENV
94+
echo "CABAL_PKGS_DIR=~\\AppData\\cabal\\packages" >> $GITHUB_ENV
95+
96+
- if: matrix.os != 'windows-latest'
97+
name: Set some linux/macOS specific things
98+
run: |
99+
echo "CABAL_STORE_DIR=~/.cabal/store" >> $GITHUB_ENV
100+
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
101+
102+
- if: matrix.os == 'macOS-latest' && matrix.ghc == '8.10.5'
103+
name: Workaround for GHC 8.10.5 on macOS
104+
run: |
105+
echo "# uninstalling CommandLineTools (see https://github.com/haskell/haskell-language-server/issues/1913#issuecomment-861667786)"
106+
sudo rm -rf /Library/Developer/CommandLineTools
107+
108+
# Needs to be before Cache Cabal so the cache can detect changes to the modified cabal.project file
109+
- if: matrix.ghc == '9.0.1'
110+
name: Use modified cabal.project for ghc9
111+
run: cp cabal-ghc901.project cabal.project
112+
113+
- if: matrix.ghc == '8.8.4' && matrix.os == 'windows-latest'
114+
name: Modify cabal.project to workaround segfaults for ghc-8.8.4 and windows
115+
run: |
116+
echo "package floskell" >> cabal.project
117+
echo " ghc-options: -O0" >> cabal.project
118+
119+
- name: Cache Cabal
120+
uses: actions/cache@v2
121+
env:
122+
cache-name: cache-cabal
123+
with:
124+
path: |
125+
${{ env.CABAL_PKGS_DIR }}
126+
${{ env.CABAL_STORE_DIR }}
127+
key: v2-${{ runner.os }}-${{ matrix.ghc }}-build-${{ hashFiles('cabal.project') }}
128+
restore-keys: |
129+
v2-${{ runner.os }}-${{ matrix.ghc }}-bench-${{ hashFiles('cabal.project') }}
130+
v2-${{ runner.os }}-${{ matrix.ghc }}-build-
131+
v2-${{ runner.os }}-${{ matrix.ghc }}
132+
133+
- run: cabal update
134+
135+
# Need this to work around filepath length limits in Windows
136+
- name: Shorten binary names
137+
run: |
138+
sed -i.bak -e 's/haskell-language-server/hls/g' \
139+
-e 's/haskell_language_server/hls/g' \
140+
haskell-language-server.cabal cabal.project
141+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
142+
src/**/*.hs exe/*.hs
143+
144+
# repeating builds to workaround segfaults in windows and ghc-8.8.4
145+
- name: Build
146+
run: cabal build --only-dependencies || cabal build --only-dependencies || cabal build --only-dependencies

0 commit comments

Comments
 (0)