Skip to content

Make compilation to fail on warnings#1104

Open
sarroutbi wants to merge 1 commit intokeylime:masterfrom
sarroutbi:202509030938-fail-compilation-on-warnings
Open

Make compilation to fail on warnings#1104
sarroutbi wants to merge 1 commit 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 continuous integration workflow that enforces strict compilation standards and code quality validation on all pull requests and pushes to the main branch.

@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.65%. Comparing base (1f74678) to head (690f817).

Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 39.09% <ø> (+0.02%) ⬆️
upstream-unit-tests 66.14% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 7 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
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
@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

📝 Walkthrough

Walkthrough

A new GitHub Actions workflow is added to compile Rust code and run tests on the master branch, treating all compiler warnings and Clippy findings as errors using a Keylime CI container image.

Changes

Cohort / File(s) Summary
CI Workflow Configuration
.github/workflows/compile-no-warnings.yml
Adds a new workflow that runs cargo build, cargo test, and cargo clippy with strict warning flags (-D warnings for rustc and -D clippy::all for Clippy) to enforce no-warnings compilation on pushes and pull requests to master.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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' clearly and directly describes the main change: adding a CI workflow that enforces no-warning compilation by failing builds on warnings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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

@@ -0,0 +1,28 @@
---
name: Rust
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Workflow name collides with existing rust.yml.

The existing .github/workflows/rust.yml also uses name: Rust. Having two workflows with the same display name makes status checks and PR UI ambiguous. Consider a distinct name such as No-Warnings Compilation.

-name: Rust
+name: No-Warnings Compilation
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: Rust
name: No-Warnings Compilation
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/compile-no-warnings.yml at 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.

Comment on lines +10 to +28
env:
CARGO_TERM_COLOR: always

jobs:
basic-compilation:
name: Compilation with no warnings
runs-on: ubuntu-latest
container:
image: quay.io/keylime/keylime-ci:latest
steps:
- uses: actions/checkout@v6
- name: Check compilation (no warnings)
run: RUSTFLAGS="-D warnings" cargo build
- name: Check test compilation (no warnings)
run: RUSTFLAGS="-D warnings" cargo test
- name: Check clippy errors (no warnings included)
run: cargo clippy --all-features --all-targets -- -D clippy::all -D warnings
- name: Check clippy test errors (no warnings included)
run: cargo clippy --all-features --all-targets --tests -- -D clippy::all -D warnings
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider folding these checks into the existing rust.yml workflow.

rust.yml already targets the same triggers and uses the same container for tests. Maintaining two workflows named "Rust" with overlapping checkouts/containers increases CI minutes and cognitive overhead. A single workflow with additional jobs (or additional steps in the existing tests job) would be simpler and keep RUSTFLAGS/clippy policy consistent across the repo.

🤖 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 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.

Comment on lines +23 to +24
- name: Check test compilation (no warnings)
run: RUSTFLAGS="-D warnings" cargo test
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

cargo test executes tests; use --no-run for compile-only checks.

The job is titled "Compilation with no warnings" and the step is named "Check test compilation", but cargo test compiles and runs the full test suite. Since tests/run.sh in the existing rust.yml already executes tests, this is duplicated work and may also fail for non-warning reasons (flaky tests, environment). If the intent is only to verify test-code compiles without warnings, use --no-run.

-      - name: Check test compilation (no warnings)
-        run: RUSTFLAGS="-D warnings" cargo test
+      - name: Check test compilation (no warnings)
+        run: RUSTFLAGS="-D warnings" cargo test --no-run
🤖 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 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.

Comment on lines +27 to +28
- name: Check clippy test errors (no warnings included)
run: cargo clippy --all-features --all-targets --tests -- -D clippy::all -D warnings
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Redundant clippy invocation.

--all-targets (line 26) already includes test targets, so this second step re-runs the same lints. Adding --tests on top of --all-targets does not broaden coverage—it's effectively duplicated work and CI time. Drop this step, or replace it with something that actually differs (e.g., without --all-features, or a specific target).

♻️ Proposed fix
-      - name: Check clippy test errors (no warnings included)
-        run: cargo clippy --all-features --all-targets --tests -- -D clippy::all -D warnings
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Check clippy test errors (no warnings included)
run: cargo clippy --all-features --all-targets --tests -- -D clippy::all -D warnings
🤖 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 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.

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