Skip to content

Commit e474292

Browse files
committed
[ci] Make building and testing cppyy into a reusable action
1 parent de1e51b commit e474292

File tree

5 files changed

+131
-428
lines changed

5 files changed

+131
-428
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: 'Builds and test cppyy'
2+
description: 'This action builds and tests cppyy for native platforms'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Build and Install cppyy-backend
8+
if: ${{ matrix.cppyy == 'On' && runner.os != 'Windows' }}
9+
run: |
10+
# Download cppyy-backend
11+
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git
12+
cd cppyy-backend
13+
mkdir -p $CPPINTEROP_DIR/lib build && cd build
14+
# Install CppInterOp
15+
(cd $CPPINTEROP_BUILD_DIR && cmake --build . --target install --parallel ${{ env.ncpus }} )
16+
# Build and Install cppyy-backend
17+
cmake -DCppInterOp_DIR=$CPPINTEROP_DIR ..
18+
cmake --build . --parallel ${{ env.ncpus }}
19+
cp libcppyy-backend.so $CPPINTEROP_DIR/lib/
20+
cd ..
21+
22+
- name: Install CPyCppyy
23+
if: ${{ matrix.cppyy == 'On' && runner.os != 'Windows' }}
24+
run: |
25+
python3 -m venv .venv
26+
source .venv/bin/activate
27+
# Install CPyCppyy
28+
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git
29+
mkdir CPyCppyy/build
30+
cd CPyCppyy/build
31+
cmake ..
32+
cmake --build . --parallel ${{ env.ncpus }}
33+
#
34+
export CPYCPPYY_DIR=$PWD
35+
cd ../..
36+
# We need CPYCPPYY_DIR later
37+
echo "CPYCPPYY_DIR=$CPYCPPYY_DIR" >> $GITHUB_ENV
38+
39+
- name: Install cppyy
40+
if: ${{ matrix.cppyy == 'On' && runner.os != 'Windows' }}
41+
run: |
42+
# source virtual environment
43+
source .venv/bin/activate
44+
# Install cppyy
45+
git clone --depth=1 https://github.com/compiler-research/cppyy.git
46+
cd cppyy
47+
python -m pip install --upgrade . --no-deps
48+
cd ..
49+
50+
- name: Run cppyy
51+
if: ${{ matrix.cppyy == 'On' && runner.os != 'Windows' }}
52+
run: |
53+
# Run cppyy
54+
source .venv/bin/activate
55+
export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR
56+
python -c "import cppyy"
57+
# We need PYTHONPATH later
58+
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
59+
60+
- name: Run the tests
61+
if: ${{ matrix.cppyy == 'On' && runner.os != 'Windows' }}
62+
run: |
63+
# Run the tests
64+
source .venv/bin/activate
65+
cd cppyy/test
66+
echo ::group::Prepare For Testing
67+
make all
68+
python -m pip install --upgrade pip
69+
python -m pip install pytest
70+
python -m pip install pytest-xdist
71+
python -m pip install numba
72+
echo ::endgroup::
73+
echo ::group::Run complete test suite
74+
set -o pipefail
75+
python -m pytest -sv -ra | tee complete_testrun.log 2>&1
76+
set +o pipefail
77+
echo ::group::Crashing Test Logs
78+
# See if we don't have a crash that went away
79+
# Comment out all xfails but the ones that have a run=False condition.
80+
find . -name "*.py" -exec sed -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \;
81+
python -m pytest -n 1 -m "xfail" --runxfail -sv -ra --max-worker-restart 512 | tee test_crashed.log 2>&1 || true
82+
git checkout .
83+
echo ::endgroup::
84+
echo ::group::XFAIL Test Logs
85+
# Rewrite all xfails that have a run clause to skipif. This way we will
86+
# avoid conditionally crashing xfails
87+
find . -name "*.py" -exec sed -i -E 's/(^ *)@mark.xfail\(run=(.*)/\1@mark.skipif(condition=not \2/g' {} \;
88+
# See if we don't have an xfail that went away
89+
python -m pytest --runxfail -sv -ra | tee test_xfailed.log 2>&1 || true
90+
git checkout .
91+
echo ::endgroup::
92+
echo ::group::Passing Test Logs
93+
94+
# Run the rest of the non-crashing tests.
95+
declare -i RETCODE=0
96+
97+
set -o pipefail
98+
99+
if [[ "${os}" != "macos"* ]]; then
100+
echo "Running valgrind on passing tests"
101+
CLANG_VERSION="${{ matrix.clang-runtime }}"
102+
103+
if [[ "${{ matrix.cling }}" == "On" ]]; then
104+
CLANG_INTERPRETER="cling"
105+
else
106+
CLANG_INTERPRETER="clang"
107+
fi
108+
109+
if [[ "${{ matrix.os }}" == *"arm"* ]]; then
110+
SUPPRESSION_FILE="../etc/${CLANG_INTERPRETER}${CLANG_VERSION}-valgrind_arm.supp"
111+
else
112+
SUPPRESSION_FILE="../etc/${CLANG_INTERPRETER}${CLANG_VERSION}-valgrind.supp"
113+
fi
114+
fi
115+
export RETCODE=+$?
116+
echo ::endgroup::
117+
118+
RETCODE=+$?
119+
120+
echo "Complete Test Suite Summary: \n"
121+
tail -n1 complete_testrun.log
122+
echo "Crashing Summary: \n"
123+
tail -n1 test_crashed.log
124+
echo "XFAIL Summary:"
125+
tail -n1 test_xfailed.log
126+
echo "Return Code: ${RETCODE}"
127+
exit $RETCODE

.github/workflows/MacOS-arm.yml

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -390,107 +390,7 @@ jobs:
390390

391391
- uses: ./.github/actions/Build_and_Test_CppInterOp
392392

393-
- name: Build and Install cppyy-backend
394-
if: ${{ matrix.cppyy == 'On' }}
395-
run: |
396-
# Download cppyy-backend
397-
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git
398-
cd cppyy-backend
399-
mkdir -p $CPPINTEROP_DIR/lib build && cd build
400-
# Install CppInterOp
401-
(cd $CPPINTEROP_BUILD_DIR && cmake --build . --target install --parallel ${{ env.ncpus }} )
402-
# Build and Install cppyy-backend
403-
cmake -DCppInterOp_DIR=$CPPINTEROP_DIR ..
404-
cmake --build . --parallel ${{ env.ncpus }}
405-
cp libcppyy-backend.dylib $CPPINTEROP_DIR/lib/
406-
cd ..
407-
408-
- name: Install CPyCppyy
409-
if: ${{ matrix.cppyy == 'On' }}
410-
run: |
411-
python3 -m venv .venv
412-
source .venv/bin/activate
413-
# Install CPyCppyy
414-
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git
415-
mkdir CPyCppyy/build
416-
cd CPyCppyy/build
417-
cmake ..
418-
cmake --build . --parallel ${{ env.ncpus }}
419-
#
420-
export CPYCPPYY_DIR=$PWD
421-
cd ../..
422-
# We need CPYCPPYY_DIR later
423-
echo "CPYCPPYY_DIR=$CPYCPPYY_DIR" >> $GITHUB_ENV
424-
- name: Install cppyy
425-
if: ${{ matrix.cppyy == 'On' }}
426-
run: |
427-
# source virtual environment
428-
source .venv/bin/activate
429-
# Install cppyy
430-
git clone --depth=1 https://github.com/compiler-research/cppyy.git
431-
cd cppyy
432-
python -m pip install --upgrade . --no-deps
433-
cd ..
434-
- name: Run cppyy
435-
if: ${{ matrix.cppyy == 'On' }}
436-
run: |
437-
# Run cppyy
438-
source .venv/bin/activate
439-
export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR
440-
python -c "import cppyy"
441-
# We need PYTHONPATH later
442-
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
443-
- name: Run the tests
444-
if: ${{ matrix.cppyy == 'On' }}
445-
run: |
446-
# Run the tests
447-
source .venv/bin/activate
448-
cd cppyy/test
449-
echo ::group::Prepare For Testing
450-
make all
451-
python -m pip install --upgrade pip
452-
python -m pip install pytest
453-
python -m pip install pytest-xdist
454-
python -m pip install numba
455-
echo ::endgroup::
456-
echo ::group::Run complete test suite
457-
set -o pipefail
458-
python -m pytest -sv -ra | tee complete_testrun.log 2>&1
459-
set +o pipefail
460-
echo ::group::Crashing Test Logs
461-
# See if we don't have a crash that went away
462-
# Comment out all xfails but the ones that have a run=False condition.
463-
find . -name "*.py" -exec gsed -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \;
464-
python -m pytest -n 1 -m "xfail" --runxfail -sv -ra --max-worker-restart 512 | tee test_crashed.log 2>&1 || true
465-
git checkout .
466-
echo ::endgroup::
467-
echo ::group::XFAIL Test Logs
468-
# Rewrite all xfails that have a run clause to skipif. This way we will
469-
# avoid conditionally crashing xfails
470-
find . -name "*.py" -exec gsed -i -E 's/(^ *)@mark.xfail\(run=(.*)/\1@mark.skipif(condition=not \2/g' {} \;
471-
# See if we don't have an xfail that went away
472-
python -m pytest --runxfail -sv -ra | tee test_xfailed.log 2>&1 || true
473-
git checkout .
474-
echo ::endgroup::
475-
echo ::group::Passing Test Logs
476-
477-
# Run the rest of the non-crashing tests.
478-
declare -i RETCODE=0
479-
480-
set -o pipefail
481-
export RETCODE=+$?
482-
echo ::endgroup::
483-
484-
RETCODE=+$?
485-
486-
echo "Complete Test Suite Summary: \n"
487-
tail -n1 complete_testrun.log
488-
echo "Crashing Summary: \n"
489-
tail -n1 test_crashed.log
490-
echo "XFAIL Summary:"
491-
tail -n1 test_xfailed.log
492-
echo "Return Code: ${RETCODE}"
493-
exit $RETCODE
393+
- uses: ./.github/actions/Build_and_Test_cppyy
494394

495395
- name: Show debug info
496396
if: ${{ failure() }}

.github/workflows/MacOS.yml

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -359,107 +359,7 @@ jobs:
359359

360360
- uses: ./.github/actions/Build_and_Test_CppInterOp
361361

362-
- name: Build and Install cppyy-backend
363-
if: ${{ matrix.cppyy == 'On' }}
364-
run: |
365-
# Download cppyy-backend
366-
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git
367-
cd cppyy-backend
368-
mkdir -p $CPPINTEROP_DIR/lib build && cd build
369-
# Install CppInterOp
370-
(cd $CPPINTEROP_BUILD_DIR && cmake --build . --target install --parallel ${{ env.ncpus }} )
371-
# Build and Install cppyy-backend
372-
cmake -DCppInterOp_DIR=$CPPINTEROP_DIR ..
373-
cmake --build . --parallel ${{ env.ncpus }}
374-
cp libcppyy-backend.dylib $CPPINTEROP_DIR/lib/
375-
cd ..
376-
377-
- name: Install CPyCppyy
378-
if: ${{ matrix.cppyy == 'On' }}
379-
run: |
380-
python3 -m venv .venv
381-
source .venv/bin/activate
382-
# Install CPyCppyy
383-
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git
384-
mkdir CPyCppyy/build
385-
cd CPyCppyy/build
386-
cmake ..
387-
cmake --build . --parallel ${{ env.ncpus }}
388-
#
389-
export CPYCPPYY_DIR=$PWD
390-
cd ../..
391-
# We need CPYCPPYY_DIR later
392-
echo "CPYCPPYY_DIR=$CPYCPPYY_DIR" >> $GITHUB_ENV
393-
- name: Install cppyy
394-
if: ${{ matrix.cppyy == 'On' }}
395-
run: |
396-
# source virtual environment
397-
source .venv/bin/activate
398-
# Install cppyy
399-
git clone --depth=1 https://github.com/compiler-research/cppyy.git
400-
cd cppyy
401-
python -m pip install --upgrade . --no-deps
402-
cd ..
403-
- name: Run cppyy
404-
if: ${{ matrix.cppyy == 'On' }}
405-
run: |
406-
# Run cppyy
407-
source .venv/bin/activate
408-
export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR
409-
python -c "import cppyy"
410-
# We need PYTHONPATH later
411-
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
412-
- name: Run the tests
413-
if: ${{ matrix.cppyy == 'On' }}
414-
run: |
415-
# Run the tests
416-
source .venv/bin/activate
417-
cd cppyy/test
418-
echo ::group::Prepare For Testing
419-
make all
420-
python -m pip install --upgrade pip
421-
python -m pip install pytest
422-
python -m pip install pytest-xdist
423-
python -m pip install numba
424-
echo ::endgroup::
425-
echo ::group::Run complete test suite
426-
set -o pipefail
427-
python -m pytest -sv -ra | tee complete_testrun.log 2>&1
428-
set +o pipefail
429-
echo ::group::Crashing Test Logs
430-
# See if we don't have a crash that went away
431-
# Comment out all xfails but the ones that have a run=False condition.
432-
find . -name "*.py" -exec gsed -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \;
433-
python -m pytest -n 1 -m "xfail" --runxfail -sv -ra --max-worker-restart 512 | tee test_crashed.log 2>&1 || true
434-
git checkout .
435-
echo ::endgroup::
436-
echo ::group::XFAIL Test Logs
437-
# Rewrite all xfails that have a run clause to skipif. This way we will
438-
# avoid conditionally crashing xfails
439-
find . -name "*.py" -exec gsed -i -E 's/(^ *)@mark.xfail\(run=(.*)/\1@mark.skipif(condition=not \2/g' {} \;
440-
# See if we don't have an xfail that went away
441-
python -m pytest --runxfail -sv -ra | tee test_xfailed.log 2>&1 || true
442-
git checkout .
443-
echo ::endgroup::
444-
echo ::group::Passing Test Logs
445-
446-
# Run the rest of the non-crashing tests.
447-
declare -i RETCODE=0
448-
449-
set -o pipefail
450-
export RETCODE=+$?
451-
echo ::endgroup::
452-
453-
RETCODE=+$?
454-
455-
echo "Complete Test Suite Summary: \n"
456-
tail -n1 complete_testrun.log
457-
echo "Crashing Summary: \n"
458-
tail -n1 test_crashed.log
459-
echo "XFAIL Summary:"
460-
tail -n1 test_xfailed.log
461-
echo "Return Code: ${RETCODE}"
462-
exit $RETCODE
362+
- uses: ./.github/actions/Build_and_Test_cppyy
463363

464364
- name: Show debug info
465365
if: ${{ failure() }}

0 commit comments

Comments
 (0)