Main #252
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
release: | |
types: [published] | |
schedule: | |
- cron: '30 20 * * *' # Warning: Timezone dep - 20:00 is 1:00 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: ubu22-gcc12-clang-repl-17 | |
os: ubuntu-22.04 | |
compiler: gcc-12 | |
clang-runtime: '17' | |
cling: Off | |
cppyy: Off | |
extra_cmake_options: '-DLLVM_USE_LINKER=lld' | |
- name: ubu22-gcc12-clang-repl-17-cppyy | |
os: ubuntu-22.04 | |
compiler: gcc-12 | |
clang-runtime: '17' | |
cling: Off | |
cppyy: On | |
extra_cmake_options: '-DLLVM_USE_LINKER=lld' | |
- name: ubu22-gcc9-clang-repl-16 | |
os: ubuntu-22.04 | |
compiler: gcc-9 | |
clang-runtime: '16' | |
cling: Off | |
cppyy: Off | |
coverage: true | |
extra_cmake_options: '-DLLVM_USE_LINKER=lld' | |
- name: ubu22-gcc9-clang-repl-16-cppyy | |
os: ubuntu-22.04 | |
compiler: gcc-9 | |
clang-runtime: '16' | |
cling: Off | |
cppyy: On | |
coverage: true | |
extra_cmake_options: '-DLLVM_USE_LINKER=lld' | |
- name: ubu22-gcc9-clang13-cling | |
os: ubuntu-22.04 | |
compiler: gcc-9 | |
clang-runtime: '13' | |
cling: On | |
cling-version: '1.0' | |
cppyy: Off | |
extra_cmake_options: '-DLLVM_USE_LINKER=lld' | |
- name: ubu22-gcc9-clang13-cling-cppyy | |
os: ubuntu-22.04 | |
compiler: gcc-9 | |
clang-runtime: '13' | |
cling: On | |
cling-version: '1.0' | |
cppyy: On | |
extra_cmake_options: '-DLLVM_USE_LINKER=lld' | |
- name: osx13-x86-clang-clang-repl-17 | |
os: macos-13 | |
compiler: clang | |
clang-runtime: '17' | |
cling: Off | |
cppyy: Off | |
- name: osx13-x86-clang-clang-repl-17-cppyy | |
os: macos-13 | |
compiler: clang | |
clang-runtime: '17' | |
cling: Off | |
cppyy: On | |
- name: osx13-x86-clang-clang-repl-16 | |
os: macos-13 | |
compiler: clang | |
clang-runtime: '16' | |
cling: Off | |
cppyy: Off | |
- name: osx13-x86-clang-clang-repl-16-cppyy | |
os: macos-13 | |
compiler: clang | |
clang-runtime: '16' | |
cling: Off | |
cppyy: On | |
- name: osx13-x86-clang-clang13-cling | |
os: macos-13 | |
compiler: clang | |
clang-runtime: '13' | |
cling: On | |
cling-version: '1.0' | |
cppyy: Off | |
- name: osx13-x86-clang-clang13-cling-cppyy | |
os: macos-13 | |
compiler: clang | |
clang-runtime: '13' | |
cling: On | |
cling-version: '1.0' | |
cppyy: On | |
#Block commented out until free tier for m1 | |
#exists (expected sometime 2024) and key for os | |
#can be replaced | |
#- name: osx13-arm64-clang-clang-repl-17 | |
# os: macos-13-arm64 | |
# compiler: clang | |
# clang-runtime: '17' | |
# cling: Off | |
# cppyy: Off | |
# | |
#- name: osx13-arm64-clang-clang-repl-17-cppyy | |
# os: macos-13-arm64 | |
# compiler: clang | |
# clang-runtime: '17' | |
# cling: Off | |
# cppyy: On | |
# | |
#- name: osx13-arm64-clang-clang-repl-16 | |
# os: macos-13-arm64 | |
# compiler: clang | |
# clang-runtime: '16' | |
# cling: Off | |
# cppyy: Off | |
# | |
#- name: osx13-arm64-clang-clang-repl-16-cppyy | |
# os: macos-13-arm64 | |
# compiler: clang | |
# clang-runtime: '16' | |
# cling: Off | |
# cppyy: On | |
# | |
#- name: osx13-arm64-clang-clang13-cling | |
# os: macos-13-arm64 | |
# compiler: clang | |
# clang-runtime: '13' | |
# cling: On | |
# cling-version: '1.0' | |
# cppyy: Off | |
# | |
#- name: osx13-arm64-clang-clang13-cling-cppyy | |
# os: macos-13-arm64 | |
# compiler: clang | |
# clang-runtime: '13' | |
# cling: On | |
# cling-version: '1.0' | |
# cppyy: On | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Save PR Info | |
run: | | |
mkdir -p ./pr | |
echo ${{ github.event.number }} > ./pr/NR | |
echo ${{ github.repository }} > ./pr/REPO | |
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') | |
if [[ "$cling_on" == "ON" ]]; then | |
export CLING_HASH=$(git ls-remote https://github.com/root-project/cling.git HEAD| tr '\t' '-') | |
else | |
export CLING_HASH="Repl" | |
fi | |
# FIXME: We need something like cling-llvm to bump automatically... | |
export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm${{ matrix.clang-runtime}} | tr '\t' '-') | |
echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV | |
echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV | |
- uses: nelonoel/[email protected] | |
- name: Setup default Build Type on *nux | |
if: runner.os != 'windows' | |
run: | | |
echo "BUILD_TYPE=Release" >> $GITHUB_ENV | |
echo "CODE_COVERAGE=0" >> $GITHUB_ENV | |
os="${{ matrix.os }}" | |
if [[ "${os}" == "macos"* ]]; then | |
echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV | |
else | |
echo "ncpus=$(nproc --all)" >> $GITHUB_ENV | |
fi | |
- name: Setup compiler on Linux | |
if: runner.os == 'Linux' | |
run: | | |
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html | |
vers="${compiler#*-}" | |
os_codename="`cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2`" | |
##sudo apt update | |
if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then | |
sudo apt install -y gcc-${vers} g++-${vers} lld | |
echo "CC=gcc-${vers}" >> $GITHUB_ENV | |
echo "CXX=g++-${vers}" >> $GITHUB_ENV | |
else | |
if ! sudo apt install -y clang-${vers}; then | |
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | |
echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-${vers} main" | sudo tee -a /etc/apt/sources.list | |
sudo apt update | |
sudo apt install -y clang-${vers} | |
fi | |
echo "CC=clang-${vers}" >> $GITHUB_ENV | |
echo "CXX=clang++-${vers}" >> $GITHUB_ENV | |
fi | |
env: | |
compiler: ${{ matrix.compiler }} | |
- name: Setup compiler on macOS | |
if: runner.os == 'macOS' | |
run: | | |
vers="${compiler#*-}" | |
if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then | |
brew install "gcc@$vers" | |
echo "CC=gcc-${vers}" >> $GITHUB_ENV | |
echo "CXX=g++-${vers}" >> $GITHUB_ENV | |
else | |
echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV | |
#Use clang-15 and clang++-15 compiler that is installed on runner, instead of one | |
#provided by MacOS (could brew install clang-16/17 to use consistent version | |
#of clang) | |
echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV | |
echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV | |
fi | |
env: | |
compiler: ${{ matrix.compiler }} | |
- name: Install deps on Linux | |
if: runner.os == 'Linux' | |
run: | | |
# Install deps | |
sudo apt update | |
sudo apt install git g++ debhelper devscripts gnupg python3 valgrind | |
conda install -y -q -c conda-forge \ | |
distro \ | |
pytest | |
- name: Install deps on MacOS | |
if: runner.os == 'macOS' | |
run: | | |
#gcc, gnupg and python3 installed on Github runner | |
#brew install git gcc gnupg python@3 | |
#Select latest xcode available on macos-13 | |
sudo xcode-select -s /Applications/Xcode_15.1.app/Contents/Developer | |
brew update | |
brew upgrade | |
pip install distro pytest | |
- name: Restore Cache LLVM/Clang runtime build directory | |
uses: actions/cache/restore@v3 | |
id: cache | |
with: | |
path: | | |
llvm-project | |
${{ matrix.cling=='On' && 'cling' || '' }} | |
#key: ...-.x-patch-${{ hashFiles('patches/llvm/*') }} | |
#key: ${{ env.CLING_HASH }}-${{ env.LLVM_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x | |
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }} | |
- name: Build LLVM/Cling on Unix if the cache is invalid | |
if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }} | |
run: | | |
os="${{ matrix.os }}" | |
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') | |
if [[ "${cling_on}" == "ON" ]]; then | |
git clone https://github.com/root-project/cling.git | |
cd ./cling | |
git checkout tags/v${{ matrix.cling-version }} | |
cd .. | |
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git | |
else # repl | |
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git | |
fi | |
cd llvm-project | |
# Apply patches | |
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" | |
compgen -G "../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch" > /dev/null && find ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch -exec basename {} \; -print -exec git apply {} \; | |
# Build | |
mkdir build | |
cd build | |
if [[ "${cling_on}" == "ON" ]]; then | |
cmake -DLLVM_ENABLE_PROJECTS=clang \ | |
-DLLVM_EXTERNAL_PROJECTS=cling \ | |
-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \ | |
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_ENABLE_ASSERTIONS=ON \ | |
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \ | |
-DCLANG_ENABLE_ARCMT=OFF \ | |
-DCLANG_ENABLE_FORMAT=OFF \ | |
-DCLANG_ENABLE_BOOTSTRAP=OFF \ | |
../llvm | |
cmake --build . --target clang --parallel ${{ env.ncpus }} | |
cmake --build . --target cling --parallel ${{ env.ncpus }} | |
# Now build gtest.a and gtest_main for CppInterOp to run its tests. | |
cmake --build . --target gtest_main --parallel ${{ env.ncpus }} | |
else | |
cmake -DLLVM_ENABLE_PROJECTS=clang \ | |
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_ENABLE_ASSERTIONS=ON \ | |
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \ | |
-DCLANG_ENABLE_ARCMT=OFF \ | |
-DCLANG_ENABLE_FORMAT=OFF \ | |
-DCLANG_ENABLE_BOOTSTRAP=OFF \ | |
../llvm | |
cmake --build . --target clang clang-repl --parallel ${{ env.ncpus }} | |
fi | |
cd ../../ | |
- name: Save Cache LLVM/Clang runtime build directory | |
uses: actions/cache/save@v3 | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
with: | |
path: | | |
llvm-project | |
${{ matrix.cling=='On' && 'cling' || '' }} | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
- name: Setup code coverage | |
if: ${{ success() && (matrix.coverage == true) }} | |
run: | | |
sudo apt install lcov | |
echo "CODE_COVERAGE=1" >> $GITHUB_ENV | |
echo "BUILD_TYPE=Debug" >> $GITHUB_ENV | |
- name: Build and Test/Install CppInterOp on Unix Systems | |
if: ${{ runner.os != 'windows' }} | |
run: | | |
LLVM_DIR="$(pwd)/llvm-project" | |
LLVM_BUILD_DIR="$(pwd)/llvm-project/build" | |
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') | |
if [[ "${cling_on}" == "ON" ]]; then | |
CLING_DIR="$(pwd)/cling" | |
CLING_BUILD_DIR="$(pwd)/cling/build" | |
CPLUS_INCLUDE_PATH="${CLING_DIR}/tools/cling/include:${CLING_BUILD_DIR}/include:${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include:$PWD/include" | |
else | |
CPLUS_INCLUDE_PATH="${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include:$PWD/include" | |
fi | |
export CB_PYTHON_DIR="$PWD/cppyy-backend/python" | |
export CPPINTEROP_DIR="$CB_PYTHON_DIR/cppyy_backend" | |
# Build CppInterOp next to cling and llvm-project. | |
mkdir build && cd build | |
export CPPINTEROP_BUILD_DIR=$PWD | |
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') | |
if [[ "${cling_on}" == "ON" ]]; then | |
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ | |
-DUSE_CLING=ON \ | |
-DUSE_REPL=OFF \ | |
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \ | |
-DLLVM_DIR=$LLVM_BUILD_DIR \ | |
-DBUILD_SHARED_LIBS=ON \ | |
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ | |
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \ | |
../ | |
else | |
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ | |
-DUSE_CLING=OFF \ | |
-DUSE_REPL=ON \ | |
-DLLVM_DIR=$LLVM_BUILD_DIR \ | |
-DBUILD_SHARED_LIBS=ON \ | |
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ | |
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \ | |
../ | |
fi | |
os="${{ matrix.os }}" | |
cmake --build . --target check-cppinterop --parallel ${{ env.ncpus }} | |
cppyy_on=$(echo "${{ matrix.cppyy }}" | tr '[:lower:]' '[:upper:]') | |
if [[ ("${cppyy_on}" != "ON") && ("${os}" == "ubuntu"*) ]]; then | |
# TODO: Remove "|| true" when fix memory issues in LLVM/Clang 17 | |
valgrind --track-origins=yes --error-exitcode=1 unittests/CppInterOp/CppInterOpTests 2>&1 >/dev/null || true | |
fi | |
cd .. | |
# We need CB_PYTHON_DIR later | |
echo "CB_PYTHON_DIR=$CB_PYTHON_DIR" >> $GITHUB_ENV | |
# We need CPPINTEROP_DIR, LLVM_BUILD_DIR and CPLUS_INCLUDE_PATH later | |
echo "CPPINTEROP_BUILD_DIR=$CPPINTEROP_BUILD_DIR" >> $GITHUB_ENV | |
echo "CPPINTEROP_DIR=$CPPINTEROP_DIR" >> $GITHUB_ENV | |
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV | |
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV | |
- name: Build and Install cppyy-backend on Unix Systems | |
if: ${{ (runner.os != 'windows') && (matrix.cppyy == 'On') }} | |
run: | | |
# Download cppyy-backend | |
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git | |
cd cppyy-backend | |
mkdir -p $CPPINTEROP_DIR/lib build && cd build | |
# Install CppInterOp | |
(cd $CPPINTEROP_BUILD_DIR && cmake --build . --target install --parallel $(nproc --all)) | |
# Build and Install cppyy-backend | |
cmake -DCppInterOp_DIR=$CPPINTEROP_DIR .. | |
cmake --build . --parallel $(nproc --all) | |
OS=$(uname -s) | |
if [[ "$OS" == "Darwin" ]]; then | |
cp libcppyy-backend.dylib $CPPINTEROP_DIR/lib/ | |
else | |
cp libcppyy-backend.so $CPPINTEROP_DIR/lib/ | |
fi | |
##cling_on="${{ matrix.cling }}" | |
##if [[ "${cling_on^^}" == "ON" ]]; then | |
## cp $LLVM_BUILD_DIR/lib/libcling.so $CPPINTEROP_DIR/lib/ | |
##fi | |
# | |
cd .. | |
- name: Install CPyCppyy on Unix Systems | |
if: ${{ (runner.os != 'windows') && (matrix.cppyy == 'On') }} | |
run: | | |
# Setup virtual environment | |
python3 -m venv .venv | |
source .venv/bin/activate | |
# Install CPyCppyy | |
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git | |
mkdir CPyCppyy/build | |
cd CPyCppyy/build | |
cmake .. | |
cmake --build . --parallel $(nproc --all) | |
# | |
export CPYCPPYY_DIR=$PWD | |
cd ../.. | |
# We need CPYCPPYY_DIR later | |
echo "CPYCPPYY_DIR=$CPYCPPYY_DIR" >> $GITHUB_ENV | |
- name: Install cppyy on Unix Systems | |
if: ${{ (runner.os != 'windows') && (matrix.cppyy == 'On') }} | |
run: | | |
# source virtual environment | |
source .venv/bin/activate | |
# Install cppyy | |
git clone --depth=1 https://github.com/compiler-research/cppyy.git | |
cd cppyy | |
python -m pip install --upgrade . --no-deps | |
cd .. | |
- name: Run cppyy on Unix Systems | |
if: ${{ (runner.os != 'windows') && (matrix.cppyy == 'On') }} | |
run: | | |
# Run cppyy | |
source .venv/bin/activate | |
export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR | |
python -c "import cppyy" | |
# We need PYTHONPATH later | |
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV | |
- name: Run the tests on Unix Systems | |
continue-on-error: true | |
if: ${{ (runner.os != 'windows') && (matrix.cppyy == 'On') }} | |
run: | | |
# Run the tests | |
source .venv/bin/activate | |
cd cppyy/test | |
echo ::group::Prepare For Testing | |
make all | |
python -m pip install --upgrade pip | |
python -m pip install pytest | |
python -m pip install pytest-xdist | |
echo ::endgroup:: | |
echo ::group::Crashing Test Logs | |
# See if we don't have a crash that went away | |
# Comment out all xfails but the ones that have a run=False condition. | |
find . -name "*.py" -exec sed -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \; | |
python -m pytest -n 1 -m "xfail" --runxfail -sv --max-worker-restart 512 | tee test_crashed.log 2>&1 | |
git checkout . | |
echo ::endgroup:: | |
echo ::group::XFAIL Test Logs | |
# Rewrite all xfails that have a run clause to skipif. This way we will | |
# avoid conditionally crashing xfails | |
find . -name "*.py" -exec sed -i -E 's/(^ *)@mark.xfail\(run=(.*)/\[email protected](condition=not \2/g' {} \; | |
# See if we don't have an xfail that went away | |
python -m pytest --runxfail -sv | tee test_xfailed.log 2>&1 | |
git checkout . | |
echo ::endgroup:: | |
echo ::group::Passing Test Logs | |
# Run the rest of the non-crashing tests. | |
declare -i RETCODE=0 | |
set -o pipefail | |
valgrind --error-exitcode=1 --suppressions=../etc/valgrind-cppyy-cling.supp python -m pytest -m "not xfail" -v | |
export RETCODE=+$? | |
echo ::endgroup:: | |
RETCODE=+$? | |
echo "Crashing Summary: \n" | |
tail -n1 test_crashed.log | |
echo "XFAIL Summary:" | |
tail -n1 test_xfailed.log | |
echo "Return Code: ${RETCODE}" | |
exit $RETCODE | |
- name: Show debug info | |
if: ${{ failure() }} | |
run: | | |
export | |
echo $GITHUB_ENV | |
- name: Setup tmate session | |
if: ${{ failure() }} | |
uses: mxschmitt/action-tmate@v3 | |
# When debugging increase to a suitable value! | |
timeout-minutes: ${{ github.event.pull_request && 1 || 20 }} | |
- name: Prepare code coverage report | |
if: ${{ success() && (matrix.coverage == true) }} | |
run: | | |
# Create lcov report | |
# capture coverage info | |
vers="${CC#*-}" | |
lcov --directory build/ --capture --output-file coverage.info --gcov-tool /usr/bin/gcov-${vers} | |
lcov --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' ${{ github.workspace }}'/llvm-project/*' ${{ github.workspace }}'/unittests/*' --output-file coverage.info | |
# output coverage data for debugging (optional) | |
lcov --list coverage.info | |
- name: Upload to codecov.io | |
if: ${{ success() && (matrix.coverage == true) }} | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.info |