Skip to content

Generate Haddocks in CI (#813) #897

Generate Haddocks in CI (#813)

Generate Haddocks in CI (#813) #897

Workflow file for this run

name: Build
on:
push:
paths-ignore:
- '.github/workflows/docs.yaml'
- 'docs/*/**'
branches: [master]
pull_request:
paths-ignore:
- '.github/workflows/docs.yaml'
- 'docs/*/**'
jobs:
continuous-integration:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- ghc-version: "8.10.7"
- ghc-version: "9.0.2"
- ghc-version: "9.2.8"
- ghc-version: "9.4.8"
- ghc-version: "9.6.7"
duckdb: true
- ghc-version: "9.8.4"
duckdb: true
- ghc-version: "9.10.3"
duckdb: true
# Only one GHC version should have 'upload-documentation: true'
upload-documentation: true
- ghc-version: "9.12.2"
duckdb: true
- ghc-version: "9.14.1"
duckdb: true
steps:
- uses: actions/checkout@v4
- name: Install cabal/ghc
uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc-version }}
cabal-version: '3.12.1.0'
# duckdb-simple is only supported for GHC 9.6+
- name: Disable beam-duckdb
if: ${{ !matrix.duckdb }}
run: |
sed -i '/beam-duckdb/d' ./cabal.project
sed -i '/beam-backend-bench/d' ./cabal.project
- name: Generate freeze file
run: |
cabal update
# Building documentation is slightly more expensive, so we only enable it
cabal configure --disable-optimization ${{ matrix.upload-documentation && '--enable-doc' || '' }}
cabal freeze
# Exclude the timestamp of Hackage index update from our cache key, to
# avoid invalidating cache too often.
# This idea comes from github.com/jaspervdj/hakyll
sed '/^index-state: /d' cabal.project.freeze > dependencies-versions
- name: Cache cabal work
uses: actions/cache@v4
with:
path: |
dist-newstyle
${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ hashFiles('dependencies-versions', 'cabal.project.local') }}-${{ matrix.upload-documentation && 'withdocs' || 'nodocs' }}-cabal-install
- name: Install DuckDB artifact
if: ${{ matrix.duckdb }}
run: |
curl -L -o libduckdb.zip https://github.com/duckdb/duckdb/releases/download/v1.5.2/libduckdb-linux-amd64.zip && \
unzip libduckdb.zip
sudo mv libduckdb.so /usr/lib/libduckdb.so
sudo mv duckdb.h /usr/include/
sudo ldconfig
rm libduckdb.zip
- name: Build dependencies
run: |
cabal build all --only-dependencies
- name: Build beam packages
run: |
cabal build all
- name: Run tests
run: |
cabal test all
- name: Run benchmarks
if: ${{ matrix.duckdb }}
run: |
BEAM_BENCH_ROWS=100000 cabal -v0 bench beam-backend-bench:beam-postgres \
&& cabal -v0 bench beam-backend-bench:beam-sqlite \
&& cabal -v0 bench beam-backend-bench:beam-duckdb
# For releases, Haddock documentation may not be be automatically
# generated by Hackage due to missing dependencies (e.g. libduckdb, libpq).
#
# Therefore, we build Haddock documentation suitable for upload to Hackage, which are
# used when doing manual releases. We only do this for a single GHC version to reuse the work already done in
# this matrix entry.
- name: Build Haddock documentation for Hackage
if: ${{ matrix.upload-documentation }}
run: |
cabal haddock all --haddock-for-hackage
- name: Upload Haddock artifacts
if: ${{ matrix.upload-documentation && github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-haddock-artifact
path: dist-newstyle/*-docs.tar.gz
retention-days: 7
release-artifacts:
# Only build release artifacts if `continuous-integration` is successful
needs: [continuous-integration]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
# Note that we do not check `beam-backend-bench` because this package is
# not meant to be released.
- name: Check packages for common mistakes
run: |
for pkg in $(find . -mindepth 1 -maxdepth 1 -type d -name "beam-*" -not -name "beam-backend-bench")
do
cd $pkg
echo "Checking $pkg"
cabal check
cd $GITHUB_WORKSPACE
done
# Note that the ubuntu-24.04 image includes cabal
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#haskell-tools
- name: Build release artifacts
run : |
cabal sdist all
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: github.ref == 'refs/heads/master'
with:
name: ${{ runner.os }}-release-artifact
path: dist-newstyle/sdist/beam-*
retention-days: 7