Skip to content

(build) Improve input parameters for workflows, changed to dynamic matrix #4278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/actions/docker-manifests/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'Docker Manifests'
description: 'Docker Publish Manifests'
inputs:
distro:
dockerDistro:
description: 'Linux Distro'
required: true
targetFramework:
dotnetVersion:
description: '.net version'
required: true
docker_registry_username:
Expand Down Expand Up @@ -32,7 +32,7 @@ runs:
-
name: '[Docker Publish Manifests] DockerHub'
shell: pwsh
run: dotnet run/docker.dll --target=DockerManifest --arch=amd64 --arch=arm64 --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry dockerhub
run: dotnet run/docker.dll --target=DockerManifest --arch=amd64 --arch=arm64 --dotnet_version=${{ inputs.dotnetVersion }} --docker_distro=${{ inputs.dockerDistro }} --docker_registry dockerhub
-
name: Login to GitHub
uses: docker/login-action@v3
Expand All @@ -43,4 +43,4 @@ runs:
-
name: '[Docker Publish Manifests] GitHub'
shell: pwsh
run: dotnet run/docker.dll --target=DockerManifest --arch=amd64 --arch=arm64 --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry github
run: dotnet run/docker.dll --target=DockerManifest --arch=amd64 --arch=arm64 --dotnet_version=${{ inputs.dotnetVersion }} --docker_distro=${{ inputs.dockerDistro }} --docker_registry github
8 changes: 4 additions & 4 deletions .github/actions/docker-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ inputs:
arch:
description: 'Docker architecture'
required: true
distro:
dockerDistro:
description: 'Linux Distro'
required: true
targetFramework:
dotnetVersion:
description: '.net version'
required: true
docker_registry_username:
Expand Down Expand Up @@ -35,7 +35,7 @@ runs:
-
name: '[Docker Publish] DockerHub'
shell: pwsh
run: dotnet run/docker.dll --target=DockerPublish --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry dockerhub --verbosity=diagnostic
run: dotnet run/docker.dll --target=DockerPublish --arch=${{ inputs.arch }} --dotnet_version=${{ inputs.dotnetVersion }} --docker_distro=${{ inputs.dockerDistro }} --docker_registry dockerhub --verbosity=diagnostic
-
name: Login to GitHub
uses: docker/login-action@v3
Expand All @@ -46,4 +46,4 @@ runs:
-
name: '[Docker Publish] GitHub'
shell: pwsh
run: dotnet run/docker.dll --target=DockerPublish --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry github --verbosity=diagnostic
run: dotnet run/docker.dll --target=DockerPublish --arch=${{ inputs.arch }} --dotnet_version=${{ inputs.dotnetVersion }} --docker_distro=${{ inputs.dockerDistro }} --docker_registry github --verbosity=diagnostic
8 changes: 4 additions & 4 deletions .github/actions/docker-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ inputs:
arch:
description: 'Docker architecture'
default: 'amd64'
distro:
dockerDistro:
description: 'Linux Distro'
default: 'debian.12'
targetFramework:
dotnetVersion:
description: '.net version'
default: '8.0'

Expand All @@ -17,8 +17,8 @@ runs:
-
name: '[Docker Build & Test] DockerHub'
shell: pwsh
run: dotnet run/docker.dll --target=DockerTest --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry dockerhub --verbosity=diagnostic
run: dotnet run/docker.dll --target=DockerTest --arch=${{ inputs.arch }} --dotnet_version=${{ inputs.dotnetVersion }} --docker_distro=${{ inputs.dockerDistro }} --docker_registry dockerhub --verbosity=diagnostic
-
name: '[Docker Build & Test] GitHub'
shell: pwsh
run: dotnet run/docker.dll --target=DockerTest --arch=${{ inputs.arch }} --docker_dotnetversion=${{ inputs.targetFramework }} --docker_distro=${{ inputs.distro }} --docker_registry github --verbosity=diagnostic
run: dotnet run/docker.dll --target=DockerTest --arch=${{ inputs.arch }} --dotnet_version=${{ inputs.dotnetVersion }} --docker_distro=${{ inputs.dockerDistro }} --docker_registry github --verbosity=diagnostic
25 changes: 11 additions & 14 deletions .github/workflows/_artifacts_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,25 @@ 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"

jobs:
artifacts:
name: ${{ matrix.distro }} - net${{ matrix.targetFramework }}
name: ${{ matrix.dockerDistro }} - net${{ matrix.dotnetVersion }}
runs-on: ${{ inputs.runner }}
strategy:
fail-fast: false
matrix:
distro:
- alpine.3.20
- centos.stream.9
- debian.12
- fedora.40
- ubuntu.20.04
- ubuntu.22.04
- ubuntu.24.04
targetFramework: [ '8.0', '6.0' ]

matrix:
dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
steps:
-
name: Checkout
Expand All @@ -53,4 +50,4 @@ jobs:
-
name: '[Test Artifacts]'
shell: pwsh
run: dotnet run/artifacts.dll --target=ArtifactsTest --arch=${{ inputs.arch }} --docker_dotnetversion=${{ matrix.targetFramework }} --docker_distro=${{ matrix.distro }}
run: dotnet run/artifacts.dll --target=ArtifactsTest --arch=${{ inputs.arch }} --dotnet_version=${{ matrix.dotnetVersion }} --docker_distro=${{ matrix.dockerDistro }}
29 changes: 13 additions & 16 deletions .github/workflows/_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,25 @@ 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"

jobs:
docker:
name: ${{ matrix.distro }} - net${{ matrix.targetFramework }}
name: ${{ matrix.dockerDistro }} - net${{ matrix.dotnetVersion }}
runs-on: ${{ inputs.runner }}
strategy:
fail-fast: false
matrix:
distro:
- alpine.3.20
- centos.stream.9
- debian.12
- fedora.40
- ubuntu.20.04
- ubuntu.22.04
- ubuntu.24.04
targetFramework: [ '8.0', '6.0' ]

dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
steps:
-
name: Checkout
Expand Down Expand Up @@ -65,16 +62,16 @@ jobs:
uses: ./.github/actions/docker-test
with:
arch: ${{ inputs.arch }}
distro: ${{ matrix.distro }}
targetFramework: ${{ matrix.targetFramework }}
dockerDistro: ${{ matrix.dockerDistro }}
dotnetVersion: ${{ matrix.dotnetVersion }}
-
name: Docker Publish
if: success() && github.event_name != 'pull_request' && github.repository_owner == 'GitTools' && github.ref_name == 'main'
uses: ./.github/actions/docker-publish
with:
arch: ${{ inputs.arch }}
distro: ${{ matrix.distro }}
targetFramework: ${{ matrix.targetFramework }}
dockerDistro: ${{ matrix.dockerDistro }}
dotnetVersion: ${{ matrix.dotnetVersion }}
docker_registry_username: ${{ secrets.DOCKER_USERNAME }}
docker_registry_password: ${{ secrets.DOCKER_PASSWORD }}
github_registry_username: ${{ github.repository_owner }}
Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/_docker_manifests.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
on:
workflow_call:

inputs:
dockerDistros:
required: true
type: string
dotnetVersions:
required: true
type: string
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"

jobs:
manifest:
name: ${{ matrix.distro }} - net${{ matrix.targetFramework }}
name: ${{ matrix.dockerDistro }} - net${{ matrix.dotnetVersion }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
distro:
- alpine.3.20
- centos.stream.9
- debian.12
- fedora.40
- ubuntu.20.04
- ubuntu.22.04
- ubuntu.24.04
targetFramework: [ '8.0', '6.0' ]

dockerDistro: ${{ fromJson(inputs.dockerDistros) }}
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}
steps:
-
name: Checkout
Expand Down Expand Up @@ -51,8 +49,8 @@ jobs:
if: success() && github.event_name != 'pull_request' && github.repository_owner == 'GitTools' && github.ref_name == 'main'
uses: ./.github/actions/docker-manifests
with:
distro: ${{ matrix.distro }}
targetFramework: ${{ matrix.targetFramework }}
dockerDistro: ${{ matrix.dockerDistro }}
dotnetVersion: ${{ matrix.dotnetVersion }}
docker_registry_username: ${{ secrets.DOCKER_USERNAME }}
docker_registry_password: ${{ secrets.DOCKER_PASSWORD }}
github_registry_username: ${{ github.repository_owner }}
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
13 changes: 8 additions & 5 deletions .github/workflows/_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
on:
workflow_call:

inputs:
dotnetVersions:
required: true
type: string
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"

jobs:
unit_test:
name: ${{ matrix.os }} - net${{ matrix.targetFramework }}
name: ${{ matrix.os }} - net${{ matrix.dotnetVersion }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-15]
targetFramework: [ '8.0', '6.0' ]
dotnetVersion: ${{ fromJson(inputs.dotnetVersions) }}

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -29,11 +32,11 @@ jobs:
-
name: '[Unit Test]'
shell: pwsh
run: dotnet run/build.dll --target=Test --dotnet_target=${{ matrix.targetFramework }}
run: dotnet run/build.dll --target=Test --dotnet_version=${{ matrix.dotnetVersion }}

-
name: Test Summary
uses: test-summary/action@v2.4
if: matrix.targetFramework == '8.0'
if: matrix.dotnetVersion == '8.0'
with:
paths: artifacts/test-results/*.results.xml
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
Loading