[llvm] Add macOS premerge check workflow (PR #207435)

Mishal Shah via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 14:48:07 PDT 2026


https://github.com/shahmishal updated https://github.com/llvm/llvm-project/pull/207435

>From 4592973b72322eec62908bbec6409cb6b9b3ff90 Mon Sep 17 00:00:00 2001
From: Mishal Shah <mishal_shah at apple.com>
Date: Fri, 3 Jul 2026 10:41:33 -0700
Subject: [PATCH 1/6] Add macOS premerge check workflow

Added a premerge check workflow for macOS self-hosted runners to build and test projects.
---
 .github/workflows/premerge.yaml | 38 +++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index d506e631e2f21..4825b80da2c76 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -248,3 +248,41 @@ jobs:
 
           # The libcxx tests fail, so we are skipping the runtime targets.
           ninja -C build ${project_check_targets}
+
+  premerge-check-macos-self-hosted-runners:
+    name: Build and Test macOS
+    runs-on: [self-hosted, macos, apple-runners]
+    if: >-
+        github.repository_owner == 'llvm' &&
+        (github.event_name != 'pull_request' || github.event.action != 'closed')
+    steps:
+      - name: Checkout LLVM
+        uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+        with:
+          persist-credentials: false
+          fetch-depth: 2
+      - name: Install Ninja
+        run: |
+          brew install ninja
+      - name: Build and Test
+        run: |
+          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
+
+          echo "Building projects: ${projects_to_build}"
+          echo "Running project checks targets: ${project_check_targets}"
+
+          xcrun cmake -G Ninja \
+                -B build \
+                -S llvm \
+                -DLLVM_ENABLE_PROJECTS="${projects_to_build}" \
+                -DLLVM_DISABLE_ASSEMBLY_FILES=ON \
+                -DCMAKE_BUILD_TYPE=Release \
+                -DLLDB_INCLUDE_TESTS=OFF \
+                -DLLVM_ENABLE_ASSERTIONS=ON \
+
+          ninja -C build ${project_check_targets}

>From 880315710e05b23174e500f50618fea78c691d37 Mon Sep 17 00:00:00 2001
From: Mishal Shah <mishal_shah at apple.com>
Date: Fri, 3 Jul 2026 23:38:41 -0700
Subject: [PATCH 2/6] Enhance debug output in premerge workflow

Added debug statements to display changed files and building information.
---
 .github/workflows/premerge.yaml | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 4825b80da2c76..18fc6eb01c409 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -266,16 +266,23 @@ jobs:
           brew install ninja
       - name: Build and Test
         run: |
+          echo "** Debug **"
+          git diff --name-only HEAD~1...HEAD
+          echo "** Debug **"
+          
           source <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py)
 
+          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}"
+
           if [[ "${projects_to_build}" == "" ]]; then
             echo "No projects to build"
             exit 0
           fi
 
-          echo "Building projects: ${projects_to_build}"
-          echo "Running project checks targets: ${project_check_targets}"
-
           xcrun cmake -G Ninja \
                 -B build \
                 -S llvm \

>From 263f980a7052f165f26e8e4f7a49cb890966cfc4 Mon Sep 17 00:00:00 2001
From: Mishal Shah <mishal_shah at apple.com>
Date: Sat, 4 Jul 2026 00:02:52 -0700
Subject: [PATCH 3/6] [Github] Fix macOS self-hosted premerge env var sourcing

source <(...) via process substitution silently produces empty variables under macOS's bash 3.2, causing the job to skip building any projects. Write compute_projects.py output to a temp file and source that instead.
---
 .github/workflows/premerge.yaml | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 18fc6eb01c409..2a1aa447fcd54 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -266,11 +266,8 @@ jobs:
           brew install ninja
       - name: Build and Test
         run: |
-          echo "** Debug **"
-          git diff --name-only HEAD~1...HEAD
-          echo "** Debug **"
-          
-          source <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py)
+          git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py > /tmp/env_vars.sh
+          source /tmp/env_vars.sh
 
           echo "Building projects: ${projects_to_build}"
           echo "Running project checks targets: ${project_check_targets}"

>From 2199a83060a8be8ff078e085484377ea0b8c0e5c Mon Sep 17 00:00:00 2001
From: Mishal Shah <mishal_shah at apple.com>
Date: Sat, 4 Jul 2026 00:12:13 -0700
Subject: [PATCH 4/6] [Github] Install cmake for macOS self-hosted premerge
 runners

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

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 2a1aa447fcd54..fb5f1d53cf4fb 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -261,9 +261,9 @@ jobs:
         with:
           persist-credentials: false
           fetch-depth: 2
-      - name: Install Ninja
+      - name: Install Ninja and CMake
         run: |
-          brew install ninja
+          brew install ninja cmake
       - name: Build and Test
         run: |
           git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py > /tmp/env_vars.sh

>From 93c134991bcf979144dbd0471b68763e58ea35a8 Mon Sep 17 00:00:00 2001
From: Mishal Shah <mishal_shah at apple.com>
Date: Tue, 7 Jul 2026 11:25:14 -0700
Subject: [PATCH 5/6] [Github] Add sccache S3 support for macOS self-hosted
 premerge runners

Configures sccache with the sccache-bucket S3 bucket (us-west-2) for
the self-hosted macOS premerge job to speed up rebuilds.
---
 .github/workflows/premerge.yaml | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index fb5f1d53cf4fb..0d2b6554fd0c6 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -261,10 +261,14 @@ jobs:
         with:
           persist-credentials: false
           fetch-depth: 2
-      - name: Install Ninja and CMake
+      - name: Install Ninja, CMake, and sccache
         run: |
           brew install ninja cmake
+          command -v sccache >/dev/null || brew install sccache
       - name: Build and Test
+        env:
+          SCCACHE_BUCKET: sccache-bucket
+          SCCACHE_REGION: us-west-2
         run: |
           git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py > /tmp/env_vars.sh
           source /tmp/env_vars.sh
@@ -280,6 +284,10 @@ jobs:
             exit 0
           fi
 
+          export SCCACHE_IDLE_TIMEOUT=0
+          mkdir -p artifacts
+          SCCACHE_LOG=info SCCACHE_ERROR_LOG=$(pwd)/artifacts/sccache.log sccache --start-server
+
           xcrun cmake -G Ninja \
                 -B build \
                 -S llvm \
@@ -288,5 +296,9 @@ jobs:
                 -DCMAKE_BUILD_TYPE=Release \
                 -DLLDB_INCLUDE_TESTS=OFF \
                 -DLLVM_ENABLE_ASSERTIONS=ON \
+                -DCMAKE_C_COMPILER_LAUNCHER=sccache \
+                -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
 
           ninja -C build ${project_check_targets}
+
+          sccache --show-stats

>From 5c1893cc4fbad140f8b280ec2b1787e9d0a889b1 Mon Sep 17 00:00:00 2001
From: Mishal Shah <mishal_shah at apple.com>
Date: Tue, 7 Jul 2026 14:46:46 -0700
Subject: [PATCH 6/6] [Github] Fix output/env var name mismatches in macOS
 self-hosted premerge job

The Compute Projects step's outputs and the Build and Test step's
env vars used inconsistent names (macos-projects vs projects_to_build,
hyphen vs underscore), so the gating condition was always false and
PROJECTS/CHECK_TARGETS were always empty. Align names with the pattern
used in the Windows job.
---
 .github/workflows/premerge.yaml | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 0d2b6554fd0c6..0525e0f6841bd 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -265,10 +265,8 @@ jobs:
         run: |
           brew install ninja cmake
           command -v sccache >/dev/null || brew install sccache
-      - name: Build and Test
-        env:
-          SCCACHE_BUCKET: sccache-bucket
-          SCCACHE_REGION: us-west-2
+      - name: Compute Projects
+        id: vars
         run: |
           git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py > /tmp/env_vars.sh
           source /tmp/env_vars.sh
@@ -279,11 +277,16 @@ jobs:
           echo "Running runtimes checks targets: ${runtimes_check_targets}"
           echo "Running runtimes checks requiring reconfiguring targets: ${runtimes_check_targets_needs_reconfig}"
 
-          if [[ "${projects_to_build}" == "" ]]; then
-            echo "No projects to build"
-            exit 0
-          fi
-
+          echo "macos-projects=${projects_to_build}" >> $GITHUB_OUTPUT
+          echo "macos-check-targets=${project_check_targets}" >> $GITHUB_OUTPUT
+      - name: Build and Test
+        if: ${{ steps.vars.outputs.macos-projects != '' }}
+        env:
+          SCCACHE_BUCKET: sccache-bucket
+          SCCACHE_REGION: us-west-2
+          PROJECTS: ${{ steps.vars.outputs.macos-projects }}
+          CHECK_TARGETS: ${{ steps.vars.outputs.macos-check-targets }}
+        run: |
           export SCCACHE_IDLE_TIMEOUT=0
           mkdir -p artifacts
           SCCACHE_LOG=info SCCACHE_ERROR_LOG=$(pwd)/artifacts/sccache.log sccache --start-server
@@ -291,7 +294,7 @@ jobs:
           xcrun cmake -G Ninja \
                 -B build \
                 -S llvm \
-                -DLLVM_ENABLE_PROJECTS="${projects_to_build}" \
+                -DLLVM_ENABLE_PROJECTS="${PROJECTS}" \
                 -DLLVM_DISABLE_ASSEMBLY_FILES=ON \
                 -DCMAKE_BUILD_TYPE=Release \
                 -DLLDB_INCLUDE_TESTS=OFF \
@@ -299,6 +302,14 @@ jobs:
                 -DCMAKE_C_COMPILER_LAUNCHER=sccache \
                 -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
 
-          ninja -C build ${project_check_targets}
+          echo "::group::Build $PROJECTS"
+          ninja -C build
+          echo "::endgroup::"
+
+          for target in ${CHECK_TARGETS}; do
+            echo "::group::Running $target"
+            ninja -C build "$target"
+            echo "::endgroup::"
+          done
 
           sccache --show-stats



More information about the llvm-commits mailing list