Skip to content

Make compilation to fail on warnings#1104

Open
sarroutbi wants to merge 5 commits intokeylime:masterfrom
sarroutbi:202509030938-fail-compilation-on-warnings
Open

Make compilation to fail on warnings#1104
sarroutbi wants to merge 5 commits intokeylime:masterfrom
sarroutbi:202509030938-fail-compilation-on-warnings

Conversation

@sarroutbi
Copy link
Copy Markdown
Contributor

@sarroutbi sarroutbi commented Sep 3, 2025

The new workflow runs on every push and pull request to the master branch and performs the following checks:

  • cargo build: Compiles the main application.
  • cargo test: Compiles the test suite.

Both steps are executed with the RUSTFLAGS="-D warnings" environment variable. This flag instructs the Rust compiler to treat all warnings as fatal errors, which will cause the build to fail if any warnings are present. This helps prevent latent bugs and ensures the code base remains clean.

These are some reasons to enforce a "No Warnings" Policy:

  1. Future-Proofing Code: A warning in the current version of a compiler might become a hard error in a future version. Code that compiles with warnings today may fail to compile tomorrow after a simple rustup update, causing unexpected build failures. Enforcing a "no warnings" policy ensures your code is robust against compiler updates.

  2. Preventing Latent Bugs: Many warnings are not just stylistic suggestions; they often point to subtle logical flaws, potential null pointer dereferences, race conditions, or undefined behavior. A classic example is an "unused variable" warning, which can indicate that a necessary calculation was performed but its result was never used.

  3. Improving Code Readability and Reducing Noise: When a build produces dozens of warnings, developers become desensitized to them. This "warning fatigue" can cause them to miss a new, critical warning that appears among the noise. A clean, warning-free build ensures that any new message from the compiler gets immediate attention.

  4. Maintaining a Culture of Quality: A strict "no warnings" policy sets a high standard for the team. It encourages developers to write clean, precise, and intentional code, fostering a culture where quality is not negotiable.

Summary by CodeRabbit

  • Chores
    • Added a CI workflow that runs on pushes and pull requests to build the project, run tests, and perform lint checks.
    • CI runs in an isolated environment to ensure consistent, reproducible results.
    • Compiler and linter warnings are now treated as failures, enforcing stricter code quality across all checks.

@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch from fe3610d to 1ffaa0c Compare September 3, 2025 07:45
@sarroutbi
Copy link
Copy Markdown
Contributor Author

This will be kept until compilation warnings are fixed in master branch. Once they are, new job should PASS and it should be merged to keep master branch clean

@sarroutbi sarroutbi changed the title Make compilation to fail on warnings [DONOTMERGEYET] Make compilation to fail on warnings Sep 3, 2025
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch 3 times, most recently from a3b1702 to 6da554c Compare September 3, 2025 08:32
@sarroutbi sarroutbi marked this pull request as draft September 3, 2025 09:14
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.69%. Comparing base (8ea3e26) to head (71c7521).

Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 39.06% <ø> (ø)
upstream-unit-tests 66.33% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 6 files with indirect coverage changes

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

@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch 2 times, most recently from 5a00dd1 to 0672ac6 Compare September 3, 2025 15:54
@ansasaki ansasaki mentioned this pull request Sep 24, 2025
30 tasks
@sarroutbi sarroutbi mentioned this pull request Nov 26, 2025
36 tasks
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch from 0672ac6 to 18e6de8 Compare November 27, 2025 16:06
@sarroutbi sarroutbi marked this pull request as ready for review November 28, 2025 09:58
@sarroutbi sarroutbi changed the title [DONOTMERGEYET] Make compilation to fail on warnings Make compilation to fail on warnings Nov 28, 2025
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch from 18e6de8 to 6644542 Compare November 28, 2025 11:56
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch 2 times, most recently from db03739 to dede790 Compare January 16, 2026 08:15
@sarroutbi sarroutbi requested a review from ansasaki January 16, 2026 09:56
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch 2 times, most recently from c7f35d2 to 6ac9052 Compare January 19, 2026 13:04
@ansasaki ansasaki mentioned this pull request Mar 25, 2026
33 tasks
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch from 6ac9052 to 690f817 Compare April 17, 2026 14:06
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Warning

Rate limit exceeded

@sarroutbi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 43 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6098a6e7-4864-4385-aa54-ea9388cc0c38

📥 Commits

Reviewing files that changed from the base of the PR and between ff70eb0 and 71c7521.

📒 Files selected for processing (1)
  • .github/workflows/compile-no-warnings.yml
📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow that runs on push/pull_request to master, executes inside quay.io/keylime/keylime-ci:latest, sets CARGO_TERM_COLOR=always, and runs cargo build, cargo test --no-run, and cargo clippy with RUSTFLAGS="-D warnings" and Clippy configured to treat warnings as failures.

Changes

Cohort / File(s) Summary
CI Workflow Configuration
​.github/workflows/compile-no-warnings.yml
Introduces a workflow triggered on push and pull_request to master. Uses the quay.io/keylime/keylime-ci:latest container, sets CARGO_TERM_COLOR=always, runs cargo build and cargo test --no-run with RUSTFLAGS="-D warnings", and runs cargo clippy --all-features --all-targets with -- -D clippy::all -D warnings so warnings/lints fail the job.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Make compilation to fail on warnings' directly and clearly summarizes the main change—adding a GitHub Actions workflow that treats Rust warnings as errors to fail compilation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/compile-no-warnings.yml:
- Around line 10-28: Remove this separate compile-no-warnings workflow and fold
its checks into the existing Rust workflow by adding a new job (or extra steps
in the existing tests job) that runs the same commands (the basic-compilation
job’s steps: RUSTFLAGS="-D warnings" cargo build, RUSTFLAGS="-D warnings" cargo
test, cargo clippy --all-features --all-targets -- -D clippy::all -D warnings,
and the clippy tests invocation) and reuse the same container configuration and
triggers as rust.yml; ensure the job name is unique (not duplicating the "Rust"
workflow display name), preserve the RUSTFLAGS/clippy flags and matrix/runner
settings from compile-no-warnings, and then delete compile-no-warnings.yml to
avoid duplicate checkouts and CI minutes.
- Line 2: The workflow's display name "Rust" collides with the existing
rust.yml; update the workflow name value (the YAML top-level name field
currently set to "Rust") to a unique, descriptive string such as "No-Warnings
Compilation" so it no longer conflicts with the existing rust workflow and
produces unambiguous status checks in the PR UI.
- Around line 23-24: The step currently runs `RUSTFLAGS="-D warnings" cargo
test`, which executes tests; change it to run compile-only by adding the
`--no-run` flag so the job only checks that test code compiles without warnings.
Update the step that invokes `cargo test` (the command string RUSTFLAGS="-D
warnings" cargo test) to use RUSTFLAGS="-D warnings" cargo test --no-run so it
does not run the tests.
- Around line 27-28: The CI step named "Check clippy test errors (no warnings
included)" is redundant because the command cargo clippy --all-features
--all-targets --tests -- -D clippy::all -D warnings duplicates the coverage of
the earlier clippy invocation; remove this step or change its flags so it
actually differs (for example, keep the step but remove --all-targets and use
--tests only, or remove --tests and run a more specific invocation without
--all-features), ensuring the unique step name and the command string are
updated accordingly so CI does not re-run identical linting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ab53e4f6-eb3f-432c-8fd1-a2481aa52e7d

📥 Commits

Reviewing files that changed from the base of the PR and between 1f74678 and 690f817.

📒 Files selected for processing (1)
  • .github/workflows/compile-no-warnings.yml

Comment thread .github/workflows/compile-no-warnings.yml Outdated
Comment thread .github/workflows/compile-no-warnings.yml Outdated
Comment thread .github/workflows/compile-no-warnings.yml Outdated
Comment thread .github/workflows/compile-no-warnings.yml Outdated
@ansasaki ansasaki mentioned this pull request Apr 21, 2026
33 tasks
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch from 690f817 to 3d51ebc Compare April 27, 2026 13:14
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/compile-no-warnings.yml:
- Around line 19-20: Add the same safe.directory git config used in rust.yml by
inserting a step immediately after the checkout step (the step using
actions/checkout@v6) that runs git config --system --add safe.directory "$PWD"
so the container won’t hit Git “dubious ownership” errors when build scripts or
tools (e.g., vergen, git-backed dependencies) access repository metadata; place
this as a plain run step in the container job steps sequence right after the
checkout step.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: db342a37-495e-4f8e-8c4b-2cc2bd662c9b

📥 Commits

Reviewing files that changed from the base of the PR and between 690f817 and 3d51ebc.

📒 Files selected for processing (1)
  • .github/workflows/compile-no-warnings.yml

Comment thread .github/workflows/compile-no-warnings.yml
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch 2 times, most recently from 872ce93 to d2866d3 Compare April 27, 2026 14:25
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/compile-no-warnings.yml (1)

19-20: ⚠️ Potential issue | 🟡 Minor

Add safe.directory git config for container compatibility.

The existing rust.yml workflow includes a git config --system --add safe.directory "$PWD" step after checkout to prevent "dubious ownership" errors when the workspace UID differs from the container user. Build scripts that access Git metadata (e.g., vergen, git dependencies) may fail without this configuration.

♻️ Proposed fix
       - uses: actions/checkout@v6
+      - name: Set git safe.directory for the working directory
+        run: git config --system --add safe.directory "$PWD"
       - name: Check compilation (no warnings)
         run: RUSTFLAGS="-D warnings" cargo build
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/compile-no-warnings.yml around lines 19 - 20, After the
actions/checkout@v6 step, add a step that runs git config --system --add
safe.directory "$PWD" to mark the workspace safe for container users;
specifically insert a new run step (run: git config --system --add
safe.directory "$PWD") immediately after the uses: actions/checkout@v6 entry so
builds that access Git metadata (vergen/git deps) won’t fail with "dubious
ownership".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/compile-no-warnings.yml:
- Around line 25-26: The clippy workflow command contains an extra space before
the `--` separator in the string "cargo clippy --all-features --all-targets  --
-D clippy::all -D warnings"; remove the duplicate space so the command reads
with a single space before `--` to keep formatting consistent (update the `Check
clippy errors (no warnings included)` run command).

---

Duplicate comments:
In @.github/workflows/compile-no-warnings.yml:
- Around line 19-20: After the actions/checkout@v6 step, add a step that runs
git config --system --add safe.directory "$PWD" to mark the workspace safe for
container users; specifically insert a new run step (run: git config --system
--add safe.directory "$PWD") immediately after the uses: actions/checkout@v6
entry so builds that access Git metadata (vergen/git deps) won’t fail with
"dubious ownership".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 28f030d8-049c-4c3b-815e-2ea4d5b6b86f

📥 Commits

Reviewing files that changed from the base of the PR and between 3d51ebc and d2866d3.

📒 Files selected for processing (1)
  • .github/workflows/compile-no-warnings.yml

Comment thread .github/workflows/compile-no-warnings.yml Outdated
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch from c48b692 to 4f20bd9 Compare April 27, 2026 14:28
sarroutbi and others added 4 commits April 28, 2026 10:10
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
Rename workflow from "Rust" to "No-Warnings Compilation" to avoid
collision with rust.yml, add --no-run to cargo test so it only checks
compilation, and remove the duplicate clippy step since --all-targets
already includes test targets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
The container job can hit "dubious ownership" errors when build
scripts or tools access repository metadata. Add the same
safe.directory step already used in rust.yml.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
@sarroutbi sarroutbi force-pushed the 202509030938-fail-compilation-on-warnings branch from 3d3d750 to ff70eb0 Compare April 28, 2026 08:10
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/compile-no-warnings.yml:
- Around line 17-18: Replace the mutable image tag
"quay.io/keylime/keylime-ci:latest" under the container.image key with a
digest-pinned reference (e.g. "quay.io/keylime/keylime-ci@sha256:<digest>");
locate the string "quay.io/keylime/keylime-ci:latest" in the workflow and update
it to the digest you obtain from Quay (or your registry) so the CI uses an
immutable, reproducible image; ensure you commit the exact sha256 value and
update any documentation or comments explaining how to refresh the digest when
intentionally upgrading the image.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 57072011-a25b-42d1-be32-df206d1b9fc4

📥 Commits

Reviewing files that changed from the base of the PR and between d2866d3 and ff70eb0.

📒 Files selected for processing (1)
  • .github/workflows/compile-no-warnings.yml

Comment thread .github/workflows/compile-no-warnings.yml Outdated
Replace mutable :latest tag with sha256 digest for reproducible builds.
Include a comment with the skopeo command to refresh the digest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
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.

3 participants