-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (76 loc) · 2.96 KB
/
ci-python.yml
File metadata and controls
90 lines (76 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Python API Tests 🐍
on:
push:
jobs:
python-tests:
runs-on: ubuntu-latest
env:
PINEAPPL_VERSION: 1.4.0-alpha1
APFELXX_BRANCH: QED
steps:
- uses: actions/checkout@v4
# ---- Python environment ----
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
# ---- System C++ build tools ----
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake pkg-config libyaml-cpp-dev ninja-build
# ---- Cache local installs (.local) ----
- name: Cache PineAPPL and APFEL++
id: cache-local
uses: actions/cache@v4
with:
path: ~/.local
key: >
${{ runner.os }}-local-
pineappl-${{ env.PINEAPPL_VERSION }}-
apfelxx-${{ env.APFELXX_BRANCH }}-
${{ hashFiles('.github/workflows/ci-python.yml') }}
# ---- Install PineAPPL C API (if not cached) ----
- name: Install PineAPPL C API
if: steps.cache-local.outputs.cache-hit != 'true'
run: |
curl --proto '=https' --tlsv1.2 -sSf https://nnpdf.github.io/pineappl/install-capi.sh \
| sh -s -- --prefix "$HOME/.local" --version $PINEAPPL_VERSION
# ---- Build APFEL++ from source (if not cached) ----
- name: Build and install APFEL++
if: steps.cache-local.outputs.cache-hit != 'true'
run: |
git clone --branch $APFELXX_BRANCH https://github.com/vbertone/apfelxx.git /tmp/apfelxx
cd /tmp/apfelxx
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local
make -j$(nproc)
make install
# ---- Export C++ library paths ----
- name: Export local paths
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
# ---- Python dependencies ----
- name: Install Python dependencies
run: |
pip install meson ninja pybind11 pineappl numpy pytest
# ---- Build pineapfel with Meson (produces the Python extension .so) ----
- name: Build pineapfel
run: |
meson setup builddir
ninja -C builddir
# ---- Expose the Python package for in-tree testing ----
- name: Set up pineapfel Python package
run: |
SO_FILE=$(ls builddir/_pineapfel*.so 2>/dev/null | head -1)
if [ -z "$SO_FILE" ]; then
echo "ERROR: _pineapfel*.so not found in builddir/" && exit 1
fi
ln -sf "$(pwd)/$SO_FILE" pineapfel_pyapi/pineapfel/
echo "PYTHONPATH=$(pwd)/pineapfel_pyapi" >> $GITHUB_ENV
# ---- Run the Python test suite ----
- name: Run Python tests
run: |
python3 -m pytest pineapfel_pyapi/tests/ -v --tb=short