Skip to content

Commit 51df654

Browse files
authored
PR validation pipelines (#10)
* Added PR pipelines * Include some of the idea into git * Central package management and fixes * PR comment fixes * Formatting fixes * PR comment fixes * Possible integration test fixes * Common pipeline * Fixed the pipelines * Fixing the pipeline * Unit/int tests in parallel * Fixed integration tests * Code cleanup * Use JB cleanup * PR validation fixes * Depend on formatting * PR comment fixes * PR adjustments
1 parent e30acf6 commit 51df654

54 files changed

Lines changed: 2888 additions & 620 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coderabbit.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
language: en-US
2+
3+
reviews:
4+
profile: chill
5+
request_changes_workflow: false
6+
auto_review:
7+
enabled: true
8+
drafts: false
9+
path_filters:
10+
- '!**/*.Designer.cs'
11+
- '!**/*.g.cs'
12+
- '!**/obj/**'
13+
- '!**/bin/**'
14+
- '!**/*.diff'
15+
path_instructions:
16+
- path: src/ServiceBusToolset.Application/**
17+
instructions: >
18+
This is the Application layer using Vertical Slice Architecture.
19+
Each feature is a self-contained slice with Command, CommandHandler, and Result types.
20+
Uses martinothanar/Mediator (source-generated) for CQRS and Ardalis.Result for return types.
21+
Cross-cutting concerns live in Common/ folders at the appropriate level.
22+
- path: src/ServiceBusToolset.CLI/**
23+
instructions: >
24+
This is the CLI presentation layer. It must not contain business logic.
25+
CLI handlers inject ISender (Mediator) to dispatch commands to the Application layer.
26+
Uses CommandLineParser for argument parsing and Spectre.Console for output.
27+
- path: tests/**
28+
instructions: >
29+
Test classes follow [ClassName]Should naming. Test methods follow [Action]_When[Condition] naming.
30+
Use Shouldly for assertions and NSubstitute for mocking. Never use #region/#endregion.
31+
- path: .github/workflows/**
32+
instructions: >
33+
Review for security best practices: pin action versions, avoid script injection
34+
via untrusted inputs, ensure secrets are not logged.
35+
tools:
36+
actionlint:
37+
enabled: true
38+
markdownlint:
39+
enabled: true
40+
yamllint:
41+
enabled: true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Setup .NET & Restore
2+
description: Setup .NET SDK, cache NuGet packages, and restore dependencies. Requires actions/checkout to run first.
3+
4+
inputs:
5+
dotnet-version:
6+
description: '.NET SDK version to install'
7+
required: false
8+
default: '10.0.x'
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Setup .NET
14+
uses: actions/setup-dotnet@baa11fbfe1d6520db94683bd5c7a3818018e4309 # v5.1.0
15+
with:
16+
dotnet-version: ${{ inputs.dotnet-version }}
17+
18+
- name: Cache NuGet packages
19+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
20+
with:
21+
path: ~/.nuget/packages
22+
key: nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
23+
restore-keys: nuget-
24+
25+
- name: Restore dependencies
26+
run: dotnet restore
27+
shell: bash

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: nuget
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: github-actions
10+
directory: /
11+
schedule:
12+
interval: weekly
13+
open-pull-requests-limit: 5
14+
15+
- package-ecosystem: github-actions
16+
directory: /.github/actions/setup-dotnet-build
17+
schedule:
18+
interval: weekly
19+
open-pull-requests-limit: 5

.github/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
changelog:
2+
categories:
3+
- title: Features
4+
labels: [enhancement]
5+
- title: Bug Fixes
6+
labels: [bug]
7+
- title: Dependencies
8+
labels: [dependencies]
9+
- title: Other Changes
10+
labels: ['*']

.github/workflows/alpha-release.yml

Lines changed: 92 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Alpha Release
22

33
on:
44
push:
5-
branches: [master, 'feature/GK/cicd-pipelines']
5+
branches: [master]
66
paths-ignore:
77
- '**.md'
88
- 'docs/**'
@@ -13,39 +13,116 @@ on:
1313
required: false
1414
default: '1.0.0'
1515

16+
permissions:
17+
contents: read
18+
19+
concurrency:
20+
group: alpha-release-${{ github.ref }}
21+
cancel-in-progress: true
22+
1623
env:
1724
BASE_VERSION: '1.0.0'
1825

1926
jobs:
20-
alpha-release:
27+
test:
28+
name: Run Unit Tests
2129
runs-on: ubuntu-latest
30+
timeout-minutes: 10
2231

2332
steps:
2433
- name: Checkout
25-
uses: actions/checkout@v4
34+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2635

27-
- name: Setup .NET
28-
uses: actions/setup-dotnet@v4
36+
- name: Setup .NET & Restore
37+
uses: ./.github/actions/setup-dotnet-build
38+
39+
- name: Build
40+
run: dotnet build -c Release --no-restore
41+
42+
- name: Run unit tests
43+
run: >
44+
dotnet test tests/ServiceBusToolset.Application.Tests
45+
-c Release --no-build
46+
--collect:"XPlat Code Coverage"
47+
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
48+
49+
- name: Generate coverage report
50+
uses: danielpalme/ReportGenerator-GitHub-Action@ee0ae774f6d3afedcbd1683c1ab21b83670bdf8e # 5.5.1
2951
with:
30-
dotnet-version: '10.0.x'
52+
reports: ./**/coverage.cobertura.xml
53+
targetdir: ./coverage-report
54+
reporttypes: TextSummary
55+
56+
- name: Extract and publish coverage badge
57+
id: coverage
58+
env:
59+
GIST_TOKEN: ${{ secrets.GIST_TOKEN }}
60+
run: |
61+
SUMMARY=$(cat ./coverage-report/Summary.txt)
62+
LINE_COVERAGE=$(echo "$SUMMARY" | grep -i 'Line coverage' | grep -oP '[\d.]+(?=%)')
63+
echo "Line coverage: ${LINE_COVERAGE}%"
64+
if [ -z "$LINE_COVERAGE" ]; then
65+
echo "::warning::Could not parse line coverage"
66+
exit 0
67+
fi
68+
echo "coverage=${LINE_COVERAGE}" >> $GITHUB_OUTPUT
69+
# Determine badge color
70+
if (( $(echo "$LINE_COVERAGE >= 80" | bc -l) )); then
71+
COLOR="brightgreen"
72+
elif (( $(echo "$LINE_COVERAGE >= 60" | bc -l) )); then
73+
COLOR="yellowgreen"
74+
else
75+
COLOR="red"
76+
fi
77+
echo "color=${COLOR}" >> $GITHUB_OUTPUT
78+
79+
- name: Update coverage badge gist
80+
if: steps.coverage.outputs.coverage != '' && env.GIST_TOKEN != ''
81+
uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0
82+
with:
83+
auth: ${{ secrets.GIST_TOKEN }}
84+
gistID: ${{ vars.COVERAGE_GIST_ID }}
85+
filename: coverage-badge.json
86+
label: coverage
87+
message: ${{ steps.coverage.outputs.coverage }}%
88+
color: ${{ steps.coverage.outputs.color }}
89+
90+
alpha-release:
91+
name: Alpha Release
92+
runs-on: ubuntu-latest
93+
needs: test
94+
timeout-minutes: 10
95+
96+
steps:
97+
- name: Checkout
98+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
99+
100+
- name: Setup .NET & Restore
101+
uses: ./.github/actions/setup-dotnet-build
102+
103+
- name: Build
104+
run: dotnet build -c Release --no-restore
31105

32106
- name: Generate version
33107
id: version
108+
env:
109+
INPUT_BASE_VERSION: ${{ github.event.inputs.base_version }}
34110
run: |
35111
# Use input version if provided (workflow_dispatch), otherwise use env default
36-
BASE="${{ github.event.inputs.base_version || env.BASE_VERSION }}"
112+
BASE="${INPUT_BASE_VERSION:-$BASE_VERSION}"
113+
# Validate version matches strict semver pattern
114+
if [[ ! "$BASE" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
115+
echo "::error::Invalid base version '$BASE'. Must match X.Y.Z semver format."
116+
exit 1
117+
fi
37118
ALPHA_VERSION="${BASE}-alpha.${GITHUB_RUN_NUMBER}"
38119
echo "version=$ALPHA_VERSION" >> $GITHUB_OUTPUT
39120
echo "Generated version: $ALPHA_VERSION"
40121
41-
- name: Restore dependencies
42-
run: dotnet restore
43-
44-
- name: Build
45-
run: dotnet build -c Release --no-restore
46-
47122
- name: Pack
48-
run: dotnet pack src/ServiceBusToolset.CLI -c Release --no-build -o ./artifacts -p:Version=${{ steps.version.outputs.version }}
123+
env:
124+
VERSION: ${{ steps.version.outputs.version }}
125+
run: dotnet pack src/ServiceBusToolset.CLI -c Release --no-build -o ./artifacts -p:Version="$VERSION"
49126

50127
- name: Push to NuGet
51128
env:
@@ -55,4 +132,4 @@ jobs:
55132
echo "::warning::NUGET_API_KEY secret not set, skipping publish"
56133
exit 0
57134
fi
58-
dotnet nuget push ./artifacts/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate
135+
dotnet nuget push ./artifacts/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate

0 commit comments

Comments
 (0)