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

Feature/optimisations for header value builders #130

Merged
merged 11 commits into from
Dec 2, 2024
68 changes: 61 additions & 7 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: '9.0.x'

- name: Install dotnet-format tool
run: dotnet tool install -g dotnet-format
Expand All @@ -35,16 +35,16 @@ jobs:
build:

needs: [check-code-formatting]

runs-on: ubuntu-latest
name: Build code base, checking for compilation errors

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET Core
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
Expand All @@ -54,12 +54,66 @@ jobs:

- name: Build
run: dotnet build --configuration Release --no-restore

test:
# This job is adapted from https://josh-ops.com/posts/github-code-coverage/
# It adds a code coverage report to all PR builds
needs: [build]
runs-on: ubuntu-latest
name: Run all tests and generate PR-level code coverage report

steps:

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Run all tests
run: dotnet test OwaspHeaders.Core.sln --verbosity normal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage
working-directory: ${{env.working-directory}}

- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: 'coverage/*/coverage.cobertura.xml'
badge: true
format: 'markdown'
output: 'both'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2.9.0
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

- name: Write to Job Summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY

package:
needs: [build, test]
runs-on: ubuntu-latest
name: Create the NuGet package for PR-level user testing

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: pack
run: dotnet pack src/OwaspHeaders.Core.csproj --configuration Release --no-build --no-restore
- name: Build NuGet Package
run: dotnet pack src/OwaspHeaders.Core.csproj --configuration Release

- uses: actions/upload-artifact@v4
if: ${{ success() }}
Expand Down
45 changes: 39 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET Core
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
Expand All @@ -32,14 +32,47 @@ jobs:

- name: Build
run: dotnet build --configuration Release --no-restore

test:
needs: [build]
runs-on: ubuntu-latest
name: Run all tests

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Run all tests
run: dotnet test OwaspHeaders.Core.Tests/OwaspHeaders.Core.Tests.csproj

- name: Test
run: dotnet test --no-restore --verbosity normal

- name: pack
run: dotnet pack src/OwaspHeaders.Core.csproj --configuration Release --no-build --no-restore
package:
needs: [build, test]
runs-on: ubuntu-latest
name: Create and upload NuGet package

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Build NuGet package
run: dotnet pack src/OwaspHeaders.Core.csproj --configuration Release

- name: Push NuGet package
run: dotnet nuget push **\*.nupkg --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_API_KEY}}
env:
GITHUB_TOKEN: ${{ secrets.NUGET_API_KEY }}
GITHUB_TOKEN: ${{ secrets.NUGET_API_KEY }}
1 change: 1 addition & 0 deletions OwaspHeaders.Core.Example/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using OwaspHeaders.Core.Extensions;
Loading
Loading