[llvm] Pre compute (PR #224941)

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 20 09:11:14 PDT 2026


https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/224941

None

>From 6335b76f268fc4ceec33fcad10fe0a8afd6c64b3 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 19 Sep 2026 17:00:01 -0700
Subject: [PATCH 1/3] workflows/premerge: Remove full checkout when computing
 macOS changes for pushes

We can compute the changes using the API like we do for pull requests.
---
 .github/workflows/premerge.yaml | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index c6d604533f1f6..ce3ec08a47156 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -200,18 +200,11 @@ jobs:
       # pushes (e.g. release branches) there is no PR to query, so we fall
       # back to a git diff, which needs real history.
       - name: Checkout LLVM (sparse)
-        if: github.event_name == 'pull_request'
         uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
         with:
           persist-credentials: false
           sparse-checkout: .ci
           sparse-checkout-cone-mode: false
-      - name: Checkout LLVM
-        if: github.event_name != 'pull_request'
-        uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
-        with:
-          persist-credentials: false
-          fetch-depth: 2
       - name: Get Changed Files
         env:
           GH_TOKEN: ${{ github.token }}
@@ -221,7 +214,7 @@ jobs:
           if [[ "${{ github.event_name }}" == "pull_request" ]]; then
             gh api "repos/${REPO}/pulls/${PR_NUMBER}/files" --paginate --jq '.[].filename' > /tmp/changed_files.txt
           else
-            git diff --name-only HEAD~1...HEAD > /tmp/changed_files.txt
+            gh api "repos/${REPO}/compare/${{ github.event.before }}...${{ github.event.after }}" --paginate --jq '.files[].filename' > /tmp/changed_files.txt
           fi
       - name: Compute Projects
         id: vars

>From 403886647e4571fbf9e1b2e86436515ea0c83024 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sun, 20 Sep 2026 08:02:20 -0700
Subject: [PATCH 2/3] Remove comment

---
 .github/workflows/premerge.yaml | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index ce3ec08a47156..3878153f3e698 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -195,10 +195,6 @@ jobs:
       macos-runtimes: ${{ steps.vars.outputs.macos-runtimes }}
       macos-runtimes-check-targets: ${{ steps.vars.outputs.macos-runtimes-check-targets }}
     steps:
-      # For pull requests we get the changed files from the GitHub API, so we
-      # only need a sparse checkout of .ci/ to run compute_projects.py. For
-      # pushes (e.g. release branches) there is no PR to query, so we fall
-      # back to a git diff, which needs real history.
       - name: Checkout LLVM (sparse)
         uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
         with:

>From a84785fa8b8bf407948fe00cd21d72c81dedb867 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sun, 20 Sep 2026 09:10:22 -0700
Subject: [PATCH 3/3] XXX: pre-compute

---
 .ci/compute_projects.py         |   6 +-
 .github/workflows/premerge.yaml | 133 ++++++++++++++++----------------
 2 files changed, 70 insertions(+), 69 deletions(-)

diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py
index 936397b779eb0..079b56e6b459b 100644
--- a/.ci/compute_projects.py
+++ b/.ci/compute_projects.py
@@ -7,6 +7,7 @@
 """
 
 from collections.abc import Set
+import json
 import pathlib
 import platform
 import sys
@@ -388,5 +389,6 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
         current_platform = sys.argv[1]
     changed_files = [line.strip() for line in sys.stdin.readlines()]
     env_variables = get_env_variables(changed_files, current_platform)
-    for env_variable in env_variables:
-        print(f"{env_variable}='{env_variables[env_variable]}'")
+    json.dumps(env_variables)
+#    for env_variable in env_variables:
+        #print(f"{env_variable}='{env_variables[env_variable]}'")
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 3878153f3e698..c6820c16759e3 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -23,11 +23,68 @@ concurrency:
   cancel-in-progress: true
 
 jobs:
+  # Computes which projects/check-targets to build and test on the
+  # self-hosted macOS runners.
+  premerge-compute-macos:
+    name: Compute Projects
+    if: >-
+        github.repository_owner == 'llvm' &&
+        (github.event_name != 'pull_request' || github.event.action != 'closed')
+    runs-on: ubuntu-22.04
+    permissions:
+      contents: read
+      pull-requests: read
+    outputs:
+      macos-projects: ${{ steps.vars.outputs.macos-projects }}
+      macos-check-targets: ${{ steps.vars.outputs.macos-check-targets }}
+      macos-runtimes: ${{ steps.vars.outputs.macos-runtimes }}
+      macos-runtimes-check-targets: ${{ steps.vars.outputs.macos-runtimes-check-targets }}
+      Linux-values: ${{ steps.vars.outputs.Linux-values }}
+      Windows-values: ${{ steps.vars.outputs.Windows-values }}
+      Darwin-values: ${{ steps.vars.outputs.Darwin-values }}
+      
+    steps:
+      - name: Checkout LLVM (sparse)
+        uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
+        with:
+          persist-credentials: false
+          sparse-checkout: .ci
+          sparse-checkout-cone-mode: false
+      - name: Get Changed Files
+        env:
+          GH_TOKEN: ${{ github.token }}
+          PR_NUMBER: ${{ github.event.pull_request.number }}
+          REPO: ${{ github.repository }}
+        run: |
+          if [[ "${{ github.event_name }}" == "pull_request" ]]; then
+            gh api "repos/${REPO}/pulls/${PR_NUMBER}/files" --paginate --jq '.[].filename' > /tmp/changed_files.txt
+          else
+            gh api "repos/${REPO}/compare/${{ github.event.before }}...${{ github.event.after }}" --paginate --jq '.files[].filename' > /tmp/changed_files.txt
+          fi
+      - name: Compute Projects
+        id: vars
+        run: |
+          for p in Linux Windows Darwin; do
+            echo $p-values=$(python3 .ci/compute_projects.py $p < /tmp/changed_files.txt) >> $GITHUB_OUTPUT
+          done
+
+#          echo "Building projects: ${projects_to_build}"
+#          echo "Running project checks targets: ${project_check_targets}"
+#          echo "Building runtimes: ${runtimes_to_build}"
+#          echo "Running runtimes checks targets: ${runtimes_check_targets}"
+#          echo "Running runtimes checks requiring reconfiguring targets: ${runtimes_check_targets_needs_reconfig}"
+
+#          echo "macos-projects=${projects_to_build}" >> $GITHUB_OUTPUT
+#          echo "macos-check-targets=${project_check_targets}" >> $GITHUB_OUTPUT
+#          echo "macos-runtimes=${runtimes_to_build}" >> $GITHUB_OUTPUT
+#          echo "macos-runtimes-check-targets=${runtimes_check_targets}" >> $GITHUB_OUTPUT
   premerge-checks-linux:
     name: Build and Test Linux
+    needs: premerge-compute
     if: >-
         github.repository_owner == 'llvm' &&
-        (github.event_name != 'pull_request' || github.event.action != 'closed')
+        (github.event_name != 'pull_request' || github.event.action != 'closed') &&
+        fromJSON(needs.premerge-compute.outputs.Linux-values).projects_to_build != ''
     runs-on: llvm-premerge-linux-runners
     defaults:
       run:
@@ -40,22 +97,18 @@ jobs:
         uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
         with:
           persist-credentials: false
-          fetch-depth: 2
       - name: Build and Test
         timeout-minutes: 120
         env:
           GITHUB_TOKEN: ${{ github.token }}
           GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
-        run: |
-          git config --global --add safe.directory '*'
-
-          source <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py)
-
-          if [[ "${projects_to_build}" == "" ]]; then
-            echo "No projects to build"
-            exit 0
-          fi
+          projects_to_build: ${{ fromJSON(needs.premerge-compute.outputs.Linux-values).projects_to_build }}
+          project_check_targets: ${{ fromJSON(needs.premerge-compute.outputs.Linux-values).project_check_targets }}
+          runtimes_to_build: ${{ fromJSON(needs.premerge-compute.outputs.Linux-values).runtimes_to_build }}
+          runtimes_check_targets: ${{ fromJSON(needs.premerge-compute-outputs.Linux-values).runtimes_check_targets }}
+          runtimes_check_targets_needs_reconfig: ${{ fromJSON(needs.premerge-compute-outputs.Linux-values).runtimes_check_targets_needs_reconfig}}
 
+        run: |
           echo "Building projects: ${projects_to_build}"
           echo "Running project checks targets: ${project_check_targets}"
           echo "Building runtimes: ${runtimes_to_build}"
@@ -104,6 +157,7 @@ jobs:
 
   premerge-checks-windows:
     name: Build and Test Windows
+    needs: premerge-compute
     if: >-
         github.repository_owner == 'llvm' &&
         (github.event_name != 'pull_request' || github.event.action != 'closed')
@@ -173,65 +227,10 @@ jobs:
           path: |
             comments-Windows-AMD64
 
-  # Computes which projects/check-targets to build and test on the
-  # self-hosted macOS runners. This job intentionally runs on a
-  # GitHub-hosted runner rather than a self-hosted one, since self-hosted
-  # macOS capacity is limited and shouldn't be spent just to compute what
-  # to build. Its outputs feed premerge-check-macos below, which does the
-  # actual build/test on the self-hosted runners, so changes here directly
-  # affect what runs there.
-  premerge-compute-macos:
-    name: Compute macOS Projects
-    if: >-
-        github.repository_owner == 'llvm' &&
-        (github.event_name != 'pull_request' || github.event.action != 'closed')
-    runs-on: ubuntu-22.04
-    permissions:
-      contents: read
-      pull-requests: read
-    outputs:
-      macos-projects: ${{ steps.vars.outputs.macos-projects }}
-      macos-check-targets: ${{ steps.vars.outputs.macos-check-targets }}
-      macos-runtimes: ${{ steps.vars.outputs.macos-runtimes }}
-      macos-runtimes-check-targets: ${{ steps.vars.outputs.macos-runtimes-check-targets }}
-    steps:
-      - name: Checkout LLVM (sparse)
-        uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
-        with:
-          persist-credentials: false
-          sparse-checkout: .ci
-          sparse-checkout-cone-mode: false
-      - name: Get Changed Files
-        env:
-          GH_TOKEN: ${{ github.token }}
-          PR_NUMBER: ${{ github.event.pull_request.number }}
-          REPO: ${{ github.repository }}
-        run: |
-          if [[ "${{ github.event_name }}" == "pull_request" ]]; then
-            gh api "repos/${REPO}/pulls/${PR_NUMBER}/files" --paginate --jq '.[].filename' > /tmp/changed_files.txt
-          else
-            gh api "repos/${REPO}/compare/${{ github.event.before }}...${{ github.event.after }}" --paginate --jq '.files[].filename' > /tmp/changed_files.txt
-          fi
-      - name: Compute Projects
-        id: vars
-        run: |
-          python3 .ci/compute_projects.py Darwin < /tmp/changed_files.txt > /tmp/env_vars.sh
-          source /tmp/env_vars.sh
-
-          echo "Building projects: ${projects_to_build}"
-          echo "Running project checks targets: ${project_check_targets}"
-          echo "Building runtimes: ${runtimes_to_build}"
-          echo "Running runtimes checks targets: ${runtimes_check_targets}"
-          echo "Running runtimes checks requiring reconfiguring targets: ${runtimes_check_targets_needs_reconfig}"
-
-          echo "macos-projects=${projects_to_build}" >> $GITHUB_OUTPUT
-          echo "macos-check-targets=${project_check_targets}" >> $GITHUB_OUTPUT
-          echo "macos-runtimes=${runtimes_to_build}" >> $GITHUB_OUTPUT
-          echo "macos-runtimes-check-targets=${runtimes_check_targets}" >> $GITHUB_OUTPUT
 
   premerge-check-macos:
     name: Build and Test macOS arm64
-    needs: premerge-compute-macos
+    needs: premerge-compute
     runs-on: [self-hosted, macOS, ARM64, apple-runners]
     # Skip the self-hosted runner entirely if there is nothing to build,
     # rather than tying up a runner slot for a no-op run.



More information about the llvm-commits mailing list