Skip to content
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

try to introduce .yml templates so introducing new packages requires less work #2036

Closed
wants to merge 2 commits into from
Closed
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
33 changes: 33 additions & 0 deletions .github/templates/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
parameters:
pipelineName: '' # required -- CI pipeline name
tags: [] # required -- list of tags
projectPath: '' # required -- relative path to csproj with health check
packageName: '' # required -- name of the NuGet package

name: ${{ parameters.pipelineName }}

on:
push:
tags: ${{ parameters.tags }}

jobs:
build:
env:
BUILD_CONFIG: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore
run: dotnet restore ${{ parameters.projectPath }}
- name: Build
run: dotnet build --no-restore ${{ parameters.projectPath }} -c $BUILD_CONFIG
- name: Pack
run: dotnet pack --no-build ${{ parameters.projectPath }} -c $BUILD_CONFIG -o ./artifacts
- name: Publish
run: dotnet nuget push ./artifacts/${{ parameters.packageName }}.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
35 changes: 35 additions & 0 deletions .github/templates/cd_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
parameters:
pipelineName: '' # required -- CI pipeline name
tags: [] # required -- list of tags
projectPath: '' # required -- relative path to csproj with health check
packageName: '' # required -- name of the NuGet package
versionPrefix: '' # required -- the prefix of the version suffix

name: ${{ parameters.pipelineName }}

on:
push:
tags: ${{ parameters.tags }}

jobs:
build:
env:
BUILD_CONFIG: Release
VERSION_SUFFIX: ${{ parameters.versionPrefix }}.${{ github.run_number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore
run: dotnet restore ${{ parameters.projectPath }}
- name: Build
run: dotnet build --no-restore ${{ parameters.projectPath }} -c $BUILD_CONFIG
- name: Pack
run: dotnet pack --no-build ${{ parameters.projectPath }} --version-suffix $VERSION_SUFFIX -c $BUILD_CONFIG -o ./artifacts
- name: Publish
run: dotnet nuget push ./artifacts/${{ parameters.packageName }}.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
60 changes: 60 additions & 0 deletions .github/templates/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
parameters:
pipelineName: '' # required -- CI pipeline name
paths: [] # required -- list of paths
projectPath: '' # required -- relative path to csproj with health check
testProjectPath: '' # required -- relative path to csproj with health check tests
flags: '' # required -- code coverage flags

name: ${{ parameters.pipelineName }}

on:
workflow_dispatch:
push:
branches: [ master ]
paths: ${{ parameters.paths }}
tags-ignore:
- release-*
- preview-*

pull_request:
branches: [ master ]
paths: ${{ parameters.paths }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore
run: |
dotnet restore ${{ parameters.projectPath }} &&
dotnet restore ${{ parameters.testProjectPath }}
- name: Check formatting
run: |
dotnet format --no-restore --verify-no-changes --severity warn ${{ parameters.projectPath }} || (echo "Run 'dotnet format' to fix issues" && exit 1) &&
dotnet format --no-restore --verify-no-changes --severity warn ${{ parameters.testProjectPath }} || (echo "Run 'dotnet format' to fix issues" && exit 1)
- name: Build
run: |
dotnet build --no-restore ${{ parameters.projectPath }}
dotnet build --no-restore ${{ parameters.testProjectPath }}
- name: Test
run: >
dotnet test
${{ parameters.testProjectPath }}
--no-restore
--no-build
--collect "XPlat Code Coverage"
--results-directory .coverage
--
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
flags: ${{ parameters.flags }}
directory: .coverage
31 changes: 5 additions & 26 deletions .github/workflows/healthchecks_azurekeyvault_cd.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
name: HealthChecks AzureKeyVault DB CD

on:
push:
- template: /.github/templates/cd.yml
parameters:
pipelineName: HealthChecks AzureKeyVault DB CD
tags:
- release-azurekeyvault-*
- release-all-*

jobs:
build:
env:
BUILD_CONFIG: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore
run: dotnet restore ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj
- name: Build
run: dotnet build --no-restore ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj -c $BUILD_CONFIG
- name: Pack
run: dotnet pack --no-build ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj -c $BUILD_CONFIG -o ./artifacts
- name: Publish
run: dotnet nuget push ./artifacts/AspNetCore.HealthChecks.AzureKeyVault.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
projectPath: ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj
packageName: AspNetCore.HealthChecks.AzureKeyVault
33 changes: 6 additions & 27 deletions .github/workflows/healthchecks_azurekeyvault_cd_preview.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
name: HealthChecks AzureKeyVault DB Preview CD

on:
push:
- template: /.github/templates/cd_preview.yml
parameters:
pipelineName: HealthChecks AzureKeyVault DB Preview CD
tags:
- preview-azurekeyvault-*
- preview-all-*

jobs:
build:
env:
BUILD_CONFIG: Release
VERSION_SUFFIX: rc2.${{ github.run_number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore
run: dotnet restore ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj
- name: Build
run: dotnet build --no-restore ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj -c $BUILD_CONFIG
- name: Pack
run: dotnet pack --no-build ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj --version-suffix $VERSION_SUFFIX -c $BUILD_CONFIG -o ./artifacts
- name: Publish
run: dotnet nuget push ./artifacts/AspNetCore.HealthChecks.AzureKeyVault.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
projectPath: ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj
packageName: AspNetCore.HealthChecks.AzureKeyVault
versionPrefix: rc2
65 changes: 7 additions & 58 deletions .github/workflows/healthchecks_azurekeyvault_ci.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,14 @@
name: HealthChecks AzureKeyVault DB CI

on:
workflow_dispatch:
push:
branches: [ master ]
paths:
- src/HealthChecks.AzureKeyVault/**
- test/HealthChecks.AzureKeyVault.Tests/**
- test/_SHARED/**
- .github/workflows/healthchecks_azurekeyvault_ci.yml
- Directory.Build.props
- Directory.Build.targets
tags-ignore:
- release-*
- preview-*

pull_request:
branches: [ master ]
- template: /.github/templates/ci.yml
parameters:
pipelineName: HealthChecks AzureKeyVault DB CI
paths:
- src/HealthChecks.AzureKeyVault/**
- test/HealthChecks.AzureKeyVault.Tests/**
- test/_SHARED/**
- .github/templates/ci.yml
- .github/workflows/healthchecks_azurekeyvault_ci.yml
- Directory.Build.props
- Directory.Build.targets

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore
run: |
dotnet restore ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj &&
dotnet restore ./test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj
- name: Check formatting
run: |
dotnet format --no-restore --verify-no-changes --severity warn ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj || (echo "Run 'dotnet format' to fix issues" && exit 1) &&
dotnet format --no-restore --verify-no-changes --severity warn ./test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj || (echo "Run 'dotnet format' to fix issues" && exit 1)
- name: Build
run: |
dotnet build --no-restore ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj
dotnet build --no-restore ./test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj
- name: Test
run: >
dotnet test
./test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj
--no-restore
--no-build
--collect "XPlat Code Coverage"
--results-directory .coverage
--
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
flags: AzureKeyVault
directory: .coverage
projectPath: ./src/HealthChecks.AzureKeyVault/HealthChecks.AzureKeyVault.csproj
testProjectPath: ./test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj
flags: AzureKeyVault
31 changes: 5 additions & 26 deletions .github/workflows/healthchecks_azurekeyvault_secrets_cd.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
name: HealthChecks Azure KeyVault Secrets CD

on:
push:
- template: /.github/templates/cd.yml
parameters:
pipelineName: HealthChecks Azure KeyVault Secrets CD
tags:
- release-azurekeyvault-secrets-*
- release-all-*

jobs:
build:
env:
BUILD_CONFIG: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore
run: dotnet restore ./src/HealthChecks.Azure.KeyVault.Secrets/HealthChecks.Azure.KeyVault.Secrets.csproj
- name: Build
run: dotnet build --no-restore ./src/HealthChecks.Azure.KeyVault.Secrets/HealthChecks.Azure.KeyVault.Secrets.csproj -c $BUILD_CONFIG
- name: Pack
run: dotnet pack --no-build ./src/HealthChecks.Azure.KeyVault.Secrets/HealthChecks.Azure.KeyVault.Secrets.csproj -c $BUILD_CONFIG -o ./artifacts
- name: Publish
run: dotnet nuget push ./artifacts/AspNetCore.HealthChecks.Azure.KeyVault.Secrets.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
projectPath: ./src/HealthChecks.Azure.KeyVault.Secrets/HealthChecks.Azure.KeyVault.Secrets.csproj
packageName: AspNetCore.HealthChecks.Azure.KeyVault.Secrets
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
name: HealthChecks Azure KeyVault Secrets Preview CD

on:
push:
- template: /.github/templates/cd_preview.yml
parameters:
pipelineName: HealthChecks Azure KeyVault Secrets Preview CD
tags:
- preview-azurekeyvault-secrets-*
- preview-all-*

jobs:
build:
env:
BUILD_CONFIG: Release
VERSION_SUFFIX: rc1.${{ github.run_number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Restore
run: dotnet restore ./src/HealthChecks.Azure.KeyVault.Secrets/HealthChecks.Azure.KeyVault.Secrets.csproj
- name: Build
run: dotnet build --no-restore ./src/HealthChecks.Azure.KeyVault.Secrets/HealthChecks.Azure.KeyVault.Secrets.csproj -c $BUILD_CONFIG
- name: Pack
run: dotnet pack --no-build ./src/HealthChecks.Azure.KeyVault.Secrets/HealthChecks.Azure.KeyVault.Secrets.csproj --version-suffix $VERSION_SUFFIX -c $BUILD_CONFIG -o ./artifacts
- name: Publish
run: dotnet nuget push ./artifacts/AspNetCore.HealthChecks.Azure.KeyVault.Secrets.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
projectPath: ./src/HealthChecks.Azure.KeyVault.Secrets/HealthChecks.Azure.KeyVault.Secrets.csproj
packageName: AspNetCore.HealthChecks.Azure.KeyVault.Secrets
versionPrefix: rc1
Loading