Skip to content

Commit 050f241

Browse files
committed
CI: stack is preinstalled on GHA runners
- windows: compute STACK_ROOT before checkout
1 parent 6637b17 commit 050f241

File tree

3 files changed

+32
-71
lines changed

3 files changed

+32
-71
lines changed

.github/workflows/test-linux.yaml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ jobs:
2727
restore-keys: |
2828
${{ runner.os }}-stack-global
2929
30-
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
31-
id: stack-programs
32-
uses: actions/cache/restore@v3
33-
with:
34-
path: ~/.local/bin
35-
key: ${{ runner.os }}-stack-programs-${{ hashFiles('**.yaml') }}
36-
restore-keys: |
37-
${{ runner.os }}-stack-programs
38-
3930
- name: 💾 Restore cached .stack-work
4031
id: stack-work
4132
uses: actions/cache/restore@v3
@@ -49,10 +40,11 @@ jobs:
4940

5041
- name: ⏬ Install stack
5142
run: |
52-
mkdir -p ~/.local/bin
53-
export PATH=~/.local/bin:$PATH
43+
# mkdir -p ~/.local/bin
44+
# export PATH=~/.local/bin:$PATH
45+
## Stack is preinstalled on the GHA runners
5446
# curl -sL https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack
55-
if [[ ! -x ~/.local/bin/stack ]]; then curl -sL https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack; fi
47+
# if [[ ! -x ~/.local/bin/stack ]]; then curl -sL https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack; fi
5648
stack --version
5749
5850
- name: ⏬ Install GHC
@@ -78,13 +70,6 @@ jobs:
7870
path: ~/.stack
7971
key: ${{ steps.stack-global.outputs.cache-primary-key }}
8072

81-
- name: 💾 Cache stack-installed programs in ~/.local/bin
82-
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
83-
uses: actions/cache/save@v3
84-
with:
85-
path: ~/.local/bin
86-
key: ${{ steps.stack-programs.outputs.cache-primary-key }}
87-
8873
- name: 💾 Cache .stack-work
8974
if: always() && steps.stack-work.outputs.cache-hit != 'true'
9075
uses: actions/cache/save@v3

.github/workflows/test-mac.yaml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ jobs:
2727
restore-keys: |
2828
${{ runner.os }}-stack-global
2929
30-
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
31-
id: stack-programs
32-
uses: actions/cache/restore@v3
33-
with:
34-
path: ~/.local/bin
35-
key: ${{ runner.os }}-stack-programs-${{ hashFiles('**.yaml') }}
36-
restore-keys: |
37-
${{ runner.os }}-stack-programs
38-
3930
- name: 💾 Restore cached .stack-work
4031
id: stack-work
4132
uses: actions/cache/restore@v3
@@ -53,10 +44,11 @@ jobs:
5344
5445
- name: ⏬ Install stack
5546
run: |
56-
mkdir -p ~/.local/bin
57-
export PATH=~/.local/bin:$PATH
47+
# mkdir -p ~/.local/bin
48+
# export PATH=~/.local/bin:$PATH
49+
## Stack is preinstalled on the GHA runners
5850
# brew install gnu-tar; curl -sL https://get.haskellstack.org/stable/osx-x86_64.tar.gz | gtar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack
59-
if [[ ! -x ~/.local/bin/stack ]]; then brew install gnu-tar; curl -sL https://get.haskellstack.org/stable/osx-x86_64.tar.gz | gtar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack; fi
51+
# if [[ ! -x ~/.local/bin/stack ]]; then brew install gnu-tar; curl -sL https://get.haskellstack.org/stable/osx-x86_64.tar.gz | gtar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack; fi
6052
stack --version
6153
6254
- name: ⏬ Install GHC
@@ -80,13 +72,6 @@ jobs:
8072
path: ~/.stack
8173
key: ${{ steps.stack-global.outputs.cache-primary-key }}
8274

83-
- name: 💾 Cache stack-installed programs in ~/.local/bin
84-
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
85-
uses: actions/cache/save@v3
86-
with:
87-
path: ~/.local/bin
88-
key: ${{ steps.stack-programs.outputs.cache-primary-key }}
89-
9075
- name: 💾 Cache .stack-work
9176
if: always() && steps.stack-work.outputs.cache-hit != 'true'
9277
uses: actions/cache/save@v3

.github/workflows/test-windows.yaml

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ on:
88
pull_request:
99
branches: [master]
1010

11+
defaults:
12+
run:
13+
shell: bash
14+
1115
jobs:
1216
build:
1317
runs-on: windows-latest
1418
steps:
1519

20+
- name: Determine stack root
21+
run: |
22+
STACK_ROOT="$(stack --system-ghc --no-install-ghc path --stack-root || echo "C:/Users/runneradmin/AppData/Local/Programs/stack/x86_64-windows")"
23+
echo "STACK_ROOT = ${STACK_ROOT}"
24+
echo STACK_ROOT="${STACK_ROOT}" >> "${GITHUB_ENV}"
25+
1626
- name: 📥 Checkout repository
1727
uses: actions/checkout@v4
1828

@@ -22,21 +32,10 @@ jobs:
2232
id: stack-global
2333
uses: actions/cache/restore@v3
2434
with:
25-
path: C:\Users\runneradmin\AppData\Roaming\stack\
26-
key: ${{ runner.os }}-appdata-roaming-stack-${{ hashFiles('**.yaml') }}
27-
restore-keys: |
28-
${{ runner.os }}-appdata-roaming-stack
29-
30-
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
31-
id: stack-programs
32-
uses: actions/cache/restore@v3
33-
with:
34-
path: C:\Users\runneradmin\AppData\Local\Programs\stack\
35-
# which files signal a change in stack's global db ?
36-
# **.yaml includes */package.yaml and stack.yaml* (too many), and hopefully no other changing yamls
37-
key: ${{ runner.os }}-appdata-local-programs-stack-${{ hashFiles('**.yaml') }}
35+
path: ${{ env.STACK_ROOT }}
36+
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
3837
restore-keys: |
39-
${{ runner.os }}-appdata-local-programs-stack
38+
${{ runner.os }}-stack-global
4039
4140
- name: 💾 Restore cached .stack-work
4241
id: stack-work
@@ -50,56 +49,47 @@ jobs:
5049
# actions
5150

5251
- name: ⏬ Install stack
52+
## Stack is preinstalled on GHA runners.
53+
#
5354
#if: steps.stack-programs-dir.outputs.cache-hit != 'true'
5455
# this step is needed to get stack.exe into PATH, for now
56+
# curl -sL https://get.haskellstack.org/stable/windows-x86_64.zip -o stack.zip
57+
# 7z x stack.zip stack.exe
5558
run: |
56-
curl -sL https://get.haskellstack.org/stable/windows-x86_64.zip -o stack.zip
57-
7z x stack.zip stack.exe
5859
which stack
5960
stack --version
60-
which ./stack
61-
./stack --version
62-
# must avoid GHC versions broken on windows such as 8.8.3 with https://gitlab.haskell.org/ghc/ghc/issues/17926
63-
# current default stack.yaml uses GHC 8.8.4 which hopefully is ok
6461
6562
- name: ⏬ Install GHC
6663
# if: steps.stack-programs-dir.outputs.cache-hit != 'true'
6764
# set PATH=C:\Users\runneradmin\AppData\Local\Programs\stack\local\bin;%PATH%
6865
run: |
69-
./stack --no-terminal setup --install-ghc
66+
stack --no-terminal setup --install-ghc
7067
7168
- name: Install the icu library
7269
run: |
73-
./stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf
70+
stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf
7471
7572
- name: 📸 Build Snapshot
7673
run: |
77-
./stack build --no-terminal --only-snapshot -j1
74+
stack build --no-terminal --only-snapshot -j1
7875
7976
- name: 🧰 Build Dependencies
8077
run: |
81-
./stack build --no-terminal --only-dependencies
78+
stack build --no-terminal --only-dependencies
8279
8380
- name: 🔨 Build and run tests
8481
run: |
85-
./stack test
82+
stack test
8683
8784
# things to be cached
8885

8986
- name: 💾 Cache stack global package db
9087
if: always() && steps.stack-global.outputs.cache-hit != 'true'
9188
uses: actions/cache/save@v3
9289
with:
93-
path: ~/.stack
90+
path: ${{ env.STACK_ROOT }}
9491
key: ${{ steps.stack-global.outputs.cache-primary-key }}
9592

96-
- name: 💾 Cache stack-installed programs in ~/.local/bin
97-
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
98-
uses: actions/cache/save@v3
99-
with:
100-
path: ~/.local/bin
101-
key: ${{ steps.stack-programs.outputs.cache-primary-key }}
102-
10393
- name: 💾 Cache .stack-work
10494
if: always() && steps.stack-work.outputs.cache-hit != 'true'
10595
uses: actions/cache/save@v3
@@ -111,6 +101,7 @@ jobs:
111101
# artifacts:
112102

113103
- name: 📦 Compress executable and data files
104+
shell: pwsh
114105
run: |
115106
# locate the data-dir
116107
$snapshot = (stack path --snapshot-install-root)

0 commit comments

Comments
 (0)