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 dc29a1b
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 27 deletions.
63 changes: 41 additions & 22 deletions .github/workflow-gen/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Duende Software. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System.Linq.Expressions;
using Logicality.GitHub.Actions.Workflow;
using static GitHubContexts;

Expand All @@ -9,22 +10,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 +59,63 @@ 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;

job.Permissions(
.Strategy()
.Matrix(("os", component.RunsOn))
.Job
.RunsOn("${{ matrix.os }}")
.Defaults()
.Run("bash", component.Name)
.Job;

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

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;

packJob.StepSetupDotNet();

packJob.StepInstallCACerts();

job.StepToolRestore();
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 Down Expand Up @@ -180,7 +199,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
23 changes: 22 additions & 1 deletion .github/workflows/access-token-management-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
Expand All @@ -29,6 +29,10 @@ jobs:
run:
shell: bash
working-directory: access-token-management
strategy:
matrix:
os:
- ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
Expand All @@ -53,6 +57,23 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
fail-on-empty: true
pack:
name: Pack
needs:
- build
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: access-token-management
steps:
- 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
24 changes: 23 additions & 1 deletion .github/workflows/identity-model-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
Expand All @@ -29,6 +29,11 @@ jobs:
run:
shell: bash
working-directory: identity-model
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
timeout-minutes: 15
steps:
- name: Checkout
Expand All @@ -53,6 +58,23 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
fail-on-empty: true
pack:
name: Pack
needs:
- build
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: identity-model
steps:
- 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
24 changes: 23 additions & 1 deletion .github/workflows/identity-model-oidc-client-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
Expand All @@ -29,6 +29,11 @@ jobs:
run:
shell: bash
working-directory: identity-model-oidc-client
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
timeout-minutes: 15
steps:
- name: Checkout
Expand All @@ -53,6 +58,23 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
fail-on-empty: true
pack:
name: Pack
needs:
- build
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: identity-model-oidc-client
steps:
- 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
24 changes: 23 additions & 1 deletion .github/workflows/ignore-this-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
Expand All @@ -29,6 +29,11 @@ jobs:
run:
shell: bash
working-directory: ignore-this
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
timeout-minutes: 15
steps:
- name: Checkout
Expand All @@ -53,6 +58,23 @@ jobs:
reporter: dotnet-trx
fail-on-error: true
fail-on-empty: true
pack:
name: Pack
needs:
- build
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ignore-this
steps:
- 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 ignore-this/src/IgnoreThis/IgnoreThis.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>Duende.IgnoreThis</PackageId>
Expand Down

0 comments on commit dc29a1b

Please sign in to comment.