|
| 1 | +name: Haskell CI |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + merge_group: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + - "release/*" |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + ghc: ["9.6", "9.12"] |
| 23 | + os: [windows-latest] |
| 24 | + |
| 25 | + env: |
| 26 | + # Modify this value to "invalidate" all cabal caches. |
| 27 | + CABAL_CACHE_VERSION: "2024-05-22" |
| 28 | + # Modify this value to "invalidate" the cabal store cache only. |
| 29 | + CACHE_VERSION: "20220919" |
| 30 | + # Modify this value to "invalidate" the dist-newstyle cache only. |
| 31 | + DIST_CACHE_VERSION: "20221122" |
| 32 | + |
| 33 | + steps: |
| 34 | + |
| 35 | + - name: "Install System Dependencies via pacman (msys2)" |
| 36 | + if: runner.os == 'Windows' |
| 37 | + shell: 'C:/msys64/usr/bin/bash.exe -e {0}' |
| 38 | + run: | |
| 39 | + /usr/bin/pacman -S --noconfirm mingw-w64-x86_64-pkg-config mingw-w64-x86_64-openssl mingw-w64-x86_64-sed base-devel autoconf-wrapper autoconf automake libtool make |
| 40 | +
|
| 41 | + - name: Install Haskell |
| 42 | + uses: input-output-hk/actions/haskell@latest |
| 43 | + id: setup-haskell |
| 44 | + with: |
| 45 | + ghc-version: ${{ matrix.ghc }} |
| 46 | + cabal-version: "3.12.1.0" |
| 47 | + |
| 48 | + - uses: actions/checkout@v6 |
| 49 | + |
| 50 | + - name: "Configure cabal.project.local" |
| 51 | + run: | |
| 52 | + cp scripts/ci/cabal.project.local.${{ runner.os }} cabal.project.local |
| 53 | +
|
| 54 | + - name: Update PATH |
| 55 | + if: runner.os == 'Windows' |
| 56 | + run: | |
| 57 | + $env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH) |
| 58 | + echo "PATH=$env:PATH" >> $env:GITHUB_ENV |
| 59 | +
|
| 60 | + - name: Update Hackage and CHaP |
| 61 | + run: cabal update |
| 62 | + |
| 63 | + - name: Record dependencies |
| 64 | + id: record-deps |
| 65 | + run: | |
| 66 | + cabal build all --dry-run |
| 67 | + cat dist-newstyle/cache/plan.json | jq -L .github/workflows/jq-install-plan | sort | uniq > dependencies.txt |
| 68 | +
|
| 69 | + - uses: actions/cache/restore@v4 |
| 70 | + name: "Restore cache: `cabal store`" |
| 71 | + id: cache-dependencies |
| 72 | + with: |
| 73 | + path: ${{ steps.setup-haskell.outputs.cabal-store }} |
| 74 | + key: cache-dependencies-${{ env.CABAL_CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} |
| 75 | + restore-keys: cache-dependencies-${{ env.CABAL_CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }} |
| 76 | + |
| 77 | + - uses: actions/cache@v4 |
| 78 | + name: "Cache `dist-newstyle`" |
| 79 | + with: |
| 80 | + path: | |
| 81 | + dist-newstyle |
| 82 | + !dist-newstyle/**/.git |
| 83 | + key: cache-dist-${{ env.CABAL_CACHE_VERSION }}-${{ env.DIST_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project') }} |
| 84 | + restore-keys: cache-dist-${{ env.CABAL_CACHE_VERSION }}-${{ env.DIST_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }} |
| 85 | + |
| 86 | + - name: Build dependencies |
| 87 | + run: cabal build --only-dependencies all -j |
| 88 | + |
| 89 | + - uses: actions/cache/save@v4 |
| 90 | + name: "Save cache: `cabal store`" |
| 91 | + if: always() && steps.cache-dependencies.outputs.cache-hit != 'true' |
| 92 | + with: |
| 93 | + path: ${{ steps.setup-haskell.outputs.cabal-store }} |
| 94 | + key: ${{ steps.cache-dependencies.outputs.cache-primary-key }} |
| 95 | + |
| 96 | + - name: Build all packages |
| 97 | + run: cabal build all -j |
| 98 | + |
| 99 | + # Uncomment the following back in for debugging. Remember to launch a `pwsh` from |
| 100 | + # the tmux session to debug `pwsh` issues. And be reminded that the `/msys2` and |
| 101 | + # `/msys2/mingw64` paths are not in PATH by default for the workflow, but tmate |
| 102 | + # will put them in. |
| 103 | + # You may also want to run |
| 104 | + # |
| 105 | + # $env:PATH=("C:\Program Files\PowerShell\7;{0}" -f $env:ORIGINAL_PATH) |
| 106 | + # |
| 107 | + # to restore the original path. Do note that some test might need msys2 |
| 108 | + # and will silently fail if msys2 is not in path. See the "Run tests" step. |
| 109 | + # |
| 110 | + # - name: Setup tmate session |
| 111 | + # if: ${{ failure() }} |
| 112 | + # uses: mxschmitt/action-tmate@v3 |
| 113 | + # with: |
| 114 | + # limit-access-to-actor: true |
0 commit comments