Skip to content

Commit 4390240

Browse files
author
cleilson pereira
committed
feat: Implement GitHub Actions workflows for CI/CD, code coverage, and pull request validation
- Added CI/CD pipeline (`ci.yml`) for automated builds, tests, and package creation. - Introduced code coverage workflow (`coverage.yml`) to generate and upload coverage reports. - Created pull request validation workflow (`pr-validation.yml`) to ensure code quality on PRs. - Established release workflow (`release.yml`) for automated NuGet package publishing. - Configured version update workflow (`update-version.yml`) for managing version bumps and changelog updates. - Integrated Dependabot configuration (`dependabot.yml`) for automatic dependency updates. - Added GitVersion configuration (`GitVersion.yml`) for semantic versioning management. - Updated README.md and changelog.md to reflect new CI/CD features and workflows.
1 parent 8aa46b1 commit 4390240

11 files changed

Lines changed: 864 additions & 1 deletion

File tree

.github/README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# GitHub Actions Workflows
2+
3+
This repository includes several GitHub Actions workflows to automate building, testing, and releasing the Iso20022Library.
4+
5+
## Available Workflows
6+
7+
### 1. CI/CD Pipeline (`ci.yml`)
8+
9+
**Triggers:**
10+
- Push to `main` or `develop` branches
11+
- Pull requests to `main` or `develop` branches
12+
13+
**Jobs:**
14+
- **build-and-test**: Builds the solution and runs all tests
15+
- **code-quality**: Performs static code analysis
16+
- **package**: Creates NuGet packages (only on `main` branch)
17+
- **security-scan**: Runs security vulnerability scanning
18+
19+
**Features:**
20+
- Tests multiple .NET versions
21+
- Caches NuGet packages for faster builds
22+
- Uploads test results and artifacts
23+
- Creates NuGet packages for releases
24+
25+
### 2. Pull Request Validation (`pr-validation.yml`)
26+
27+
**Triggers:**
28+
- Pull request opened, synchronized, or reopened
29+
30+
**Features:**
31+
- Lightweight validation for PRs
32+
- Comments build status on PRs
33+
- Fast feedback for contributors
34+
35+
### 3. Release and Publish (`release.yml`)
36+
37+
**Triggers:**
38+
- GitHub release published
39+
- Manual workflow dispatch
40+
41+
**Features:**
42+
- Builds and tests the solution
43+
- Creates versioned NuGet packages
44+
- Publishes to NuGet.org (requires API key)
45+
- Creates GitHub release assets
46+
47+
## Setup Requirements
48+
49+
### Required Secrets
50+
51+
For the workflows to function properly, you need to configure the following repository secrets:
52+
53+
1. **NUGET_API_KEY**: API key for publishing to NuGet.org
54+
- Go to Repository Settings → Secrets and variables → Actions
55+
- Add a new secret named `NUGET_API_KEY`
56+
- Get your API key from https://www.nuget.org/account/apikeys
57+
58+
### Optional Configuration
59+
60+
- **Reviewers**: Update the `dependabot.yml` file to use your GitHub username
61+
- **Branch Protection**: Consider enabling branch protection rules for `main` branch
62+
63+
## Usage Examples
64+
65+
### Running Tests Locally
66+
67+
Before pushing changes, you can run the same commands locally:
68+
69+
```bash
70+
# Restore dependencies
71+
dotnet restore
72+
73+
# Build solution
74+
dotnet build --no-restore --configuration Release
75+
76+
# Run tests
77+
dotnet test --no-build --configuration Release --verbosity normal
78+
```
79+
80+
### Creating a Release
81+
82+
1. **Automatic Release** (recommended):
83+
- Create a new release on GitHub
84+
- Tag it with a version (e.g., `v1.0.0`)
85+
- The workflow will automatically build and publish
86+
87+
2. **Manual Release**:
88+
- Go to Actions → Release and Publish
89+
- Click "Run workflow"
90+
- Enter the version number
91+
- Click "Run workflow"
92+
93+
### Version Naming Convention
94+
95+
- **Stable releases**: `1.0.0`, `1.1.0`, `2.0.0`
96+
- **Pre-releases**: `1.0.0-alpha.1`, `1.0.0-beta.1`, `1.0.0-rc.1`
97+
- **Development builds**: `1.0.0-alpha.20250127120000` (auto-generated)
98+
99+
## Workflow Status
100+
101+
You can monitor workflow status in several ways:
102+
103+
1. **Repository Badge**: Add this to your README.md:
104+
```markdown
105+
![CI/CD](https://github.com/yourusername/Iso20022Library/workflows/CI/CD%20Pipeline/badge.svg)
106+
```
107+
108+
2. **Actions Tab**: View detailed logs and results in the repository's Actions tab
109+
110+
3. **Pull Request Checks**: Status checks appear automatically on PRs
111+
112+
## Troubleshooting
113+
114+
### Common Issues
115+
116+
1. **NuGet publish fails**: Ensure `NUGET_API_KEY` secret is configured correctly
117+
2. **Tests fail on CI but pass locally**: Check for environment-specific dependencies
118+
3. **Package version conflicts**: Ensure version numbers follow semantic versioning
119+
120+
### Getting Help
121+
122+
- Check the Actions tab for detailed error logs
123+
- Review the workflow YAML files for configuration details
124+
- Ensure all required secrets are properly configured
125+
126+
## Contributing
127+
128+
When contributing to this repository:
129+
130+
1. All PRs will automatically trigger the PR validation workflow
131+
2. Ensure tests pass locally before pushing
132+
3. Follow the established coding standards
133+
4. Update documentation if adding new features
134+
135+
The workflows are designed to maintain code quality and ensure reliable releases of the Iso20022Library.

.github/dependabot.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for .NET dependencies
4+
- package-ecosystem: "nuget"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "06:00"
10+
open-pull-requests-limit: 10
11+
reviewers:
12+
- "marci"
13+
assignees:
14+
- "marci"
15+
commit-message:
16+
prefix: "chore"
17+
include: "scope"
18+
labels:
19+
- "dependencies"
20+
- "nuget"
21+
22+
# Enable version updates for GitHub Actions
23+
- package-ecosystem: "github-actions"
24+
directory: "/"
25+
schedule:
26+
interval: "weekly"
27+
day: "monday"
28+
time: "06:00"
29+
open-pull-requests-limit: 5
30+
reviewers:
31+
- "marci"
32+
assignees:
33+
- "marci"
34+
commit-message:
35+
prefix: "ci"
36+
include: "scope"
37+
labels:
38+
- "dependencies"
39+
- "github-actions"

.github/workflows/ci.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
build-and-test:
11+
name: Build and Test
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
dotnet-version: ['8.0.x']
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # Shallow clones should be disabled for better analysis
23+
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v4
26+
with:
27+
dotnet-version: ${{ matrix.dotnet-version }}
28+
29+
- name: Cache NuGet packages
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.nuget/packages
33+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
34+
restore-keys: |
35+
${{ runner.os }}-nuget-
36+
37+
- name: Restore dependencies
38+
run: dotnet restore
39+
40+
- name: Build solution
41+
run: dotnet build --no-restore --configuration Release
42+
43+
- name: Run tests
44+
run: dotnet test --no-build --configuration Release --verbosity normal --logger trx --results-directory TestResults
45+
46+
- name: Publish test results
47+
uses: dorny/test-reporter@v1
48+
if: success() || failure()
49+
with:
50+
name: .NET Test Results
51+
path: TestResults/*.trx
52+
reporter: dotnet-trx
53+
fail-on-error: true
54+
55+
- name: Upload test results
56+
uses: actions/upload-artifact@v4
57+
if: always()
58+
with:
59+
name: test-results
60+
path: TestResults/
61+
retention-days: 30
62+
63+
code-quality:
64+
name: Code Quality Analysis
65+
runs-on: ubuntu-latest
66+
needs: build-and-test
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
74+
- name: Setup .NET
75+
uses: actions/setup-dotnet@v4
76+
with:
77+
dotnet-version: '8.0.x'
78+
79+
- name: Restore dependencies
80+
run: dotnet restore
81+
82+
- name: Build solution
83+
run: dotnet build --no-restore --configuration Release
84+
85+
- name: Run code analysis
86+
run: dotnet build --verbosity normal --configuration Release /p:TreatWarningsAsErrors=true
87+
88+
package:
89+
name: Create NuGet Package
90+
runs-on: ubuntu-latest
91+
needs: [build-and-test, code-quality]
92+
if: github.ref == 'refs/heads/main'
93+
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v4
97+
with:
98+
fetch-depth: 0
99+
100+
- name: Setup .NET
101+
uses: actions/setup-dotnet@v4
102+
with:
103+
dotnet-version: '8.0.x'
104+
105+
- name: Restore dependencies
106+
run: dotnet restore
107+
108+
- name: Create version number
109+
id: version
110+
run: |
111+
VERSION="1.0.0-alpha.$(date +%Y%m%d%H%M%S)"
112+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
113+
echo "Creating version: $VERSION"
114+
115+
- name: Pack NuGet packages
116+
run: |
117+
dotnet pack Iso20022Library.Domain/Iso20022Library.Domain.csproj --no-restore --configuration Release --output ./packages /p:Version=${{ steps.version.outputs.VERSION }}
118+
dotnet pack Iso20022Library.Messages/Iso20022Library.Messages.csproj --no-restore --configuration Release --output ./packages /p:Version=${{ steps.version.outputs.VERSION }}
119+
dotnet pack Iso20022Library.Infrastructure/Iso20022Library.Infrastructure.csproj --no-restore --configuration Release --output ./packages /p:Version=${{ steps.version.outputs.VERSION }}
120+
dotnet pack Iso20022Library.Application/Iso20022Library.Application.csproj --no-restore --configuration Release --output ./packages /p:Version=${{ steps.version.outputs.VERSION }}
121+
122+
- name: Upload NuGet packages
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: nuget-packages
126+
path: ./packages/*.nupkg
127+
retention-days: 90
128+
129+
security-scan:
130+
name: Security Scan
131+
runs-on: ubuntu-latest
132+
needs: build-and-test
133+
134+
steps:
135+
- name: Checkout code
136+
uses: actions/checkout@v4
137+
138+
- name: Setup .NET
139+
uses: actions/setup-dotnet@v4
140+
with:
141+
dotnet-version: '8.0.x'
142+
143+
- name: Restore dependencies
144+
run: dotnet restore
145+
146+
- name: Install security scan tool
147+
run: dotnet tool install --global security-scan
148+
149+
- name: Run security scan
150+
run: security-scan *.sln --excl-dev=true
151+
continue-on-error: true

0 commit comments

Comments
 (0)