diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index c196a0d..21bd714 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -13,35 +13,57 @@ jobs: build: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - os: - - ubuntu-latest - - macos-latest - - windows-latest + ghc: ["9.2.8", "9.4.8", "9.6.4", "9.8.1"] + cabal: ["3.10.2.1"] + os: [ubuntu-latest, windows-latest, macOS-latest] + exclude: + - ghc: "9.4.8" + os: windows-latest + - ghc: "9.4.8" + os: macOS-latest + - ghc: "9.8.1" + os: windows-latest + - ghc: "9.8.1" + os: macOS-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-haskell@v1 + - uses: actions/setup-haskell@v2 with: - ghc-version: '9.2' - cabal-version: '3.6' + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + cabal-update: true - - name: Cache - uses: actions/cache@v3 + - name: "Restore cache" + uses: actions/cache/restore@v4 + id: restore-cabal-cache env: - cache-name: cache-cabal + cache-name: cache-cabal-build with: - path: ~/.cabal - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + path: ${{ steps.setup-haskell.outputs.cabal-store }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}- + ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}- - - name: Install dependencies - run: | - cabal update - cabal build --only-dependencies --enable-tests --enable-benchmarks + - name: Install cabal dependencies + id: build-dependencies + run: cabal build --only-dependencies --enable-tests --enable-benchmarks all + + - name: "Save cache" + uses: actions/cache/save@v4 + id: save-cabal-cache + # Note: cache-hit will be set to true only when cache hit occurs for the + # exact key match. For a partial key match via restore-keys or a cache + # miss, it will be set to false. + if: steps.build-dependencies.outcome == 'success' && steps.restore-cabal-cache.outputs.cache-hit != 'true' + with: + path: ${{ steps.setup-haskell.outputs.cabal-store }} + key: ${{ steps.restore-cabal-cache.outputs.cache-primary-key }} + - name: Build run: cabal build --enable-tests --enable-benchmarks all - name: Run tests