Skip to content
Closed
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
7 changes: 7 additions & 0 deletions .github/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<configuration>
<packageSources>
<clear />
<!-- GitHub Actions: Use only nuget.org (no local Nexus) -->
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
61 changes: 56 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,58 @@
version: 2
updates:
- package-ecosystem: nuget
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
# .NET NuGet dependencies - Main project
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
labels:
- "dependencies"
- "nuget"
commit-message:
prefix: "chore"
include: "scope"
# Security updates are automatically prioritized
versioning-strategy: increase
# Group Minor/Patch updates
groups:
production-dependencies:
patterns:
- "*"
update-types:
- "minor"
- "patch"

# Sample project dependencies
- package-ecosystem: "nuget"
directory: "/sample"
schedule:
interval: "daily"
open-pull-requests-limit: 5
labels:
- "dependencies"
- "nuget"
- "sample"

# MinimalClean template dependencies
- package-ecosystem: "nuget"
directory: "/MinimalClean"
schedule:
interval: "daily"
open-pull-requests-limit: 5
labels:
- "dependencies"
- "nuget"
- "minimal"

# GitHub Actions - important for Node.js 20/24 updates!
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 5
labels:
- "dependencies"
- "github-actions"
commit-message:
prefix: "ci"
179 changes: 179 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# GitHub Actions Workflows

This directory contains CI/CD workflows for the Clean Architecture template.

## Workflows

### 🪟 Windows Build & Test (`windows-build-test.yml`)

**Purpose**: Windows-specific build and test pipeline for .NET 10

**Triggers**:
- Push to `main`, `develop`, or `issue-*/**` branches
- Pull requests to `main` or `develop`
- Manual workflow dispatch

**Matrix**:
- **OS**: `windows-latest`
- **Configurations**: `Debug`, `Release`

**Steps**:
1. Checkout code
2. Setup .NET 10 SDK (preview)
3. Use CI-specific NuGet.Config (nuget.org only, no Nexus)
4. Restore dependencies
5. Build solution (Debug & Release)
6. Run all tests with code coverage
7. Upload test results and coverage artifacts

**Artifacts**:
- Test results (TRX format, 30 days retention)
- Code coverage (Cobertura format, 30 days retention)

---

### 🌍 Cross-Platform Build & Test (`cross-platform-build-test.yml`)

**Purpose**: Ensure compatibility across Windows, Linux, and macOS

**Triggers**:
- Push to `main` or `develop`
- Pull requests to `main` or `develop`
- Manual workflow dispatch

**Matrix**:
- **OS**: `windows-latest`, `ubuntu-latest`, `macos-latest`
- **Configurations**: `Debug`, `Release`
- **Total jobs**: 6 (3 OS × 2 configurations)

**Steps**:
1. Checkout code
2. Setup .NET 10 SDK (preview)
3. Restore dependencies
4. Build solution
5. Run tests with coverage
6. Upload artifacts

---

## Local Development vs CI/CD

### NuGet Configuration

**Local Development** (`NuGet.Config` in root):
```xml
<packageSources>
<add key="nexus" value="http://localhost:8081/repository/nuget-group/index.json" allowInsecureConnections="true" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
```

**CI/CD** (`.github/NuGet.Config`):
```xml
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
```

The workflows automatically copy `.github/NuGet.Config` to the root during the build process.

---

## .NET 10 SDK

All workflows use:
```yaml
- name: Setup .NET 10 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
dotnet-quality: 'preview'
```

**Note**: .NET 10 is in preview. Update `dotnet-quality` to `ga` when it reaches General Availability.

---

## Running Workflows Manually

### Via GitHub UI
1. Go to **Actions** tab
2. Select workflow (e.g., "Windows Build & Test")
3. Click **Run workflow**
4. Select branch
5. Click **Run workflow** button

### Via GitHub CLI
```bash
# Windows Build & Test
gh workflow run windows-build-test.yml --ref issue-915/windows-build-test

# Cross-Platform Build & Test
gh workflow run cross-platform-build-test.yml --ref main
```

---

## Viewing Results

### Build Status Badges

Add to your README.md:

```markdown
![Windows Build](https://github.com/MartinHock/CleanArchitecture/actions/workflows/windows-build-test.yml/badge.svg)
![Cross-Platform Build](https://github.com/MartinHock/CleanArchitecture/actions/workflows/cross-platform-build-test.yml/badge.svg)
```

### Artifacts

Test results and code coverage are available as downloadable artifacts for 30 days:
- **Artifacts tab** in each workflow run
- Named: `test-results-{os}-{configuration}` and `coverage-{os}-{configuration}`

---

## Troubleshooting

### Restore Fails with HTTP Error

The workflows use only `nuget.org`. If restore fails:
1. Check if .NET 10 SDK packages are available
2. Verify no local `NuGet.Config` overrides CI config
3. Check GitHub Actions logs for detailed errors

### Test Failures

1. Check **Test Results** artifact (TRX file)
2. Review **Code Coverage** artifact
3. Run locally: `dotnet test --configuration Debug --logger "trx"`

### Build Fails on Specific OS

The cross-platform workflow uses `fail-fast: false`, so builds continue even if one OS fails.
Check individual job logs to identify OS-specific issues.

---

## Best Practices

✅ **Do**:
- Run workflows on feature branches before merging
- Review test results and coverage artifacts
- Fix failing tests promptly
- Keep workflows updated with latest GitHub Actions versions

❌ **Don't**:
- Commit local `NuGet.Config` with Nexus configuration
- Skip tests to make builds "pass"
- Ignore warnings in build output
- Use outdated SDK versions

---

## Related Documentation

- [GitHub Actions Docs](https://docs.github.com/en/actions)
- [.NET 10 Preview](https://dotnet.microsoft.com/download/dotnet/10.0)
- [Clean Architecture Template](../../README.md)
- [Copilot Instructions](../copilot-instructions.md)
33 changes: 14 additions & 19 deletions .github/workflows/build-ramdisk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,37 @@ name: Build and Test with Ramdisk
on:
push:
branches:
- main
- '**'
workflow_dispatch:
pull_request:

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v6

# Step 2: Set up .NET environment
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: '10.0.x'
dotnet-quality: 'ga'

- name: Setup CI NuGet Config
run: cp .github/NuGet.Config NuGet.Config

# Step 3: Prepare a directory in /dev/shm
- name: Set up Ramdisk Directory
run: |
mkdir -p /dev/shm/ramdisk/project
run: mkdir -p /dev/shm/ramdisk/project

# Step 4: Copy source code to the ramdisk
- name: Copy Code to Ramdisk
run: |
cp -r $GITHUB_WORKSPACE/* /dev/shm/ramdisk/project

# Step 5: Debug Directory Contents
- name: Debug Directory
run: |
ls -R /dev/shm/ramdisk/project
run: cp -a "$GITHUB_WORKSPACE"/. /dev/shm/ramdisk/project/

# Step 6: Build and Test from the ramdisk
- name: Build and Test
run: |
cd /dev/shm/ramdisk/project
dotnet build Clean.Architecture.slnx --configuration Debug
dotnet test Clean.Architecture.slnx --
cp .github/NuGet.Config NuGet.Config
dotnet restore Clean.Architecture.slnx
dotnet build Clean.Architecture.slnx --configuration Debug --no-restore
dotnet test Clean.Architecture.slnx --configuration Debug --no-build --verbosity normal --filter "FullyQualifiedName!~DockerAvailabilityTests"
45 changes: 29 additions & 16 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
name: CodeQL Analysis
name: CodeQL

on:
push:
branches: [ main ]
branches:
- '**'
pull_request:
workflow_dispatch:
schedule:
- cron: '0 8 * * *'
- cron: '0 3 * * 1'

jobs:
analyze:
name: CodeQL Analysis
name: Analyze C#
runs-on: ubuntu-latest

permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
id: checkout_repo
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v5

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
dotnet-quality: 'ga'

- name: Initialize CodeQL
id: init_codeql
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
queries: security-and-quality
languages: csharp
build-mode: manual

- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Restore
run: dotnet restore ./Clean.Architecture.slnx --configfile .github/workflows/nuget.ci.config

- name: Perform CodeQL Analysis
id: analyze_codeql
uses: github/codeql-action/analyze@v3
- name: Build
run: dotnet build ./Clean.Architecture.slnx --configuration Release --no-restore

# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)
- name: Analyze
uses: github/codeql-action/analyze@v4
Loading