Skip to content

Commit 92e173e

Browse files
committed
(build) use dynamic matrix in workflow
1 parent cdaadde commit 92e173e

File tree

8 files changed

+86
-57
lines changed

8 files changed

+86
-57
lines changed

.github/workflows/_artifacts_linux.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ on:
77
arch:
88
required: true
99
type: string
10-
10+
dockerDistros:
11+
required: true
12+
type: string
13+
dotnetVersions:
14+
required: true
15+
type: string
1116
env:
1217
DOTNET_INSTALL_DIR: "./.dotnet"
1318
DOTNET_ROLL_FORWARD: "Major"
@@ -18,17 +23,9 @@ jobs:
1823
runs-on: ${{ inputs.runner }}
1924
strategy:
2025
fail-fast: false
21-
matrix:
22-
dockerDistro:
23-
- alpine.3.20
24-
- centos.stream.9
25-
- debian.12
26-
- fedora.40
27-
- ubuntu.20.04
28-
- ubuntu.22.04
29-
- ubuntu.24.04
30-
dotnetVersion: [ '8.0', '6.0' ]
31-
26+
matrix:
27+
dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
28+
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
3229
steps:
3330
-
3431
name: Checkout

.github/workflows/_docker.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ on:
77
arch:
88
required: true
99
type: string
10-
10+
dockerDistros:
11+
required: true
12+
type: string
13+
dotnetVersions:
14+
required: true
15+
type: string
1116
env:
1217
DOTNET_INSTALL_DIR: "./.dotnet"
1318
DOTNET_ROLL_FORWARD: "Major"
@@ -19,16 +24,8 @@ jobs:
1924
strategy:
2025
fail-fast: false
2126
matrix:
22-
dockerDistro:
23-
- alpine.3.20
24-
- centos.stream.9
25-
- debian.12
26-
- fedora.40
27-
- ubuntu.20.04
28-
- ubuntu.22.04
29-
- ubuntu.24.04
30-
dotnetVersion: [ '8.0', '6.0' ]
31-
27+
dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
28+
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
3229
steps:
3330
-
3431
name: Checkout

.github/workflows/_docker_manifests.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
on:
22
workflow_call:
3-
3+
inputs:
4+
dockerDistros:
5+
required: true
6+
type: string
7+
dotnetVersions:
8+
required: true
9+
type: string
410
env:
511
DOTNET_INSTALL_DIR: "./.dotnet"
612
DOTNET_ROLL_FORWARD: "Major"
@@ -12,16 +18,8 @@ jobs:
1218
strategy:
1319
fail-fast: false
1420
matrix:
15-
dockerDistro:
16-
- alpine.3.20
17-
- centos.stream.9
18-
- debian.12
19-
- fedora.40
20-
- ubuntu.20.04
21-
- ubuntu.22.04
22-
- ubuntu.24.04
23-
dotnetVersion: [ '8.0', '6.0' ]
24-
21+
dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
22+
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
2523
steps:
2624
-
2725
name: Checkout

.github/workflows/_prepare.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
on:
22
workflow_call:
3-
3+
outputs:
4+
dockerDistros:
5+
description: 'List of Docker distros'
6+
value: ${{ jobs.set_matrix.outputs.dockerDistros }}
7+
dotnetVersions:
8+
description: 'List of .NET versions'
9+
value: ${{ jobs.set_matrix.outputs.dotnetVersions }}
410
jobs:
511
prepare:
612
name: ${{ matrix.os }}
@@ -40,3 +46,22 @@ jobs:
4046
name: '[Prepare]'
4147
shell: pwsh
4248
run: dotnet run/build.dll --target=BuildPrepare
49+
set_matrix:
50+
needs: [ prepare ]
51+
name: Set Matrix
52+
runs-on: ubuntu-latest
53+
outputs:
54+
dockerDistros: ${{ steps.set_matrix.outputs.dockerDistros }}
55+
dotnetVersions: ${{ steps.set_matrix.outputs.dotnetVersions }}
56+
steps:
57+
-
58+
name: Checkout
59+
uses: actions/checkout@v4
60+
-
61+
name: Restore State
62+
uses: ./.github/actions/cache-restore
63+
-
64+
name: '[Matrix]'
65+
id: set_matrix
66+
shell: pwsh
67+
run: dotnet run/config.dll --target=SetMatrix

.github/workflows/_unit_tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
on:
22
workflow_call:
3-
3+
inputs:
4+
dotnetVersions:
5+
required: true
6+
type: string
47
env:
58
DOTNET_INSTALL_DIR: "./.dotnet"
69
DOTNET_ROLL_FORWARD: "Major"
@@ -14,7 +17,7 @@ jobs:
1417
fail-fast: false
1518
matrix:
1619
os: [windows-latest, ubuntu-latest, macos-15]
17-
dotnetVersion: [ '8.0', '6.0' ]
20+
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
1821

1922
runs-on: ${{ matrix.os }}
2023
steps:

.github/workflows/ci.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
prepare:
4444
name: Prepare
4545
uses: ./.github/workflows/_prepare.yml
46-
46+
4747
build:
4848
name: Build & Package
4949
needs: [ prepare ]
@@ -53,6 +53,8 @@ jobs:
5353
name: Test
5454
needs: [ prepare ]
5555
uses: ./.github/workflows/_unit_tests.yml
56+
with:
57+
dotnetVersions: ${{ needs.prepare.outputs.dotnetVersions }}
5658
secrets: inherit
5759

5860
artifacts_windows_test:
@@ -61,7 +63,7 @@ jobs:
6163
uses: ./.github/workflows/_artifacts_windows.yml
6264

6365
artifacts_linux_test:
64-
needs: [ build ]
66+
needs: [ prepare, build ]
6567
name: Artifacts Linux (${{ matrix.arch }})
6668
strategy:
6769
fail-fast: false
@@ -75,9 +77,11 @@ jobs:
7577
with:
7678
runner: ${{ matrix.runner }}
7779
arch: ${{ matrix.arch }}
80+
dockerDistros: ${{ needs.prepare.outputs.dockerDistros }}
81+
dotnetVersions: ${{ needs.prepare.outputs.dotnetVersions }}
7882

7983
docker_linux_images:
80-
needs: [ build ]
84+
needs: [ prepare, build ]
8185
name: Docker Images (${{ matrix.arch }})
8286
strategy:
8387
fail-fast: false
@@ -92,12 +96,17 @@ jobs:
9296
with:
9397
runner: ${{ matrix.runner }}
9498
arch: ${{ matrix.arch }}
99+
dockerDistros: ${{ needs.prepare.outputs.dockerDistros }}
100+
dotnetVersions: ${{ needs.prepare.outputs.dotnetVersions }}
95101
secrets: inherit
96102

97103
docker_linux_manifests:
98-
needs: [ docker_linux_images ]
104+
needs: [ prepare, docker_linux_images ]
99105
name: Docker Manifests
100106
uses: ./.github/workflows/_docker_manifests.yml
107+
with:
108+
dockerDistros: ${{ needs.prepare.outputs.dockerDistros }}
109+
dotnetVersions: ${{ needs.prepare.outputs.dotnetVersions }}
101110
secrets: inherit
102111

103112
publish:

.github/workflows/docs.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ env:
3333
jobs:
3434
prepare:
3535
name: Prepare Build
36-
runs-on: ${{ matrix.os }}
37-
strategy:
38-
fail-fast: false
39-
matrix:
40-
os: [windows-latest, ubuntu-latest]
36+
runs-on: ubuntu-latest
4137

4238
steps:
4339
-
@@ -127,7 +123,7 @@ jobs:
127123
publish:
128124
name: Publish docs
129125
needs: [ validate ]
130-
runs-on: windows-latest
126+
runs-on: ubuntu-latest
131127
env:
132128
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
133129
GITHUB_USERNAME: ${{ github.actor }}
@@ -143,8 +139,7 @@ jobs:
143139
-
144140
name: '[Build Schemas]'
145141
shell: pwsh
146-
run: |
147-
dotnet run/docs.dll --target=GenerateSchemas
142+
run: dotnet run/docs.dll --target=GenerateSchemas
148143
-
149144
name: '[Publish Documentation]'
150145
if: ${{ github.event_name == 'repository_dispatch' }}

build/CI.sln

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
3434
..\.github\workflows\format.yml = ..\.github\workflows\format.yml
3535
..\.github\workflows\homebrew.yml = ..\.github\workflows\homebrew.yml
3636
..\.github\workflows\release.yml = ..\.github\workflows\release.yml
37-
..\.github\workflows\_artifacts_linux.yml = ..\.github\workflows\_artifacts_linux.yml
38-
..\.github\workflows\_artifacts_windows.yml = ..\.github\workflows\_artifacts_windows.yml
39-
..\.github\workflows\_build.yml = ..\.github\workflows\_build.yml
40-
..\.github\workflows\_docker.yml = ..\.github\workflows\_docker.yml
41-
..\.github\workflows\_docker_manifests.yml = ..\.github\workflows\_docker_manifests.yml
42-
..\.github\workflows\_prepare.yml = ..\.github\workflows\_prepare.yml
43-
..\.github\workflows\_publish.yml = ..\.github\workflows\_publish.yml
44-
..\.github\workflows\_unit_tests.yml = ..\.github\workflows\_unit_tests.yml
4537
..\.github\workflows\stale.yml = ..\.github\workflows\stale.yml
4638
..\.github\workflows\winget.yml = ..\.github\workflows\winget.yml
4739
..\.github\workflows\mkdocs.yml = ..\.github\workflows\mkdocs.yml
@@ -87,6 +79,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "artifacts-attest", "artifac
8779
..\.github\actions\artifacts-attest\action.yml = ..\.github\actions\artifacts-attest\action.yml
8880
EndProjectSection
8981
EndProject
82+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{C9CB0BFB-E2C4-44F6-86A4-54DDF600EE5D}"
83+
ProjectSection(SolutionItems) = preProject
84+
..\.github\workflows\_artifacts_linux.yml = ..\.github\workflows\_artifacts_linux.yml
85+
..\.github\workflows\_artifacts_windows.yml = ..\.github\workflows\_artifacts_windows.yml
86+
..\.github\workflows\_build.yml = ..\.github\workflows\_build.yml
87+
..\.github\workflows\_docker.yml = ..\.github\workflows\_docker.yml
88+
..\.github\workflows\_docker_manifests.yml = ..\.github\workflows\_docker_manifests.yml
89+
..\.github\workflows\_prepare.yml = ..\.github\workflows\_prepare.yml
90+
..\.github\workflows\_publish.yml = ..\.github\workflows\_publish.yml
91+
..\.github\workflows\_unit_tests.yml = ..\.github\workflows\_unit_tests.yml
92+
EndProjectSection
93+
EndProject
9094
Global
9195
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9296
Debug|Any CPU = Debug|Any CPU
@@ -133,5 +137,6 @@ Global
133137
{965AC311-8A65-4AEB-B11F-3E4EBDFFBB8F} = {A9B92261-AB9C-47D6-A8A7-616A5A62B063}
134138
{FF815E24-AE9E-49E5-BC93-F859450F9CD0} = {A9B92261-AB9C-47D6-A8A7-616A5A62B063}
135139
{C4A801B1-45B1-4D2E-8911-4823778BF582} = {A9B92261-AB9C-47D6-A8A7-616A5A62B063}
140+
{C9CB0BFB-E2C4-44F6-86A4-54DDF600EE5D} = {8E5B758F-925A-49E4-9011-20AD2A9E1F43}
136141
EndGlobalSection
137142
EndGlobal

0 commit comments

Comments
 (0)