Skip to content

Commit a1c2c43

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

File tree

5 files changed

+141
-428
lines changed

5 files changed

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