|
| 1 | +name: stack |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +defaults: |
| 11 | + run: |
| 12 | + shell: bash |
| 13 | + |
| 14 | +jobs: |
| 15 | + stack: |
| 16 | + name: Stack ${{ matrix.ghc }} on ${{ matrix.os }} |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + timeout-minutes: 60 |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + |
| 24 | + - os: macos-latest |
| 25 | + ghc: 9.8.2 |
| 26 | + resolver: nightly-2024-06-22 |
| 27 | + - os: macos-latest |
| 28 | + ghc: 9.2.8 |
| 29 | + resolver: lts-20.26 |
| 30 | + # GHC < 9.2 not supported on macos-14 ARM runner |
| 31 | + # https://github.com/haskell-actions/setup/issues/77 |
| 32 | + |
| 33 | + - os: windows-latest |
| 34 | + ghc: 9.8.2 |
| 35 | + resolver: nightly-2024-06-22 |
| 36 | + - os: windows-latest |
| 37 | + ghc: 8.4.4 |
| 38 | + resolver: lts-12.26 |
| 39 | + |
| 40 | + - os: ubuntu-latest |
| 41 | + ghc: 9.8.2 |
| 42 | + resolver: nightly-2024-06-22 |
| 43 | + - os: ubuntu-latest |
| 44 | + ghc: 9.6.5 |
| 45 | + resolver: lts-22.26 |
| 46 | + - os: ubuntu-latest |
| 47 | + ghc: 9.4.8 |
| 48 | + resolver: lts-21.25 |
| 49 | + - os: ubuntu-latest |
| 50 | + ghc: 9.2.8 |
| 51 | + resolver: lts-20.26 |
| 52 | + - os: ubuntu-latest |
| 53 | + ghc: 9.0.2 |
| 54 | + resolver: lts-19.33 |
| 55 | + - os: ubuntu-latest |
| 56 | + ghc: 8.10.7 |
| 57 | + resolver: lts-18.28 |
| 58 | + - os: ubuntu-latest |
| 59 | + ghc: 8.8.4 |
| 60 | + resolver: lts-16.31 |
| 61 | + - os: ubuntu-latest |
| 62 | + ghc: 8.6.5 |
| 63 | + resolver: lts-14.27 |
| 64 | + - os: ubuntu-latest |
| 65 | + ghc: 8.4.4 |
| 66 | + resolver: lts-12.26 |
| 67 | + |
| 68 | + # Tests need directory-1.3.1.0 which entered LTS for GHC 8.4. |
| 69 | + # - os: ubuntu-latest |
| 70 | + # ghc: 8.2.2 |
| 71 | + # resolver: lts-11.22 |
| 72 | + # - os: ubuntu-latest |
| 73 | + # ghc: 8.0.2 |
| 74 | + # resolver: lts-9.21 |
| 75 | + |
| 76 | + env: |
| 77 | + stack: 'stack --system-ghc --no-install-ghc' |
| 78 | + |
| 79 | + steps: |
| 80 | + |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: Install GHC and stack with haskell-actions/setup |
| 84 | + uses: haskell-actions/setup@v2 |
| 85 | + id: setup |
| 86 | + with: |
| 87 | + ghc-version: ${{ matrix.ghc }} |
| 88 | + enable-stack: true |
| 89 | + cabal-update: false |
| 90 | + |
| 91 | + - name: Create stack.yaml |
| 92 | + run: | |
| 93 | + cat > stack.yaml <<EOF |
| 94 | + resolver: ${{ matrix.resolver }} |
| 95 | + compiler: ghc-${{ matrix.ghc }} |
| 96 | + packages: [.] |
| 97 | + EOF |
| 98 | +
|
| 99 | + # According to https://github.com/commercialhaskell/stack/issues/5754#issuecomment-1696156869 |
| 100 | + # not all of ~/.stack should be cached, |
| 101 | + # only the index (pantry) and the dependencies (sqlite3+snapshots). |
| 102 | + |
| 103 | + ## Pantry |
| 104 | + ######################################################################## |
| 105 | + |
| 106 | + - name: Restore cached stack pantry |
| 107 | + uses: actions/cache/restore@v4 |
| 108 | + id: cache-pantry |
| 109 | + with: |
| 110 | + path: ${{ steps.setup.outputs.stack-root }}/pantry |
| 111 | + key: ${{ runner.os }}-stack-${{ steps.setup.outputs.stack-version }}-pantry-resolver-${{ matrix.resolver }} |
| 112 | + # No fall-back keys here! |
| 113 | + |
| 114 | + - name: Stack update |
| 115 | + if: steps.cache-pantry.outputs.cache-hit != 'true' |
| 116 | + run: ${{ env.stack }} update |
| 117 | + |
| 118 | + - name: Cache stack pantry |
| 119 | + if: steps.cache-pantry.outputs.cache-hit != 'true' |
| 120 | + uses: actions/cache/save@v4 |
| 121 | + with: |
| 122 | + path: ${{ steps.setup.outputs.stack-root }}/pantry |
| 123 | + key: ${{ steps.cache-pantry.outputs.cache-primary-key }} |
| 124 | + |
| 125 | + ## Dependencies |
| 126 | + ######################################################################## |
| 127 | + |
| 128 | + - name: Stack build plan |
| 129 | + run: ${{ env.stack }} test --dry-run > '.build-plan.txt' |
| 130 | + |
| 131 | + - name: Restore cached dependencies |
| 132 | + uses: actions/cache/restore@v4 |
| 133 | + id: cache-deps |
| 134 | + with: |
| 135 | + path: | |
| 136 | + ${{ steps.setup.outputs.stack-root }}/stack.sqlite3 |
| 137 | + ${{ steps.setup.outputs.stack-root }}/snapshots |
| 138 | + key: ${{ runner.os }}-stack-${{ steps.setup.outputs.stack-version }}-ghc-${{ steps.setup.outputs.ghc-version }}-resolver-${{ matrix.resolver }}-plan-${{ hashfiles('.build-plan.txt') }} |
| 139 | + restore-keys: | |
| 140 | + ${{ runner.os }}-stack-${{ steps.setup.outputs.stack-version }}-ghc-${{ steps.setup.outputs.ghc-version }}-resolver-${{ matrix.resolver }}- |
| 141 | + ${{ runner.os }}-stack-${{ steps.setup.outputs.stack-version }}-ghc-${{ steps.setup.outputs.ghc-version }}- |
| 142 | +
|
| 143 | + - name: Build dependencies |
| 144 | + if: steps.cache-deps.outputs.cache-hit != 'true' |
| 145 | + run: ${{ env.stack }} test --dependencies-only |
| 146 | + |
| 147 | + - name: Cache dependencies |
| 148 | + if: steps.cache-deps.outputs.cache-hit != 'true' |
| 149 | + uses: actions/cache/save@v4 |
| 150 | + with: |
| 151 | + path: | |
| 152 | + ${{ steps.setup.outputs.stack-root }}/stack.sqlite3 |
| 153 | + ${{ steps.setup.outputs.stack-root }}/snapshots |
| 154 | + key: ${{ steps.cache-deps.outputs.cache-primary-key }} |
| 155 | + |
| 156 | + ## Build and test STMonadTrans |
| 157 | + ######################################################################## |
| 158 | + |
| 159 | + - name: Build w/ tests |
| 160 | + run: ${{ env.stack }} test --no-run-tests |
| 161 | + |
| 162 | + - name: Run tests |
| 163 | + run: ${{ env.stack }} test |
0 commit comments