Skip to content

fix(docker): ship .editorconfig into the API image build - #835

Merged
tolstenko merged 1 commit into
mainfrom
fix/api-docker-editorconfig
Oct 13, 2026
Merged

tolstenko merged 1 commit into
mainfrom
fix/api-docker-editorconfig

Conversation

@tolstenko

Copy link
Copy Markdown
Contributor

Problem

After #833 fixed the web image, the Devtron API image now fails at the publish step with 56 Sonar analyzer errors:

/src/Source/Modules/GameGuild.SharedKernel/.../RedisCachingOptions.cs(64,19): error S3928: The parameter name 'ConnectionString' is not declared in the argument list.
/src/Source/Modules/GameGuild.SharedKernel/CQRS/Abstractions/Requests.cs(12,27): error S2326: 'TResponse' is not used in the interface.
...
ERROR: dotnet publish ... did not complete successfully: exit code: 1

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 = none in the root .editorconfig — the only place Sonar severities are configured (no apps/api-scoped editorconfig exists).

The API image never receives it:

  1. .dockerignore is deny-all and never allowlisted .editorconfig
  2. apps/api/Dockerfile never COPYs it

So the image compiles against Sonar default severities while GameGuild.SharedKernel.csproj sets TreatWarningsAsErrors=true → 56 errors, exit 1. CI is green because the checkout always has the file.

Fix

  • .dockerignore: !.editorconfig
  • apps/api/Dockerfile: COPY .editorconfig ./ into the build stage workdir (/src), where Roslyn resolves it as an ancestor of Source/**
  • 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 waive

Verification (full build-stage docker builds)

Files Result
original (main) 56 analyzer errors, exit 1 — matches the Devtron log exactly
with fix publish succeeds, exit 0

Test verified red-on-broken / green-on-fixed locally.

Cherry-pick to develop to follow (same latent bug there).

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
Copilot AI balanced review requested due to automatic review settings October 13, 2026 00:57
@cla-bot cla-bot Bot added the cla-signed label Oct 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 .editorconfig into /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}`,
);
});
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 15 complexity

Metric Results
Complexity 15

View in Codacy

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.

@tolstenko
tolstenko merged commit 627a29b into main Oct 13, 2026
25 checks passed
@tolstenko
tolstenko deleted the fix/api-docker-editorconfig branch October 13, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants