Build and test #120
Workflow file for this run
This file contains hidden or 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: Build and test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| merge_group: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| setup-matrix: | |
| name: Setup matrix | |
| runs-on: 'ubuntu-latest' | |
| timeout-minutes: 5 | |
| outputs: | |
| matrix: ${{ steps.setup-matrix.outputs.matrix }} | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: 🛠️ Setup matrix (PR) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: | | |
| { echo 'MATRIX_COMBINATIONS<<EOF' | |
| echo '{"runner": "ubuntu-latest", "ghc": "9.4", "llvm": "15"},' | |
| echo '{"runner": "macos-latest" , "ghc": "9.4", "llvm": "14"},' | |
| echo EOF | |
| } >> "$GITHUB_ENV" | |
| - name: 🛠️ Setup matrix (MQ, push to main) | |
| if: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| { echo 'MATRIX_COMBINATIONS<<EOF' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "15"},' | |
| echo '{"runner": "macos-latest" , "ghc": "9.4", "llvm": "14"},' | |
| # Vary LLVM version from 14 to 20. | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "14"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "16"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "18"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "20"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "21"},' | |
| # Vary GHC version from 9.2 to 9.14. | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.2", "llvm": "14"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.6", "llvm": "14"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.8", "llvm": "14"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.10", "llvm": "14"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.12", "llvm": "14"},' | |
| echo '{"runner": "ubuntu-latest" , "ghc": "9.14", "llvm": "14"},' | |
| echo EOF | |
| } >> "$GITHUB_ENV" | |
| - name: 🛠️ Setup matrix | |
| id: setup-matrix | |
| run: | | |
| echo $MATRIX_COMBINATIONS | |
| MATRIX="{\"include\":[$MATRIX_COMBINATIONS]}" | |
| echo $MATRIX | |
| { | |
| echo 'MATRIX<<EOF' | |
| echo "$MATRIX" | |
| echo EOF | |
| } >> "$GITHUB_OUTPUT" | |
| check-success: | |
| name: Check success | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| needs: | |
| - build-and-test | |
| defaults: | |
| run: | |
| shell: bash | |
| if: ${{ !cancelled() }} | |
| steps: | |
| - name: 🧪 Report failure | |
| if: ${{ needs.build-and-test.result == 'failure' }} | |
| run: | | |
| echo "Some jobs failed" | |
| exit 1 | |
| - name: 🧪 Report success | |
| if: ${{ needs.build-and-test.result == 'success' }} | |
| run: | | |
| echo "All jobs succeeded" | |
| exit 0 | |
| build-and-test: | |
| name: Run (${{ matrix.runner }}, GHC${{ matrix.ghc }}, LLVM${{matrix.llvm }}) | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 45 | |
| needs: | |
| - setup-matrix | |
| strategy: | |
| matrix: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }} | |
| fail-fast: false | |
| env: | |
| # Increment this number to reset caches. | |
| # | |
| # Caches of the cabal store generally grow in size: new packages are | |
| # added, but never removed. Unless we start with a fresh cabal store once | |
| # in a while. The cache-reset-number is part of the cache key, and if it | |
| # is incremented, then the "Restor cache" step fails to restore a cache, | |
| # meaning we will start with an empty cabal store that we will then save a | |
| # new cache for. | |
| cache-reset-number: 0 | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: 🛠️ Set git to use LF | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| - name: 🛠️ Fix git on macOS (prioritize system git over Homebrew) | |
| if: runner.os == 'macOS' | |
| run: | | |
| echo "/usr/bin" >> "$GITHUB_PATH" | |
| - name: 📥 Checkout | |
| uses: actions/checkout@v6 | |
| - name: (Debug) Check disk usage (init) | |
| run: | | |
| echo "--- Disk usage ---" | |
| df -h | |
| echo "--- Home directory size ---" | |
| du -sh $HOME | |
| - name: 🛠️ Setup Haskell | |
| id: setup-haskell | |
| uses: haskell-actions/setup@v2 | |
| with: | |
| ghc-version: ${{ matrix.ghc }} | |
| cabal-version: 3.16 | |
| - name: 🧪 Debug (Haskell) | |
| run: | | |
| echo '### ghc --version' | |
| ghc --version | |
| echo '### ghc-pkg list' | |
| ghc-pkg list | |
| echo '### ghc --info' | |
| ghc --info | |
| - name: 🛠️ Install LLVM/Clang | |
| uses: ./.github/actions/setup-llvm | |
| with: | |
| version: ${{ matrix.llvm }} | |
| - name: (Debug) Check disk usage (after GHC and LLVM install) | |
| run: | | |
| echo "--- Disk usage ---" | |
| df -h | |
| echo "--- Home directory size ---" | |
| du -sh $HOME | |
| - name: 🛠️ Configure | |
| run: | | |
| cabal configure \ | |
| --enable-tests \ | |
| --enable-benchmarks \ | |
| --disable-documentation \ | |
| --ghc-options="-Werror" | |
| cat cabal.project.local | |
| - name: 💾 Generate Cabal plan | |
| run: cabal build all --dry-run | |
| - name: 💾 Restore cache | |
| id: cache-cabal-restore | |
| uses: actions/cache/restore@v5 | |
| env: | |
| key: build-and-test-${{ env.cache-reset-number }}-${{ matrix.runner }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}-llvm-${{ matrix.llvm }} | |
| with: | |
| path: ${{ steps.setup-haskell.outputs.cabal-store }} | |
| key: ${{ env.key }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }} | |
| restore-keys: ${{ env.key }}- | |
| - name: 🛠️ Build Cabal dependencies | |
| run: cabal build all --only-dependencies | |
| # Only save a new cache if it does not exist yet | |
| - name: 💾 Save Cabal dependencies | |
| uses: actions/cache/save@v5 | |
| if: ${{ steps.cache-cabal-restore.outputs.cache-hit != 'true' }} | |
| with: | |
| path: ${{ steps.setup-haskell.outputs.cabal-store }} | |
| key: ${{ steps.cache-cabal-restore.outputs.cache-primary-key }} | |
| - name: 🏗️ Build | |
| run: cabal build all | |
| - name: (Debug) Check disk usage (after build) | |
| run: | | |
| echo "--- Disk usage ---" | |
| df -h | |
| echo "--- Home directory size ---" | |
| du -sh $HOME | |
| - name: 🧪 Test | |
| run: cabal test all --test-show-details=direct |