Skip to content
Open
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
145 changes: 145 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: CI Pipeline

on:
push:
branches: [main, develop, 'feature/**']
pull_request:
branches: [main, develop]

jobs:
build:
name: Build & Restore
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Restore
run: dotnet restore

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

unit-tests:
name: Unit Tests & Coverage
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

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

- name: Restore
run: dotnet restore

- name: Run Unit Tests with Coverage
run: |
dotnet test BPCalculator.Tests/BPCalculator.Tests.csproj \
--configuration Release \
--collect:"XPlat Code Coverage" \
--results-directory ./coverage \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Exclude="[*]BPCalculator.Pages.Pages_*,[*]BPCalculator.Pages.ErrorModel,[*]BPCalculator.Pages.PrivacyModel,[*]BPCalculator.Program,[*]BPCalculator.Startup"

- name: Install ReportGenerator
run: dotnet tool install -g dotnet-reportgenerator-globaltool

- name: Generate Coverage Report
run: |
reportgenerator \
-reports:./coverage/**/coverage.cobertura.xml \
-targetdir:./coverage-html \
-reporttypes:Html

- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ./coverage-html

bdd-tests:
name: BDD Tests
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

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

- name: Restore
run: dotnet restore

- name: Run BDD Tests
run: |
dotnet test BPCalculator.BDDTests/BPCalculator.BDDTests.csproj \
--configuration Release

security:
name: Security Scans
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Gitleaks Secret Scan
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

- name: Restore
run: dotnet restore

- name: Snyk Dependency Scan
uses: snyk/actions/dotnet@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high

sonarcloud:
name: SonarCloud Analysis
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Install SonarScanner
run: dotnet tool install --global dotnet-sonarscanner

- name: SonarCloud Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet sonarscanner begin \
/k:"${{ secrets.SONAR_PROJECT_KEY }}" \
/o:"${{ secrets.SONAR_ORG_KEY }}" \
/d:sonar.host.url="https://sonarcloud.io" \
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"
dotnet build --no-incremental
dotnet sonarscanner end \
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"
26 changes: 26 additions & 0 deletions BPCalculator.BDDTests/BPCalculator.BDDTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="SpecFlow.xUnit" Version="3.9.74" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Include="Features\*.feature" CopyToOutputDirectory="Always" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPCalculator\BPCalculator.csproj" />
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions BPCalculator.BDDTests/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BPCalculator.BDDTests;

public class Class1
{

}
Binary file not shown.
Loading