-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
DryRun Security SummaryThe 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 summarySummary: 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:
Code AnalysisWe ran |
There was a problem hiding this 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:
Consider including additional Rust-related files:
.cargo/**/*
for cargo config filesrust-toolchain*
for toolchain specifications*.toml
for workspace configuration filesThe 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:
Split the workflow into two files:
rust-required.yml
: Always runs fmt/clippy (required checks)rust-tests.yml
: Runs tests conditionally with path filtersUse 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:
- Consider adding a manual trigger to force test execution:
on: workflow_dispatch: # Allow manual triggers
- 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.
@@ -3,8 +3,10 @@ name: Rust | |||
on: | |||
push: | |||
branches: [main] | |||
paths: ['**/*.rs', '**/Cargo.*', '.github/**/*', 'crates/ext-processor/protobuf/**/*'] |
There was a problem hiding this comment.
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
, andlocal_envoy.yaml
are referenced intests/multi_phase.rs
andtests/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
This might not work well with required status checks? It might also be better to split clippy and the linter out?
Summary by CodeRabbit