summaryrefslogtreecommitdiff
path: root/.github/workflows/build-all-versions.yml
blob: dfaaa32dfe9f3105ebe458a883acd698e02b4c1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Based on the template here: https://kodimensional.dev/github-actions
name: Build with stack and cabal

# Trigger the workflow on push or pull request, but only for the master branch
on:
  pull_request:
  push:
    branches: [master]

jobs:
  cabal:
    name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        cabal: ["latest"]
        ghc:
          - "8.6.5"
          - "8.8.3"
          - "8.10.7"
          - "9.6.7"
        exclude:
          - os: macos-latest
            ghc: 8.8.3
          - os: macos-latest
            ghc: 8.6.5
          - os: macos-latest
            ghc: 8.10.7
          - os: windows-latest
            ghc: 8.8.3
          - os: windows-latest
            ghc: 8.6.5
          - os: windows-latest
            ghc: 8.10.7

    steps:
    - uses: actions/checkout@v2
      if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'

    - uses: haskell-actions/setup@v2
      id: setup-haskell-cabal
      name: Setup Haskell
      with:
        ghc-version: ${{ matrix.ghc }}
        cabal-version: ${{ matrix.cabal }}

    - name: Freeze
      run: |
        cabal freeze

    - uses: actions/cache@v4
      name: Cache ~/.cabal/store
      with:
        path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
        key: ${{ runner.os }}-${{ matrix.ghc }}
        # key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}

    - name: Build
      run: |
        cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
        cabal build all

    # - name: Test
    #   run: |
    #     cabal test all

  stack:
    name: stack / ghc ${{ matrix.ghc }}
    runs-on: ${{ matrix.ghc == '7.10.3' && 'ubuntu-20.04' || 'ubuntu-latest' }}
    strategy:
      matrix:
        stack: ["latest"]
        ghc: ["8.4.4", "8.6.5", "8.8.4", "8.10.7", "9.0.2", "9.6.7"]

    steps:
    - uses: actions/checkout@v2
      if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'

    - uses: haskell-actions/setup@v2
      name: Setup Haskell Stack
      with:
        ghc-version: ${{ matrix.ghc }}
        stack-version: 'latest'
        enable-stack: true


    # Fix linker errrors on ghc-7.10.3 for ubuntu (see https://github.com/commercialhaskell/stack/blob/255cd830627870cdef34b5e54d670ef07882523e/doc/faq.md#i-get-strange-ld-errors-about-recompiling-with--fpic)
    - run: sed -i.bak 's/"C compiler link flags", "/&-no-pie /' /home/runner/.ghcup/ghc/7.10.3/lib/ghc-7.10.3/settings
      if: matrix.ghc == '7.10.3'

    - uses: actions/cache@v4
      name: Cache ~/.stack
      with:
        path: ~/.stack
        key: ${{ runner.os }}-${{ matrix.ghc }}-stack--${{ hashFiles(format('stack-ghc{0}', matrix.ghc)) }}
        restore-keys: |
             ${{ runner.os }}-${{ matrix.ghc }}-stack

    - name: Build
      run: |
        stack build --test --no-run-tests --system-ghc --stack-yaml stack-ghc${{ matrix.ghc }}.yaml

    - name: Test
      run: |
        stack test --system-ghc --stack-yaml stack-ghc${{ matrix.ghc }}.yaml