From 6711875b081e5f2436fe4d3b5039386a4478dbcd Mon Sep 17 00:00:00 2001 From: Haoran Du Date: Sun, 7 Jun 2026 22:46:58 +0800 Subject: [PATCH 1/2] Refine CI install and test checks --- .github/workflows/pr_code_check.yaml | 9 +++++---- .github/workflows/test.yaml | 15 +++++++++++---- setup.py | 3 +++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr_code_check.yaml b/.github/workflows/pr_code_check.yaml index 285e5228..9ed87684 100644 --- a/.github/workflows/pr_code_check.yaml +++ b/.github/workflows/pr_code_check.yaml @@ -3,9 +3,11 @@ name: PR code review on: workflow_dispatch: pull_request: + branches: + - pybind11 push: branches: - - master + - pybind11 concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -44,6 +46,5 @@ jobs: - name: Build and install run: pip install --verbose . - - name: Test - run: python tests/test.py - + - name: Smoke test + run: python -c "import os, tempfile; os.chdir(tempfile.gettempdir()); import easygraph as eg; G = eg.Graph(); G.add_edge(1, 2); assert G.number_of_nodes() == 2; assert G.number_of_edges() == 1" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7b3ab9b9..33ff4187 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,6 +1,13 @@ name: Test the package with pytest -on: [push, pull_request, workflow_dispatch] +on: + workflow_dispatch: + pull_request: + branches: + - pybind11 + push: + branches: + - pybind11 jobs: pytest: @@ -12,12 +19,12 @@ jobs: # ubuntu 22.04 has deprecated python 3.6 python-version: [ "3.8", "3.9", "3.10","3.11", "3.12"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -36,4 +43,4 @@ jobs: - name: Test with pytest run: | - pytest --disable-warnings --ignore=cpp_easygraph + pytest easygraph --disable-warnings diff --git a/setup.py b/setup.py index f4262b0f..9498e69b 100644 --- a/setup.py +++ b/setup.py @@ -47,6 +47,9 @@ def build_extension(self, ext: CMakeExtension) -> None: cmake_args = [ f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}", f"-DPYTHON_EXECUTABLE={sys.executable}", + f"-DPython_EXECUTABLE={sys.executable}", + f"-DPython3_EXECUTABLE={sys.executable}", + "-DPYBIND11_FINDPYTHON=ON", f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm f"-DEASYGRAPH_ENABLE_GPU={'ON' if enable_gpu else 'OFF'}", ] From 6f0db9a69ce41a0d305aac13ae49bcf318651fad Mon Sep 17 00:00:00 2001 From: Haoran Du Date: Sun, 7 Jun 2026 22:53:14 +0800 Subject: [PATCH 2/2] Run pre-commit on changed files in CI --- .github/workflows/pre-commit.yaml | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index e6cad41c..dfffd269 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -1,17 +1,38 @@ name: pre-commit on: + workflow_dispatch: pull_request: + branches: + - pybind11 push: + branches: + - pybind11 jobs: pre-commit: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 with: - python-version: '3.10' - - uses: pre-commit/action@v3.0.0 + fetch-depth: 0 + + - uses: actions/setup-python@v5 with: - extra_args: "--all-files" \ No newline at end of file + python-version: '3.10' + + - name: Install pre-commit + run: python -m pip install pre-commit + + - name: Run pre-commit on changed files + shell: bash + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + base_ref="${{ github.event.pull_request.base.sha }}" + elif [[ -n "${{ github.event.before }}" && ! "${{ github.event.before }}" =~ ^0+$ ]]; then + base_ref="${{ github.event.before }}" + else + base_ref="$(git rev-parse HEAD~1)" + fi + + pre-commit run --show-diff-on-failure --color=always --from-ref "$base_ref" --to-ref "${{ github.sha }}"