|
| 1 | +name: build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [master] |
| 5 | + pull_request: |
| 6 | + branches: [master] |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + os: [ubuntu-latest] |
| 16 | + ghc-version: ['9.6.6'] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set up GHC ${{ matrix.ghc-version }} |
| 22 | + uses: haskell-actions/setup@v2 |
| 23 | + id: setup |
| 24 | + with: |
| 25 | + ghc-version: ${{ matrix.ghc-version }} |
| 26 | + cabal-version: '3.14.1.1' |
| 27 | + cabal-update: true |
| 28 | + |
| 29 | + - name: Extract New-Versions git trailer from Renovate |
| 30 | + run: | |
| 31 | + if [ ! -f cabal.project ] |
| 32 | + then echo 'packages: .' > cabal.project |
| 33 | + fi |
| 34 | + for constraint in $(git log "--format=%(trailers:key=New-Versions,valueonly=true)" -1) |
| 35 | + do echo "constraints: $constraint" >> cabal.project |
| 36 | + done |
| 37 | +
|
| 38 | + - name: Show cabal.project |
| 39 | + run: | |
| 40 | + cat cabal.project |
| 41 | +
|
| 42 | + - name: Configure the build |
| 43 | + run: | |
| 44 | + cabal configure --enable-tests --enable-benchmarks --disable-documentation |
| 45 | + cabal build all --dry-run |
| 46 | + # The last step generates dist-newstyle/cache/plan.json for the cache key. |
| 47 | + |
| 48 | + - name: Restore cached dependencies |
| 49 | + uses: actions/cache/restore@v4 |
| 50 | + id: cache |
| 51 | + env: |
| 52 | + key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} |
| 53 | + with: |
| 54 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 55 | + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} |
| 56 | + restore-keys: ${{ env.key }}- |
| 57 | + |
| 58 | + - name: Install dependencies |
| 59 | + # If we had an exact cache hit, the dependencies will be up to date. |
| 60 | + if: steps.cache.outputs.cache-hit != 'true' |
| 61 | + run: cabal build all --only-dependencies |
| 62 | + |
| 63 | + # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. |
| 64 | + - name: Save cached dependencies |
| 65 | + uses: actions/cache/save@v4 |
| 66 | + # If we had an exact cache hit, trying to save the cache would error because of key clash. |
| 67 | + if: steps.cache.outputs.cache-hit != 'true' |
| 68 | + with: |
| 69 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 70 | + key: ${{ steps.cache.outputs.cache-primary-key }} |
| 71 | + |
| 72 | + - name: Build |
| 73 | + run: cabal build all |
| 74 | + |
| 75 | + - name: Run tests |
| 76 | + run: cabal test all |
| 77 | + |
| 78 | + - name: Check cabal file |
| 79 | + run: cabal check |
| 80 | + |
| 81 | + - name: Build documentation |
| 82 | + run: |
| 83 | + cabal haddock all --disable-documentation |
| 84 | + # --disable-documentation disables building documentation for dependencies. |
| 85 | + # The package's own documentation is still built, |
| 86 | + # yet contains no links to the documentation of the dependencies. |
0 commit comments