Skip to content

Commit a96e088

Browse files
committed
Use specific cache for build
1 parent 4023d39 commit a96e088

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

.github/actions/setup-build/action.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ inputs:
1111
os:
1212
description: "Operating system: Linux, Windows or macOS"
1313
required: true
14+
cache-prefix:
15+
description: "To allow make unique the cache key"
16+
required: false
17+
default: ""
1418
runs:
1519
using: "composite"
1620
steps:
@@ -114,11 +118,11 @@ runs:
114118
cache-name: compiled-deps
115119
with:
116120
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
117-
key: ${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
121+
key: ${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
118122
restore-keys: |
119-
${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-
120-
${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-
121-
${{ env.cache-name }}-${{ inputs.os }}-
123+
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-
124+
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-
125+
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-
122126
123127
# We remove the freeze file because it could interfere with the build
124128
- name: "Remove freeze file"

.github/workflows/build.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ${{ matrix.os }}
14-
container: ${{ (matrix.os == 'ubuntu-18.04' && 'alpine:3.12') || '' }}
14+
container: ${{ (runner.os == 'Linux' && 'alpine:3.12') || '' }}
1515
defaults:
1616
run:
17-
shell: ${{ (matrix.os == 'windows-latest' && 'bash') || 'sh' }}
17+
shell: ${{ (runner.os == 'Windows' && 'bash') || 'sh' }}
1818
strategy:
1919
fail-fast: false
2020
matrix:
@@ -35,7 +35,7 @@ jobs:
3535

3636
steps:
3737
- name: Install system dependencies
38-
if: matrix.os == 'ubuntu-18.04'
38+
if: runner.os == 'Linux'
3939
run: |
4040
apk add --no-cache curl gcc g++ gmp-dev ncurses-dev libffi-dev make xz gzip tar perl git bash sudo binutils-gold
4141
apk add --no-cache zlib zlib-dev zlib-static gmp gmp-dev ncurses-static
@@ -50,25 +50,26 @@ jobs:
5050
with:
5151
ghc: ${{ matrix.ghc }}
5252
os: ${{ runner.os }}
53+
cache-prefix: ${{ github.workflow }}
5354

5455
- name: (Windows) Platform specifics
55-
if: matrix.os == 'windows-latest'
56+
if: runner.os == 'Windows'
5657
env:
5758
GHC_VER: ${{ matrix.ghc }}
5859
run: |
5960
echo "EXE_EXT=.exe" >> $GITHUB_ENV
6061
echo "GHC_VERSION=$GHC_VER" >> $GITHUB_ENV
6162
6263
- name: (Linux) Platform specifics
63-
if: matrix.os == 'ubuntu-18.04'
64+
if: runner.os == 'Linux'
6465
env:
6566
GHC_VER: ${{ matrix.ghc }}
6667
run: |
6768
echo "LINUX_CABAL_ARGS=--enable-executable-static --ghc-options=-split-sections" >> $GITHUB_ENV
6869
echo "GHC_VERSION=$GHC_VER" >> $GITHUB_ENV
6970
7071
- name: (macOS) Platform specifics
71-
if: matrix.os == 'macOS-latest'
72+
if: runner.os == 'macOS'
7273
env:
7374
GHC_VER: ${{ matrix.ghc }}
7475
run: |
@@ -77,7 +78,6 @@ jobs:
7778
- name: Build the server
7879
# Try building it twice in case of flakey builds on Windows
7980
run: |
80-
echo "Path: $PATH"
8181
cabal build exe:hls -O2 $LINUX_CABAL_ARGS || cabal build exe:hls -O2 $LINUX_CABAL_ARGS -j1
8282
8383
- name: Compress server binary
@@ -106,13 +106,13 @@ jobs:
106106
with:
107107
upload_url: ${{ github.event.release.upload_url }}
108108
asset_path: ${{ steps.compress_server_binary.outputs.path }}
109-
asset_name: haskell-language-server-${{ runner.OS }}-${{ env.GHC_VERSION }}${{env.EXE_EXT}}.${{ steps.compress_server_binary.outputs.extension }}
109+
asset_name: haskell-language-server-${{ runner.os }}-${{ env.GHC_VERSION }}${{env.EXE_EXT}}.${{ steps.compress_server_binary.outputs.extension }}
110110
asset_content_type: ${{ steps.compress_server_binary.outputs.content_type }}
111111

112112
- name: Upload server to workflow artifacts
113113
uses: actions/upload-artifact@v2
114114
with:
115-
name: haskell-language-server-${{ runner.OS }}-${{ matrix.ghc }}${{env.EXE_EXT}}.${{ steps.compress_server_binary.outputs.extension }}
115+
name: haskell-language-server-${{ runner.os }}-${{ matrix.ghc }}${{env.EXE_EXT}}.${{ steps.compress_server_binary.outputs.extension }}
116116
path: ${{ steps.compress_server_binary.outputs.path }}
117117

118118
- name: (GHC 8.10) Build the wrapper
@@ -146,14 +146,14 @@ jobs:
146146
with:
147147
upload_url: ${{ github.event.release.upload_url }}
148148
asset_path: ${{ steps.compress_wrapper_binary.outputs.path }}
149-
asset_name: haskell-language-server-wrapper-${{ runner.OS }}${{env.EXE_EXT}}.${{ steps.compress_wrapper_binary.outputs.extension }}
149+
asset_name: haskell-language-server-wrapper-${{ runner.os }}${{env.EXE_EXT}}.${{ steps.compress_wrapper_binary.outputs.extension }}
150150
asset_content_type: ${{ steps.compress_wrapper_binary.outputs.content_type}}
151151

152152
- name: (GHC 8.10) Upload wrapper to workflow artifacts
153153
uses: actions/upload-artifact@v2
154154
if: matrix.ghc == '8.10.7'
155155
with:
156-
name: haskell-language-server-wrapper-${{ runner.OS }}${{env.EXE_EXT}}.${{ steps.compress_wrapper_binary.outputs.extension }}
156+
name: haskell-language-server-wrapper-${{ runner.os }}${{env.EXE_EXT}}.${{ steps.compress_wrapper_binary.outputs.extension }}
157157
path: ${{ steps.compress_wrapper_binary.outputs.path }}
158158

159159
# generates a custom tarball with sources, used by `ghcup compile hls`
@@ -196,22 +196,22 @@ jobs:
196196
runs-on: ubuntu-18.04
197197
strategy:
198198
matrix:
199-
os: [ "Linux"
200-
, "macOS"
201-
, "Windows"
202-
]
199+
target-os: [ "Linux"
200+
, "macOS"
201+
, "Windows"
202+
]
203203
steps:
204204
- uses: actions/download-artifact@v2
205205

206206
- name: Generate tarball with all binaries
207207
run: |
208208
# move the binaries for the specific platform into bin/
209209
mkdir bin
210-
mv haskell-language-server-${{ matrix.os }}-*/* bin
211-
mv haskell-language-server-wrapper-${{ matrix.os }}.*/* bin
210+
mv haskell-language-server-${{ matrix.target-os }}-*/* bin
211+
mv haskell-language-server-wrapper-${{ matrix.target-os }}.*/* bin
212212
# decompress them
213213
cd bin
214-
if [[ "${{ matrix.os }}" == "Windows" ]]; then
214+
if [[ "${{ matrix.target-os }}" == "Windows" ]]; then
215215
7z x "*.zip"
216216
rm *.zip
217217
else
@@ -227,13 +227,13 @@ jobs:
227227
with:
228228
upload_url: ${{ github.event.release.upload_url }}
229229
asset_path: bin/haskell-language-server.tar.gz
230-
asset_name: haskell-language-server-${{ matrix.os }}-${{ github.event.release.tag_name }}.tar.gz
230+
asset_name: haskell-language-server-${{ matrix.target-os }}-${{ github.event.release.tag_name }}.tar.gz
231231
asset_content_type: application/gzip
232232

233233
- name: Upload binaries tarball to workflow artifacts
234234
uses: actions/upload-artifact@v2
235235
with:
236-
name: haskell-language-server-${{ matrix.os }}-${{ github.event.release.tag_name }}.tar.gz
236+
name: haskell-language-server-${{ matrix.target-os }}-${{ github.event.release.tag_name }}.tar.gz
237237
path: bin/haskell-language-server.tar.gz
238238

239239
sha256sum:

0 commit comments

Comments
 (0)