Add Haddock docs building #108
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: | ||
# Reusing caches requires building in `main` branch | ||
- push | ||
# Does not seem to work | ||
- merge_group | ||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup DevX | ||
uses: input-output-hk/actions/devx@latest | ||
with: | ||
platform: 'x86_64-linux' | ||
compiler-nix-name: 'ghc96' | ||
minimal: false | ||
iog: true | ||
- name: Check Nix env | ||
shell: devx {0} | ||
run: | | ||
echo 'Running in DevX' | ||
ghc --version | ||
cabal --version | ||
- name: Use cabal cache | ||
id: cache-cabal | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
~/.cabal-devx | ||
dist-newstyle | ||
key: ${{ runner.os }}-ghc964-${{ hashFiles('**/*.cabal', '**/cabal.project', '**/cabal.project.freeze') }} | ||
restore-keys: ${{ runner.os }}-ghc964- | ||
- name: Cabal build and test | ||
shell: devx {0} | ||
run: | | ||
cabal update | ||
cabal build | ||
cabal test | ||
- name: Install and run linters | ||
shell: devx {0} | ||
run: | | ||
cabal install --overwrite-policy=always cabal-fmt | ||
cabal install --overwrite-policy=always fourmolu | ||
/home/runner/.cabal-devx/bin/cabal-fmt --check cem-script.cabal | ||
/home/runner/.cabal-devx/bin/fourmolu --mode check . | ||
- name: Build haddock | ||
shell: devx {0} | ||
run: | | ||
cabal haddock-project --hackage --internal | ||
- name: Save cabal cache | ||
uses: actions/cache/save@v3 | ||
if: always() | ||
with: | ||
path: | | ||
~/.cabal-devx | ||
dist-newstyle | ||
key: ${{ runner.os }}-ghc964-${{ hashFiles('**/*.cabal', '**/cabal.project', '**/cabal.project.freeze') }} | ||
- name: Save cabal cache (generic key) | ||
uses: actions/cache/save@v3 | ||
if: always() | ||
with: | ||
path: | | ||
~/.cabal-devx | ||
dist-newstyle | ||
key: ${{ runner.os }}-ghc964- | ||
build-docs: | ||
runs-on: ubuntu-latest | ||
if: ${{ vars.GITHUB_REF_NAME == 'master' }} | ||
steps: | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v5 | ||
- name: Move Haddock (fixing wrong internal lib build) | ||
run: | | ||
mkdir -p docs/_site/haddocks/cem-script/src | ||
mv --backup=nil -u -f haddocks/cem-script-*/src/* docs/_site/haddocks/cem-script/src | ||
rm -r haddocks/cem-script-*/src | ||
mv --backup=nil -u -f haddocks/cem-script-*/* docs/_site/haddocks/cem-script | ||
- name: Build with Jekyll | ||
uses: actions/jekyll-build-pages@v1 | ||
with: | ||
source: ./ | ||
destination: ./_site | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
deploy-docs-to-github-pages: | ||
if: ${{ vars.GITHUB_REF_NAME == 'master' }} | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |