Skip to content

Commit 996540b

Browse files
authored
CI: Add macos to build and update caching strategy (#194)
1 parent 78a27b4 commit 996540b

File tree

1 file changed

+69
-40
lines changed

1 file changed

+69
-40
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ env:
1818
MINIO_ACCESS_KEY: minio
1919
MINIO_SECRET_KEY: minio123
2020
MINIO_LOCAL: 1
21-
MINIO_SECURE: 1
2221

2322
jobs:
2423
ormolu:
@@ -35,12 +34,12 @@ jobs:
3534
- uses: actions/checkout@v4
3635

3736
- name: "Set up HLint"
38-
uses: haskell/actions/hlint-setup@v2
37+
uses: haskell-actions/hlint-setup@v2
3938
with:
4039
version: "3.5"
4140

4241
- name: "Run HLint"
43-
uses: haskell/actions/hlint-run@v2
42+
uses: haskell-actions/hlint-run@v2
4443
with:
4544
path: '["src/", "test/", "examples"]'
4645
fail-on: warning
@@ -51,57 +50,70 @@ jobs:
5150
needs: ormolu
5251
strategy:
5352
matrix:
54-
os: [ubuntu-latest, windows-latest] # Removed macos-latest due to cert issues.
53+
os: [ubuntu-latest, windows-latest, macos-latest]
5554
cabal: ["3.8", "latest"]
5655
ghc:
5756
- "9.6"
5857
- "9.4"
5958
- "9.2"
6059
- "9.0"
6160
- "8.10"
62-
# exclude:
63-
# - os: windows-latest
64-
# ghc: "9.4"
65-
# cabal: "3.6"
61+
exclude:
62+
- os: macos-latest
63+
ghc: "8.10"
64+
- os: macos-latest
65+
ghc: "9.0"
66+
# Cabal 3.8 supports GHC < 9.6
67+
- cabal: "3.8"
68+
ghc: "9.6"
6669

6770
steps:
6871
- uses: actions/checkout@v4
6972
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
7073

71-
- uses: haskell/actions/setup@v2
72-
id: setup-haskell-cabal
74+
- uses: haskell-actions/setup@v2
75+
id: setup
7376
name: Setup Haskell
7477
with:
7578
ghc-version: ${{ matrix.ghc }}
7679
cabal-version: ${{ matrix.cabal }}
80+
cabal-update: true
7781

7882
- name: Configure
7983
run: |
80-
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct -fexamples -fdev -flive-test
84+
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct -fexamples -fdev -flive-test
85+
cabal build all --dry-run
86+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
8187

82-
- name: Freeze
83-
run: |
84-
cabal freeze
85-
86-
- uses: actions/cache@v3
87-
name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle
88+
- name: Restore cached dependencies
89+
uses: actions/cache/restore@v4
90+
id: cache
91+
env:
92+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
8893
with:
89-
path: |
90-
~/.cabal/packages
91-
~/.cabal/store
92-
dist-newstyle
93-
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal', '**/cabal.project', '**/cabal.project.freeze') }}
94-
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
94+
path: ${{ steps.setup.outputs.cabal-store }}
95+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
96+
restore-keys: ${{ env.key }}-
9597

9698
- name: Install dependencies
97-
run: |
98-
cabal build --only-dependencies
99+
# If we had an exact cache hit, the dependencies will be up to date.
100+
if: steps.cache.outputs.cache-hit != 'true'
101+
run: cabal build all --only-dependencies
102+
103+
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
104+
- name: Save cached dependencies
105+
uses: actions/cache/save@v4
106+
# If we had an exact cache hit, trying to save the cache would error because of key clash.
107+
if: steps.cache.outputs.cache-hit != 'true'
108+
with:
109+
path: ${{ steps.setup.outputs.cabal-store }}
110+
key: ${{ steps.cache.outputs.cache-primary-key }}
99111

100112
- name: Build
101113
run: |
102-
cabal build
114+
cabal build all
103115
104-
- name: Setup MinIO for testing (Linux)
116+
- name: Setup TLS certs for MinIO for testing (Linux)
105117
if: matrix.os == 'ubuntu-latest'
106118
run: |
107119
mkdir -p /tmp/minio /tmp/minio-config/certs
@@ -110,13 +122,14 @@ jobs:
110122
sudo cp /tmp/minio-config/certs/public.crt /usr/local/share/ca-certificates/
111123
sudo update-ca-certificates
112124
113-
- name: Setup MinIO for testing (MacOS)
125+
## Currently disable TLS setup for MacOS due to issues in trusting it on MacOS.
126+
- name: Setup TLS certs for MinIO for testing (MacOS)
114127
if: matrix.os == 'macos-latest'
115128
run: |
116129
mkdir -p /tmp/minio /tmp/minio-config/certs
117130
cp test/cert/* /tmp/minio-config/certs/
118131
(cd /tmp/minio; wget -q https://dl.min.io/server/minio/release/darwin-amd64/minio; chmod +x ./minio)
119-
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /tmp/minio-config/certs/public.crt
132+
# sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /tmp/minio-config/certs/public.crt
120133
121134
- name: Setup MinIO for testing (Windows)
122135
if: matrix.os == 'windows-latest'
@@ -126,25 +139,42 @@ jobs:
126139
Invoke-WebRequest -Uri https://dl.minio.io/server/minio/release/windows-amd64/minio.exe -OutFile $HOME/minio.exe
127140
Import-Certificate -FilePath "$env:temp/minio-config/certs/public.crt" -CertStoreLocation Cert:\LocalMachine\Root
128141
129-
- name: Test (Non-Windows)
130-
if: matrix.os != 'windows-latest'
142+
- name: Test (Linux)
143+
if: matrix.os == 'ubuntu-latest'
144+
env:
145+
MINIO_SECURE: 1
131146
run: |
132147
/tmp/minio/minio server --quiet --certs-dir /tmp/minio-config/certs data1 data2 data3 data4 2>&1 > minio.log &
133148
ghc --version
134149
cabal --version
135-
cabal test
150+
cabal test all
151+
152+
- name: Test (MacOS)
153+
if: matrix.os == 'macos-latest'
154+
# # Leave MINIO_SECURE unset to disable TLS in tests.
155+
# env:
156+
# MINIO_SECURE: 1
157+
run: |
158+
/tmp/minio/minio server --quiet data1 data2 data3 data4 2>&1 > minio.log &
159+
ghc --version
160+
cabal --version
161+
cabal test all
136162
137163
- name: Test (Windows)
138164
if: matrix.os == 'windows-latest'
165+
env:
166+
MINIO_SECURE: 1
139167
run: |
140168
Start-Process -NoNewWindow -FilePath "$HOME/minio.exe" -ArgumentList "--certs-dir", "$env:temp/minio-config/certs", "server", "$env:temp/data1", "$env:temp/data2", "$env:temp/data3", "$env:temp/data4"
141169
ghc --version
142170
cabal --version
143-
cabal test
171+
cabal test all
144172
145173
stack:
146174
name: stack / ghc ${{ matrix.ghc }}
147175
runs-on: ${{ matrix.os }}
176+
env:
177+
MINIO_SECURE: 1
148178
strategy:
149179
matrix:
150180
ghc:
@@ -159,14 +189,13 @@ jobs:
159189
- uses: actions/checkout@v4
160190
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
161191

162-
- name: Install Haskell Stack
163-
run: |
164-
if ! which stack
165-
then
166-
curl -sSL https://get.haskellstack.org/ | sh
167-
fi
192+
- uses: haskell-actions/setup@v2
193+
with:
194+
ghc-version: ${{ matrix.ghc }}
195+
enable-stack: true
196+
stack-version: "latest"
168197

169-
- uses: actions/cache@v3
198+
- uses: actions/cache@v4
170199
name: Cache ~/.stack
171200
with:
172201
path: ~/.stack

0 commit comments

Comments
 (0)