From 1b0d4995a6bef60d9e13ea9395d3d36ad4165b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Thu, 5 Mar 2026 12:06:39 +0200 Subject: [PATCH 1/7] Add CI workflow for benchmarks Runs benchmarks on PRs and pushes to master, uploads results as artifact. --- .github/workflows/bench.yml | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/bench.yml diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 0000000..4ccc8a5 --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,42 @@ +name: Benchmarks + +on: + pull_request: + branches: [master] + push: + branches: [master] + +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Haskell + uses: haskell-actions/setup@v2 + with: + ghc-version: '9.10.3' + cabal-version: '3.12' + + - name: Cache cabal packages + uses: actions/cache@v4 + with: + path: | + ~/.cabal/packages + ~/.cabal/store + dist-newstyle + key: ${{ runner.os }}-cabal-${{ hashFiles('**/*.cabal') }} + restore-keys: | + ${{ runner.os }}-cabal- + + - name: Build + run: cabal build bench + + - name: Run benchmarks + run: cabal run bench -- --csv bench-results.csv + + - name: Upload benchmark results + uses: actions/upload-artifact@v4 + with: + name: benchmark-results + path: bench-results.csv From f7cfffc7cbe092231ff1d7088e0dbc6d2b8b9aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Thu, 5 Mar 2026 12:07:29 +0200 Subject: [PATCH 2/7] Add tests to CI workflow - Rename bench.yml to ci.yml - Add test job that runs in parallel with benchmarks --- .github/workflows/{bench.yml => ci.yml} | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) rename .github/workflows/{bench.yml => ci.yml} (57%) diff --git a/.github/workflows/bench.yml b/.github/workflows/ci.yml similarity index 57% rename from .github/workflows/bench.yml rename to .github/workflows/ci.yml index 4ccc8a5..a5f24ae 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Benchmarks +name: CI on: pull_request: @@ -7,6 +7,34 @@ on: branches: [master] jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Haskell + uses: haskell-actions/setup@v2 + with: + ghc-version: '9.10.3' + cabal-version: '3.12' + + - name: Cache cabal packages + uses: actions/cache@v4 + with: + path: | + ~/.cabal/packages + ~/.cabal/store + dist-newstyle + key: ${{ runner.os }}-cabal-${{ hashFiles('**/*.cabal') }} + restore-keys: | + ${{ runner.os }}-cabal- + + - name: Build + run: cabal build all + + - name: Run tests + run: cabal test --test-show-details=direct + benchmark: runs-on: ubuntu-latest steps: From f2a913eb5f3d8d11baacd87f00a0aa75d845d0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Thu, 5 Mar 2026 12:10:27 +0200 Subject: [PATCH 3/7] Run tests across multiple GHC versions Test matrix: 9.6.7, 9.8.4, 9.10.2, 9.12.2 --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5f24ae..e921689 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,13 +9,16 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + ghc-version: ['9.6.7', '9.8.4', '9.10.2', '9.12.2'] steps: - uses: actions/checkout@v4 - name: Setup Haskell uses: haskell-actions/setup@v2 with: - ghc-version: '9.10.3' + ghc-version: ${{ matrix.ghc-version }} cabal-version: '3.12' - name: Cache cabal packages @@ -25,9 +28,9 @@ jobs: ~/.cabal/packages ~/.cabal/store dist-newstyle - key: ${{ runner.os }}-cabal-${{ hashFiles('**/*.cabal') }} + key: ${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal-${{ hashFiles('**/*.cabal') }} restore-keys: | - ${{ runner.os }}-cabal- + ${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal- - name: Build run: cabal build all From 4fdabee54a50e3452cf5bebb680888af10c7be16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Thu, 5 Mar 2026 12:13:08 +0200 Subject: [PATCH 4/7] Add required job for branch protection - Add fail-fast: false to run all matrix jobs - Add required job that depends on all tests passing --- .github/workflows/ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e921689..3aae8d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: ghc-version: ['9.6.7', '9.8.4', '9.10.2', '9.12.2'] steps: @@ -71,3 +72,15 @@ jobs: with: name: benchmark-results path: bench-results.csv + + required: + runs-on: ubuntu-latest + needs: [test] + if: always() + steps: + - name: Check required jobs + run: | + if [ "${{ needs.test.result }}" != "success" ]; then + echo "Tests failed" + exit 1 + fi From 9da9005a584284e8b13de25bfd83fb4f25e37621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Thu, 5 Mar 2026 14:42:09 +0200 Subject: [PATCH 5/7] Remove required job from CI --- .github/workflows/ci.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3aae8d5..7376b92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,15 +72,3 @@ jobs: with: name: benchmark-results path: bench-results.csv - - required: - runs-on: ubuntu-latest - needs: [test] - if: always() - steps: - - name: Check required jobs - run: | - if [ "${{ needs.test.result }}" != "success" ]; then - echo "Tests failed" - exit 1 - fi From a3fef646cb10b760fc7865f520f86814763202b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Thu, 5 Mar 2026 14:50:53 +0200 Subject: [PATCH 6/7] Add fourmolize script --- scripts/fourmolize.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 scripts/fourmolize.sh diff --git a/scripts/fourmolize.sh b/scripts/fourmolize.sh new file mode 100755 index 0000000..71f7620 --- /dev/null +++ b/scripts/fourmolize.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [[ $# -gt 0 ]]; then + case "$1" in + --changes) + # Run fourmolu on changes compared to `master`. + git diff --diff-filter=MA --name-only origin/master HEAD -- '*.hs' + ;; + *) + echo "Invalid option: $1" >&2 + exit 1 + ;; + esac +else + git ls-files -- '*.hs' +fi \ + | { grep -v Setup.hs || true; } \ + | xargs -r fourmolu -m inplace + +git diff --exit-code From 221ad0f2df2b61bc2950fd491aa425f867a5c5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Thu, 5 Mar 2026 14:52:41 +0200 Subject: [PATCH 7/7] Copied fourmolu CI job from cardano-ledger --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7376b92..890074c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,3 +72,28 @@ jobs: with: name: benchmark-results path: bench-results.csv + + fourmolu: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - name: Install fourmolu + run: | + FOURMOLU_VERSION="0.17.0.0" + BINDIR=$HOME/.local/bin + mkdir -p "$BINDIR" + curl -sSfL "https://github.com/fourmolu/fourmolu/releases/download/v${FOURMOLU_VERSION}/fourmolu-${FOURMOLU_VERSION}-linux-x86_64" -o "$BINDIR/fourmolu" + chmod a+x "$BINDIR/fourmolu" + echo "$BINDIR" >> $GITHUB_PATH + + - name: Run fourmolu + run: ./scripts/fourmolize.sh