Skip to content

Commit ad00ef4

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

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

.github/workflows/cache-deps.yml

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

0 commit comments

Comments
 (0)