-
-
Notifications
You must be signed in to change notification settings - Fork 638
Optimize CI with change-driven gating #1902
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a41f78c
Optimize CI workflows with change-driven gating
justin808 e569c15
Optimize CI for faster branch builds and fix critical issues
justin808 b0b49cd
Fix Pro workflows: use correct working-directory for detect-changes
justin808 deb7bb9
Fix workflow syntax: remove matrix context from job-level if conditions
justin808 fbda2dc
Update CONTRIBUTING.md files with CI optimization documentation
justin808 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Run CI Command | ||
|
|
||
| Analyze the current branch changes and run appropriate CI checks locally. | ||
|
|
||
| ## Instructions | ||
|
|
||
| 1. First, run `script/ci-changes-detector origin/master` to analyze what changed | ||
| 2. Show the user what the detector recommends | ||
| 3. Ask the user if they want to: | ||
| - Run the recommended CI jobs (`bin/ci-local`) | ||
| - Run all CI jobs (`bin/ci-local --all`) | ||
| - Run a fast subset (`bin/ci-local --fast`) | ||
| - Run specific jobs manually | ||
| 4. Execute the chosen option and report results | ||
| 5. If any jobs fail, offer to help fix the issues | ||
|
|
||
| ## Options | ||
|
|
||
| - `bin/ci-local` - Run CI based on detected changes | ||
| - `bin/ci-local --all` - Run all CI checks (same as CI on master) | ||
| - `bin/ci-local --fast` - Run only fast checks, skip slow integration tests | ||
| - `bin/ci-local [base-ref]` - Compare against a specific ref instead of origin/master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Detect Changes | ||
|
|
||
| on: | ||
| workflow_call: | ||
| outputs: | ||
| docs_only: | ||
| description: 'Only documentation files changed' | ||
| value: ${{ jobs.detect.outputs.docs_only }} | ||
| run_lint: | ||
| description: 'Should run linting' | ||
| value: ${{ jobs.detect.outputs.run_lint }} | ||
| run_ruby_tests: | ||
| description: 'Should run Ruby tests' | ||
| value: ${{ jobs.detect.outputs.run_ruby_tests }} | ||
| run_js_tests: | ||
| description: 'Should run JS tests' | ||
| value: ${{ jobs.detect.outputs.run_js_tests }} | ||
| run_dummy_tests: | ||
| description: 'Should run dummy app tests' | ||
| value: ${{ jobs.detect.outputs.run_dummy_tests }} | ||
| run_generators: | ||
| description: 'Should run generator tests' | ||
| value: ${{ jobs.detect.outputs.run_generators }} | ||
|
|
||
| jobs: | ||
| detect: | ||
| runs-on: ubuntu-22.04 | ||
| outputs: | ||
| docs_only: ${{ steps.changes.outputs.docs_only }} | ||
| run_lint: ${{ steps.changes.outputs.run_lint }} | ||
| run_ruby_tests: ${{ steps.changes.outputs.run_ruby_tests }} | ||
| run_js_tests: ${{ steps.changes.outputs.run_js_tests }} | ||
| run_dummy_tests: ${{ steps.changes.outputs.run_dummy_tests }} | ||
| run_generators: ${{ steps.changes.outputs.run_generators }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Detect changes | ||
| id: changes | ||
| run: | | ||
| # For master branch, always run everything | ||
| if [ "${{ github.ref }}" = "refs/heads/master" ]; then | ||
| echo "docs_only=false" >> "$GITHUB_OUTPUT" | ||
| echo "run_lint=true" >> "$GITHUB_OUTPUT" | ||
| echo "run_ruby_tests=true" >> "$GITHUB_OUTPUT" | ||
| echo "run_js_tests=true" >> "$GITHUB_OUTPUT" | ||
| echo "run_dummy_tests=true" >> "$GITHUB_OUTPUT" | ||
| echo "run_generators=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # For PRs, analyze changes | ||
| BASE_SHA="${{ github.event.pull_request.base.sha || github.event.before }}" | ||
| script/ci-changes-detector "$BASE_SHA" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
Verify if this reusable workflow is actually called via
workflow_call.The
detect-changes.ymlis defined as a reusable workflow usingworkflow_call, but the other workflows (main.yml, lint-js-and-ruby.yml, etc.) don't appear to call it. Instead, they duplicate the detect-changes job inline. This breaks the DRY principle and creates maintenance burden if the detection logic changes.Option A (recommended): Refactor workflows to call this reusable workflow instead of duplicating it. Example:
Option B: If inline duplication is intentional (e.g., to avoid job dependency overhead), remove the standalone
detect-changes.ymlfile to avoid confusion.Please clarify which approach is intended.
🏁 Script executed:
Length of output: 497
Length of output: 1893
Length of output: 930
Fix missing fallback in detect-changes.yml and consolidate reusable workflow usage.
The reusable workflow is correctly defined but not used—8 workflows duplicate the detect-changes job inline instead. More critically, detect-changes.yml has a bug: it lacks the
'origin/master'fallback forBASE_SHAthat all inline implementations include.Line 56 in detect-changes.yml:
BASE_SHA="${{ github.event.pull_request.base.sha || github.event.before }}"Should match the robust fallback used in main.yml, lint-js-and-ruby.yml, and others:
BASE_SHA="${{ github.event.pull_request.base.sha || github.event.before || 'origin/master' }}"Once fixed, refactor workflows to call the reusable workflow via
uses: ./.github/workflows/detect-changes.ymlto eliminate duplication.🤖 Prompt for AI Agents