diff --git a/.github/actions/setup-haskell/action.yml b/.github/actions/setup-haskell/action.yml new file mode 100644 index 0000000..3a805e1 --- /dev/null +++ b/.github/actions/setup-haskell/action.yml @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: MPL-2.0 +name: Cached Haskell toolchain +description: Restore the installed compiler before configuring GHC and Cabal +inputs: + ghc-version: + description: Exact GHC version + required: true +outputs: + cabal-store: + description: Cabal dependency store + value: ${{ steps.haskell.outputs.cabal-store }} +runs: + using: composite + steps: + - name: Locate GHCup installation + if: runner.os != 'Windows' + id: root + shell: bash + run: | + mkdir -p "$HOME/.ghcup" + toolchain_root="$(cd "$HOME/.ghcup" && pwd -P)" + echo "path=$toolchain_root" >> "$GITHUB_OUTPUT" + - name: Restore installed compiler + if: runner.os != 'Windows' + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: | + ${{ steps.root.outputs.path }}/ghc/${{ inputs.ghc-version }} + ${{ steps.root.outputs.path }}/bin + ${{ steps.root.outputs.path }}/cabal/3.16.1.0 + key: toolchain-v2-${{ runner.os }}-${{ runner.arch }}-${{ env.ImageOS }}-${{ env.ImageVersion }}-ghc-${{ inputs.ghc-version }}-cabal-3.16.1.0 + - uses: haskell-actions/setup@7fd2bb5ca789761088fbc831406b2910e47e56f1 # v2 + id: haskell + with: + ghc-version: ${{ inputs.ghc-version }} + cabal-version: '3.16.1.0' + cabal-update: false diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml new file mode 100644 index 0000000..ced4c22 --- /dev/null +++ b/.github/workflows/compatibility.yml @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: MPL-2.0 +name: Full compatibility + +on: + schedule: + - cron: '0 3 * * 0' + workflow_dispatch: + +permissions: + contents: read + +jobs: + compatibility: + uses: ./.github/workflows/validate.yml + with: + full-matrix: true diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9e361da..181d7c1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,10 +24,9 @@ jobs: python-version: '3.12' cache: pip cache-dependency-path: requirements-docs.txt - - uses: haskell-actions/setup@7fd2bb5ca789761088fbc831406b2910e47e56f1 # v2 + - uses: ./.github/actions/setup-haskell with: ghc-version: '9.10.3' - cabal-version: '3.16.1.0' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: build-docs/cabal diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index a8dbc0a..bd9b604 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -8,12 +8,22 @@ on: pull_request: paths-ignore: ['docs/**', 'mkdocs.yml', 'requirements-docs.txt', 'tools/build_docs.py', 'README.md'] workflow_dispatch: + inputs: + full-matrix: + description: Run all compiler and portability combinations + type: boolean + default: true + workflow_call: + inputs: + full-matrix: + type: boolean + default: false permissions: contents: read concurrency: - group: validate-${{ github.event.pull_request.number || github.ref }} + group: validate-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: @@ -21,16 +31,14 @@ jobs: strategy: fail-fast: false matrix: - ghc: ['9.6.7', '9.10.3'] - buildtype: [debug, release] + include: ${{ fromJSON(inputs.full-matrix && '[{"ghc":"9.6.7","buildtype":"debug","primary":false},{"ghc":"9.6.7","buildtype":"release","primary":false},{"ghc":"9.10.3","buildtype":"debug","primary":false},{"ghc":"9.10.3","buildtype":"release","primary":true}]' || '[{"ghc":"9.10.3","buildtype":"debug","primary":true}]') }} runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - uses: haskell-actions/setup@7fd2bb5ca789761088fbc831406b2910e47e56f1 # v2 + - uses: ./.github/actions/setup-haskell id: haskell with: ghc-version: ${{ matrix.ghc }} - cabal-version: '3.16.1.0' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: | @@ -52,7 +60,7 @@ jobs: sudo apt-get install -y liblapacke-dev libopenblas-dev zlib1g-dev cmake ninja-build clang python -m pip install meson==1.8.5 numpy cffi - name: Wave compiler - if: matrix.ghc == '9.10.3' && matrix.buildtype == 'release' + if: matrix.primary env: GH_TOKEN: ${{ github.token }} run: | @@ -66,7 +74,7 @@ jobs: - name: Build and integration tests run: | wave_tests=auto - if [ '${{ matrix.ghc }}' = '9.10.3' ] && [ '${{ matrix.buildtype }}' = release ]; then + if [ '${{ matrix.primary }}' = true ]; then wave_tests=enabled fi meson setup build-ci --buildtype=${{ matrix.buildtype }} -Doffline=true -Dwerror=true -Dpython_bindings=enabled -Dwave_bindings="$wave_tests" -Dbenchmarks=true @@ -75,10 +83,10 @@ jobs: python tools/check_install.py build-ci python tools/check_abi.py build-ci/libhmath.so - name: Sanitized metadata and DLPack fuzzing - if: matrix.ghc == '9.10.3' && matrix.buildtype == 'release' + if: matrix.primary run: python tools/run_fuzz.py --runs=100000 --output=build-ci/fuzz.log - name: Native benchmark smoke - if: matrix.ghc == '9.10.3' && matrix.buildtype == 'release' + if: matrix.primary run: | python tools/benchmark.py --library=build-ci/libhmath.so --native=build-ci/hmath-native-benchmark --iterations=10 --output=build-ci/benchmark.json - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 @@ -95,11 +103,10 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - uses: haskell-actions/setup@7fd2bb5ca789761088fbc831406b2910e47e56f1 # v2 + - uses: ./.github/actions/setup-haskell id: haskell with: ghc-version: '9.10.3' - cabal-version: '3.16.1.0' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: | @@ -133,6 +140,7 @@ jobs: run: cabal bench hmath-criterion -fvalidation-frameworks -fcriterion-benchmarks --benchmark-options='--iters 1' portability-build: + if: inputs.full-matrix # Build probes do not establish full native platform support. strategy: fail-fast: false @@ -141,11 +149,10 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - uses: haskell-actions/setup@7fd2bb5ca789761088fbc831406b2910e47e56f1 # v2 + - uses: ./.github/actions/setup-haskell id: haskell with: ghc-version: '9.10.3' - cabal-version: '3.16.1.0' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: |