|
7 | 7 | push: |
8 | 8 | branches: [ "master" ] |
9 | 9 |
|
| 10 | +defaults: |
| 11 | + run: |
| 12 | + shell: bash |
| 13 | + |
10 | 14 | jobs: |
11 | | - ghc: |
| 15 | + # this action can extract the Cabal 'tested-with' field |
| 16 | + tested-with-matrix: |
| 17 | + name: "Generate matrix from cabal" |
| 18 | + outputs: |
| 19 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Extract the tested GHC versions |
| 23 | + id: set-matrix |
| 24 | + uses: kleidukos/get-tested@v0.1.9.1 |
| 25 | + with: |
| 26 | + cabal-file: mtl.cabal |
| 27 | + ubuntu-version: "latest" |
| 28 | + macos-version: "latest" |
| 29 | + windows-version: "latest" |
| 30 | + version: 0.1.9.1 |
| 31 | + |
| 32 | + # workaround for https://github.com/Kleidukos/get-tested/issues/93 |
| 33 | + # we only want the GHC versions, not the whole matrix |
| 34 | + tested-with-ghcs: |
| 35 | + name: "Extract GHC versions from tested-with-matrix" |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: ["tested-with-matrix"] |
| 38 | + outputs: |
| 39 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Generate output |
| 43 | + id: set-matrix |
| 44 | + run: | |
| 45 | + set -euo pipefail |
| 46 | +
|
| 47 | + # input might be something like: |
| 48 | + # {"include":[{"ghc":"8.10","newest":false,"oldest":true ,"os":"macos-latest"} |
| 49 | + # ,{"ghc":"9.2" ,"newest":false,"oldest":false,"os":"macos-latest"} |
| 50 | + # ]} |
| 51 | + # and we want: |
| 52 | + # ["8.10","9.2"] |
| 53 | + ghc_versions=$(echo '${{ needs.tested-with-matrix.outputs.matrix }}' | jq -c -r '[.include[].ghc] | unique') |
| 54 | +
|
| 55 | + echo "${ghc_versions}" |
| 56 | + echo matrix="${ghc_versions}" >> "$GITHUB_OUTPUT" |
| 57 | +
|
| 58 | + lts-matrix: |
| 59 | + name: "Generate matrix of last n Stackage LTSes" |
| 60 | + runs-on: ubuntu-latest |
| 61 | + outputs: |
| 62 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Generate output |
| 66 | + id: set-matrix |
| 67 | + run: | |
| 68 | + STACK_TEST_NUM=4 |
| 69 | + set -euo pipefail |
| 70 | +
|
| 71 | + # the input is something like this: |
| 72 | + # {"lts":"lts-24.36", "lts-0":"lts-0.7", "lts-1":"lts-1.15", "nightly":"nightly-2026-04-10"} |
| 73 | + # and we want the last n LTS, sorted and deduplicated without nightlies: |
| 74 | + # ["lts-0.7", "lts-1.15", "lts-24.36"] |
| 75 | + lts_versions=$(curl -s https://www.stackage.org/download/snapshots.json | jq -c -r --arg n "$STACK_TEST_NUM" ' |
| 76 | + [.[] | select(startswith("nightly") | not)] |
| 77 | + | unique |
| 78 | + | sort_by(split("-")[1] | split(".") | map(tonumber)) |
| 79 | + | .[-(($n | tonumber)):] |
| 80 | + ') |
| 81 | + echo "${lts_versions}" |
| 82 | + echo matrix="${lts_versions}" >> "$GITHUB_OUTPUT" |
| 83 | +
|
| 84 | + cabal: |
12 | 85 | name: "GHC ${{ matrix.ghc }} on ${{ matrix.os }}" |
13 | 86 | runs-on: ${{ matrix.os }} |
| 87 | + needs: ["tested-with-ghcs"] |
14 | 88 | strategy: |
15 | 89 | matrix: |
16 | 90 | os: [ubuntu-latest, macos-latest, windows-latest] |
17 | | - ghc: ['8.10', '9.2', '9.8', '9.10', '9.12'] |
| 91 | + ghc: ${{ fromJSON(needs.tested-with-ghcs.outputs.matrix) }} |
18 | 92 | exclude: |
19 | 93 | - os: macos-latest |
20 | 94 | ghc: '8.10' # ghc-8.10 does not support ARM |
21 | 95 | fail-fast: false |
22 | 96 | steps: |
23 | 97 | - name: Checkout base repo |
24 | | - uses: actions/checkout@v4 |
| 98 | + uses: actions/checkout@v6 |
25 | 99 |
|
26 | 100 | - name: Set up Haskell |
27 | 101 | id: setup-haskell |
28 | | - uses: haskell-actions/setup@v2 |
| 102 | + uses: haskell/ghcup-setup@v1 |
| 103 | + with: |
| 104 | + ghc: ${{ matrix.ghc }} |
| 105 | + cabal: 'latest' |
| 106 | + |
| 107 | + - name: Cabal update |
| 108 | + run: | |
| 109 | + cabal update |
| 110 | +
|
| 111 | + - name: Prepare build dir |
| 112 | + run: | |
| 113 | + cabal sdist -z -o . |
| 114 | + cabal get mtl-*.tar.gz |
| 115 | + rm -f cabal.project |
| 116 | +
|
| 117 | + - name: Build |
| 118 | + run: | |
| 119 | + cd mtl-*/ |
| 120 | + cabal build --ghc-options='-Werror' all |
| 121 | +
|
| 122 | + - uses: actions/upload-artifact@v7 |
29 | 123 | with: |
30 | | - ghc-version: ${{ matrix.ghc }} |
31 | | - cabal-version: 'latest' |
| 124 | + name: ${{ matrix.os }}-${{ matrix.ghc }}-plan.json |
| 125 | + path: mtl-*/dist-newstyle/cache/plan.json |
| 126 | + |
| 127 | +# - name: Test |
| 128 | +# run: | |
| 129 | +# cabal --enable-tests --test-show-details=direct all |
32 | 130 |
|
33 | | - - name: Configure |
34 | | - run: cabal new-configure |
| 131 | + - name: Haddock |
| 132 | + run: | |
| 133 | + cd mtl-*/ |
| 134 | + cabal haddock all |
35 | 135 |
|
36 | | - - name: Freeze |
37 | | - run: cabal freeze |
| 136 | + - name: Cabal check |
| 137 | + run: | |
| 138 | + cd mtl-*/ |
| 139 | + cabal check |
38 | 140 |
|
39 | | - - name: Cache |
40 | | - uses: actions/cache@v4 |
| 141 | + stack: |
| 142 | + name: "LTS ${{ matrix.lts }} on ${{ matrix.os }}" |
| 143 | + runs-on: ${{ matrix.os }} |
| 144 | + needs: ["lts-matrix"] |
| 145 | + strategy: |
| 146 | + matrix: |
| 147 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 148 | + lts: ${{ fromJSON(needs.lts-matrix.outputs.matrix) }} |
| 149 | + fail-fast: false |
| 150 | + steps: |
| 151 | + - name: Checkout base repo |
| 152 | + uses: actions/checkout@v6 |
| 153 | + |
| 154 | + - name: Set up Haskell |
| 155 | + id: setup-haskell |
| 156 | + uses: haskell/ghcup-setup@v1 |
41 | 157 | with: |
42 | | - path: ${{ steps.setup-haskell.outputs.cabal-store }} |
43 | | - key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} |
44 | | - restore-keys: ${{ runner.os }}-${{ matrix.ghc }}- |
| 158 | + stack: 'latest' |
| 159 | + stack-hook: false |
45 | 160 |
|
46 | 161 | - name: Build |
47 | | - run: cabal build |
| 162 | + run: | |
| 163 | + [ ! -e stack.yaml ] |
| 164 | + # create stack.yaml |
| 165 | + stack init --resolver=${{ matrix.lts }} |
| 166 | + # build |
| 167 | + stack build |
48 | 168 |
|
49 | 169 | mhs: |
| 170 | + name: "MicroHS ${{ matrix.mhs }}" |
50 | 171 | runs-on: ubuntu-latest |
| 172 | + strategy: |
| 173 | + matrix: |
| 174 | + mhs: ["0.15.4.0"] |
| 175 | + fail-fast: false |
51 | 176 | steps: |
52 | 177 | - name: checkout mhs repo |
53 | | - uses: actions/checkout@v4 |
| 178 | + uses: actions/checkout@v6 |
54 | 179 | with: |
55 | 180 | repository: augustss/MicroHs |
56 | | - ref: v0.14.15.0 |
| 181 | + ref: v${{ matrix.mhs }} |
57 | 182 | path: mhs |
58 | 183 |
|
59 | 184 | - name: make and install mhs |
60 | 185 | run: | |
61 | 186 | cd mhs |
62 | 187 | make minstall |
63 | | -
|
64 | | - - name: checkout transformers repo |
65 | | - uses: actions/checkout@v4 |
66 | | - with: |
67 | | - repository: augustss/transformers |
68 | | - path: transformers |
69 | | - |
70 | | - - name: compile and install transformers package |
71 | | - run: | |
72 | | - PATH="$HOME/.mcabal/bin:$PATH" |
73 | | - cd transformers |
74 | | - mcabal install |
| 188 | + echo "$HOME/.mcabal/bin" >> "$GITHUB_PATH" |
75 | 189 |
|
76 | 190 | - name: checkout mtl repo |
77 | | - uses: actions/checkout@v4 |
| 191 | + uses: actions/checkout@v6 |
78 | 192 | with: |
79 | 193 | path: mtl |
80 | 194 |
|
81 | 195 | - name: compile and install mtl package |
82 | 196 | run: | |
83 | | - PATH="$HOME/.mcabal/bin:$PATH" |
84 | 197 | cd mtl |
85 | | - mcabal install |
| 198 | + mcabal -r install |
0 commit comments