-
Notifications
You must be signed in to change notification settings - Fork 88
fix(ci): Improve workflow efficiency by optimizing runner usage and eliminating duplicate runs #1824
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
base: main
Are you sure you want to change the base?
fix(ci): Improve workflow efficiency by optimizing runner usage and eliminating duplicate runs #1824
Changes from all commits
745a05f
702cbbe
b59fbd5
e4a44de
e0e89b6
ada1991
fce9337
9f49be4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,14 +26,16 @@ concurrency: | |
| cancel-in-progress: "${{github.ref != 'refs/heads/main'}}" | ||
|
|
||
| jobs: | ||
| skip-duplicate-check: | ||
| uses: "./.github/workflows/skip-duplicate-check.yaml" | ||
|
|
||
| filter-relevant-changes: | ||
| name: "filter-relevant-changes" | ||
| runs-on: &runner >- | ||
| ${{ | ||
| github.repository_owner == 'y-scope' | ||
| && fromJSON('["self-hosted", "x64", "ubuntu-noble"]') | ||
| || 'ubuntu-24.04' | ||
| }} | ||
| needs: "skip-duplicate-check" | ||
| if: "needs.skip-duplicate-check.outputs.should_skip != 'true'" | ||
| # This job only performs git operations to detect changed paths, so we use a GitHub-hosted | ||
| # runner to avoid consuming self-hosted runner resources needed for heavier build jobs. | ||
| runs-on: "ubuntu-24.04" | ||
|
Comment on lines
32
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for all references to needs.filter-relevant-changes.outputs in the workflow
rg -n "needs\.filter-relevant-changes\.outputs" .github/workflows/clp-artifact-build.yaml | head -20Repository: y-scope/clp Length of output: 1636 🏁 Script executed: #!/bin/bash
# Also get the file size first to determine how to read it
wc -l .github/workflows/clp-artifact-build.yamlRepository: y-scope/clp Length of output: 100 🏁 Script executed: #!/bin/bash
# Get the lines around 46-52 and also around 121 and 234 to see the downstream jobs
echo "=== Lines 46-52 (filter-relevant-changes job) ==="
sed -n '46,52p' .github/workflows/clp-artifact-build.yaml
echo ""
echo "=== Lines 115-135 (around centos-stream-9-deps-image) ==="
sed -n '115,135p' .github/workflows/clp-artifact-build.yaml
echo ""
echo "=== Lines 228-248 (around centos-stream-9-binaries) ==="
sed -n '228,248p' .github/workflows/clp-artifact-build.yamlRepository: y-scope/clp Length of output: 2120 Verify downstream job behavior when When Ensure downstream jobs handle the skipped status correctly by:
🤖 Prompt for AI Agents |
||
| outputs: | ||
| centos_stream_9_image_changed: "${{steps.filter.outputs.centos_stream_9_image}}" | ||
| manylinux_2_28_x86_64_image_changed: "${{steps.filter.outputs.manylinux_2_28_x86_64_image}}" | ||
|
|
@@ -104,7 +106,14 @@ jobs: | |
| name: "centos-stream-9-deps-image" | ||
| if: "needs.filter-relevant-changes.outputs.centos_stream_9_image_changed == 'true'" | ||
| needs: "filter-relevant-changes" | ||
| runs-on: *runner | ||
| # Define a reusable runner configuration for jobs that require Docker and benefit from | ||
| # self-hosted runner resources. Falls back to GitHub-hosted runners for non-y-scope forks. | ||
| runs-on: &runner >- | ||
| ${{ | ||
| github.repository_owner == 'y-scope' | ||
| && fromJSON('["self-hosted", "x64", "ubuntu-noble"]') | ||
| || 'ubuntu-24.04' | ||
| }} | ||
| steps: | ||
| - uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" | ||
| with: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||
| name: "skip-duplicate-check" | ||||||||
|
|
||||||||
| # Reusable workflow to skip duplicate runs when both push and pull_request events trigger on the | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this docstring, can we also explain how this workflow interacts / may conflict with the caller workflow's |
||||||||
| # same commit. Other workflows can call this and check the `should_skip` output to avoid redundant | ||||||||
| # work. | ||||||||
| # | ||||||||
| # Usage: | ||||||||
| # jobs: | ||||||||
| # skip-check: | ||||||||
| # uses: "./.github/workflows/skip-duplicate-check.yaml" | ||||||||
| # | ||||||||
| # my-job: | ||||||||
| # needs: "skip-check" | ||||||||
| # if: "needs.skip-check.outputs.should_skip != 'true'" | ||||||||
| # ... | ||||||||
|
|
||||||||
| on: | ||||||||
| workflow_call: | ||||||||
| outputs: | ||||||||
| should_skip: | ||||||||
| description: "Whether the workflow run should be skipped" | ||||||||
| value: "${{jobs.check.outputs.should_skip}}" | ||||||||
|
|
||||||||
| jobs: | ||||||||
| check: | ||||||||
| name: "skip-duplicate-check" | ||||||||
| runs-on: "ubuntu-24.04" | ||||||||
| outputs: | ||||||||
| should_skip: "${{steps.skip_check.outputs.should_skip}}" | ||||||||
| steps: | ||||||||
| - id: "skip_check" | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we omit this |
||||||||
| uses: "fkirc/skip-duplicate-actions@v5" | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
for security / reproducibility concerns, in case the publisher republish the version with different contents |
||||||||
| with: | ||||||||
| # Skip duplicate runs for the same content (e.g., when both push and pull_request trigger) | ||||||||
| concurrent_skipping: "same_content" | ||||||||
| skip_after_successful_duplicate: "true" | ||||||||
| # Always run for scheduled builds and manual triggers. | ||||||||
| # NOTE: This is a JSON array string (required by the action), with escaped quotes for | ||||||||
| # yamllint compliance. | ||||||||
| do_not_skip: "[\"schedule\", \"workflow_dispatch\"]" | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
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.
maybe renaming this as
check-duplicate-run? like other steps place the verb at the beginning of the ids