GitHub Actions: Revise workflow #17
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Haskell CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
concurrency: | ||
group: ci-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
install-stack: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Restore cached ~/.stack | ||
id: cache-restore | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/.local/bin/stack | ||
~/.stack | ||
key: test-${{ runner.os }}-${{ hashFiles('stack.lts.yaml') }} | ||
- run: | | ||
if [ ! -f ~/.local/bin/stack ]; then | ||
curl -sSL https://get.haskellstack.org/ | sh -s - -f | ||
fi | ||
- name: Save ~/.stack | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: | | ||
~/.local/bin/stack | ||
~/.stack | ||
key: test-${{ runner.os }}-${{ hashFiles('stack.lts.yaml') }} | ||
stack-test: | ||
runs-on: ubuntu-latest | ||
needs: install-stack | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cached ~/.stack | ||
id: cache-restore | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/.local/bin/stack | ||
~/.stack | ||
key: test-${{ runner.os }}-${{ hashFiles('stack.lts.yaml') }} | ||
- if: steps.cache-restore.outputs.cache-hit != 'true' | ||
run: exit 1 | ||
- run: | | ||
~/.local/bin/stack init | ||
~/.local/bin/stack test | ||
- name: Save ~/.stack | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: | | ||
~/.local/bin/stack | ||
~/.stack | ||
key: test-${{ runner.os }}-${{ hashFiles('stack.lts.yaml') }} | ||
fourmolu: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cached fourmolu | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ~/.local/bin/fourmolu | ||
key: fourmolu-0.16.2.0 | ||
- run: | | ||
if [ ! -f ~/.local/bin/fourmolu ]; then | ||
mkdir -p ~/.local/bin | ||
curl -o ~/.local/bin/fourmolu -L https://github.com/fourmolu/fourmolu/releases/download/v0.16.2.0/fourmolu-0.16.2.0-linux-x86_64 | ||
chmod +x ~/.local/bin/fourmolu | ||
fi | ||
- name: Save fourmolu cache | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ~/.local/bin/fourmolu | ||
key: fourmolu-0.16.2.0 | ||
- run: ~/.local/bin/fourmolu --mode check src test | ||
hlint: | ||
needs: restore | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore cached hlint | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ~/.local/bin/hlint | ||
key: hlint-3.8 | ||
- run: | | ||
if [ ! -f ~/.local/bin/hlint ]; then | ||
mkdir -p ~/.local/bin | ||
curl -o /tmp/hlint.tar.gz -L https://github.com/ndmitchell/hlint/releases/download/v3.8/hlint-3.8-x86_64-linux.tar.gz | ||
tar xzf /tmp/hlint.tar.gz --directory=/tmp | ||
cp /tmp/hlint-3.8/hlint ~/.local/bin/hlint | ||
fi | ||
- name: Save hlint cache | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ~/.local/bin/hlint | ||
key: hlint-3.8 | ||
- run: ~/.local/bin/hlint src test |