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

Modernise build and migrate to GitHub Actions for CI #2775

Merged
merged 28 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1a2b67b
Configure Visual Studio Code extensions
martincostello Apr 3, 2024
fb677eb
Fix/suppress build warnings
martincostello Apr 3, 2024
ea6f2d5
Run npm audit fix
martincostello Apr 3, 2024
d3ec037
Delete build.txt
martincostello Apr 3, 2024
3d29509
Modernise build
martincostello Apr 3, 2024
dc51910
Remove licenseUrl
martincostello Apr 3, 2024
ff8f4be
Add GitHub Actions workflows
martincostello Apr 3, 2024
16f8201
Configure dependabot
martincostello Apr 3, 2024
b634341
Fix report path
martincostello Apr 3, 2024
39d88ea
Set executable bit
martincostello Apr 3, 2024
030c3af
Fix DotNetSwaggerPath
martincostello Apr 3, 2024
baf8254
Fix permissions
martincostello Apr 3, 2024
16c4cc9
Change PR build version suffix
martincostello Apr 3, 2024
7f0b0e6
Fix paths used with exec
martincostello Apr 3, 2024
11e6ce7
Remove XML file
martincostello Apr 3, 2024
33181c2
Another attempt to fix paths
martincostello Apr 3, 2024
405d4f1
Add Swashbuckle.AspNetCore.Cli reference
martincostello Apr 3, 2024
e201606
Lowercase Configuration
martincostello Apr 3, 2024
4e72a0b
Fix condition
martincostello Apr 3, 2024
03c79b1
Tighten coverage scope
martincostello Apr 3, 2024
d324b8e
Remove SDK setup steps
martincostello Apr 3, 2024
54daca9
Re-add setup-dotnet
martincostello Apr 3, 2024
c327787
Change syntax
martincostello Apr 3, 2024
31f9fec
Try Windows
martincostello Apr 3, 2024
09fedd0
Try manual build
martincostello Apr 3, 2024
703d2b8
Rename step
martincostello Apr 3, 2024
5345377
Simplify condition
martincostello Apr 10, 2024
5e2ea49
Bump version
martincostello Apr 3, 2024
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
6 changes: 4 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ root = true

[*]
end_of_line = CRLF
insert_final_newline = true

[*.{config,cs,xml}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.{proj,props,sln,targets}]
indent_style = tab
[*.{proj,props,sln,targets,yml}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true

[*.{kproj,csproj,json,ps1,psd1,psm1,resx,rst}]
Expand Down
17 changes: 17 additions & 0 deletions .github/actionlint-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "actionlint",
"pattern": [
{
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
"file": 1,
"line": 2,
"column": 3,
"message": 4,
"code": 5
}
]
}
]
}
58 changes: 58 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
day: wednesday
time: "10:00"
timezone: Europe/London
# TODO Enable npm updates
#- package-ecosystem: npm
# directory: "/src/Swashbuckle.AspNetCore.ReDoc"
# schedule:
# interval: weekly
# day: wednesday
# time: "10:00"
# timezone: Europe/London
#- package-ecosystem: npm
# directory: "/src/Swashbuckle.AspNetCore.SwaggerUI"
# schedule:
# interval: weekly
# day: wednesday
# time: "10:00"
# timezone: Europe/London
- package-ecosystem: nuget
directory: "/"
groups:
coverlet:
patterns:
- coverlet*
Microsoft.OpenApi:
patterns:
- Microsoft.OpenApi*
xunit:
patterns:
- xunit*
schedule:
interval: weekly
day: wednesday
time: "10:00"
timezone: Europe/London
ignore:
# Ignore the libraries which are "pinned"
- dependency-name: "IdentityServer4"
- dependency-name: "IdentityServer4.AccessTokenValidation"
- dependency-name: "Microsoft.AspNetCore"
- dependency-name: "Microsoft.AspNetCore.App"
- dependency-name: "Microsoft.AspNetCore.Mvc.ApiExplorer"
- dependency-name: "Microsoft.AspNetCore.Mvc.DataAnnotations"
- dependency-name: "Microsoft.AspNetCore.Mvc.Formatters.Json"
- dependency-name: "Microsoft.AspNetCore.Mvc.NewtonsoftJson"
- dependency-name: "Microsoft.AspNetCore.Mvc.Testing"
- dependency-name: "Microsoft.AspNetCore.Routing"
- dependency-name: "Microsoft.AspNetCore.StaticFiles"
- dependency-name: "Microsoft.Extensions.FileProviders.Embedded"
- dependency-name: "Microsoft.OpenApi"
- dependency-name: "Microsoft.OpenApi.Readers"
- dependency-name: "System.Text.Json"
36 changes: 36 additions & 0 deletions .github/workflows/actions-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: actions-lint

on:
push:
branches: [ master ]
paths-ignore:
- '**/*.gitattributes'
- '**/*.gitignore'
- '**/*.md'
pull_request:
branches: [ master ]
workflow_dispatch:

permissions:
contents: read

env:
FORCE_COLOR: 3
TERM: xterm

jobs:
lint:
runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Add actionlint problem matcher
run: echo "::add-matcher::.github/actionlint-matcher.json"

- name: Lint workflows
uses: docker://rhysd/actionlint@sha256:daa1edae4a6366f320b68abb60b74fb59a458c17b61938d3c62709d92b231558 # v1.6.27
with:
args: -color
166 changes: 166 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: build

on:
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
workflow_dispatch:

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
NUGET_XMLDOC_MODE: skip
TERM: xterm

permissions:
contents: read

jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}

outputs:
dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }}

strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest

steps:

- name: Checkout code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Setup .NET SDK
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
id: setup-dotnet

- name: Setup NuGet cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props') }}
restore-keys: ${{ runner.os }}-nuget-

- name: Build, Package and Test
shell: pwsh
run: |
./build.ps1

- name: Upload Coverage Reports
if: always()
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: coverage-${{ runner.os }}
path: ./artifacts/coverage
if-no-files-found: ignore

- name: Upload coverage to Codecov
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4.1.1
with:
files: ./artifacts/coverage/coverage.cobertura.xml
flags: ${{ runner.os }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Publish NuGet packages
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: packages-${{ runner.os }}
path: ./artifacts/package/release
if-no-files-found: error

validate-packages:
needs: build
runs-on: ubuntu-latest
steps:

- name: Download packages
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: packages-Windows

- name: Setup .NET SDK
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
with:
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}

- name: Validate NuGet packages
shell: pwsh
run: |
dotnet tool install --global dotnet-validate --version 0.0.1-preview.304
$packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName }
$invalidPackages = 0
foreach ($package in $packages) {
dotnet validate package local $package
if ($LASTEXITCODE -ne 0) {
$invalidPackages++
}
}
if ($invalidPackages -gt 0) {
Write-Output "::error::$invalidPackages NuGet package(s) failed validation."
}

publish-myget:
needs: [ build, validate-packages ]
runs-on: ubuntu-latest
if: |
github.event.repository.fork == false &&
(github.ref_name == github.event.repository.default_branch ||
startsWith(github.ref, 'refs/tags/v'))

environment:
name: MyGet.org
url: https://www.myget.org/gallery/domaindrivendev

steps:

- name: Download packages
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: packages-Windows

- name: Setup .NET SDK
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
with:
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}

- name: Push signed NuGet packages to NuGet.org
run: |
dotnet nuget push "*.nupkg" --api-key ${{ secrets.MYGET_TOKEN }} --skip-duplicate --source https://www.myget.org/F/domaindrivendev/api/v2

publish-nuget:
needs: [ build, validate-packages ]
runs-on: ubuntu-latest
if: |
github.event.repository.fork == false &&
startsWith(github.ref, 'refs/tags/v')

environment:
name: NuGet.org
url: https://www.nuget.org/profiles/domaindrivendev

steps:

- name: Download packages
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: packages-Windows

- name: Setup .NET SDK
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
with:
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}

- name: Push signed NuGet packages to NuGet.org
run: |
dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate --source https://api.nuget.org/v3/index.json
45 changes: 45 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: codeql-analysis

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '0 8 * * MON'
workflow_dispatch:

permissions:
actions: read
contents: read

jobs:
code-ql:

runs-on: ubuntu-latest

permissions:
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Setup .NET SDK
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0

- name: Initialize CodeQL
uses: github/codeql-action/init@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
languages: csharp
build-mode: manual

- name: Build
shell: pwsh
run: |
dotnet build --configuration Release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
category: '/language:csharp'
44 changes: 44 additions & 0 deletions .github/workflows/ossf-scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: ossf-scorecard

on:
push:
branches: [ master ]
schedule:
- cron: '0 8 * * MON'
workflow_dispatch:

permissions: read-all

jobs:
analysis:
name: analysis
runs-on: ubuntu-latest

permissions:
id-token: write
security-events: write

steps:
- name: Checkout code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
persist-credentials: false

- name: Run analysis
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
publish_results: true
results_file: results.sarif
results_format: sarif

- name: Upload artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: SARIF
path: results.sarif
retention-days: 5

- name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
sarif_file: results.sarif
Loading