Skip to content

Commit

Permalink
(build) use dynamic matrix in workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Oct 31, 2024
1 parent cdaadde commit 92e173e
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 57 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/_artifacts_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ on:
arch:
required: true
type: string

dockerDistros:
required: true
type: string
dotnetVersions:
required: true
type: string
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"
Expand All @@ -18,17 +23,9 @@ jobs:
runs-on: ${{ inputs.runner }}
strategy:
fail-fast: false
matrix:
dockerDistro:
- alpine.3.20
- centos.stream.9
- debian.12
- fedora.40
- ubuntu.20.04
- ubuntu.22.04
- ubuntu.24.04
dotnetVersion: [ '8.0', '6.0' ]

matrix:
dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
steps:
-
name: Checkout
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ on:
arch:
required: true
type: string

dockerDistros:
required: true
type: string
dotnetVersions:
required: true
type: string
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"
Expand All @@ -19,16 +24,8 @@ jobs:
strategy:
fail-fast: false
matrix:
dockerDistro:
- alpine.3.20
- centos.stream.9
- debian.12
- fedora.40
- ubuntu.20.04
- ubuntu.22.04
- ubuntu.24.04
dotnetVersion: [ '8.0', '6.0' ]

dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
steps:
-
name: Checkout
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/_docker_manifests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
on:
workflow_call:

inputs:
dockerDistros:
required: true
type: string
dotnetVersions:
required: true
type: string
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"
Expand All @@ -12,16 +18,8 @@ jobs:
strategy:
fail-fast: false
matrix:
dockerDistro:
- alpine.3.20
- centos.stream.9
- debian.12
- fedora.40
- ubuntu.20.04
- ubuntu.22.04
- ubuntu.24.04
dotnetVersion: [ '8.0', '6.0' ]

dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
steps:
-
name: Checkout
Expand Down
27 changes: 26 additions & 1 deletion .github/workflows/_prepare.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
on:
workflow_call:

outputs:
dockerDistros:
description: 'List of Docker distros'
value: ${{ jobs.set_matrix.outputs.dockerDistros }}
dotnetVersions:
description: 'List of .NET versions'
value: ${{ jobs.set_matrix.outputs.dotnetVersions }}
jobs:
prepare:
name: ${{ matrix.os }}
Expand Down Expand Up @@ -40,3 +46,22 @@ jobs:
name: '[Prepare]'
shell: pwsh
run: dotnet run/build.dll --target=BuildPrepare
set_matrix:
needs: [ prepare ]
name: Set Matrix
runs-on: ubuntu-latest
outputs:
dockerDistros: ${{ steps.set_matrix.outputs.dockerDistros }}
dotnetVersions: ${{ steps.set_matrix.outputs.dotnetVersions }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Restore State
uses: ./.github/actions/cache-restore
-
name: '[Matrix]'
id: set_matrix
shell: pwsh
run: dotnet run/config.dll --target=SetMatrix
7 changes: 5 additions & 2 deletions .github/workflows/_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
on:
workflow_call:

inputs:
dotnetVersions:
required: true
type: string
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"
Expand All @@ -14,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-15]
dotnetVersion: [ '8.0', '6.0' ]
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}

runs-on: ${{ matrix.os }}
steps:
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
prepare:
name: Prepare
uses: ./.github/workflows/_prepare.yml

build:
name: Build & Package
needs: [ prepare ]
Expand All @@ -53,6 +53,8 @@ jobs:
name: Test
needs: [ prepare ]
uses: ./.github/workflows/_unit_tests.yml
with:
dotnetVersions: ${{ needs.prepare.outputs.dotnetVersions }}
secrets: inherit

artifacts_windows_test:
Expand All @@ -61,7 +63,7 @@ jobs:
uses: ./.github/workflows/_artifacts_windows.yml

artifacts_linux_test:
needs: [ build ]
needs: [ prepare, build ]
name: Artifacts Linux (${{ matrix.arch }})
strategy:
fail-fast: false
Expand All @@ -75,9 +77,11 @@ jobs:
with:
runner: ${{ matrix.runner }}
arch: ${{ matrix.arch }}
dockerDistros: ${{ needs.prepare.outputs.dockerDistros }}
dotnetVersions: ${{ needs.prepare.outputs.dotnetVersions }}

docker_linux_images:
needs: [ build ]
needs: [ prepare, build ]
name: Docker Images (${{ matrix.arch }})
strategy:
fail-fast: false
Expand All @@ -92,12 +96,17 @@ jobs:
with:
runner: ${{ matrix.runner }}
arch: ${{ matrix.arch }}
dockerDistros: ${{ needs.prepare.outputs.dockerDistros }}
dotnetVersions: ${{ needs.prepare.outputs.dotnetVersions }}
secrets: inherit

docker_linux_manifests:
needs: [ docker_linux_images ]
needs: [ prepare, docker_linux_images ]
name: Docker Manifests
uses: ./.github/workflows/_docker_manifests.yml
with:
dockerDistros: ${{ needs.prepare.outputs.dockerDistros }}
dotnetVersions: ${{ needs.prepare.outputs.dotnetVersions }}
secrets: inherit

publish:
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ env:
jobs:
prepare:
name: Prepare Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ubuntu-latest

steps:
-
Expand Down Expand Up @@ -127,7 +123,7 @@ jobs:
publish:
name: Publish docs
needs: [ validate ]
runs-on: windows-latest
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
Expand All @@ -143,8 +139,7 @@ jobs:
-
name: '[Build Schemas]'
shell: pwsh
run: |
dotnet run/docs.dll --target=GenerateSchemas
run: dotnet run/docs.dll --target=GenerateSchemas
-
name: '[Publish Documentation]'
if: ${{ github.event_name == 'repository_dispatch' }}
Expand Down
21 changes: 13 additions & 8 deletions build/CI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
..\.github\workflows\format.yml = ..\.github\workflows\format.yml
..\.github\workflows\homebrew.yml = ..\.github\workflows\homebrew.yml
..\.github\workflows\release.yml = ..\.github\workflows\release.yml
..\.github\workflows\_artifacts_linux.yml = ..\.github\workflows\_artifacts_linux.yml
..\.github\workflows\_artifacts_windows.yml = ..\.github\workflows\_artifacts_windows.yml
..\.github\workflows\_build.yml = ..\.github\workflows\_build.yml
..\.github\workflows\_docker.yml = ..\.github\workflows\_docker.yml
..\.github\workflows\_docker_manifests.yml = ..\.github\workflows\_docker_manifests.yml
..\.github\workflows\_prepare.yml = ..\.github\workflows\_prepare.yml
..\.github\workflows\_publish.yml = ..\.github\workflows\_publish.yml
..\.github\workflows\_unit_tests.yml = ..\.github\workflows\_unit_tests.yml
..\.github\workflows\stale.yml = ..\.github\workflows\stale.yml
..\.github\workflows\winget.yml = ..\.github\workflows\winget.yml
..\.github\workflows\mkdocs.yml = ..\.github\workflows\mkdocs.yml
Expand Down Expand Up @@ -87,6 +79,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "artifacts-attest", "artifac
..\.github\actions\artifacts-attest\action.yml = ..\.github\actions\artifacts-attest\action.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{C9CB0BFB-E2C4-44F6-86A4-54DDF600EE5D}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\_artifacts_linux.yml = ..\.github\workflows\_artifacts_linux.yml
..\.github\workflows\_artifacts_windows.yml = ..\.github\workflows\_artifacts_windows.yml
..\.github\workflows\_build.yml = ..\.github\workflows\_build.yml
..\.github\workflows\_docker.yml = ..\.github\workflows\_docker.yml
..\.github\workflows\_docker_manifests.yml = ..\.github\workflows\_docker_manifests.yml
..\.github\workflows\_prepare.yml = ..\.github\workflows\_prepare.yml
..\.github\workflows\_publish.yml = ..\.github\workflows\_publish.yml
..\.github\workflows\_unit_tests.yml = ..\.github\workflows\_unit_tests.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -133,5 +137,6 @@ Global
{965AC311-8A65-4AEB-B11F-3E4EBDFFBB8F} = {A9B92261-AB9C-47D6-A8A7-616A5A62B063}
{FF815E24-AE9E-49E5-BC93-F859450F9CD0} = {A9B92261-AB9C-47D6-A8A7-616A5A62B063}
{C4A801B1-45B1-4D2E-8911-4823778BF582} = {A9B92261-AB9C-47D6-A8A7-616A5A62B063}
{C9CB0BFB-E2C4-44F6-86A4-54DDF600EE5D} = {8E5B758F-925A-49E4-9011-20AD2A9E1F43}
EndGlobalSection
EndGlobal

0 comments on commit 92e173e

Please sign in to comment.