|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [ master ] |
| 7 | + |
| 8 | +# Cancel any in-progress run on the same branch/PR when new commits arrive |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + cabal: |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + ghc: ['9.8','9.6','9.4','9.2','8.8'] |
| 19 | + # Base set of OSes |
| 20 | + os: [ubuntu-latest, macos-13, windows-latest] |
| 21 | + # Also build on Apple Silicon where supported (GHC >= 9.2) |
| 22 | + include: |
| 23 | + - os: macos-latest |
| 24 | + ghc: '9.8' |
| 25 | + - os: macos-latest |
| 26 | + ghc: '9.6' |
| 27 | + - os: macos-latest |
| 28 | + ghc: '9.4' |
| 29 | + - os: macos-latest |
| 30 | + ghc: '9.2' |
| 31 | + runs-on: ${{ matrix.os }} |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Setup Haskell |
| 37 | + uses: haskell/actions/setup@v2 |
| 38 | + with: |
| 39 | + ghc-version: ${{ matrix.ghc }} |
| 40 | + cabal-version: latest |
| 41 | + |
| 42 | + # Cache Cabal store + dist-newstyle (Unix) |
| 43 | + - name: Cache Cabal (Unix) |
| 44 | + if: runner.os != 'Windows' |
| 45 | + uses: actions/cache@v3 |
| 46 | + with: |
| 47 | + path: | |
| 48 | + ~/.cabal/store |
| 49 | + dist-newstyle |
| 50 | + key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/*.cabal','**/cabal.project*') }} |
| 51 | + restore-keys: | |
| 52 | + ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal- |
| 53 | +
|
| 54 | + # Cache Cabal store + dist-newstyle (Windows) |
| 55 | + - name: Cache Cabal (Windows) |
| 56 | + if: runner.os == 'Windows' |
| 57 | + uses: actions/cache@v3 |
| 58 | + with: |
| 59 | + path: | |
| 60 | + C:\Users\runneradmin\AppData\Roaming\cabal\store |
| 61 | + dist-newstyle |
| 62 | + key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/*.cabal','**/cabal.project*') }} |
| 63 | + restore-keys: | |
| 64 | + ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal- |
| 65 | +
|
| 66 | + - name: cabal update |
| 67 | + run: cabal update |
| 68 | + |
| 69 | + # Ensure solver includes tests/benches in all runs (fixes GHC 8.8 behaviour) |
| 70 | + - name: Enable tests/benchmarks (Unix) |
| 71 | + if: runner.os != 'Windows' |
| 72 | + run: | |
| 73 | + echo "tests: True" >> cabal.project.local |
| 74 | + echo "benchmarks: True" >> cabal.project.local |
| 75 | +
|
| 76 | + - name: Enable tests/benchmarks (Windows) |
| 77 | + if: runner.os == 'Windows' |
| 78 | + shell: powershell |
| 79 | + run: | |
| 80 | + "tests: True" | Out-File -FilePath cabal.project.local -Append -Encoding ascii |
| 81 | + "benchmarks: True" | Out-File -FilePath cabal.project.local -Append -Encoding ascii |
| 82 | +
|
| 83 | + - name: Build (deps) |
| 84 | + run: cabal build --only-dependencies --enable-tests --enable-benchmarks -j |
| 85 | + |
| 86 | + - name: Build |
| 87 | + run: cabal build all --enable-tests --enable-benchmarks -j |
| 88 | + |
| 89 | + - name: Test |
| 90 | + run: cabal test all --enable-tests --test-show-details=direct |
| 91 | + |
| 92 | + - name: Package checks |
| 93 | + run: cabal check |
| 94 | + |
| 95 | + - name: Make sdist |
| 96 | + run: cabal sdist |
| 97 | + |
| 98 | + - name: Upload sdist artifact |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + with: |
| 101 | + name: sdist-${{ matrix.os }}-ghc-${{ matrix.ghc }} |
| 102 | + path: dist-newstyle/sdist/*.tar.gz |
| 103 | + if-no-files-found: error |
| 104 | + |
| 105 | + # Build the produced sdist in a clean workspace to ensure the release tarball compiles |
| 106 | + sdist-build: |
| 107 | + needs: cabal |
| 108 | + strategy: |
| 109 | + fail-fast: false |
| 110 | + matrix: |
| 111 | + ghc: ['9.8','9.6','9.4','9.2','8.8'] |
| 112 | + runs-on: ubuntu-latest |
| 113 | + |
| 114 | + steps: |
| 115 | + - name: Setup Haskell |
| 116 | + uses: haskell/actions/setup@v2 |
| 117 | + with: |
| 118 | + ghc-version: ${{ matrix.ghc }} |
| 119 | + cabal-version: latest |
| 120 | + |
| 121 | + - name: Download sdist (from Linux job) |
| 122 | + uses: actions/download-artifact@v4 |
| 123 | + with: |
| 124 | + name: sdist-ubuntu-latest-ghc-${{ matrix.ghc }} |
| 125 | + # files land in ./ by default in v4 unless path is specified |
| 126 | + |
| 127 | + - name: Build sdist in clean dir |
| 128 | + shell: bash |
| 129 | + run: | |
| 130 | + set -euo pipefail |
| 131 | + TARBALL="$(ls ./*.tar.gz | head -n1)" |
| 132 | + BASENAME="$(basename "$TARBALL" .tar.gz)" |
| 133 | + mkdir -p work |
| 134 | + tar -xzf "$TARBALL" -C work |
| 135 | + cd "work/$BASENAME" |
| 136 | + echo "tests: True" >> cabal.project.local |
| 137 | + echo "benchmarks: True" >> cabal.project.local |
| 138 | + cabal update |
| 139 | + cabal build all --enable-tests -j |
| 140 | + cabal test all --enable-tests --test-show-details=direct |
0 commit comments