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

Mishal Shah via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 22:08:20 PDT 2026


================
@@ -199,52 +199,113 @@ jobs:
           path: |
             comments-Windows-AMD64
 
-  premerge-check-macos:
-    name: MacOS Premerge Checks
-    runs-on: macos-14
+  # 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' &&
-      (startswith(github.ref_name, 'release/') ||
-       startswith(github.base_ref, 'release/')) &&
-      (github.event_name != 'pull_request' || github.event.action != 'closed')
+        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 }}
     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)
+        if: github.event_name == 'pull_request'
+        uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+        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 de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
         with:
           persist-credentials: false
           fetch-depth: 2
-      - name: Setup ccache
-        uses: hendrikmuhs/ccache-action at 33522472633dbd32578e909b315f5ee43ba878ce # v1.2.22
-        with:
-          max-size: "2000M"
-      - name: Install Ninja
-        run: |
-          brew install ninja
-      - name: Build and Test
+      - name: Get Changed Files
+        env:
+          GH_TOKEN: ${{ github.token }}
+          PR_NUMBER: ${{ github.event.pull_request.number }}
+          REPO: ${{ github.repository }}
         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
+          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
           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
 
-          # -DLLVM_DISABLE_ASSEMBLY_FILES=ON is for
-          # https://github.com/llvm/llvm-project/issues/81967
-          # Disable sharding in lit so that the LIT_XFAIL environment var works.
-          cmake -G Ninja \
+  premerge-check-macos:
+    name: Build and Test macOS arm64
+    needs: premerge-compute-macos
+    runs-on: [self-hosted, macos, 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.
+    if: >-
+        github.repository_owner == 'llvm' &&
+        (github.event_name != 'pull_request' || github.event.action != 'closed') &&
+        needs.premerge-compute-macos.outputs.macos-projects != ''
+    steps:
+      - name: Checkout LLVM
+        uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+        with:
+          persist-credentials: false
+          fetch-depth: 2
+      - 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
+          PROJECTS: ${{ needs.premerge-compute-macos.outputs.macos-projects }}
+          CHECK_TARGETS: ${{ needs.premerge-compute-macos.outputs.macos-check-targets }}
+          CLANG_TOOLCHAIN_PROGRAM_TIMEOUT: 120
+        run: |
+          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 \
-                -DLLVM_ENABLE_PROJECTS="${projects_to_build}" \
+                -DLLVM_ENABLE_PROJECTS="${PROJECTS}" \
                 -DLLVM_DISABLE_ASSEMBLY_FILES=ON \
                 -DCMAKE_BUILD_TYPE=Release \
                 -DLLDB_INCLUDE_TESTS=OFF \
                 -DLLVM_ENABLE_ASSERTIONS=ON \
-                -DCMAKE_C_COMPILER_LAUNCHER=ccache \
-                -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
+                -DCMAKE_C_COMPILER_LAUNCHER=sccache \
+                -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
 
-          # The libcxx tests fail, so we are skipping the runtime targets.
-          ninja -C build ${project_check_targets}
+          ninja -C build ${CHECK_TARGETS}
+      - name: Stop sccache
+        if: always()
+        run: sccache --stop-server
----------------
shahmishal wrote:

This will get address with https://github.com/llvm/llvm-project/pull/207435/changes/91c4bcca698770cf87f29f00911a13f745a232db

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


More information about the llvm-commits mailing list