Skip to content

fix: resolve compiler warnings and add CI warning detection#76

Merged
loothero merged 2 commits intomainfrom
game-component-fix-warnings
Mar 8, 2026
Merged

fix: resolve compiler warnings and add CI warning detection#76
loothero merged 2 commits intomainfrom
game-component-fix-warnings

Conversation

@loothero
Copy link
Member

@loothero loothero commented Mar 8, 2026

Summary

  • Fix 8 compiler warnings across 6 files (unused imports, unhandled #[must_use])
  • Add CI warning detection to both pr-ci.yml and main-ci.yml — build and test steps now fail on source-located compiler warnings
  • Intentionally includes one unused import (Fixed in math/tests.cairo) to verify CI catches it — will be fixed in follow-up push

Test plan

  • Verify CI detects the intentional warning and fails the build/test step
  • After fixing the warning, verify CI passes cleanly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • CI pipelines now capture build and test output, scan for Cairo compiler warnings, and fail jobs when warnings are detected; test logs are preserved for post-run inspection.
    • Removed unused imports and simplified public export lists across several packages to tidy interfaces and reduce surface area.

Fix unused imports in objectives, entry_requirement, prize, and
ticket_booth. Handle #[must_use] return in entry_fee mock.

Intentionally leave one unused import (Fixed in math/tests.cairo)
to verify CI catches warnings. Will be fixed in follow-up push.

Add warning detection to both CI workflows: build and test steps
now fail when source-located compiler warnings are found.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 8, 2026 18:41
@loothero loothero requested a review from starknetdev as a code owner March 8, 2026 18:41
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances code quality and maintainability by eliminating existing compiler warnings and establishing a robust CI process to prevent future regressions. By making CI builds fail on warnings, it ensures that all new code adheres to strict quality standards, improving the overall reliability and readability of the codebase.

Highlights

  • Compiler Warnings Resolved: Resolved 8 compiler warnings across 6 files, addressing issues such as unused imports and unhandled #[must_use] attributes.
  • CI Warning Detection Implemented: Integrated CI warning detection into pr-ci.yml and main-ci.yml, configuring build and test steps to fail on source-located compiler warnings.
  • CI Validation: Included an intentional unused import in math/tests.cairo to validate the new CI warning detection mechanism.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/interfaces/src/minigame/objectives.cairo
    • Removed unused import GameObjective.
  • packages/metagame/src/entry_fee/tests/mocks/entry_fee_mock.cairo
    • Addressed a #[must_use] warning by explicitly ignoring the return value of set_entry_fee.
  • packages/metagame/src/entry_requirement/entry_requirement_component.cairo
    • Removed unused imports IEntryValidatorDispatcher and IEntryValidatorDispatcherTrait.
    • Removed unused import ExtensionConfig.
  • packages/metagame/src/prize/structs.cairo
    • Removed unused import StorePacking.
  • packages/metagame/src/ticket_booth/ticket_booth_component.cairo
    • Removed unused imports GameExpiration and GoldenPassInfo.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/main-ci.yml
    • .github/workflows/pr-ci.yml
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Mar 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a6b7da59-e5b9-4547-8e73-7b5181aa9e08

📥 Commits

Reviewing files that changed from the base of the PR and between 39c4ead and 09140e0.

📒 Files selected for processing (1)
  • packages/utilities/src/math/tests.cairo

📝 Walkthrough

Walkthrough

This PR changes CI workflows to capture build and test output and fail on any detected Cairo compiler warnings, and makes small code cleanups in several Cairo files (removing unused imports and discarding an unused return value in a test mock).

Changes

Cohort / File(s) Summary
CI Warning Detection
\.github/workflows/main-ci.yml, \.github/workflows/pr-ci.yml
Replace simple compile/test steps with guarded versions that tee output to a log, scan for Cairo compiler warnings, and fail the job printing surrounding context when warnings are found.
Import Cleanup
packages/interfaces/src/minigame/objectives.cairo, packages/metagame/src/entry_requirement/entry_requirement_component.cairo, packages/metagame/src/ticket_booth/ticket_booth_component.cairo, packages/metagame/src/prize/structs.cairo, packages/utilities/src/math/tests.cairo
Removed unused or redundant public imports and test-only imports (e.g., GameObjective, validator dispatcher imports, ExtensionConfig, GameExpiration/GoldenPassInfo, StorePacking, Fixed).
Return Value Handling (test mock)
packages/metagame/src/entry_fee/tests/mocks/entry_fee_mock.cairo
Change set_entry_fee to discard the return value from the underlying call by binding to a dummy variable (let _ = ...).

Sequence Diagram(s)

sequenceDiagram
    participant GH as "GitHub Actions Runner"
    participant Build as "Workspace Build (cairo-compile)"
    participant Tests as "Test Runner"
    participant Log as "Log File (/tmp/test.log)"
    participant Scanner as "CI Warning Scanner"

    GH->>Build: run build, stream output -> /tmp/build.log
    Build-->>GH: success/failure + stdout/stderr
    GH->>Tests: run tests, pipe output -> /tmp/test.log
    Tests-->>Log: write combined stdout/stderr
    GH->>Scanner: scan /tmp/build.log and /tmp/test.log for Cairo warnings
    alt warnings found
        Scanner-->>GH: print warning context, fail job
    else no warnings
        Scanner-->>GH: report clean, continue
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • starknetdev

Poem

🐰 I hopped through logs and trimmed imports light,
Chased compiler whispers into the night,
CI now listens with a vigilant ear,
Warnings surrendered — the path is clear,
A tiny hop, a tidy code delight. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description covers what changed, why it matters, and includes a test plan. However, it lacks structured sections from the template (Scope, Change Type, Validation, Risk, etc.). Complete missing template sections: mark 'fix' and 'packages/**' scope, document validation commands run, risk level, and any security considerations for the import/export changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: resolve compiler warnings and add CI warning detection' clearly and directly summarizes both main changes in the PR: fixing compiler warnings and adding CI detection.
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
  • Post copyable unit tests in a comment
  • Commit unit tests in branch game-component-fix-warnings

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

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request focuses on improving code quality by resolving compiler warnings, primarily related to unused imports and unhandled #[must_use] return values. The changes are correct and achieve the goal of cleaning up the codebase. I have one suggestion to improve a test mock by propagating a return value instead of just ignoring it, which would make the mock more useful for testing.

Comment on lines 39 to 42
#[external(v0)]
fn set_entry_fee(ref self: ContractState, context_id: u64, entry_fee: EntryFee) {
self.entry_fee.set_entry_fee(context_id, entry_fee);
let _ = self.entry_fee.set_entry_fee(context_id, entry_fee);
}

Choose a reason for hiding this comment

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

medium

While let _ = ... silences the compiler warning, it's generally better to propagate #[must_use] return values, especially in a test mock. The underlying set_entry_fee function returns an Option<EntryFeeConfig>, which could be valuable for assertions in your tests.

By modifying the function to return this value, the mock becomes more transparent and robust. You'll also need to add EntryFeeConfig to your imports from crate::entry_fee::structs.

    #[external(v0)]
    fn set_entry_fee(ref self: ContractState, context_id: u64, entry_fee: EntryFee) -> Option<EntryFeeConfig> {
        self.entry_fee.set_entry_fee(context_id, entry_fee)
    }

@codecov
Copy link

codecov bot commented Mar 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 cleans up Cairo compiler warnings across the metagame and interfaces packages, and tightens CI so that source-located compiler warnings cause workflow failures. This supports the repo’s goal of keeping smart-contract builds/test runs warning-free and preventing warning regressions from landing on main.

Changes:

  • Remove unused imports and address #[must_use] return values to eliminate existing compiler warnings.
  • Update pr-ci.yml and main-ci.yml to detect (and fail on) compiler warnings during scarb build and snforge test.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/metagame/src/ticket_booth/ticket_booth_component.cairo Removes unused struct imports from the ticket booth component.
packages/metagame/src/prize/structs.cairo Removes an unused test-only import.
packages/metagame/src/entry_requirement/entry_requirement_component.cairo Removes unused extension dispatcher imports and an unused struct import.
packages/metagame/src/entry_fee/tests/mocks/entry_fee_mock.cairo Explicitly discards a #[must_use] return value to silence warnings in the mock.
packages/interfaces/src/minigame/objectives.cairo Removes an unused import from the minigame objectives interface.
.github/workflows/pr-ci.yml Adds build/test log capture and warning detection to fail PR CI on compiler warnings.
.github/workflows/main-ci.yml Adds build/test log capture and warning detection to fail main CI on compiler warnings.

Comment on lines +449 to +453
if: always() && steps.cache-tools.outcome != 'failure'
run: |
if [ -f /tmp/test.log ] && grep -qE '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/test.log; then
echo "::error::Test compilation produced warnings. Fix all warnings before merging."
grep -B1 -E '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/test.log
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

The warning detector is keyed only on source-location lines (--> *.cairo:line:col), which are also emitted for compilation errors. Because this step runs with if: always(), a compile failure can be misreported as “warnings” (and potentially add noise on top of the real failure). Consider narrowing the grep to actual warning headers (e.g., match warning: and then include the following location lines), or gate this step to only run when the test command succeeded.

Suggested change
if: always() && steps.cache-tools.outcome != 'failure'
run: |
if [ -f /tmp/test.log ] && grep -qE '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/test.log; then
echo "::error::Test compilation produced warnings. Fix all warnings before merging."
grep -B1 -E '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/test.log
if: success() && steps.cache-tools.outcome != 'failure'
run: |
if [ -f /tmp/test.log ] && grep -q '^warning:' /tmp/test.log; then
echo "::error::Test compilation produced warnings. Fix all warnings before merging."
grep -A1 -E '^warning:' /tmp/test.log

Copilot uses AI. Check for mistakes.
Comment on lines +301 to +303
if [ -f /tmp/test.log ] && grep -qE '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/test.log; then
echo "::error::Test compilation produced warnings. Fix all warnings before merging."
grep -B1 -E '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/test.log
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

The warning detector is keyed only on source-location lines (--> *.cairo:line:col), which are also emitted for compilation errors. Because this step runs with if: always(), a compile failure can be misreported as “warnings” (and potentially add noise on top of the real failure). Consider narrowing the grep to actual warning headers (e.g., match warning: and then include the following location lines), or gate this step to only run when the test command succeeded.

Suggested change
if [ -f /tmp/test.log ] && grep -qE '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/test.log; then
echo "::error::Test compilation produced warnings. Fix all warnings before merging."
grep -B1 -E '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/test.log
if [ -f /tmp/test.log ] && grep -q 'warning:' /tmp/test.log; then
echo "::error::Test compilation produced warnings. Fix all warnings before merging."
grep -n -B2 -A2 'warning:' /tmp/test.log

Copilot uses AI. Check for mistakes.
CI correctly detected the intentional warning — remove it now.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@loothero loothero merged commit 21a52e1 into main Mar 8, 2026
27 checks passed
@loothero loothero deleted the game-component-fix-warnings branch March 8, 2026 19:05
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