Skip to content

ci: add format/lint jobs and align PR checks across all repos#70

Merged
devops-thiago merged 9 commits intomainfrom
ci/add-format-lint-pr-checks
Mar 5, 2026
Merged

ci: add format/lint jobs and align PR checks across all repos#70
devops-thiago merged 9 commits intomainfrom
ci/add-format-lint-pr-checks

Conversation

@devops-thiago
Copy link
Owner

@devops-thiago devops-thiago commented Mar 3, 2026

What

Align CI pipeline structure across all 6 OTel repos.

Changes

  • Add concurrency block to cancel stale runs on new pushes
  • Add format and lint jobs using each repo native tooling
  • Gate test and build on format+lint passing
  • Add PR-only docker-build job with Trivy vulnerability scan
  • .NET: split docker-build (PR gate) from docker-publish (main-only push)

Note

Medium Risk
Touches API/data model and EF seed/mapping, which can be breaking for clients and migrations, and makes substantial CI pipeline changes that could fail builds if coverage/report paths differ across environments.

Overview
This PR changes the user domain model and API contract from FirstName/LastName/PhoneNumber to a single Name plus optional Bio, updating Models/User, DTOs/UserDto, EF mappings/seed data in UserDbContext, and the CRUD flow in UserService/UserController (including sanitized email logging/tracing).

It also overhauls CI: adds formatting + lint gates, conditional concurrency cancellation, switches coverage generation/checking to Cobertura + SonarQube.xml via reportgenerator and a coverlet.runsettings, updates SonarCloud configuration, and adds a PR-only docker-build job that builds the image and runs Trivy with SARIF upload; tests are updated/expanded (new SQLite-based UserDbContextTests, formatter tests) and Microsoft.EntityFrameworkCore.Sqlite is added for test coverage of seeding/constraints.

Written by Cursor Bugbot for commit c62cc2e. This will update automatically on new commits. Configure here.

- Add concurrency block to cancel stale runs
- Add format and lint jobs (repo-specific tooling)
- Gate test/build on format+lint passing
- Add PR docker-build job with Trivy vulnerability scan
- Align job structure with Go/Node.js/Python pattern
Copilot AI review requested due to automatic review settings March 3, 2026 01:18
@github-advanced-security
Copy link

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.

Copy link

Copilot AI left a 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 updates CI to add a PR-only Docker build with Trivy scanning and adjusts deployment gating, while also introducing a broad .NET refactor that changes the User domain model/DTO contract and updates tests accordingly.

Changes:

  • Add a PR-only docker-build job that builds the image and runs a Trivy SARIF scan; change deploy to depend on docker-publish.
  • Enforce file-scoped namespaces / using placement via .editorconfig and apply formatting across the .NET codebase.
  • Rename the User contract from FirstName/LastName/PhoneNumber to Name/Bio and update services/controllers/tests.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
UserApi.Tests/TestUtilities.cs Formatting + DTO field updates in test helpers.
UserApi.Tests/TestConfiguration.cs File-scoped namespace formatting; test DB setup retained.
UserApi.Tests/Services/UserServiceTests.cs Updates assertions/fixtures for new Name/Bio model.
UserApi.Tests/Models/UserModelTests.cs Updates model property tests for Name/Bio.
UserApi.Tests/GlobalUsings.cs Reorders/expands global usings for test project.
UserApi.Tests/DTOs/UserDtoValidationTests.cs Updates DTO validation tests for new DTO shape.
UserApi.Tests/Controllers/UserControllerUnitTests.cs Updates controller unit tests for new DTO/model fields.
UserApi.Tests/Controllers/UserControllerIntegrationTests.cs Updates integration tests + AutoFixture customizations for new fields.
UserApi.Tests/Controllers/UserControllerHelperMethodsTests.cs Formatting-only updates for helper method tests.
Services/UserService.cs Updates service mapping/business logic for Name/Bio.
Program.cs Reorders usings; keeps custom JSON output formatter registration.
Models/User.cs Replaces name/phone fields with Name + Bio and updates annotations.
Infrastructure/CompatibleSystemTextJsonOutputFormatter.cs Formatting-only updates; keeps custom formatter behavior.
Data/UserDbContext.cs Updates EF model config + seed data for new fields.
DTOs/UserDto.cs Updates DTO contract (Name/Bio) and response DTO.
Controllers/UserController.cs Keeps behavior but updates types + adds/keeps telemetry + sanitized logging helpers.
.github/workflows/ci.yml Adds PR docker-build + Trivy scan; adjusts deploy dependency.
.editorconfig Enforces file-scoped namespaces and using directive placement/sorting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 95.12195% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.56%. Comparing base (4ef92ee) to head (c62cc2e).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
Services/UserService.cs 81.81% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
+ Coverage   89.97%   97.56%   +7.58%     
==========================================
  Files           7        5       -2     
  Lines         459      287     -172     
  Branches       61       14      -47     
==========================================
- Hits          413      280     -133     
+ Misses         30        5      -25     
+ Partials       16        2      -14     
Flag Coverage Δ
unittests 97.56% <95.12%> (+7.58%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Pin trivy-action from @master to @0.24.0 for supply-chain safety
- Guard SARIF upload to same-repo PRs only (fixes fork permission issue)
- Remove [InlineData("   ")] from name validation test: [Required] does not
  reject whitespace-only strings, making that case incorrect
- Replace Substring(0, 5) with Guid.NewGuid().ToString("N")[..5] in
  AutoFixture customizations to eliminate flaky ArgumentOutOfRangeException
Copilot AI added a commit that referenced this pull request Mar 3, 2026
- guard cancel-in-progress for main branch runs
- fix codecov deprecated 'file' param to 'files'
- pin docker/build-push-action to SHA in docker-build job
- upgrade trivy-action from 0.24.0 to 0.34.2
- add exit-code: '0' to trivy to prevent failure on findings
- remove unnecessary TRIVY_SKIP_VERSION_CHECK env var
The coverage artifact was being extracted to the repo root instead
of the coverage/ directory, so SonarCloud couldn't find the
OpenCover.xml and Cobertura.xml reports. Add path: coverage to
the download-artifact step to restore the expected directory
structure.
- add RegularExpression validation on CreateUserDto.Name to reject
  whitespace-only input (addresses Copilot review comment)
- add whitespace InlineData test case for name validation
- add UserDbContext tests with SQLite provider to cover seed data
  branch, unique email index, required fields, and primary key config
- add CompatibleSystemTextJsonOutputFormatter tests covering
  constructor, JSON serialization, null object, and Unicode encoding
- add Microsoft.EntityFrameworkCore.Sqlite test dependency

All 118 tests pass locally.
- Pin docker/setup-buildx-action, aquasecurity/trivy-action,
  github/codeql-action/upload-sarif, and docker/login-action
  to full commit SHAs (resolves SonarCloud security hotspot S7637)
- Switch coverage report format from OpenCover (paid-only in
  reportgenerator) to SonarQube generic format
- Use sonar.coverageReportPaths instead of sonar.cs.opencover.reportsPaths
- Update coverage threshold check to use Cobertura XML
Replace broken dotnet-coverage report command (removed in v18) with
python3 xml.etree to extract line-rate from Cobertura XML. The step
now fails the build if coverage is below the threshold or if the
coverage report file is missing.
Add coverlet.runsettings to exclude obj/ and Migrations/ paths plus
compiler-generated attributes from XPlat Code Coverage. Fixes false
65% line-rate caused by uncoverable OpenAPI source-generated files
in obj/. Actual project coverage is 98.2%.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Pure POCO/DTO classes contain only auto-properties with no
executable logic. Coverlet cannot instrument them, so SonarCloud
sees uncovered new lines, dragging the new-code coverage to 70%.

Add **/Models/** and **/DTOs/** to sonar.coverage.exclusions in
both the PR-analysis and branch-analysis scanner blocks.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 5, 2026

@devops-thiago devops-thiago merged commit 5367b03 into main Mar 5, 2026
13 checks passed
@devops-thiago devops-thiago deleted the ci/add-format-lint-pr-checks branch March 5, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants