Define expectFailure
in terms of expectFailureWith
#361
This file contains hidden or 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: "Haddock documentation" | |
on: | |
workflow_dispatch: | |
push: | |
jobs: | |
haddocks: | |
name: "Haddocks" | |
environment: cabal-cache | |
runs-on: ${{ matrix.os }} | |
env: | |
# Modify this value to "invalidate" the cabal cache. | |
CABAL_CACHE_VERSION: "2024-05-01-1" | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
ghc: ["9.6"] | |
cabal: ["3.14"] | |
os: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Haskell | |
uses: input-output-hk/actions/haskell@latest | |
id: setup-haskell | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
cabal-version: ${{ matrix.cabal }} | |
- name: Install system dependencies | |
uses: input-output-hk/actions/base@latest | |
with: | |
use-sodium-vrf: true # default is true | |
- uses: actions/checkout@v4 | |
- name: Cabal update | |
run: cabal update | |
# A dry run `build all` operation does *NOT* download anything, it just looks at the package | |
# indices to generate an install plan. | |
- name: Build dry run | |
run: cabal build all --enable-tests --dry-run --minimize-conflict-set | |
# From the install plan we generate a dependency list. | |
- name: Record dependencies | |
id: record-deps | |
run: | | |
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(.style != "local") | .id' | sort | uniq > dependencies.txt | |
# Use a fresh cache each month | |
- name: Store month number as environment variable used in cache version | |
run: echo "MONTHNUM=$(date -u '+%m')" >> "$GITHUB_ENV" | |
# From the dependency list we restore the cached dependencies. | |
# We use the hash of `dependencies.txt` as part of the cache key because that will be stable | |
# until the `index-state` values in the `cabal.project` file changes. | |
- name: Restore cached dependencies | |
uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
path: | | |
${{ steps.setup-haskell.outputs.cabal-store }} | |
dist-newstyle | |
key: | |
cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.MONTHNUM }}-${{ hashFiles('dependencies.txt') }} | |
# try to restore previous cache from this month if there's no cache for the dependencies set | |
restore-keys: | | |
cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.MONTHNUM }}- | |
# Now we install the dependencies. If the cache was found and restored in the previous step, | |
# this should be a no-op, but if the cache key was not found we need to build stuff so we can | |
# cache it for the next step. | |
- name: Install dependencies | |
run: cabal build all --enable-tests --only-dependencies | |
# Always store the cabal cache. | |
# This can fail (benign failure) if there is already a hash at that key. | |
- name: Cache Cabal store | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
${{ steps.setup-haskell.outputs.cabal-store }} | |
dist-newstyle | |
key: | |
${{ steps.cache.outputs.cache-primary-key }} | |
# Now we build. | |
- name: Build all | |
run: cabal build all | |
- name: build Haddock documentation 🔧 | |
run: | | |
mkdir -p ./haddocks | |
./scripts/haddocs.sh ./haddocks | |
- name: deploy to gh-pages 🚀 | |
run: | | |
rm dependencies.txt # Otherwise checkout below will fail | |
git config --local user.email "[email protected]" | |
git config --local user.name ${{ github.actor }} | |
git fetch origin gh-pages:gh-pages | |
git checkout gh-pages | |
cp -r ./haddocks/* ./ | |
rm -rf haddocks | |
git add -A | |
git commit -m "Deployed haddocks" || true | |
git push https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git HEAD:gh-pages |