[llvm] [GitHub] Add basic CI for libclang Python binding unit tests (PR #76784)

Craig Hesling via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 19:54:46 PST 2024


https://github.com/linux4life798 updated https://github.com/llvm/llvm-project/pull/76784

>From 1e4fb1515c389c53273d024b6e0585897b70888c Mon Sep 17 00:00:00 2001
From: Craig Hesling <craig at hesling.com>
Date: Fri, 29 Dec 2023 23:03:41 -0500
Subject: [PATCH 1/2] [GitHub] Add CI for libclang Python unit tests

* Run on all pull requests and direct pushes.
* This makes use of the existing llvm-project-tests.yml
  recipe, which will preload ccache from previous runs.
* Building libclang currently takes about 9mins when
  ccache is warm and about an 1hr 20mins if it is cold
  using the standard GitHub ubuntu runner.
* This could be broken into the following two steps:
  - # Build libclang dependency.
    ninja -C build libclang
  - # Run Python unit tests.
    ninja -C build check-clang-python

Issue #76601.
---
 .github/workflows/libclang-python-tests.yml | 42 +++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 .github/workflows/libclang-python-tests.yml

diff --git a/.github/workflows/libclang-python-tests.yml b/.github/workflows/libclang-python-tests.yml
new file mode 100644
index 00000000000000..7b6541c054e26b
--- /dev/null
+++ b/.github/workflows/libclang-python-tests.yml
@@ -0,0 +1,42 @@
+name: Libclang Python Binding Tests
+
+permissions:
+  contents: read
+
+on:
+  workflow_dispatch:
+  push:
+    paths:
+      - 'clang/bindings/python/**'
+      - 'clang/tools/libclang/**'
+      - 'clang/CMakeList.txt'
+      - 'cmake/**'
+      - '.github/workflows/libclang-python-tests.yml'
+      - '.github/workflows/llvm-project-tests.yml'
+  pull_request:
+    paths:
+      - 'clang/bindings/python/**'
+      - 'clang/tools/libclang/**'
+      - 'clang/CMakeList.txt'
+      - 'cmake/**'
+      - '.github/workflows/libclang-python-tests.yml'
+      - '.github/workflows/llvm-project-tests.yml'
+
+concurrency:
+  # Skip intermediate builds: always.
+  # Cancel intermediate builds: only if it is a pull request build.
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
+
+jobs:
+  check-clang-python:
+    if: github.repository_owner == 'llvm'
+    # Build libclang and then run the libclang Python binding's unit tests.
+    name: Build and run Python unit tests
+    uses: ./.github/workflows/llvm-project-tests.yml
+    with:
+      build_target: check-clang-python
+      projects: clang
+      # There is an issue running on "windows-2019".
+      # See https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.
+      os_list: '["ubuntu-latest"]'

>From 2bc9282e313e7f2e1b911f1310d7a74fac11b24e Mon Sep 17 00:00:00 2001
From: Craig Hesling <craig at hesling.com>
Date: Tue, 2 Jan 2024 19:14:25 -0500
Subject: [PATCH 2/2] [GitHub] Remove libclang Python actions fork protection

Remove the check that only allows the action to run if
it is running from the parent llvm organization repo.
This is meant to protect contributors that fork the
project from automatically launching actions with their
account quota.

This shouldn't be necessary, since GitHub Actions are
disabled automatically on forks. The following docs says
"When a public repository is forked, scheduled workflows
are disabled by default.".

https://docs.github.com/en/actions/using-workflows/disabling-and-enabling-a-workflow

Issue #76601.
---
 .github/workflows/libclang-python-tests.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.github/workflows/libclang-python-tests.yml b/.github/workflows/libclang-python-tests.yml
index 7b6541c054e26b..f2a47be4fd0623 100644
--- a/.github/workflows/libclang-python-tests.yml
+++ b/.github/workflows/libclang-python-tests.yml
@@ -30,7 +30,6 @@ concurrency:
 
 jobs:
   check-clang-python:
-    if: github.repository_owner == 'llvm'
     # Build libclang and then run the libclang Python binding's unit tests.
     name: Build and run Python unit tests
     uses: ./.github/workflows/llvm-project-tests.yml



More information about the llvm-commits mailing list