Skip to content

Commit 9a1aba2

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

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

.github/workflows/cache-deps.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
matrix:
46+
ghc: ["9.0.1", '8.10.7', '8.10.6', "8.10.5", "8.8.4", "8.8.3", "8.6.5"]
47+
os: [ubuntu-latest, macOS-latest]
48+
include:
49+
# only test supported ghc major versions
50+
- os: ubuntu-latest
51+
ghc: '9.0.1'
52+
- os: ubuntu-latest
53+
ghc: '8.10.7'
54+
- os: ubuntu-latest
55+
ghc: '8.8.4'
56+
- os: ubuntu-latest
57+
ghc: '8.6.5'
58+
- os: windows-latest
59+
ghc: '9.0.1'
60+
- os: windows-latest
61+
ghc: '8.10.7'
62+
- os: windows-latest
63+
ghc: '8.6.5'
64+
# only build rest of supported ghc versions for windows
65+
- os: windows-latest
66+
ghc: '8.10.6'
67+
- os: windows-latest
68+
ghc: '8.10.5'
69+
- os: windows-latest
70+
ghc: '8.8.4'
71+
72+
steps:
73+
- uses: actions/checkout@v2
74+
with:
75+
submodules: true
76+
- uses: haskell/actions/setup@v1
77+
with:
78+
ghc-version: ${{ matrix.ghc }}
79+
cabal-version: "3.4"
80+
81+
- if: matrix.os == 'windows-latest'
82+
name: Set some window specific things
83+
run: |
84+
echo "CABAL_STORE_DIR=$SYSTEMDRIVE\\SR" >> $GITHUB_ENV
85+
echo "CABAL_PKGS_DIR=~\\AppData\\cabal\\packages" >> $GITHUB_ENV
86+
87+
- if: matrix.os != 'windows-latest'
88+
name: Set some linux/macOS specific things
89+
run: |
90+
echo "CABAL_STORE_DIR=~/.cabal/store" >> $GITHUB_ENV
91+
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
92+
93+
- if: matrix.os == 'macOS-latest' && matrix.ghc == '8.10.5'
94+
name: Workaround for GHC 8.10.5 on macOS
95+
run: |
96+
echo "# uninstalling CommandLineTools (see https://github.com/haskell/haskell-language-server/issues/1913#issuecomment-861667786)"
97+
sudo rm -rf /Library/Developer/CommandLineTools
98+
99+
# Needs to be before Cache Cabal so the cache can detect changes to the modified cabal.project file
100+
- if: matrix.ghc == '9.0.1'
101+
name: Use modified cabal.project for ghc9
102+
run: cp cabal-ghc901.project cabal.project
103+
104+
- if: matrix.ghc == '8.8.4' && matrix.os == 'windows-latest'
105+
name: Modify cabal.project to workaround segfaults for ghc-8.8.4 and windows
106+
run: |
107+
echo "package floskell" >> cabal.project
108+
echo " ghc-options: -O0" >> cabal.project
109+
110+
- name: Cache Cabal
111+
uses: actions/cache@v2
112+
env:
113+
cache-name: cache-cabal
114+
with:
115+
path: |
116+
${{ env.CABAL_PKGS_DIR }}
117+
${{ env.CABAL_STORE_DIR }}
118+
key: v2-${{ runner.os }}-${{ matrix.ghc }}-build-${{ hashFiles('cabal.project') }}
119+
restore-keys: |
120+
v2-${{ runner.os }}-${{ matrix.ghc }}-bench-${{ hashFiles('cabal.project') }}
121+
v2-${{ runner.os }}-${{ matrix.ghc }}-build-
122+
v2-${{ runner.os }}-${{ matrix.ghc }}
123+
124+
- run: cabal update
125+
126+
# Need this to work around filepath length limits in Windows
127+
- name: Shorten binary names
128+
run: |
129+
sed -i.bak -e 's/haskell-language-server/hls/g' \
130+
-e 's/haskell_language_server/hls/g' \
131+
haskell-language-server.cabal cabal.project
132+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
133+
src/**/*.hs exe/*.hs
134+
135+
# repeating builds to workaround segfaults in windows and ghc-8.8.4
136+
- name: Build
137+
run: cabal build --only-dependencies || cabal build --only-dependencies || cabal build --only-dependencies

0 commit comments

Comments
 (0)