Skip to content

Commit

Permalink
CI: stack is preinstalled on GHA runners
Browse files Browse the repository at this point in the history
- windows: compute STACK_ROOT before checkout
  • Loading branch information
andreasabel committed Nov 20, 2023
1 parent 6637b17 commit fce9710
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 71 deletions.
23 changes: 4 additions & 19 deletions .github/workflows/test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ jobs:
restore-keys: |
${{ runner.os }}-stack-global
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
id: stack-programs
uses: actions/cache/restore@v3
with:
path: ~/.local/bin
key: ${{ runner.os }}-stack-programs-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-programs
- name: 💾 Restore cached .stack-work
id: stack-work
uses: actions/cache/restore@v3
Expand All @@ -49,10 +40,11 @@ jobs:

- name: ⏬ Install stack
run: |
mkdir -p ~/.local/bin
export PATH=~/.local/bin:$PATH
# mkdir -p ~/.local/bin
# export PATH=~/.local/bin:$PATH
## Stack is preinstalled on the GHA runners
# 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
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
# 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
stack --version
- name: ⏬ Install GHC
Expand All @@ -78,13 +70,6 @@ jobs:
path: ~/.stack
key: ${{ steps.stack-global.outputs.cache-primary-key }}

- name: 💾 Cache stack-installed programs in ~/.local/bin
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.local/bin
key: ${{ steps.stack-programs.outputs.cache-primary-key }}

- name: 💾 Cache .stack-work
if: always() && steps.stack-work.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
Expand Down
23 changes: 4 additions & 19 deletions .github/workflows/test-mac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ jobs:
restore-keys: |
${{ runner.os }}-stack-global
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
id: stack-programs
uses: actions/cache/restore@v3
with:
path: ~/.local/bin
key: ${{ runner.os }}-stack-programs-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-programs
- name: 💾 Restore cached .stack-work
id: stack-work
uses: actions/cache/restore@v3
Expand All @@ -53,10 +44,11 @@ jobs:
- name: ⏬ Install stack
run: |
mkdir -p ~/.local/bin
export PATH=~/.local/bin:$PATH
# mkdir -p ~/.local/bin
# export PATH=~/.local/bin:$PATH
## Stack is preinstalled on the GHA runners
# 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
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
# 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
stack --version
- name: ⏬ Install GHC
Expand All @@ -80,13 +72,6 @@ jobs:
path: ~/.stack
key: ${{ steps.stack-global.outputs.cache-primary-key }}

- name: 💾 Cache stack-installed programs in ~/.local/bin
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.local/bin
key: ${{ steps.stack-programs.outputs.cache-primary-key }}

- name: 💾 Cache .stack-work
if: always() && steps.stack-work.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
Expand Down
56 changes: 23 additions & 33 deletions .github/workflows/test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ on:
pull_request:
branches: [master]

defaults:
run:
shell: bash

jobs:
build:
runs-on: windows-latest
steps:

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

Expand All @@ -22,21 +32,10 @@ jobs:
id: stack-global
uses: actions/cache/restore@v3
with:
path: C:\Users\runneradmin\AppData\Roaming\stack\
key: ${{ runner.os }}-appdata-roaming-stack-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-appdata-roaming-stack
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
id: stack-programs
uses: actions/cache/restore@v3
with:
path: C:\Users\runneradmin\AppData\Local\Programs\stack\
# which files signal a change in stack's global db ?
# **.yaml includes */package.yaml and stack.yaml* (too many), and hopefully no other changing yamls
key: ${{ runner.os }}-appdata-local-programs-stack-${{ hashFiles('**.yaml') }}
path: ${{ env.STACK_ROOT }}
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-appdata-local-programs-stack
${{ runner.os }}-stack-global
- name: 💾 Restore cached .stack-work
id: stack-work
Expand All @@ -50,56 +49,47 @@ jobs:
# actions

- name: ⏬ Install stack
## Stack is preinstalled on GHA runners.
#
#if: steps.stack-programs-dir.outputs.cache-hit != 'true'
# this step is needed to get stack.exe into PATH, for now
# curl -sL https://get.haskellstack.org/stable/windows-x86_64.zip -o stack.zip
# 7z x stack.zip stack.exe
run: |
curl -sL https://get.haskellstack.org/stable/windows-x86_64.zip -o stack.zip
7z x stack.zip stack.exe
which stack
stack --version
which ./stack
./stack --version
# must avoid GHC versions broken on windows such as 8.8.3 with https://gitlab.haskell.org/ghc/ghc/issues/17926
# current default stack.yaml uses GHC 8.8.4 which hopefully is ok
- name: ⏬ Install GHC
# if: steps.stack-programs-dir.outputs.cache-hit != 'true'
# set PATH=C:\Users\runneradmin\AppData\Local\Programs\stack\local\bin;%PATH%
run: |
./stack --no-terminal setup --install-ghc
stack --no-terminal setup --install-ghc
- name: Install the icu library
run: |
./stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf
stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf
- name: 📸 Build Snapshot
run: |
./stack build --no-terminal --only-snapshot -j1
stack build --no-terminal --only-snapshot -j1
- name: 🧰 Build Dependencies
run: |
./stack build --no-terminal --only-dependencies
stack build --no-terminal --only-dependencies
- name: 🔨 Build and run tests
run: |
./stack test
stack test
# things to be cached

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

- name: 💾 Cache stack-installed programs in ~/.local/bin
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.local/bin
key: ${{ steps.stack-programs.outputs.cache-primary-key }}

- name: 💾 Cache .stack-work
if: always() && steps.stack-work.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
Expand Down

0 comments on commit fce9710

Please sign in to comment.