CI #46
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: Build | |
on: | |
push: | |
branches: [ "main" ] | |
paths: [ "src/**", "test/**", "app/**", "package.yaml", "stack.yaml", "stack.yaml.lock", "UniHs.cabal", "Setup.hs" ] | |
# pull_request: | |
# branches: [ "main" ] | |
workflow_dispatch: | |
# inputs: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
ghc-version: ['9.6.3'] | |
include: | |
- os: windows-latest | |
stack-global: | | |
~\AppData\Roaming\stack | |
~\AppData\Local\Programs\stack | |
- os: ubuntu-latest | |
stack-global: ~/.stack | |
- os: macos-latest | |
stack-global: ~/.stack | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up GHC ${{ matrix.ghc-version }} | |
uses: haskell-actions/setup@v2 | |
id: setup | |
with: | |
ghc-version: ${{ matrix.ghc-version }} | |
enable-stack: true | |
stack-version: 'latest' | |
stack-setup-ghc: true | |
stack-no-global: false | |
- name: Restore stack global dependencies | |
uses: actions/cache/restore@v3 | |
id: cache-stack-global | |
with: | |
path: ${{ matrix.stack-global }} | |
key: ${{ matrix.os }}-stack-global- | |
- name: Restore stack-work dependencies | |
uses: actions/cache/restore@v3 | |
id: cache-stack-work | |
with: | |
path: .stack-work | |
key: ${{ matrix.os }}-stack-work- | |
- name: Install dependencies | |
if: steps.cache-stack-global.outputs.cache-hit != 'true' || steps.cache-stack-work.outputs.cache-hit != 'true' | |
run: stack build --only-dependencies | |
- name: Save stack global dependencies | |
uses: actions/cache/save@v3 | |
if: ${{ steps.cache-stack-global.outputs.cache-primary-key != steps.cache-stack-global.outputs.cache-matched-key }} | |
with: | |
path: ${{ matrix.stack-global }} | |
key: ${{ matrix.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }} | |
- name: Save stack-work dependencies | |
uses: actions/cache/save@v3 | |
if: ${{ steps.cache-stack-work.outputs.cache-primary-key != steps.cache-stack-work.outputs.cache-matched-key }} | |
with: | |
path: .stack-work | |
key: ${{ matrix.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }} | |
- name: Build | |
run: stack build | |
- name: Run tests | |
run: stack test | |
- name: Build documentation | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: stack haddock | |
- name: Get docs directory | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
echo "docs_dir=$(stack path --snapshot-doc-root)" >> "$GITHUB_ENV" | |
- name: Deploy Haddock documentation | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
with: | |
branch: gh-pages | |
folder: ${{ env.docs_dir }} | |