Skip to content

Commit

Permalink
Seperate build job from pack job and add matrix support to run tests …
Browse files Browse the repository at this point in the history
…on windows (net481 for netstandard targeted libraries)
  • Loading branch information
damianh committed Nov 19, 2024
1 parent fcf2d13 commit 1467f51
Show file tree
Hide file tree
Showing 16 changed files with 215 additions and 46 deletions.
78 changes: 52 additions & 26 deletions .github/workflow-gen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@
new("ignore-this",
["IgnoreThis"],
["IgnoreThis.Tests"],
"it"),
"it",
["ubuntu-latest", "windows-latest"]),

new("access-token-management",
["AccessTokenManagement", "AccessTokenManagement.OpenIdConnect"],
["AccessTokenManagement.Tests"],
"atm"),
"atm",
["ubuntu-latest"]),

new("identity-model",
["IdentityModel"],
["IdentityModel.Tests"],
"im"),
"im",
["ubuntu-latest", "windows-latest"]),

new("identity-model-oidc-client",
["IdentityModel.OidcClient", "IdentityModel.OidcClient.Extensions"],
["IdentityModel.OidcClient.Tests"],
"imoc")
"imoc",
["ubuntu-latest", "windows-latest"])
];

foreach (var component in components)
Expand Down Expand Up @@ -54,49 +58,71 @@ void GenerateCiWorkflow(Component component)

workflow.EnvDefaults();

var job = workflow
var buildJob = workflow
.Job("build")
.Name("Build")
.RunsOn(GitHubHostedRunners.UbuntuLatest)
.Defaults().Run("bash", component.Name)
.Job;
.Strategy()
.Matrix(("os", component.RunsOn))
.FailFast(false)
.Job
.RunsOn("${{ matrix.os }}")
.Defaults()
.Run("bash", component.Name)
.Job;

job.Permissions(
actions: Permission.Read,
contents: Permission.Read,
checks: Permission.Write,
packages: Permission.Write);
buildJob.Permissions(checks: Permission.Write, contents: Permission.Read);

job.TimeoutMinutes(15);
buildJob.TimeoutMinutes(15);

job.Step()
buildJob.Step()
.ActionsCheckout();

job.StepSetupDotNet();
buildJob.StepSetupDotNet();

foreach (var testProject in component.Tests)
{
job.StepTestAndReport(component.Name, testProject);
buildJob.StepTestAndReport(component.Name, testProject);
}

job.StepInstallCACerts();
var packJob = workflow.Job("pack")
.Name("Pack")
.RunsOn(GitHubHostedRunners.UbuntuLatest)
.Needs("build")
.Defaults()
.Run("bash", component.Name)
.Job;

job.StepToolRestore();
packJob.Permissions(
actions: Permission.Read,
contents: Permission.Read,
checks: Permission.Write,
packages: Permission.Write);

packJob.TimeoutMinutes(15);

packJob.Step()
.ActionsCheckout();

packJob.StepSetupDotNet();

packJob.StepInstallCACerts();

packJob.StepToolRestore();

foreach (var project in component.Projects)
{
job.StepPack(project);
packJob.StepPack(project);
}

job.StepSign();
packJob.StepSign();

job.StepPush("MyGet", "https://www.myget.org/F/duende_identityserver/api/v2/package", "MYGET");
packJob.StepPush("MyGet", "https://www.myget.org/F/duende_identityserver/api/v2/package", "MYGET");

job.StepPush("GitHub", "https://nuget.pkg.github.com/DuendeSoftware/index.json", "GITHUB_TOKEN")
packJob.StepPush("GitHub", "https://nuget.pkg.github.com/DuendeSoftware/index.json", "GITHUB_TOKEN")
.Env(("GITHUB_TOKEN", contexts.Secrets.GitHubToken),
("NUGET_AUTH_TOKEN", contexts.Secrets.GitHubToken));

job.StepUploadArtifacts(component.Name);
packJob.StepUploadArtifacts(component.Name);

var fileName = $"{component.Name}-ci";
WriteWorkflow(workflow, fileName);
Expand All @@ -120,7 +146,7 @@ void GenerateReleaseWorkflow(Component component)
.Defaults().Run("bash", component.Name).Job;

tagJob.Step()
.ActionsCheckout();
.ActionsCheckout("11bd71901bbe5b1630ceea73d27597364c9af683");

tagJob.StepSetupDotNet();

Expand Down Expand Up @@ -180,7 +206,7 @@ void WriteWorkflow(Workflow workflow, string fileName)
Console.WriteLine($"Wrote workflow to {filePath}");
}

record Component(string Name, string[] Projects, string[] Tests, string TagPrefix);
record Component(string Name, string[] Projects, string[] Tests, string TagPrefix, string[] RunsOn);

public static class StepExtensions
{
Expand Down
36 changes: 33 additions & 3 deletions .github/workflows/access-token-management-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
contents: read
packages: write
defaults:
run:
shell: bash
working-directory: access-token-management
strategy:
matrix:
os:
- ubuntu-latest
fail-fast: false
timeout-minutes: 15
steps:
- name: Checkout
Expand All @@ -53,6 +56,33 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
fail-on-empty: true
pack:
name: Pack
needs:
- build
runs-on: ubuntu-latest
permissions:
actions: read
checks: write
contents: read
packages: write
defaults:
run:
shell: bash
working-directory: access-token-management
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Dotnet
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25
with:
dotnet-version: |-
6.0.x
8.0.x
9.0.x
- name: Install Sectigo CodeSiging CA certificates
run: |-
sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/access-token-management-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
working-directory: access-token-management
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Setup Dotnet
Expand Down
37 changes: 34 additions & 3 deletions .github/workflows/identity-model-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
contents: read
packages: write
defaults:
run:
shell: bash
working-directory: identity-model
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
fail-fast: false
timeout-minutes: 15
steps:
- name: Checkout
Expand All @@ -53,6 +57,33 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
fail-on-empty: true
pack:
name: Pack
needs:
- build
runs-on: ubuntu-latest
permissions:
actions: read
checks: write
contents: read
packages: write
defaults:
run:
shell: bash
working-directory: identity-model
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Dotnet
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25
with:
dotnet-version: |-
6.0.x
8.0.x
9.0.x
- name: Install Sectigo CodeSiging CA certificates
run: |-
sudo apt-get update
Expand Down
37 changes: 34 additions & 3 deletions .github/workflows/identity-model-oidc-client-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
contents: read
packages: write
defaults:
run:
shell: bash
working-directory: identity-model-oidc-client
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
fail-fast: false
timeout-minutes: 15
steps:
- name: Checkout
Expand All @@ -53,6 +57,33 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
fail-on-empty: true
pack:
name: Pack
needs:
- build
runs-on: ubuntu-latest
permissions:
actions: read
checks: write
contents: read
packages: write
defaults:
run:
shell: bash
working-directory: identity-model-oidc-client
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Dotnet
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25
with:
dotnet-version: |-
6.0.x
8.0.x
9.0.x
- name: Install Sectigo CodeSiging CA certificates
run: |-
sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/identity-model-oidc-client-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
working-directory: identity-model-oidc-client
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Setup Dotnet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/identity-model-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
working-directory: identity-model
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Setup Dotnet
Expand Down
37 changes: 34 additions & 3 deletions .github/workflows/ignore-this-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
contents: read
packages: write
defaults:
run:
shell: bash
working-directory: ignore-this
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
fail-fast: false
timeout-minutes: 15
steps:
- name: Checkout
Expand All @@ -53,6 +57,33 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
fail-on-empty: true
pack:
name: Pack
needs:
- build
runs-on: ubuntu-latest
permissions:
actions: read
checks: write
contents: read
packages: write
defaults:
run:
shell: bash
working-directory: ignore-this
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Dotnet
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25
with:
dotnet-version: |-
6.0.x
8.0.x
9.0.x
- name: Install Sectigo CodeSiging CA certificates
run: |-
sudo apt-get update
Expand Down
Loading

0 comments on commit 1467f51

Please sign in to comment.