Skip to content

Commit 9147753

Browse files
author
Frederick Pringle
committed
Test generic-diff-containers during CICD too
1 parent b2b70fb commit 9147753

File tree

2 files changed

+93
-31
lines changed

2 files changed

+93
-31
lines changed

.github/workflows/haskell.yml

Lines changed: 83 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,114 @@ permissions:
1111
contents: read
1212

1313
jobs:
14+
find-packages:
15+
name: "Find packages by their .cabal files"
16+
if: ( ( github.event_name == 'push' )
17+
|| ( github.event_name == 'pull_request'
18+
&& github.event.pull_request.draft == false
19+
)
20+
)
21+
runs-on: ubuntu-latest
22+
outputs:
23+
packages: ${{ steps.set-matrix.outputs.packages }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Find packages
27+
id: set-matrix
28+
run: |
29+
set -euo pipefail
30+
31+
packages=$(
32+
find . -name '*.cabal' | sed 's/^\.\///' | while read file; do
33+
file_name=$(basename -- $file)
34+
package_name="${file_name%.*}"
35+
echo "{\"package\": \"${package_name}\", \"cabal_file\": \"${file}\"}"
36+
done | jq -s -c
37+
)
38+
echo $packages
39+
echo "packages=$packages" > "$GITHUB_OUTPUT"
40+
1441
generate-matrix:
1542
name: "Generate matrix from cabal"
1643
if: ( ( github.event_name == 'push' )
1744
|| ( github.event_name == 'pull_request'
1845
&& github.event.pull_request.draft == false
1946
)
2047
)
48+
needs:
49+
- find-packages
2150
outputs:
2251
matrix: ${{ steps.set-matrix.outputs.matrix }}
2352
runs-on: ubuntu-latest
53+
env:
54+
GET_TESTED_VERSION: 0.1.7.1
55+
PACKAGES: ${{ needs.find-packages.outputs.packages }}
56+
2457
steps:
25-
- name: Extract the tested GHC versions
26-
id: set-matrix
27-
uses: kleidukos/get-tested@v0.1.7.1
58+
- uses: actions/checkout@v4
59+
- name: Install GH CLI
60+
uses: dev-hanz-ops/install-gh-cli-action@v0.2.1
2861
with:
29-
cabal-file: generic-diff.cabal
30-
ubuntu-version: "latest"
31-
version: 0.1.7.1
62+
gh-cli-version: 2.63.0
63+
- name: Set up get-tested
64+
uses: Kleidukos/get-tested/setup-get-tested@5f873c05c435a1f50e4c5ce815d687c1bff3b93b
65+
with:
66+
version: ${{ env.GET_TESTED_VERSION }}
67+
- name: Extract GHC versions for each package
68+
id: set-matrix
69+
run: |
70+
set -euo pipefail
71+
72+
matrix=$(echo $PACKAGES | jq -c '.[]' | while read package; do
73+
name=$(echo $package | jq -r '.package')
74+
echo "Running get-tested on package ${name}" >&2
75+
cabal_file=$(echo $package | jq -r '.cabal_file')
76+
output=$(./get-tested --ubuntu-version=latest $cabal_file)
77+
echo $output | sed 's/^matrix=//' | jq ".include[] |= . + ${package}"
78+
done | jq -s -c '{ include: map(.include) | add }')
79+
80+
echo $matrix
81+
82+
echo "matrix=$matrix" > "$GITHUB_OUTPUT"
3283
3384
test:
3485
if: ( ( github.event_name == 'push' )
3586
|| ( github.event_name == 'pull_request'
3687
&& github.event.pull_request.draft == false
3788
)
3889
)
39-
name: ${{ matrix.ghc }} on ${{ matrix.os }}
90+
name: Test ${{ matrix.package }} with GHC ${{ matrix.ghc }} on ${{ matrix.os }}
4091
needs: generate-matrix
4192
runs-on: ${{ matrix.os }}
4293
strategy:
94+
fail-fast: false
4395
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
4496

4597
steps:
46-
- uses: actions/checkout@v4
98+
- uses: actions/checkout@v4
4799

48-
- uses: haskell-actions/setup@v2.7
49-
with:
50-
ghc-version: ${{ matrix.ghc }}
51-
cabal-version: '3.0'
100+
- uses: haskell-actions/setup@v2.7
101+
with:
102+
ghc-version: ${{ matrix.ghc }}
103+
cabal-version: '3.0'
52104

53-
- name: Cache
54-
uses: actions/cache@v3
55-
env:
56-
cache-name: cache-cabal
57-
with:
58-
path: ~/.cabal
59-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
60-
restore-keys: |
61-
${{ runner.os }}-build-${{ env.cache-name }}-
62-
${{ runner.os }}-build-
63-
${{ runner.os }}-
105+
- name: Cache
106+
uses: actions/cache@v3
107+
env:
108+
cache-name: cache-cabal
109+
with:
110+
path: ~/.cabal
111+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
112+
restore-keys: |
113+
${{ runner.os }}-build-${{ env.cache-name }}-
114+
${{ runner.os }}-build-
115+
${{ runner.os }}-
64116
65-
- name: Install dependencies
66-
run: |
67-
cabal update
68-
cabal build --only-dependencies --enable-tests --enable-benchmarks
69-
- name: Build
70-
run: cabal build --enable-tests --enable-benchmarks all
71-
- name: Run tests
72-
run: cabal test all
117+
- name: Install dependencies
118+
run: |
119+
cabal update
120+
cabal build --only-dependencies --enable-tests --enable-benchmarks ${{ matrix.package }}
121+
- name: Build
122+
run: cabal build --enable-tests --enable-benchmarks ${{ matrix.package }}
123+
- name: Run tests
124+
run: cabal test ${{ matrix.package }}

examples/containers-instances/generic-diff-containers.cabal

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ maintainer: freddyjepringle@gmail.com
88
copyright: Copyright(c) Frederick Pringle 2025
99
homepage: https://github.com/fpringle/generic-diff
1010
build-type: Simple
11+
tested-with:
12+
GHC == 9.12.2
13+
GHC == 9.10.1
14+
GHC == 9.8.2
15+
GHC == 9.6.5
16+
GHC == 9.4.8
17+
GHC == 9.2.8
18+
GHC == 9.0.2
19+
GHC == 8.10.7
20+
GHC == 8.6.5
1121

1222
common warnings
1323
ghc-options: -Wall

0 commit comments

Comments
 (0)