@@ -11,62 +11,118 @@ permissions:
11
11
contents : read
12
12
13
13
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
+
14
41
generate-matrix :
15
42
name : " Generate matrix from cabal"
16
43
if : ( ( github.event_name == 'push' )
17
44
|| ( github.event_name == 'pull_request'
18
45
&& github.event.pull_request.draft == false
19
46
)
20
47
)
48
+ needs :
49
+ - find-packages
21
50
outputs :
22
51
matrix : ${{ steps.set-matrix.outputs.matrix }}
23
52
runs-on : ubuntu-latest
53
+ env :
54
+ GET_TESTED_VERSION : 0.1.7.1
55
+ PACKAGES : ${{ needs.find-packages.outputs.packages }}
56
+
24
57
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
28
61
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"
32
83
33
84
test :
34
85
if : ( ( github.event_name == 'push' )
35
86
|| ( github.event_name == 'pull_request'
36
87
&& github.event.pull_request.draft == false
37
88
)
38
89
)
39
- name : ${{ matrix.ghc }} on ${{ matrix.os }}
90
+ name : Test ${{ matrix.package }} with GHC ${{ matrix.ghc }} on ${{ matrix.os }}
40
91
needs : generate-matrix
41
92
runs-on : ${{ matrix.os }}
42
93
strategy :
94
+ fail-fast : false
43
95
matrix : ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
44
96
45
97
steps :
46
- - uses : actions/checkout@v4
98
+ - uses : actions/checkout@v4
47
99
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'
52
104
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 }}-
64
116
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
+ # https://github.com/fpringle/generic-diff/actions/runs/15353395135/job/43206848857?pr=10
125
+ run : |
126
+ cabal configure --enable-tests
127
+ cd $(dirname ${{ matrix.cabal_file }})
128
+ cabal test --enable-tests
0 commit comments