Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update rust CI #215

Merged
merged 5 commits into from
Dec 9, 2024
Merged

chore: Update rust CI #215

merged 5 commits into from
Dec 9, 2024

Conversation

tedil
Copy link
Contributor

@tedil tedil commented Dec 9, 2024

Update actions used in the rust CI, switch from tarpaulin to cargo-llvm-cov

Summary by CodeRabbit

  • Chores
    • Updated GitHub Actions workflow for Rust to streamline the CI process.
    • Simplified toolchain installation and linting configurations.
    • Enhanced control flow by requiring formatting and linting checks before running tests.
    • Transitioned to direct command usage for testing and coverage collection.

Copy link

coderabbitai bot commented Dec 9, 2024

Warning

Rate limit exceeded

@tedil has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 25 seconds before requesting another review.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 39babfe and d44fb71.

📒 Files selected for processing (1)
  • .github/workflows/rust.yml (5 hunks)

Walkthrough

The pull request introduces several modifications to the GitHub Actions workflow for Rust, aimed at streamlining the continuous integration (CI) process. Key changes include updating the toolchain installation method, simplifying linting and testing commands, and enhancing job dependencies. The workflow now directly invokes tools like cargo clippy and cargo llvm-cov, eliminating the need for specific action versions. Additionally, the testing job now requires successful completion of formatting and linting jobs before execution, improving the overall control flow of the CI process.

Changes

File Path Change Summary
.github/workflows/rust.yml Updated toolchain installation to dtolnay/rust-toolchain@stable, simplified linting with cargo clippy --no-deps, modified testing to require formatting and linting jobs, transitioned coverage from actions-rs/[email protected] to cargo llvm-cov, and simplified test command to cargo test.

Poem

In the meadow where bunnies play,
Our CI flows a brighter way.
With clippy's checks and tests so neat,
We hop along, no bugs to greet!
A toolchain change, a joyful cheer,
For Rusty code, we have no fear! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 2

🧹 Outside diff range and nitpick comments (1)
.github/workflows/rust.yml (1)

Line range hint 91-95: Consider optimizing environment variable configuration

The environment variables are duplicated between fast and full test runs. Consider moving common environment variables to the job level.

Here's a suggested refactor:

  Testing:
    needs: [Formatting, Linting]
    runs-on: ubuntu-latest
+   env:
+     TEST_UTA_DATABASE_URL: postgres://uta_admin:[email protected]/uta
+     TEST_UTA_DATABASE_SCHEMA: uta_20210129
+     TEST_SEQREPO_CACHE_MODE: read
+     TEST_SEQREPO_CACHE_PATH: tests/data/seqrepo_cache.fasta

    strategy:
      matrix:
        include:
          - label: fast
          - label: full
    # ... rest of the job configuration ...

    steps:
      - name: Run cargo-llvm-cov with fast tests
        run: cargo llvm-cov --lcov --output-path lcov.info -- --test-threads 1
-       env:
-         TEST_UTA_DATABASE_URL: postgres://uta_admin:[email protected]/uta
-         TEST_UTA_DATABASE_SCHEMA: uta_20210129
-         TEST_SEQREPO_CACHE_MODE: read
-         TEST_SEQREPO_CACHE_PATH: tests/data/seqrepo_cache.fasta
        if: ${{ matrix.label == 'fast' }}

      - name: Run cargo-test with full tests
        run: "cargo test --release -- --include-ignored"
-       env:
-         TEST_UTA_DATABASE_URL: postgres://uta_admin:[email protected]/uta
-         TEST_UTA_DATABASE_SCHEMA: uta_20210129
-         TEST_SEQREPO_CACHE_MODE: read
-         TEST_SEQREPO_CACHE_PATH: tests/data/seqrepo_cache.fasta
        if: ${{ matrix.label == 'full' }}

Also applies to: 100-104

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b85d04b and 63e2839.

📒 Files selected for processing (1)
  • .github/workflows/rust.yml (4 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/rust.yml

20-20: unexpected key "components" for "step" section. expected one of "continue-on-error", "env", "id", "if", "name", "run", "shell", "timeout-minutes", "uses", "with", "working-directory"

(syntax-check)


35-35: unexpected key "components" for "step" section. expected one of "continue-on-error", "env", "id", "if", "name", "run", "shell", "timeout-minutes", "uses", "with", "working-directory"

(syntax-check)

🔇 Additional comments (3)
.github/workflows/rust.yml (3)

41-41: Good improvement in job dependencies

Adding explicit dependencies on Formatting and Linting jobs ensures that tests only run after code quality checks pass, which is more efficient.


38-38: Consider removing --no-deps flag from clippy

The --no-deps flag prevents clippy from checking how your code interacts with dependencies, which might miss potential issues in dependency usage patterns.

Let's check if there are any dependency-related lints that might be important:

✅ Verification successful

Keep the --no-deps flag in clippy

Based on the codebase analysis, the dependencies are primarily used for standard functionality and well-maintained crates like:

  • Standard library components (std)
  • Well-maintained crates (nom, thiserror, serde, etc.)
  • Established bioinformatics libraries (bio, seqrepo)

The current usage patterns don't show complex interactions with dependencies that would benefit significantly from clippy's dependency checks. The --no-deps flag helps maintain faster CI runs while still catching important issues in the project's own code.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for external dependency usage that might benefit from clippy checks
rg -l "use\s+[a-zA-Z_]+::" --type rust

Length of output: 545


Script:

#!/bin/bash
# Let's check the actual dependency usage patterns to assess potential clippy checks
rg "use\s+[a-zA-Z_]+::" --type rust -A 2

Length of output: 21585


89-90: Verify coverage configuration and test separation

The switch to cargo-llvm-cov is a good improvement as it's more maintained and integrated with LLVM. However, we should ensure:

  1. Coverage is only collected for relevant code paths
  2. The separation between fast and full tests is appropriate

Let's check the test organization:

Consider documenting the criteria for fast vs. full tests in the repository's README or CONTRIBUTING guide to help maintainers properly categorize new tests.

Also applies to: 99-99

✅ Verification successful

Test organization is well-structured with appropriate separation

The codebase shows a clear organization of tests with proper separation:

  • Only one test is marked as #[ignore] (in src/mapper/variant.rs), which is a full database test (dnah11_db_snp_full)
  • Tests are properly organized in test modules with #[cfg(test)]
  • The README clearly documents test execution modes:
    • Fast tests run by default with cargo test
    • Full tests (including ignored ones) require --include-ignored flag
    • Database tests have proper configuration via environment variables

The current coverage configuration with cargo llvm-cov running fast tests is appropriate as it:

  1. Focuses on the core functionality without long-running database tests
  2. Maintains CI performance while providing meaningful coverage data
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check test attributes to verify fast vs full test separation
rg -B 2 -A 2 "#\[ignore\]" --type rust

# Check if we have any long-running tests that should be marked as ignored
rg -l "test\s+fn\s+" --type rust | xargs rg "tokio::time::sleep|thread::sleep"

Length of output: 315


Script:

#!/bin/bash
# Let's check the test organization more comprehensively

# Find all test functions and their attributes
rg -B 2 "fn\s+\w+(_test|test_\w+|\w+_tests?)\b" --type rust

# Look for any test configuration or test utilities
fd -e rs | xargs rg "mod\s+tests?\b|#\[cfg\(test\)\]" -B 1 -A 3

# Check if there are any test-related constants or configurations
rg "const.*TEST|TEST.*const" --type rust

# Look for any test documentation
fd "README|CONTRIBUTING" | xargs rg -i "test"

Length of output: 5911

.github/workflows/rust.yml Outdated Show resolved Hide resolved
.github/workflows/rust.yml Outdated Show resolved Hide resolved
Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 63e2839 and 39babfe.

📒 Files selected for processing (1)
  • .github/workflows/rust.yml (4 hunks)
🔇 Additional comments (4)
.github/workflows/rust.yml (4)

19-24: LGTM! Formatting job changes look good

The toolchain installation is properly configured and the formatting check is appropriately simplified.


43-43: LGTM! Good job adding job dependencies

Adding explicit dependencies on Formatting and Linting jobs ensures proper workflow sequencing.


85-87: Verify coverage configuration after switching to llvm-cov

The switch from tarpaulin to llvm-cov looks good, but let's verify the coverage configuration is complete.

Consider adding a coverage configuration file (e.g., codecov.yml) to:

  • Set coverage targets
  • Configure coverage thresholds
  • Specify paths to include/exclude

Also applies to: 91-101

✅ Verification successful

Let me check the actual coverage configuration in the rust.yml file to see how llvm-cov is being used.


Let me check the content of the codecov.yml file to verify if it has proper configuration.


Coverage configuration is properly set up with llvm-cov

The switch from tarpaulin to llvm-cov is complete and well-configured:

  • Proper llvm-cov setup in rust.yml with lcov output format
  • Codecov integration is configured correctly
  • codecov.yml exists with appropriate settings:
    • Coverage range set to 70-90%
    • Patch status disabled
    • Pull request comments configured for diff and files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if we have any existing coverage configuration that needs to be updated
echo "Checking for coverage-related configuration files..."
fd -g '*coverage*' -g '*codecov*' -g '*.lcov*'

# Check if there are any coverage-related CI configurations in other workflows
echo "Checking for coverage-related CI configurations..."
rg -l 'coverage|tarpaulin|llvm-cov' .github/workflows/

Length of output: 509


Script:

#!/bin/bash
# Check the coverage configuration in rust.yml
echo "Checking rust.yml for coverage configuration..."
cat .github/workflows/rust.yml

# Also check for any codecov configuration in the root
echo -e "\nChecking for codecov.yml in root..."
ls -la codecov.yml 2>/dev/null || echo "No codecov.yml found"

Length of output: 3327


Script:

#!/bin/bash
# Check the content of codecov.yml
echo "Checking codecov.yml configuration..."
cat codecov.yml

Length of output: 928


Line range hint 1-115: Verify workflow triggers and environment consistency

The overall workflow structure looks good, but let's verify the configuration is complete.

Consider adding:

  1. A rust-toolchain.toml file to ensure consistent toolchain configuration across local and CI environments
  2. Documentation in the README about the CI workflow and required components

Comment on lines +35 to +40
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
components: clippy

- name: Lint with clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
run: cargo clippy --no-deps # --all-targets --all-features
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

🛠️ Refactor suggestion

Restore comprehensive clippy checks for better coverage

The codebase has multiple components that justify using --all-targets --all-features:

  • A benchmark target (translate_cds)
  • Extensive test dependencies indicating significant test code
  • Multiple source modules that could have conditional compilation
-run: cargo clippy --no-deps  # --all-targets --all-features
+run: cargo clippy --no-deps --all-targets --all-features
🔗 Analysis chain

Consider restoring comprehensive clippy checks

The simplified clippy command removes --all-targets --all-features flags (as seen in the comment). This might reduce the scope of linting coverage.

Let's check if these flags are important for your codebase:

Consider restoring these flags for comprehensive checking:

-run: cargo clippy --no-deps  # --all-targets --all-features
+run: cargo clippy --no-deps --all-targets --all-features

The previous output showed we have benches, lib, and multiple source files. Let's examine the Cargo.toml to understand the project structure and features better, and specifically look for test files to determine if --all-targets would be beneficial.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for different target types and features in the project
echo "Checking for different targets (lib, bin, examples, tests)..."
fd -e rs -t f . src/ examples/ tests/ benches/ 2>/dev/null

echo "Checking for feature definitions..."
rg '^\[features\]' -A 5 Cargo.toml

Length of output: 852


Script:

#!/bin/bash
# Let's check the Cargo.toml for targets and dependencies
echo "Checking Cargo.toml for targets and dependencies..."
cat Cargo.toml

# Let's also check for test files specifically
echo -e "\nChecking for test files..."
fd -t f -g '*test*.rs' .

Length of output: 1329

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.20%. Comparing base (faf4df1) to head (d44fb71).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   86.18%   92.20%   +6.01%     
==========================================
  Files          18       18              
  Lines        7166    11440    +4274     
==========================================
+ Hits         6176    10548    +4372     
+ Misses        990      892      -98     

see 18 files with indirect coverage changes

@tedil tedil merged commit 3901274 into main Dec 9, 2024
8 checks passed
@tedil tedil deleted the update-rust-ci branch December 9, 2024 14:45
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.

1 participant