Skip to content

Feature/docs basic entries #85

Feature/docs basic entries

Feature/docs basic entries #85

Workflow file for this run

name: Build repo
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'src/**'
- 'tests/**'
- 'example/**'
- '.github/workflows/**'
jobs:
check-code-formatting:
runs-on: ubuntu-latest
name: Check code formatting against editorconfig
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install dotnet-format tool
run: dotnet tool install -g dotnet-format
- name: Check Code Format
run: dotnet-format --check
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 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install dependencies
run: dotnet restore --locked-mode
- 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 minimal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage
- name: Code Coverage Summary Report
uses: irongut/[email protected]
with:
filename: 'coverage/*/coverage.cobertura.xml'
badge: true
format: 'markdown'
output: 'both'
- name: Add Coverage PR Comment
uses: marocchino/[email protected]
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: Build NuGet Package
run: dotnet pack src/OwaspHeaders.Core.csproj --configuration Release
- uses: actions/upload-artifact@v4
if: ${{ success() }}
with:
name: OwaspHeaders.Core
path: ${{ github.workspace }}/**/*.nupkg
retention-days: 5