-
Notifications
You must be signed in to change notification settings - Fork 0
Add .NET 9 Aspire project template with API, tests, and comprehensive CI/CD workflows #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .NET 9 Aspire project template with API, tests, and comprehensive CI/CD workflows #1
Conversation
|
@copilot я трошки набрехав, це темлейт для проект NuGet бібліотеки. але тести мають все одно мати вожливіть бути інтеграційними типу https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.testing.webapplicationfactory-1?view=aspnetcore-9.0 виротсвуються ось це. але головне це тести та пайлпани для гітахаба |
Co-authored-by: KSemenenko <4385716+KSemenenko@users.noreply.github.com>
Co-authored-by: KSemenenko <4385716+KSemenenko@users.noreply.github.com>
Co-authored-by: KSemenenko <4385716+KSemenenko@users.noreply.github.com>
Co-authored-by: KSemenenko <4385716+KSemenenko@users.noreply.github.com>
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR establishes a complete .NET 9 project template with .NET Aspire orchestration, including a sample API, comprehensive testing infrastructure using both WebApplicationFactory and Aspire testing approaches, and three GitHub Actions workflows for continuous integration, security analysis, and automated releases.
Key Changes
- Created a cloud-native .NET 9 application structure with Aspire orchestration (AppHost, API, ServiceDefaults, and Tests projects)
- Implemented GitHub Actions workflows for CI/CD: build/test with code coverage (ci.yml), CodeQL security scanning (codeql-analysis.yml), and automated NuGet publishing with GitHub releases (release.yml)
- Added comprehensive documentation and configuration files including README, .editorconfig, and Directory.Build.props for centralized versioning
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ProjectTemplate.sln | Solution file organizing src and tests projects into solution folders |
| Directory.Build.props | Centralized version management (1.0.0) and NuGet package metadata |
| src/ProjectTemplate.Api/* | ASP.NET Core minimal API with weather forecast endpoint and ServiceDefaults integration |
| src/ProjectTemplate.AppHost/* | Aspire orchestration host with configuration for development environments |
| src/ProjectTemplate.ServiceDefaults/* | Shared library providing OpenTelemetry, service discovery, resilience patterns, and health checks |
| tests/ProjectTemplate.Tests/* | xUnit integration tests using both WebApplicationFactory and Aspire testing approaches |
| .github/workflows/ci.yml | CI workflow for pull requests with build, test, and Codecov integration |
| .github/workflows/codeql-analysis.yml | Security analysis workflow running on pushes, PRs, and weekly schedule |
| .github/workflows/release.yml | Release workflow automating NuGet publishing and GitHub release creation |
| README.md | Comprehensive documentation covering setup, usage, API endpoints, and CI/CD configuration |
| .editorconfig | Code style configuration for C#, JSON, YAML, and other file types |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
ProjectTemplate/.github/workflows/release.yml
Lines 13 to 17 in 3ddaeb8
| name: Build and Test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
actions/upload-artifact@v4 requires the token to have actions: write, but the build job explicitly limits permissions to contents: read. Overriding permissions removes the default actions scope, so the upload step will fail with “Resource not accessible by integration” and the release workflow stops before producing packages. Add actions: write (or drop the permissions override) so artifacts can be uploaded.
ProjectTemplate/.github/workflows/release.yml
Lines 59 to 66 in 3ddaeb8
| publish-nuget: | |
| name: Publish to NuGet | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: read | |
The publish job downloads build artifacts but only grants the token contents: read. When permissions are restricted like this, the token loses the implicit actions: read scope required by actions/download-artifact@v5, so the download step cannot access the artifacts and the job will fail before pushing packages. Add actions: read (or remove the custom permissions block) for this job.
ProjectTemplate/.github/workflows/release.yml
Lines 124 to 131 in 3ddaeb8
| create-release: | |
| name: Create GitHub Release and Tag | |
| needs: publish-nuget | |
| runs-on: ubuntu-latest | |
| if: needs.publish-nuget.outputs.published == 'true' | |
| permissions: | |
| contents: write | |
The release job also calls actions/download-artifact@v5 but its permissions block only grants contents: write. Without actions: read, the token is forbidden from reading workflow artifacts and the step will error before the tag and release are created. Grant at least actions: read for this job so the artifacts uploaded earlier can be retrieved.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This PR implements a complete .NET 9 project template with .NET Aspire orchestration, including automated CI/CD pipelines for testing, security analysis, and package publishing.
What's New
Project Structure
The template provides a modern cloud-native application structure using .NET Aspire:
GitHub Actions Workflows
Three comprehensive workflows provide automated CI/CD:
CI Workflow (
ci.yml) - Runs on every pull request and push to main:CodeQL Analysis (
codeql-analysis.yml) - Security scanning that runs on:Release Workflow (
release.yml) - Automated releases on push to main:Directory.Build.propsAll workflows include explicit permissions configuration for security best practices.
Configuration & Documentation
.aspire/,*.dcplog)Technical Details
All projects target .NET 9 for consistency. The test project includes both WebApplicationFactory tests (which run in CI) and Aspire integration tests (which are skipped in CI as they require the Development Control Plane).
The release workflow intelligently handles version management:
Usage
Developers can start using this template immediately:
The Aspire Dashboard will open automatically, providing real-time monitoring of the application with distributed tracing, metrics, and logs.
Related Issues
Resolves the request for a project template with Aspire, xUnit + WebApplicationFactory tests, and GitHub Actions pipelines for CI/testing and automated NuGet publishing with releases.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
go.microsoft.comIf you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.