Skip to content

Commit

Permalink
Github Actions: a reusable hs-setup action
Browse files Browse the repository at this point in the history
  • Loading branch information
EarlGray committed Aug 18, 2024
1 parent a3c0cd4 commit 52d04b7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 65 deletions.
58 changes: 58 additions & 0 deletions .github/actions/hs-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Setup Haskell
description: Setup Haskell

runs:
using: "composite"
steps:
- name: Install system dependencies of ghc and vado
shell: bash
run: |
sudo apt install -y libncurses5 libtinfo5 libcairo2-dev libsdl2-dev libsdl2-image-dev
- uses: actions/cache@v4
name: Cache stack
env:
MANUAL_RESET: ${{ env.MANUAL_CACHE_RESET_STACK }}
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ env.MANUAL_RESET }}-${{ hashFiles('config.yaml') }}
restore-keys: ${{ runner.os }}-stack-global-${{ env.MANUAL_RESET }}-
- uses: actions/cache@v4
id: ghcup
name: Cache ghcup
env:
MANUAL_RESET: ${{ env.MANUAL_CACHE_RESET_GHC }}
with:
path: ~/.ghcup
key: ${{ runner.os }}-ghcup-global-${{ env.MANUAL_RESET }}-${{ hashFiles('config.yaml') }}
restore-keys: ${{ runner.os }}-ghcup-global-${{ env.MANUAL_RESET }}-
- uses: actions/cache@v4
id: ghc
name: Cache ghc
env:
MANUAL_RESET: ${{ env.MANUAL_CACHE_RESET_GHC }}
with:
path: /usr/local/.ghcup
key: ${{ runner.os }}-ghc-global-${{ env.MANUAL_RESET }}-${{ env.GHC_VERSION }}
restore-keys: ${{ runner.os }}-ghc-global-${{ env.MANUAL_RESET }}-${{ env.GHC_VERSION }}
- uses: actions/cache@v4
name: Cache ~/.local/bin
env:
MANUAL_RESET: ${{ env.MANUAL_CACHE_RESET_BIN }}
with:
path: ~/.local/bin
key: ${{ runner.os }}-local-global-${{ env.MANUAL_RESET }}-${{ hashFiles('gtk2hsC2hs') }}
restore-keys: ${{ runner.os }}-local-global-${{ env.MANUAL_RESET }}-

- uses: haskell-actions/setup@v2
#if: steps.ghcup.outputs.cache-hit != 'true'
with:
ghc-version: ${{ env.GHC_VERSION }}
enable-stack: true
stack-version: 'latest'

- run: stack config set install-ghc false --global && stack config set system-ghc true --global
shell: bash

- run: test -x ~/.local/bin/gtk2hsC2hs || stack install gtk2hs-buildtools
shell: bash
70 changes: 5 additions & 65 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:

env:
GHC_VERSION: '9.4.8'
MANUAL_CACHE_RESET_BIN: v0
MANUAL_CACHE_RESET_GHC: v0
MANUAL_CACHE_RESET_STACK: v0

jobs:
build:
Expand All @@ -22,39 +25,7 @@ jobs:
touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f";
done
- uses: actions/cache@v4
name: Cache stack
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-
- uses: actions/cache@v4
id: ghcup
name: Cache ghcup
with:
path: /usr/local/.ghcup
key: ${{ runner.os }}-ghcup-global-${{ hashFiles('config.yaml') }}
restore-keys: |
${{ runner.os }}-ghcup-global-
- uses: actions/cache@v4
name: Cache ~/.local/bin
with:
path: ~/.local/bin
key: ${{ runner.os }}-local-global-${{ hashFiles('gtk2hsChs') }}
restore-keys: |
${{ runner.os }}-local-global-
- uses: haskell-actions/setup@v2
if: steps.ghcup.outputs.cache-hit != 'true'
with:
ghc-version: ${{ env.GHC_VERSION }}
enable-stack: true
stack-version: 'latest'

- run: stack config set install-ghc false --global && stack config set system-ghc true --global
- run: test -x ~/.local/bin/gtk2hsC2hs || stack install gtk2hs-buildtools
- run: sudo apt install -y libcairo2-dev libsdl2-dev libsdl2-image-dev
- uses: ./.github/actions/hs-setup

- run: stack build

Expand All @@ -71,37 +42,6 @@ jobs:
touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f";
done
- uses: actions/cache@v4
name: Cache stack
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-
- uses: actions/cache@v4
name: Cache ghcup
id: ghcup
with:
path: /usr/local/.ghcup
key: ${{ runner.os }}-ghcup-global-${{ hashFiles('config.yaml') }}
restore-keys: |
${{ runner.os }}-ghcup-global-
- uses: actions/cache@v4
name: Cache ~/.local/bin
with:
path: ~/.local/bin
key: ${{ runner.os }}-local-global-${{ hashFiles('gtk2hsChs') }}
restore-keys: |
${{ runner.os }}-local-global-
- uses: haskell-actions/setup@v2
#if: steps.ghcup.outputs.cache-hit != 'true'
with:
ghc-version: ${{ env.GHC_VERSION }}
enable-stack: true
stack-version: 'latest'
- run: stack config set install-ghc false --global && stack config set system-ghc true --global
- run: test -x ~/.local/bin/gtk2hsC2hs || stack install gtk2hs-buildtools
- run: sudo apt install -y libcairo2-dev libsdl2-dev libsdl2-image-dev
- uses: ./.github/actions/hs-setup

- run: stack test --fast

0 comments on commit 52d04b7

Please sign in to comment.