|
| 1 | +name: Haskell-CI |
| 2 | +permissions: |
| 3 | + contents: read |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - 'main' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - 'main' |
| 12 | + schedule: |
| 13 | + - cron: 0 0 * * * |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + nightly: |
| 17 | + description: Run with the same settings as a nightly build |
| 18 | + type: boolean |
| 19 | + default: false |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + check-formatting: |
| 27 | + name: Check formatting |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + - name: install fourmolu |
| 32 | + run: | |
| 33 | + wget https://github.com/fourmolu/fourmolu/releases/download/v0.17.0.0/fourmolu-0.17.0.0-linux-x86_64 |
| 34 | + chmod +x fourmolu-0.17.0.0-linux-x86_64 |
| 35 | + mv fourmolu-0.17.0.0-linux-x86_64 fourmolu |
| 36 | + - run: ./fourmolu -c . |
| 37 | + |
| 38 | + test-with-cabal: |
| 39 | + name: Haskell-CI - Linux - ${{ matrix.ghc-version }} |
| 40 | + |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + ghc-version: [latest, 9.12, "9.10", 9.8, 9.6, 9.4, 9.2, 9.0, "8.10"] |
| 44 | + os: [ubuntu-latest] |
| 45 | + fail-fast: false |
| 46 | + |
| 47 | + runs-on: ${{ matrix.os }} |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Set NIGHTLY environment variable if the job was triggered by the scheduler |
| 51 | + if: "${{ github.event_name == 'schedule' |
| 52 | + || contains(github.event.pull_request.title, 'nightly') |
| 53 | + || contains(github.event.pull_request.title, 'NIGHTLY') |
| 54 | + || github.event_name == 'workflow_dispatch' && github.event.inputs.nightly }}" |
| 55 | + run: | |
| 56 | + echo "NIGHTLY=true" >> $GITHUB_ENV |
| 57 | +
|
| 58 | + - uses: actions/checkout@v4 |
| 59 | + - uses: haskell-actions/setup@v2 |
| 60 | + with: |
| 61 | + ghc-version: ${{matrix.ghc-version}} |
| 62 | + - uses: actions/cache/restore@v4 |
| 63 | + with: |
| 64 | + key: ${{ matrix.os }}-${{ matrix.ghc-version }}-${{ github.sha }} |
| 65 | + path: ~/.cabal/store |
| 66 | + restore-keys: ${{ matrix.os }}-${{ matrix.ghc-version }}- |
| 67 | + - run: cabal build all |
| 68 | + - run: cabal test all |
| 69 | + |
| 70 | + - name: Documentation (Haddock) |
| 71 | + if: "${{ matrix.ghc-version == 'latest' }}" |
| 72 | + run: | |
| 73 | + .github/workflows/ci-haddock.sh |
| 74 | +
|
| 75 | + - name: Upload Documentation |
| 76 | + if: "${{ matrix.ghc-version == 'latest' }}" |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + with: |
| 79 | + name: haddocks |
| 80 | + path: ./docs |
| 81 | + |
| 82 | + - uses: actions/cache/save@v4 |
| 83 | + with: |
| 84 | + key: ${{ matrix.os }}-${{ matrix.ghc-version }}-${{ github.sha }} |
| 85 | + path: ~/.cabal/store |
| 86 | + |
| 87 | + documentation: |
| 88 | + name: Documentation |
| 89 | + needs: [test-with-cabal] |
| 90 | + runs-on: ubuntu-latest |
| 91 | + steps: |
| 92 | + - name: Download generated documentation |
| 93 | + uses: actions/download-artifact@v4 |
| 94 | + with: |
| 95 | + name: haddocks |
| 96 | + path: docs |
| 97 | + |
| 98 | + - name: Publish Documentation |
| 99 | + if: github.event_name == 'push' |
| 100 | + uses: peaceiris/actions-gh-pages@v3 |
| 101 | + with: |
| 102 | + github_token: ${{ secrets.GITHUB_TOKEN || github.token }} |
| 103 | + publish_dir: docs/ |
| 104 | + enable_jekyll: true |
| 105 | + force_orphan: true |
0 commit comments