Skip to content

only run ci jobs for changed files - #5354

Open
LusterSourav wants to merge 7 commits into
rust-lang:mainfrom
LusterSourav:ci-changes-upstream
Open

only run ci jobs for changed files#5354
LusterSourav wants to merge 7 commits into
rust-lang:mainfrom
LusterSourav:ci-changes-upstream

Conversation

@LusterSourav

@LusterSourav LusterSourav commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

closes #3445

@rustbot rustbot added A-CI Area: CI-related items S-waiting-on-review labels Aug 2, 2026
@LusterSourav

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@LusterSourav

LusterSourav commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

@JohnTitor could u please review it

Comment thread .github/workflows/ci.yaml
@rustbot

This comment has been minimized.

@rustbot

rustbot commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/libc.git main
    $ git push --force-with-lease
    

@LusterSourav

Copy link
Copy Markdown
Contributor Author

could u please reivew this @weihanglo

@tgross35

tgross35 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Please be patient awaiting reviews, it can take a few weeks. No need to ping maintainers.

@LusterSourav

Copy link
Copy Markdown
Contributor Author

Please be patient awaiting reviews, it can take a few weeks. No need to ping maintainers.

sorry next time it wont happed

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will be a nice change for anyone working on a specific target, but I think we should go about it differently. Instead of doing some tricky things skipping steps with groups, I'd rather the python file generate the the T1, T2, and T2 VM matrices directly. That should have a cleaner CI file and also make it more clear which jobs actually got ran (as opposed to showing a green check but not actually doing something).

For an example see matrix generation at https://github.com/rust-lang/compiler-builtins/blob/9f542c0f7d9cf80949797a6212162c3d84aceffb/.github/workflows/main.yaml#L26-L49 and the use at https://github.com/rust-lang/compiler-builtins/blob/9f542c0f7d9cf80949797a6212162c3d84aceffb/.github/workflows/main.yaml#L385-L391. I'd like to keep things in libc looking somewhat similar to those.

Also important note, we need to run the complete CI in the merge queue regardless of what's changed.

View changes since this review

@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@LusterSourav

Copy link
Copy Markdown
Contributor Author

This will be a nice change for anyone working on a specific target, but I think we should go about it differently. Instead of doing some tricky things skipping steps with groups, I'd rather the python file generate the the T1, T2, and T2 VM matrices directly. That should have a cleaner CI file and also make it more clear which jobs actually got ran (as opposed to showing a green check but not actually doing something).

For an example see matrix generation at https://github.com/rust-lang/compiler-builtins/blob/9f542c0f7d9cf80949797a6212162c3d84aceffb/.github/workflows/main.yaml#L26-L49 and the use at https://github.com/rust-lang/compiler-builtins/blob/9f542c0f7d9cf80949797a6212162c3d84aceffb/.github/workflows/main.yaml#L385-L391. I'd like to keep things in libc looking somewhat similar to those.

Also important note, we need to run the complete CI in the merge queue regardless of what's changed.

View changes since this review

I updated the CI script, ci/detect-changes.py. It now creates the T1/T2/T2-VM matrices directly, similar to how compiler-builtins calculates variables. The test jobs use these matrices with matrix: include: ${{ fromJSON(...) }}. All the old checks at the step level are gone. Platforms that don't have changes won't run any tests, so skipped jobs will show up correctly. The merge queue and scheduled builds will always run the full set of matrices, but pull requests will only check for changes within the diff. Tier 2 and tier 2 VM no longer depend on tier 1. I rebased everything on the current main branch, and the CI is now passing. Can you please check it again?

@LusterSourav
LusterSourav requested a review from tgross35 August 4, 2026 19:34
@LusterSourav

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this is changing quite a bit, let's shrink the scope. Could you drop everything related to autodetecting which files indicate which target changes? I.e. get things working exactly as they currently are but using the python script rather than matrix.

Detecting what to run can come in a followup.

View changes since this review

Comment thread ci/detect-changes.py
Comment on lines +31 to +41
TIER1 = [
{"group" : "apple" ,"target":"aarch64-apple-darwin" ,"os":"macos-26" } ,
{ "group": "windows_msvc" ,"target": "aarch64-pc-windows-msvc", "os": "windows-11-arm" },
{"group": "linux", "target": "aarch64-unknown-linux-gnu", "os": "ubuntu-26.04-arm"},
{"group" : "windows_gnu" , "target": "i686-pc-windows-gnu","os":"windows-2025" } ,
{ "group":"windows_msvc","target":"i686-pc-windows-msvc","os" : "windows-2025"},
{"group": "linux", "target": "i686-unknown-linux-gnu"},
{"group": "windows_gnu", "target": "x86_64-pc-windows-gnu", "os": "windows-2025"},
{"group": "windows_msvc", "target": "x86_64-pc-windows-msvc", "os": "windows-2025"},
{"group": "linux", "target": "x86_64-unknown-linux-gnu"},
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use a dataclass to merge all targets into a single list:

class Tier(IntEnum):
    T1 = 1
    T2 = 2
    T3 = 3

@dataclass
class TestTarget:
    name: str
    os: str
    tier: Tier
    vm: bool = False
    env: dict[str, str] = field(default_factory=dict)
    artifact_tag: str | None = None

Still keep them grouped by tier, though.

Comment thread ci/detect-changes.py
return p.startswith(pat[:-3]) if pat.endswith("/**") else fnmatch.fnmatch(p, pat)


def groups_for(files) :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doc comments and type annotations, please

Comment thread ci/detect-changes.py
Comment on lines +97 to +104
code = [p for p in files if not any(match(p, d) for d in DOCS)]


if not code:
return []
hit = set ()
for p in code:
gs= { g for g , pats in PLATFORMS.items ( )if any(match (p ,x)for x in pats )}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file has chaotic formatting like this, please run through black

Comment thread .github/workflows/ci.yaml
Comment on lines 440 to +384
- name: check if any dependency failed
run: jq --exit-status 'all(.result == "success")' <<< "$NEEDS"
run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< "$NEEDS"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this still needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: CI-related items S-waiting-on-author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only run CI jobs related to the changed files

3 participants