From fbe5c89f614d9e8a6312ec42315b9dd54d48f76b Mon Sep 17 00:00:00 2001 From: Peter Lebbing Date: Tue, 28 Jan 2025 12:21:44 +0100 Subject: [PATCH 1/5] Use cabal.project.local for CI settings We had two ways of setting -Werror: it was both in the `-fci` flag and in cabal.project.local. This was redundant. Constraining the Clash version can also be put in cabal.project.local. --- .ci/apply_settings.sh | 5 ++++- .ci/build_docs.sh | 5 +---- .ci/cabal.project.local.in | 6 ++++++ .ci/test_cabal.sh | 4 ++-- .github/workflows/ci.yml | 2 +- clash-protocols-base/clash-protocols-base.cabal | 8 -------- clash-protocols/clash-protocols.cabal | 8 -------- 7 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.ci/apply_settings.sh b/.ci/apply_settings.sh index 7dbf9a70..89ec75c9 100755 --- a/.ci/apply_settings.sh +++ b/.ci/apply_settings.sh @@ -1,8 +1,11 @@ #!/bin/bash +set -uo pipefail + if [[ "$check_haddock" != @(True|False) ]]; then echo "check_haddock: Expected True or False, got \"$check_haddock\"" >&2 exit 1 fi sed <.ci/cabal.project.local.in >cabal.project.local " - s/__CHECK_HADDOCK__/$check_haddock/" + s/__CHECK_HADDOCK__/$check_haddock/ + s/__CLASH_VERSION__/$clash_version/" diff --git a/.ci/build_docs.sh b/.ci/build_docs.sh index 611f80d0..063845c8 100755 --- a/.ci/build_docs.sh +++ b/.ci/build_docs.sh @@ -1,10 +1,7 @@ #!/bin/bash set -xeou pipefail -cabal v2-haddock \ - --constraint=clash-prelude==$clash_version \ - clash-protocols \ - |& tee haddock_log +cabal v2-haddock clash-protocols |& tee haddock_log set +e diff --git a/.ci/cabal.project.local.in b/.ci/cabal.project.local.in index 179f79dc..428849db 100644 --- a/.ci/cabal.project.local.in +++ b/.ci/cabal.project.local.in @@ -1,6 +1,12 @@ package * documentation: __CHECK_HADDOCK__ +package clash-protocols-base + ghc-options: -Werror + package clash-protocols documentation: False ghc-options: -Werror + +constraints: + clash-prelude == __CLASH_VERSION__ diff --git a/.ci/test_cabal.sh b/.ci/test_cabal.sh index 337c0ac5..624c9ff5 100755 --- a/.ci/test_cabal.sh +++ b/.ci/test_cabal.sh @@ -1,6 +1,6 @@ #!/bin/bash set -xeou pipefail -cabal v2-run unittests --constraint=clash-prelude==$clash_version -fci --enable-tests -cabal v2-run doctests --constraint=clash-prelude==$clash_version -fci --enable-tests +cabal v2-run unittests --enable-tests +cabal v2-run doctests --enable-tests cabal v2-sdist clash-protocols diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ce36633..fb2937e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: - name: Build run: | - cabal build all --constraint=clash-prelude==$clash_version -fci + cabal build all --enable-tests - name: Test run: | diff --git a/clash-protocols-base/clash-protocols-base.cabal b/clash-protocols-base/clash-protocols-base.cabal index d42c32ad..e1f88851 100644 --- a/clash-protocols-base/clash-protocols-base.cabal +++ b/clash-protocols-base/clash-protocols-base.cabal @@ -9,11 +9,6 @@ license-file: LICENSE author: Martijn Bastiaan, QBayLogic B.V. maintainer: Martijn Bastiaan -flag ci - Description: Running on CI? Used to set fail-on-warning flag. - Manual: True - Default: False - flag large-tuples description: Generate instances for classes such as `Units` and `TaggedBundle` for tuples @@ -75,9 +70,6 @@ common common-options -- a no-specialize pragma to every function with a blackbox. -fno-worker-wrapper - if flag(ci) - ghc-options: -Werror - default-language: Haskell2010 build-depends: base >= 4.15.0.0, diff --git a/clash-protocols/clash-protocols.cabal b/clash-protocols/clash-protocols.cabal index c797c3d7..4ff374ce 100644 --- a/clash-protocols/clash-protocols.cabal +++ b/clash-protocols/clash-protocols.cabal @@ -20,11 +20,6 @@ data-files: src/Protocols/Hedgehog.hs src/Protocols/Hedgehog/*.hs -flag ci - Description: Running on CI? Used to set fail-on-warning flag. - Manual: True - Default: False - flag large-tuples description: Generate instances for classes such as `Units` and `TaggedBundle` for tuples @@ -86,9 +81,6 @@ common common-options -- a no-specialize pragma to every function with a blackbox. -fno-worker-wrapper - if flag(ci) - ghc-options: -Werror - default-language: Haskell2010 build-depends: base >= 4.15.0.0, From 76a9d3383fea45acadbc716e886f4318f9dbc50a Mon Sep 17 00:00:00 2001 From: Peter Lebbing Date: Tue, 28 Jan 2025 12:48:01 +0100 Subject: [PATCH 2/5] Run CI for pushes to main The GitHub workflow file mentioned the master branch, but it's called main. Fixing this means we once again run CI on pushes to main. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb2937e9..6d48f168 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,10 @@ name: CI -# Trigger the workflow on all pull requests and pushes/merges to master branch +# Trigger the workflow on all pull requests and pushes/merges to main branch on: pull_request: push: - branches: [master] + branches: [main] concurrency: From 0bf660466d7711f4d2606e6a064ee99d0c3c3dcd Mon Sep 17 00:00:00 2001 From: Peter Lebbing Date: Tue, 28 Jan 2025 12:50:11 +0100 Subject: [PATCH 3/5] Check Haddock, sdist for both packages Only the Haddock for clash-protocols was checked for warnings, and v2-sdist was only run for clash-protocols. The omission of clash-protocols-base was probably an oversight when splitting the package in two (#104). --- .ci/build_docs.sh | 2 +- .ci/cabal.project.local.in | 1 + .ci/test_cabal.sh | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.ci/build_docs.sh b/.ci/build_docs.sh index 063845c8..816ec320 100755 --- a/.ci/build_docs.sh +++ b/.ci/build_docs.sh @@ -1,7 +1,7 @@ #!/bin/bash set -xeou pipefail -cabal v2-haddock clash-protocols |& tee haddock_log +cabal v2-haddock all |& tee haddock_log set +e diff --git a/.ci/cabal.project.local.in b/.ci/cabal.project.local.in index 428849db..4212f5a2 100644 --- a/.ci/cabal.project.local.in +++ b/.ci/cabal.project.local.in @@ -2,6 +2,7 @@ package * documentation: __CHECK_HADDOCK__ package clash-protocols-base + documentation: False ghc-options: -Werror package clash-protocols diff --git a/.ci/test_cabal.sh b/.ci/test_cabal.sh index 624c9ff5..998e9dc6 100755 --- a/.ci/test_cabal.sh +++ b/.ci/test_cabal.sh @@ -3,4 +3,4 @@ set -xeou pipefail cabal v2-run unittests --enable-tests cabal v2-run doctests --enable-tests -cabal v2-sdist clash-protocols +cabal v2-sdist all From 409db0a3a6ca58377cebf36c97512b3e38002a76 Mon Sep 17 00:00:00 2001 From: Peter Lebbing Date: Tue, 28 Jan 2025 12:53:04 +0100 Subject: [PATCH 4/5] Also create cache when CI fails This can drastically reduce CI running times when a PR is opened and it initially fails CI, as it no longer needs to rebuild dependencies on every new push. --- .github/workflows/ci.yml | 53 +++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d48f168..2491a8eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,14 @@ jobs: enable-stack: true stack-version: 'latest' - - name: Cache dependencies - uses: actions/cache@v4 + # Ask Stack to use system GHC instead of installing its own copy + - name: Use system GHC + run: | + stack config set system-ghc --global true + + - name: Restore cached dependencies + uses: actions/cache/restore@v4 + id: cache with: path: ~/.stack key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.ref }}-${{ github.sha }} @@ -37,10 +43,19 @@ jobs: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.ref }}- ${{ runner.os }}-ghc-${{ matrix.ghc }}- - # Ask Stack to use system GHC instead of installing its own copy - - name: Use system GHC - run: | - stack config set system-ghc --global true + - name: Install dependencies + run: stack build --test --only-dependencies + + # Cache dependencies already at this point, so that we do not have to + # rebuild them should the subsequent steps fail + - name: Save cached dependencies + uses: actions/cache/save@v4 + # Trying to save over an existing cache gives distracting + # "Warning: Cache save failed." since they are immutable + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + with: + path: ~/.stack + key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.ref }}-${{ github.sha }} - name: Test with Stack run: | @@ -95,8 +110,14 @@ jobs: cabal v2-freeze mv cabal.project.freeze frozen - - name: Cache dependencies - uses: actions/cache@v4 + - name: Restore cached dependencies + uses: actions/cache/restore@v4 + id: cache + env: + key: + ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ + steps.setup-haskell.outputs.cabal-version }}${{ + matrix.project-variant }} with: path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ matrix.clash }}-${{ hashFiles('frozen') }} @@ -105,9 +126,23 @@ jobs: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ matrix.clash }}- ${{ runner.os }}-ghc-${{ matrix.ghc }}- + - name: Install dependencies + run: cabal v2-build all --enable-tests --only-dependencies + + # Cache dependencies already at this point, so that we do not have to + # rebuild them should the subsequent steps fail + - name: Save cached dependencies + uses: actions/cache/save@v4 + # Trying to save over an existing cache gives distracting + # "Warning: Cache save failed." since they are immutable + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + with: + path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} + key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ matrix.clash }}-${{ hashFiles('frozen') }} + - name: Build run: | - cabal build all --enable-tests + cabal v2-build all --enable-tests - name: Test run: | From 84a5530b0d106b0cf7464713c33af2440ea5531a Mon Sep 17 00:00:00 2001 From: Peter Lebbing Date: Tue, 28 Jan 2025 13:06:19 +0100 Subject: [PATCH 5/5] Bump versions in Stack and CI to latest --- .github/workflows/ci.yml | 10 +++++----- stack.yaml | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2491a8eb..21ef9594 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,8 @@ jobs: - name: Setup Stack / GHC uses: haskell-actions/setup@v2 with: - ghc-version: '9.4.8' - cabal-version: '3.10.2.1' + ghc-version: '9.8.4' + cabal-version: '3.14.1.1' enable-stack: true stack-version: 'latest' @@ -71,7 +71,7 @@ jobs: clash: - "1.8.2" cabal: - - "3.10" + - "3.14.1.1" ghc: - "9.0.2" - "9.2.8" @@ -80,11 +80,11 @@ jobs: - "9.10.1" include: - check_haddock: "False" - - ghc: "9.6.4" + - ghc: "9.6.6" check_haddock: "True" os: "ubuntu-latest" clash: "1.8.2" - cabal: "3.10" + cabal: "3.14.1.1" env: check_haddock: ${{ matrix.check_haddock }} diff --git a/stack.yaml b/stack.yaml index f93ba15c..66bffc6c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-21.25 # ghc-9.4.8 +resolver: lts-23.6 # ghc-9.8.4 packages: - clash-protocols-base @@ -7,5 +7,7 @@ packages: extra-deps: - git: https://github.com/cchalmers/circuit-notation.git commit: 564769c52aa05b90f81bbc898b7af7087d96613d -- clash-prelude-1.8.1 -- clash-prelude-hedgehog-1.8.1 +- clash-prelude-1.8.2 +- clash-prelude-hedgehog-1.8.2 +- hedgehog-1.4@sha256:9860ab34ab3951d9515c71b777d8c9c47610aae7339933e17d26ad9a4afa5618,4754 +- tasty-1.4.3@sha256:5b53fded93109f6704b599c3498eb73c5b0ed1a975f1912dd98b4b19c61f8bc9,2653