Skip to content

Commit bb4438b

Browse files
Split in tests and wheels action, use cibuildwheel
1 parent 3749a87 commit bb4438b

File tree

3 files changed

+172
-48
lines changed

3 files changed

+172
-48
lines changed

.github/workflows/tests.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
env:
11+
GEANT4_GIT_TAG: v10.7.1
12+
GEANT4_SOURCE_DIR: geant4_source
13+
GEANT4_BUILD_DIR: geant4_build
14+
GEANT4_INSTALL_DIR: geant4_install
15+
16+
17+
jobs:
18+
run_tests:
19+
name: Tests on ${{ matrix.os }}/${{ matrix.python-version }}
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [windows-latest, macos-latest, ubuntu-latest]
25+
python-version: ['3.6', '3.9']
26+
exclude:
27+
- os: macos-latest
28+
python-version: '3.6'
29+
- os: windows-latest
30+
python-version: '3.6'
31+
32+
steps:
33+
- name: Cache Geant4 install
34+
uses: actions/cache@v2
35+
id: g4cache
36+
with:
37+
path: ${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}
38+
key: ${{ env.GEANT4_GIT_TAG }}v2
39+
40+
- uses: actions/checkout@v2
41+
if: steps.g4cache.outputs.cache-hit != 'true'
42+
with:
43+
repository: Geant4/geant4
44+
ref: ${{ env.GEANT4_GIT_TAG }}
45+
path: ${{ env.GEANT4_SOURCE_DIR }}
46+
47+
- uses: lukka/get-cmake@latest
48+
if: steps.g4cache.outputs.cache-hit != 'true'
49+
50+
- name: CMake configure Geant4 Unix
51+
if: steps.g4cache.outputs.cache-hit != 'true' && runner.os != 'Windows'
52+
run: >
53+
cmake -E env CXXFLAGS="-fPIC"
54+
cmake -E env CFLAGS="-fPIC"
55+
cmake
56+
-GNinja
57+
-DBUILD_STATIC_LIBS=ON
58+
-DBUILD_SHARED_LIBS=OFF
59+
-DGEANT4_INSTALL_EXAMPLES=OFF
60+
-DGEANT4_USE_SYSTEM_EXPAT=OFF
61+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}"
62+
-S "${{ github.workspace }}/${{ env.GEANT4_SOURCE_DIR }}"
63+
-B "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}"
64+
65+
- name: CMake configure Geant4 Windows
66+
if: steps.g4cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
67+
run: >
68+
cmake
69+
-DBUILD_STATIC_LIBS=ON
70+
-DBUILD_SHARED_LIBS=OFF
71+
-DGEANT4_INSTALL_EXAMPLES=OFF
72+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}"
73+
-S "${{ github.workspace }}/${{ env.GEANT4_SOURCE_DIR }}"
74+
-B "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}"
75+
76+
- name: CMake build Geant4
77+
if: steps.g4cache.outputs.cache-hit != 'true'
78+
run: cmake --build "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}" --config Release
79+
80+
- name: CMake install Geant4
81+
if: steps.g4cache.outputs.cache-hit != 'true'
82+
run: >
83+
cmake
84+
--build "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}"
85+
--config Release
86+
--target install
87+
88+
- name: Setup environment variables
89+
shell: bash
90+
run: |
91+
echo "${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}/bin" >> $GITHUB_PATH
92+
echo "HOME=${{ github.workspace }}" >> $GITHUB_ENV
93+
94+
- uses: actions/checkout@v2
95+
with:
96+
submodules: true
97+
path: ${{ github.event.repository.name }}
98+
99+
- uses: actions/setup-python@v2
100+
with:
101+
python-version: ${{ matrix.python-version }}
102+
103+
- name: Add Python requirements
104+
run: python -m pip install --upgrade setuptools psutil
105+
106+
- name: Install ${{ github.event.repository.name }}
107+
run: python -m pip install "${{ github.workspace }}/${{ github.event.repository.name }}"
108+
109+
- name: Cache Geant4 datasets
110+
uses: actions/cache@v2
111+
with:
112+
key: ${{ env.GEANT4_GIT_TAG }}_datasets
113+
path: ${{ github.workspace }}/.geant4_pybind
114+
115+
- name: Run B1 (sanity) test
116+
run: python ${{ github.event.repository.name }}/tests/test_B1.py
117+
118+
- name: Run example tests
119+
if: runner.os == 'Linux'
120+
run: python ${{ github.event.repository.name }}/tests/test_examples.py

.github/workflows/wheels.yml

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: Wheels
22

33
on:
4-
workflow_dispatch:
5-
pull_request:
6-
push:
7-
branches:
8-
- main
94
release:
105
types:
116
- published
127

8+
env:
9+
GEANT4_GIT_TAG: v10.7.1
10+
GEANT4_SOURCE_DIR: geant4_source
11+
GEANT4_BUILD_DIR: geant4_build
12+
GEANT4_INSTALL_DIR: geant4_install
13+
1314
jobs:
1415

1516
build_sdist:
@@ -32,21 +33,18 @@ jobs:
3233

3334

3435
build_wheels:
35-
name: Wheels for ${{ matrix.os }}/${{ matrix.python-version }}
36+
name: Wheels for ${{ matrix.os }}
3637
runs-on: ${{ matrix.os }}
3738
strategy:
3839
fail-fast: false
3940
matrix:
40-
os: [ubuntu-latest, windows-latest, macos-latest]
41-
python-version: ["3.6", "3.7", "3.8", "3.9"]
42-
43-
env:
44-
GEANT4_GIT_TAG: v10.7.1
45-
GEANT4_SOURCE_DIR: geant4_source
46-
GEANT4_BUILD_DIR: geant4_build
47-
GEANT4_INSTALL_DIR: geant4_install
41+
os: [windows-latest, macos-latest]
4842

4943
steps:
44+
- uses: actions/checkout@v2
45+
with:
46+
submodules: true
47+
5048
- name: Cache Geant4 install
5149
uses: actions/cache@v2
5250
id: g4cache
@@ -70,6 +68,7 @@ jobs:
7068
cmake -E env CXXFLAGS="-fPIC"
7169
cmake -E env CFLAGS="-fPIC"
7270
cmake
71+
-GNinja
7372
-DBUILD_STATIC_LIBS=ON
7473
-DBUILD_SHARED_LIBS=OFF
7574
-DGEANT4_INSTALL_EXAMPLES=OFF
@@ -101,56 +100,61 @@ jobs:
101100
--config Release
102101
--target install
103102
104-
- name: Setup environment variables
103+
- name: Add Geant4 to the PATH
105104
shell: bash
106-
run: |
107-
echo "${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}/bin" >> $GITHUB_PATH
108-
echo "HOME=${{ github.workspace }}" >> $GITHUB_ENV
105+
run: echo "${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}/bin" >> $GITHUB_PATH
109106

110-
- uses: actions/checkout@v2
111-
with:
112-
submodules: true
113-
path: ${{ github.event.repository.name }}
107+
- uses: joerick/cibuildwheel@v1.11.0
108+
env:
109+
CIBW_BUILD: cp3*
110+
CIBW_ARCHS: native
114111

115-
- uses: actions/setup-python@v2
112+
- uses: actions/upload-artifact@v2
116113
with:
117-
python-version: ${{ matrix.python-version }}
118-
119-
- name: Add Python requirements
120-
run: python -m pip install --upgrade wheel setuptools build psutil
114+
path: wheelhouse/*.whl
121115

122-
- name: Build wheel
123-
run: python -m build ${{ github.event.repository.name }}
124116

125-
- name: Install wheel
126-
run: >
127-
python -m pip install --no-index
128-
--find-links=${{ github.event.repository.name }}/dist
129-
geant4_pybind
117+
build_wheels_linux:
118+
name: Wheels for Linux
119+
runs-on: ubuntu-latest
130120

131-
- name: Cache Geant4 datasets
132-
uses: actions/cache@v2
121+
steps:
122+
- uses: actions/checkout@v2
133123
with:
134-
key: ${{ env.GEANT4_GIT_TAG }}-datasets
135-
path: ${{ github.workspace }}/.geant4_pybind
136-
137-
- name: Run B1 (sanity) test
138-
run: python ${{ github.event.repository.name }}/tests/test_B1.py
124+
submodules: true
139125

140-
- name: Run example tests
141-
if: runner.os == 'Linux'
142-
run: python ${{ github.event.repository.name }}/tests/test_examples.py
126+
- uses: joerick/cibuildwheel@v1.11.0
127+
env:
128+
CIBW_ENVIRONMENT_LINUX: "CXXFLAGS='-fPIC' CFLAGS='-fPIC'"
129+
CIBW_BEFORE_ALL_LINUX: >
130+
python -m pip install cmake && \
131+
git clone -b ${{ env.GEANT4_GIT_TAG }} --depth 1 \
132+
https://github.com/Geant4/geant4 \
133+
"{package}/${{ env.GEANT4_SOURCE_DIR }}" && \
134+
mkdir "{package}/${{ env.GEANT4_BUILD_DIR }}" && \
135+
cd "{package}/${{ env.GEANT4_BUILD_DIR }}" && \
136+
cmake \
137+
-DCMAKE_BUILD_TYPE=Release \
138+
-DBUILD_STATIC_LIBS=ON \
139+
-DBUILD_SHARED_LIBS=OFF \
140+
-DGEANT4_INSTALL_EXAMPLES=OFF \
141+
-DGEANT4_USE_SYSTEM_EXPAT=OFF \
142+
"{package}/${{ env.GEANT4_SOURCE_DIR }}" && \
143+
make -j8 && \
144+
make install
145+
146+
CIBW_BUILD: cp3*
147+
CIBW_ARCHS: native
143148

144149
- uses: actions/upload-artifact@v2
145150
with:
146-
path: ${{ github.event.repository.name }}/dist/*.whl
151+
path: wheelhouse/*.whl
147152

148153

149154
upload_all:
150155
name: Upload if release
151-
needs: [build_wheels, build_sdist]
156+
needs: [build_wheels, build_wheels_linux, build_sdist]
152157
runs-on: ubuntu-latest
153-
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
154158

155159
steps:
156160
- uses: actions/setup-python@v2

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def build_extension(self, ext):
7575

7676
setup(
7777
name="geant4_pybind",
78-
version="0.1.0b0",
78+
version="0.1.0b1",
7979
author="Benjamin H.",
8080
author_email="haarigerharald@gmx.at",
8181
description="Alternative python bindings for Geant4 via pybind11",

0 commit comments

Comments
 (0)