6th try haskell.yml #57
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 Stack CI | |
on: | |
push: | |
branches: [ "main", "feature/**", "refactor/**" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create Stack root | |
run: | | |
mkdir -p ~/.stack | |
mkdir -p .stack-work | |
- name: Setup Haskell Stack | |
uses: haskell-actions/setup@v2 | |
with: | |
ghc-version: '9.4.8' | |
enable-stack: true | |
stack-version: 'latest' | |
stack-no-global: true | |
- name: Cache Stack package index | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.stack/pantry | |
~/.stack/indices | |
key: ${{ runner.os }}-stack-pantry-${{ hashFiles('stack.yaml') }}-v3 | |
restore-keys: | | |
${{ runner.os }}-stack-pantry- | |
- name: Cache Stack programs | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.stack/programs | |
~/.stack/setup-exe-cache | |
key: ${{ runner.os }}-stack-programs-${{ hashFiles('stack.yaml') }}-v3 | |
restore-keys: | | |
${{ runner.os }}-stack-programs- | |
- name: Initialize Stack | |
run: | | |
stack --version | |
stack config set system-ghc false | |
stack config set install-ghc true | |
# Create or update stack.yaml.lock if it doesn't exist | |
stack lock --modify-stack-yaml | |
- name: Install GHC | |
run: | | |
stack setup --resolver lts-21.25 --install-ghc --silent | |
- name: Build dependencies | |
run: | | |
stack build --only-dependencies --test --bench --no-run-benchmarks --silent | |
- name: Build and test | |
run: | | |
stack build --test --coverage --no-run-benchmarks --silent | |
stack test --coverage | |
stack hpc report . | |
- name: Install and run HLint | |
run: | | |
stack install hlint --silent | |
stack exec -- hlint . | |
- name: Check formatting | |
run: | | |
stack install ormolu --silent | |
stack exec -- ormolu --mode check $(find . -name '*.hs') | |
- name: Build documentation | |
run: stack haddock --no-haddock-deps --silent | |
- name: Run benchmarks | |
if: github.event_name == 'pull_request' | |
run: stack bench --silent | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: | | |
.stack-work/dist/**/test-reports/ | |
.stack-work/dist/**/hpc/ | |
.stack-work/dist/**/doc/ | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true |