|
| 1 | +# Modified from https://kodimensional.dev/github-actions |
| 2 | + |
| 3 | +name: CI |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + types: [synchronize, opened, reopened] |
| 8 | + paths-ignore: |
| 9 | + - "**.md" |
| 10 | + - "*.sh" |
| 11 | + - "CODEOWNERS" |
| 12 | + - "CONTRIBUTORS" |
| 13 | + - "LICENSE" |
| 14 | + - "extra/**" |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - 'master' |
| 18 | + schedule: |
| 19 | + # Additionally run once per week (At 00:00 on Sunday) to maintain cache. |
| 20 | + - cron: '0 0 * * 0' |
| 21 | + |
| 22 | +jobs: |
| 23 | + cabal: |
| 24 | + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + os: [ubuntu-latest] |
| 30 | + cabal: ["3.8.1.0"] |
| 31 | + ghc: |
| 32 | + - "8.6.5" |
| 33 | + - "8.8.4" |
| 34 | + - "8.10.7" |
| 35 | + - "9.0.2" |
| 36 | + - "9.2.4" |
| 37 | + - "9.4.2" |
| 38 | + include: |
| 39 | + - { os: macOS-latest, ghc: "9.4.2", cabal: "3.8.1.0" } |
| 40 | + - { os: windows-latest, ghc: "9.4.2", cabal: "3.8.1.0" } |
| 41 | + |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v3 |
| 44 | + |
| 45 | + - name: Setup Haskell |
| 46 | + uses: haskell/actions/setup@v2.0 |
| 47 | + id: setup-haskell-cabal |
| 48 | + with: |
| 49 | + ghc-version: ${{ matrix.ghc }} |
| 50 | + cabal-version: ${{ matrix.cabal }} |
| 51 | + |
| 52 | + - name: Configure |
| 53 | + run: | |
| 54 | + cabal configure --enable-tests --enable-benchmarks --enable-documentation --test-show-details=direct --write-ghc-environment-files=always |
| 55 | +
|
| 56 | + - name: Freeze |
| 57 | + run: | |
| 58 | + cabal freeze |
| 59 | +
|
| 60 | + - uses: actions/cache@v3 |
| 61 | + name: Cache |
| 62 | + with: |
| 63 | + path: | |
| 64 | + ${{ steps.setup-haskell-cabal.outputs.cabal-store }} |
| 65 | + dist-newstyle |
| 66 | + key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-${{ hashFiles('cabal.project.freeze') }} |
| 67 | + restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-cabal- |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: | |
| 71 | + cabal build all --only-dependencies |
| 72 | +
|
| 73 | + - name: Build |
| 74 | + run: | |
| 75 | + cabal build all |
| 76 | +
|
| 77 | + - name: Test |
| 78 | + run: | |
| 79 | + cabal test all |
| 80 | +
|
| 81 | + - name: Documentation |
| 82 | + run: | |
| 83 | + cabal haddock |
| 84 | +
|
| 85 | + stack: |
| 86 | + name: stack / ghc ${{ matrix.ghc }} |
| 87 | + runs-on: ubuntu-latest |
| 88 | + |
| 89 | + strategy: |
| 90 | + matrix: |
| 91 | + include: |
| 92 | + # GHC version must match https://www.stackage.org/nightly |
| 93 | + - stack: "2.9.1" |
| 94 | + ghc: "9.2.4" |
| 95 | + |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v3 |
| 98 | + |
| 99 | + - uses: haskell/actions/setup@v2.0 |
| 100 | + name: Setup Haskell Stack |
| 101 | + with: |
| 102 | + ghc-version: ${{ matrix.ghc }} |
| 103 | + stack-version: ${{ matrix.stack }} |
| 104 | + |
| 105 | + - name: Configure |
| 106 | + run: | |
| 107 | + cat <<EOF > stack.yaml |
| 108 | + packages: |
| 109 | + - '.' |
| 110 | + resolver: nightly-2022-11-08 |
| 111 | + EOF |
| 112 | + stack config set system-ghc true --global |
| 113 | + stack config set resolver nightly |
| 114 | + stack ls dependencies > ci-stack-depends |
| 115 | +
|
| 116 | + - uses: actions/cache@v3 |
| 117 | + name: Cache |
| 118 | + with: |
| 119 | + path: | |
| 120 | + ~/.stack |
| 121 | + stack-work |
| 122 | + key: ${{ runner.os }}-${{ matrix.ghc }}-stack-${{ hashFiles('ci-stack-depends') }} |
| 123 | + restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-stack- |
| 124 | + |
| 125 | + - name: Install dependencies |
| 126 | + run: | |
| 127 | + stack build --test --bench --no-run-tests --no-run-benchmarks --only-dependencies |
| 128 | +
|
| 129 | + - name: Build |
| 130 | + run: | |
| 131 | + stack build --test --bench --no-run-tests --no-run-benchmarks |
| 132 | +
|
| 133 | + - name: Test |
| 134 | + run: | |
| 135 | + stack test |
0 commit comments