Skip to content

Commit 971a8d6

Browse files
authored
Merge pull request #172 from easy-graph/fix/ci-pytest-and-smoke
Refine CI install and test checks
2 parents 2b6bd72 + 6f0db9a commit 971a8d6

4 files changed

Lines changed: 45 additions & 13 deletions

File tree

.github/workflows/pr_code_check.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ name: PR code review
33
on:
44
workflow_dispatch:
55
pull_request:
6+
branches:
7+
- pybind11
68
push:
79
branches:
8-
- master
10+
- pybind11
911

1012
concurrency:
1113
group: ${{ github.workflow }}-${{ github.ref }}
@@ -44,6 +46,5 @@ jobs:
4446
- name: Build and install
4547
run: pip install --verbose .
4648

47-
- name: Test
48-
run: python tests/test.py
49-
49+
- name: Smoke test
50+
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"

.github/workflows/pre-commit.yaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
name: pre-commit
22

33
on:
4+
workflow_dispatch:
45
pull_request:
6+
branches:
7+
- pybind11
58
push:
9+
branches:
10+
- pybind11
611

712
jobs:
813
pre-commit:
914
runs-on: ubuntu-22.04
1015
steps:
11-
- uses: actions/checkout@v3
12-
- uses: actions/setup-python@v4
16+
- uses: actions/checkout@v4
1317
with:
14-
python-version: '3.10'
15-
- uses: pre-commit/action@v3.0.0
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-python@v5
1621
with:
17-
extra_args: "--all-files"
22+
python-version: '3.10'
23+
24+
- name: Install pre-commit
25+
run: python -m pip install pre-commit
26+
27+
- name: Run pre-commit on changed files
28+
shell: bash
29+
run: |
30+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
31+
base_ref="${{ github.event.pull_request.base.sha }}"
32+
elif [[ -n "${{ github.event.before }}" && ! "${{ github.event.before }}" =~ ^0+$ ]]; then
33+
base_ref="${{ github.event.before }}"
34+
else
35+
base_ref="$(git rev-parse HEAD~1)"
36+
fi
37+
38+
pre-commit run --show-diff-on-failure --color=always --from-ref "$base_ref" --to-ref "${{ github.sha }}"

.github/workflows/test.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
name: Test the package with pytest
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- pybind11
8+
push:
9+
branches:
10+
- pybind11
411

512
jobs:
613
pytest:
@@ -12,12 +19,12 @@ jobs:
1219
# ubuntu 22.04 has deprecated python 3.6
1320
python-version: [ "3.8", "3.9", "3.10","3.11", "3.12"]
1421
steps:
15-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
1623
with:
1724
submodules: recursive
1825

1926
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v4
27+
uses: actions/setup-python@v5
2128
with:
2229
python-version: ${{ matrix.python-version }}
2330

@@ -36,4 +43,4 @@ jobs:
3643
3744
- name: Test with pytest
3845
run: |
39-
pytest --disable-warnings --ignore=cpp_easygraph
46+
pytest easygraph --disable-warnings

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def build_extension(self, ext: CMakeExtension) -> None:
4747
cmake_args = [
4848
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}",
4949
f"-DPYTHON_EXECUTABLE={sys.executable}",
50+
f"-DPython_EXECUTABLE={sys.executable}",
51+
f"-DPython3_EXECUTABLE={sys.executable}",
52+
"-DPYBIND11_FINDPYTHON=ON",
5053
f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
5154
f"-DEASYGRAPH_ENABLE_GPU={'ON' if enable_gpu else 'OFF'}",
5255
]

0 commit comments

Comments
 (0)