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

Run tests only if rust changes were made. #440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sporkmonger
Copy link
Contributor

@sporkmonger sporkmonger commented Dec 31, 2024

This might not work well with required status checks? It might also be better to split clippy and the linter out?

Summary by CodeRabbit

  • Chores
    • Updated GitHub Actions workflow configuration for Rust project
    • Added specific path filters to optimize workflow triggering
    • Maintained existing workflow job structure and functionality

@sporkmonger sporkmonger added size/x-small Denotes a PR that changes 0-9 lines, ignoring generated files. github_actions Pull requests that update GitHub Actions code kind/testing Categorizes issue or PR as related to testing. labels Dec 31, 2024
Copy link
Contributor

coderabbitai bot commented Dec 31, 2024

Walkthrough

The pull request modifies the .github/workflows/rust.yml file by adding specific path filters for the push and pull_request events. These filters target Rust source files, Cargo configuration files, GitHub workflow directory contents, and protobuf-related files in the ext-processor crate. The changes aim to optimize workflow triggering by limiting execution to relevant file modifications, while maintaining the existing workflow's job structure and functionality.

Changes

File Change Summary
.github/workflows/rust.yml Added path filters for Rust-related files, including source files, Cargo configs, GitHub workflow files, and protobuf files

Possibly related PRs

  • Updates spdx dependencies #439: Modifications to GitHub Actions workflows in .github/workflows/rust.yml, specifically removing a plugin update-related step

Suggested labels

size/medium, rust

Poem

🐰 A Rusty Workflow's Gentle Sieve

Paths filtered with precision's might,
Triggers dance in GitHub's soft light,
Only changed files shall invoke the test,
Efficiency becomes our quest!

Hop hop, code clean! 🚀


🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

dryrunsecurity bot commented Dec 31, 2024

DryRun Security Summary

The GitHub Actions workflow for a Rust project updates trigger conditions for running tests and builds on specific file changes, focusing on maintaining code quality while ensuring proper configuration and security of external services and dependencies.

Expand for full summary

Summary:

The provided code change is a GitHub Actions workflow file for a Rust project, and the changes are focused on updating the trigger conditions for the workflow to run on specific file changes. The changes do not directly introduce any security concerns, as the workflow is focused on linting, testing, and building the Rust project, which are standard practices for maintaining code quality and ensuring the project's integrity.

However, it's worth noting that the workflow includes several steps that interact with external services, such as Redis and Envoy. While these services are not directly part of the Rust application, their configuration and usage should be reviewed to ensure they are properly secured and do not introduce any potential vulnerabilities. Additionally, the workflow includes the installation of the protobuf compiler, which is a critical component for handling protocol buffer data. It's important to ensure that the protobuf compiler is kept up-to-date and that any vulnerabilities in the protobuf library are addressed promptly.

Files Changed:

  • .github/workflows/rust.yml: This file is a GitHub Actions workflow for a Rust project. The changes update the trigger conditions for the workflow to run on specific file changes, including Rust source files, Cargo files, files in the .github directory, and files in the crates/ext-processor/protobuf directory. These changes do not directly introduce any security concerns but should be reviewed to ensure the overall security posture of the project is maintained.

Code Analysis

We ran 9 analyzers against 1 file and 0 analyzers had findings. 9 analyzers had no findings.

View PR in the DryRun Dashboard.

Copy link
Contributor

@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

🧹 Nitpick comments (2)
.github/workflows/rust.yml (2)

6-6: Consider additional path patterns and workflow organization.

The path filters look reasonable but could be improved:

  1. Consider including additional Rust-related files:

    • .cargo/**/* for cargo config files
    • rust-toolchain* for toolchain specifications
    • *.toml for workspace configuration files
  2. The current approach might cause issues with required status checks in GitHub, as noted in the PR description. When the workflow doesn't run due to path filters, the status checks will remain in a "pending" state.

Consider these alternatives:

  1. Split the workflow into two files:

    • rust-required.yml: Always runs fmt/clippy (required checks)
    • rust-tests.yml: Runs tests conditionally with path filters
  2. Use job-level conditions instead:

jobs:
  test:
    if: |
      github.event_name == 'push' ||
      contains(github.event.pull_request.labels.*.name, 'run-tests') ||
      contains(join(github.event.pull_request.changed_files.*.filename), '.rs') ||
      contains(join(github.event.pull_request.changed_files.*.filename), 'Cargo.')

This would allow required checks to complete while still optimizing test runs.

Also applies to: 9-9


Line range hint 71-146: Consider test reliability with conditional execution.

Given the complex test matrix (Redis + Envoy versions) and service dependencies, conditional test execution is valuable for CI optimization. However, to maintain reliability:

  1. Consider adding a manual trigger to force test execution:
on:
  workflow_dispatch:  # Allow manual triggers
  1. Add a label-based override:
    paths-ignore:
      - '**/*.rs'
      - '**/Cargo.*'
      - '.github/**/*'
      - 'crates/ext-processor/protobuf/**/*'
    paths-ignore-if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-tests') }}

This ensures tests can still be run when needed, regardless of changed files.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6e8eb9 and 4cc1d20.

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

@@ -3,8 +3,10 @@ name: Rust
on:
push:
branches: [main]
paths: ['**/*.rs', '**/Cargo.*', '.github/**/*', 'crates/ext-processor/protobuf/**/*']
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

The path filters need to include test configuration files

The current path filters miss several test configuration files that are actively used in the test suite:

  • Test configuration files like bulwark.toml, gha_envoy.yaml, and local_envoy.yaml are referenced in tests/multi_phase.rs and tests/envoy.rs
  • Environment variables are used in tests (REDIS_URI in smoke_test.rs and redis.rs)

To ensure tests run when these configurations change, add tests/**/* to the paths filter:

paths: ['**/*.rs', '**/Cargo.*', '.github/**/*', 'crates/ext-processor/protobuf/**/*', 'tests/**/*']
🔗 Analysis chain

Verify the impact on test coverage.

The path filters might cause tests to be skipped even when they should run. For example:

  • Changes to GitHub Actions environment variables
  • Changes to test fixtures or config files
  • Changes to dependencies that affect test behavior

Let's verify the repository structure to ensure we're not missing critical paths:

Also applies to: 9-9

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all files that might affect tests but aren't covered by current patterns
fd -t f -E '*.rs' -E 'Cargo.*' -E '.github' -E 'protobuf' . ./tests

Length of output: 201


Script:

#!/bin/bash
# Let's check if these test files are actually used in the test code
rg -l "bulwark\.toml|gha_envoy\.yaml|local_envoy\.yaml|multi_phase\.toml|smoke_test\.toml" -g "*.rs"

Length of output: 138


Script:

#!/bin/bash
# Let's also check if there are any other non-Rust test files referenced in the tests
rg -g "*.rs" "include_str!|include_bytes!" ./tests

Length of output: 52


Script:

#!/bin/bash
# Check if there are any test-specific environment variables used
rg "std::env::|env::var" -g "*.rs" ./tests

Length of output: 195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code kind/testing Categorizes issue or PR as related to testing. size/x-small Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant