Skip to content

Commit

Permalink
Merge macOS and windows workflows
Browse files Browse the repository at this point in the history
- fix malfunctioning `!cache-hit`
  See actions/cache#1262

- cache dependencies right after their build

- add restore-key based on GHC+Cabal version
  • Loading branch information
andreasabel committed Oct 20, 2023
1 parent 8e9d0f4 commit 6b0fb7d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 79 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/macOS.yml → .github/workflows/cabal-mac-win.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: macOS
name: Cabal (macOS and Windows)

on:
push:
branches:
- master
- ci-*
- release*
paths:
- '.github/workflows/macOS.yml'
- 'tasty-silver.cabal'
Expand All @@ -26,10 +24,13 @@ defaults:

jobs:
build-and-test:
runs-on: macos-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: { os: [macos-latest, windows-latest] }

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -38,26 +39,35 @@ jobs:
with:
ghc-version: latest
cabal-version: latest
cabal-update: true

- name: Configure the build plan
run: |
cabal update
cabal configure -O1 --enable-tests
- uses: actions/cache@v3
name: Cache dependencies
- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
env:
key: ${{ runner.os }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }}
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
path: ${{ steps.setup-haskell.outputs.cabal-store }}
# The file `plan.json` contains the build information.
key: macOS-${{ hashFiles('**/plan.json') }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Install dependencies
if: ${{ !steps.cache.outputs.cache-hit }}
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
cabal build --only-dependencies
- name: Cache dependencies
uses: actions/cache/save@v3
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build
run: |
cabal build
Expand Down
67 changes: 0 additions & 67 deletions .github/workflows/windows.yml

This file was deleted.

0 comments on commit 6b0fb7d

Please sign in to comment.