Repository navigation
fix(docker): ship .editorconfig into the API image build - #835
Merged
Merged
Conversation
The Devtron API image fails at the publish step with 56 Sonar analyzer errors (S3928, S3267, S1066, S125, S1694, ...). The root .editorconfig — the only place those rules are reviewed and waived to severity=none — was absent from the Docker build context (deny-all .dockerignore) and never copied by apps/api/Dockerfile, so the image compiled against Sonar defaults while SharedKernel sets TreatWarningsAsErrors=true. Allowlist .editorconfig in .dockerignore and COPY it into the api build stage workdir (/src), where Roslyn discovers it as an ancestor of Source/**. Lock the invariant with a CI test mirroring the pnpm-patches guard. Verified with full docker builds of the `build` stage: - original files: 56 analyzer errors, exit 1 (matches the Devtron log) - with fix: publish succeeds, exit 0
There was a problem hiding this comment.
🟡 Changes recommended
The regression guard can accept a commented-out COPY and does not verify the required Sonar rule IDs.
2 open findings
What changed in this PR
Ships the root analyzer configuration into API Docker builds so Sonar severity overrides apply during publish.
Changes:
- Allowlist and copy
.editorconfiginto/src. - Add and run a Docker build-context regression test.
| File | Description |
|---|---|
.dockerignore |
Allows root .editorconfig. |
apps/api/Dockerfile |
Copies analyzer configuration into the build stage. |
.github/workflows/pr-verify.yml |
Runs the new regression test. |
scripts/ci/tests/dockerignore-api-analyzer-config.test.mjs |
Verifies build-context and analyzer invariants. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| assert.ok(buildStage, "apps/api/Dockerfile must declare a `build` stage"); | ||
| assert.match( | ||
| buildStage[1], | ||
| /COPY\s+\.editorconfig\s+\.\//, |
Comment on lines
+80
to
+89
| test("the root .editorconfig actually downgrades Sonar analyzer severities", () => { | ||
| const editorconfig = read(".editorconfig"); | ||
| const downgraded = [ | ||
| ...editorconfig.matchAll(/^\s*dotnet_diagnostic\.(S\d+)\.severity\s*=\s*none/gm), | ||
| ]; | ||
| assert.ok( | ||
| downgraded.length >= 50, | ||
| `expected the root .editorconfig to waive >=50 Sonar rules, found ${downgraded.length}`, | ||
| ); | ||
| }); |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 15 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
After #833 fixed the web image, the Devtron API image now fails at the publish step with 56 Sonar analyzer errors:
Root cause — same class as #833
Every failing rule (S3928, S3267, S1066, S125, S1694, S2326, S1210, S6610, S2139, S2219, S3877, S6608, S6667, S2094…) is already reviewed and waived to
severity = nonein the root.editorconfig— the only place Sonar severities are configured (noapps/api-scoped editorconfig exists).The API image never receives it:
.dockerignoreis deny-all and never allowlisted.editorconfigapps/api/DockerfileneverCOPYs itSo the image compiles against Sonar default severities while
GameGuild.SharedKernel.csprojsetsTreatWarningsAsErrors=true→ 56 errors, exit 1. CI is green because the checkout always has the file.Fix
.dockerignore:!.editorconfigapps/api/Dockerfile:COPY .editorconfig ./into thebuildstage workdir (/src), where Roslyn resolves it as an ancestor ofSource/**scripts/ci/tests/dockerignore-api-analyzer-config.test.mjs: regression guard (mirrors the fix(docker): allowlist patches/ so pnpm patchedDependencies resolve in web build #833 pnpm-patches test) — fails if the editorconfig leaves the build context or the Dockerfile COPY disappears; also asserts the file actually waives the Sonar rules it exists to waiveVerification (full
build-stage docker builds)Test verified red-on-broken / green-on-fixed locally.
Cherry-pick to develop to follow (same latent bug there).