Skip to content

[BOLT] Create marker for source changes in nfc-mode testing. #142931

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 2 commits into from
Jun 26, 2025

Conversation

paschalis-mpeis
Copy link
Member

Currently NFC tests only trigger when the llvm-bolt binary itself changes.

This patch adds --check-bolt-sources, which scans git output for any modifications under bolt/, excluding:

  • bolt/docs
  • bolt/utils/docker
  • bolt/utils/dot2html

If any matching files change between versions, a .llvm-bolt.changes marker is created. Buildbots can then use this marker to trigger in-tree tests.

Currently NFC tests only trigger when the llvm-bolt binary itself changes.

This patch adds `--check-bolt-sources`, which scans git output for any
modifications under bolt/, excluding:
- bolt/docs
- bolt/utils/docker
- bolt/utils/dot2html

If any matching files change between versions, a `.llvm-bolt.changes` marker is
created. Buildbots can then use this marker to trigger in-tree tests.
Copy link

github-actions bot commented Jun 5, 2025

✅ With the latest revision this PR passed the Python code formatter.

@paschalis-mpeis paschalis-mpeis force-pushed the users/paschalis-mpeis/bolt-nfc-checks-sources branch from 305cdf0 to d037f0d Compare June 5, 2025 15:41
@paschalis-mpeis paschalis-mpeis force-pushed the users/paschalis-mpeis/bolt-nfc-checks-sources branch from d037f0d to 0fe8672 Compare June 5, 2025 15:48
@paschalis-mpeis paschalis-mpeis marked this pull request as ready for review June 10, 2025 16:16
@llvmbot llvmbot added the BOLT label Jun 10, 2025
@paschalis-mpeis
Copy link
Member Author

Will be used by:

@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2025

@llvm/pr-subscribers-bolt

Author: Paschalis Mpeis (paschalis-mpeis)

Changes

Currently NFC tests only trigger when the llvm-bolt binary itself changes.

This patch adds --check-bolt-sources, which scans git output for any modifications under bolt/, excluding:

  • bolt/docs
  • bolt/utils/docker
  • bolt/utils/dot2html

If any matching files change between versions, a .llvm-bolt.changes marker is created. Buildbots can then use this marker to trigger in-tree tests.


Full diff: https://github.com/llvm/llvm-project/pull/142931.diff

1 Files Affected:

  • (modified) bolt/utils/nfc-check-setup.py (+39)
diff --git a/bolt/utils/nfc-check-setup.py b/bolt/utils/nfc-check-setup.py
index 710b183505853..275ac7b886d00 100755
--- a/bolt/utils/nfc-check-setup.py
+++ b/bolt/utils/nfc-check-setup.py
@@ -7,6 +7,29 @@
 import sys
 import textwrap
 
+def get_relevant_bolt_changes(dir: str) -> str:
+    # Return a list of bolt source changes that are relevant to testing.
+    all_changes = subprocess.run(
+        shlex.split("git show HEAD --name-only --pretty=''"),
+        cwd=dir,
+        text=True,
+        stdout=subprocess.PIPE,
+    )
+    keep_bolt = subprocess.run(
+        shlex.split("grep '^bolt'"),
+        input=all_changes.stdout,
+        text=True,
+        stdout=subprocess.PIPE,
+    )
+    keep_relevant = subprocess.run(
+        shlex.split(
+            "grep -v -e '^bolt/docs' -e '^bolt/utils/docker' -e '^bolt/utils/dot2html'"
+        ),
+        input=keep_bolt.stdout,
+        text=True,
+        stdout=subprocess.PIPE,
+    )
+    return keep_relevant.stdout
 
 def get_git_ref_or_rev(dir: str) -> str:
     # Run 'git symbolic-ref -q --short HEAD || git rev-parse --short HEAD'
@@ -36,6 +59,12 @@ def main():
         default=os.getcwd(),
         help="Path to BOLT build directory, default is current " "directory",
     )
+    parser.add_argument(
+        "--check-bolt-sources",
+        default=False,
+        action="store_true",
+        help="Create a marker file (.llvm-bolt.changes) if any relevant BOLT sources are modified",
+    )
     parser.add_argument(
         "--switch-back",
         default=False,
@@ -71,6 +100,16 @@ def main():
     # memorize the old hash for logging
     old_ref = get_git_ref_or_rev(source_dir)
 
+    if args.check_bolt_sources:
+        marker = f"{args.build_dir}/.llvm-bolt.changes"
+        if os.path.exists(marker):
+            os.remove(marker)
+        file_changes = get_relevant_bolt_changes(source_dir)
+        # Create a marker file if any relevant BOLT source files changed.
+        if len(file_changes) > 0:
+            print(f"BOLT source changes were found:\n{file_changes}")
+            open(marker, "a").close()
+
     # determine whether a stash is needed
     stash = subprocess.run(
         shlex.split("git status --porcelain"),

)
keep_relevant = subprocess.run(
shlex.split(
"grep -v -e '^bolt/docs' -e '^bolt/utils/docker' -e '^bolt/utils/dot2html'"
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to selectively include bolt/utils? I'd say utils is external to BOLT proper, and can be excluded.

Copy link
Member Author

Choose a reason for hiding this comment

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

My thinking was to include the helper python scripts, like nfc-check-setup itself, as a trigger for re-running the in-tree tests. That way, any breakage in the nfc-setup has a better chance being caught earlier in the buildbot.

We probably won't see frequent changes in the utils folder. Alternative options would be to include it as a whole, or ignore it entirely.

I lean towards the patch, though I'm not too happy with my grep's above.
No strong opinion either way. WDYT?

Copy link
Member Author

@paschalis-mpeis paschalis-mpeis Jun 26, 2025

Choose a reason for hiding this comment

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

Merged, as it was accepted, but happy to follow up and adjust this, @aaupov.

@paschalis-mpeis paschalis-mpeis merged commit d681c73 into main Jun 26, 2025
13 checks passed
@paschalis-mpeis paschalis-mpeis deleted the users/paschalis-mpeis/bolt-nfc-checks-sources branch June 26, 2025 08:32
anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
…2931)

Currently NFC tests only trigger when the llvm-bolt binary itself
changes.

This patch adds `--check-bolt-sources`, which scans git output for any
modifications under bolt/, excluding:
- bolt/docs
- bolt/utils/docker
- bolt/utils/dot2html

If any matching files change between versions, a `.llvm-bolt.changes`
marker is created. Buildbots can then use this marker to trigger in-tree
tests.
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
…2931)

Currently NFC tests only trigger when the llvm-bolt binary itself
changes.

This patch adds `--check-bolt-sources`, which scans git output for any
modifications under bolt/, excluding:
- bolt/docs
- bolt/utils/docker
- bolt/utils/dot2html

If any matching files change between versions, a `.llvm-bolt.changes`
marker is created. Buildbots can then use this marker to trigger in-tree
tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants