Skip to content

Support capture result value #710

Support capture result value

Support capture result value #710

Workflow file for this run

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-clang16
os: ubuntu-22.04
compiler: gcc-12
clang-runtime: '16'
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
- uses: nelonoel/[email protected]
- 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}
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: Restore Cache LLVM/Clang runtime build directory
uses: actions/cache/restore@v3
id: cache
with:
path: clang-dev
key: ${{ 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 runtime LLVM/Clang on Linux if the cache is invalid
if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' }}
run: |
# Warning: If this part of the clang build script is changed to give a different
# result, then clear cache 'cache' by hand:
# https://github.com/compiler-research/xeus-clang-repl/actions/caches
UNIX_DISTRO=$(lsb_release -rs)
# Fetch clang-dev
git clone --depth=1 --branch "release/${{ matrix.clang-runtime }}.x" --single-branch https://github.com/llvm/llvm-project.git clang-dev
cd clang-dev
# 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 -printf "%f\n" && git apply ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch
# Build clang-dev
mkdir build
mkdir inst
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_OPTIMIZED_TABLEGEN=On -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="openmp" -DCMAKE_INSTALL_PREFIX=../inst ../llvm
make ClangDriverOptions clang-repl openmp openmp-resource-headers -j$(nproc --all)
make install -j$(nproc --all)
make clean -j$(nproc --all)
cd ..
rm -rf $(find . -maxdepth 1 ! -name "inst" ! -name ".")
cd ..
- name: Save Cache LLVM/Clang runtime build directory
uses: actions/cache/save@v3
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
with:
path: clang-dev
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Set PATH_TO_LLVM_BUILD etc to Env
run: |
export PATH_TO_LLVM_BUILD="$(realpath clang-dev/inst)"
export PATH=$PATH_TO_LLVM_BUILD/bin:$PATH
export LD_LIBRARY_PATH=$PATH_TO_LLVM_BUILD/lib:$LD_LIBRARY_PATH
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Create clang-dev.tar.bz2 for artifact/release asset
run: |
#TODO: Clean unneeded folders...
# Tar prebuild clang-dev for dev binder containers
tar -cjf clang-dev.tar.bz2 ./clang-dev
- name: Add assets to Release
id: add_release_assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
clang-dev.tar.bz2
- name: Archive clang-dev artifact
uses: actions/upload-artifact@v3
with:
name: clang-dev
path: clang-dev.tar.bz2
retention-days: ${{ github.event_name=='schedule' && 2 || 7 }}
- name: Install xeus-clang-repl deps on Linux
if: runner.os == 'Linux' #TODO: exclude on release
run: |
# Install xeus-clang-repl deps
sudo apt-get update --yes
sudo apt-get install --yes --no-install-recommends ncurses-dev libtinfo-dev libtinfo5
#
conda update --all
conda install -y -q -c conda-forge \
'xeus>=2.0,<3.0' \
'nlohmann_json>=3.9.1,<3.10' \
'cppzmq>=4.6.0,<5' \
'xtl>=0.7,<0.8' \
pugixml \
'cxxopts>=2.2.1,<2.3' \
libuuid \
pytest \
jupyter_kernel_test
- name: Build and Install CppInterOp on Linux
if: runner.os == 'Linux'
run: |
# Build CppInterOp next to cling and llvm-project.
LLVM_DIR="$(realpath clang-dev)"
LLVM_BUILD_DIR="$(realpath clang-dev/inst)"
#CPLUS_INCLUDE_PATH="${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include"
CPLUS_INCLUDE_PATH="${LLVM_BUILD_DIR}/include/llvm:${LLVM_BUILD_DIR}/include/clang"
git clone https://github.com/compiler-research/CppInterOp.git
export CPPINTEROP_DIR=$PWD/cppyy-backend/python/cppyy_backend/
cd CppInterOp
mkdir build
cd build
export CPPINTEROP_BUILD_DIR=$PWD
cmake -DCMAKE_BUILD_TYPE=Release \
-DUSE_CLING=OFF \
-DUSE_REPL=ON \
-DLLVM_DIR=$LLVM_BUILD_DIR \
-DLLVM_USE_LINKER=gold \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
../
cmake --build . --parallel $(nproc --all)
cd ../..
# We need CPPINTEROP_DIR, LLVM_BUILD_DIR and CPLUS_INCLUDE_PATH later
echo "CPPINTEROP_DIR=$CPPINTEROP_DIR" >> $GITHUB_ENV
echo "CPPINTEROP_BUILD_DIR=$CPPINTEROP_BUILD_DIR" >> $GITHUB_ENV
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
- name: Build xeus-clang-repl on Linux
if: runner.os == 'Linux' #TODO: exclude on release
run: |
## Build and Install xeus-clang-repl
mkdir build
cd build
PP=$KERNEL_PYTHON_PREFIX
if [[ -z "$PP" ]]; then
PP=$(conda info --base)
fi
cmake -DCMAKE_PREFIX_PATH=$PP -DCMAKE_INSTALL_PREFIX=$PP \
-DCMAKE_INSTALL_LIBDIR=lib -DLLVM_DIR=$PATH_TO_LLVM_BUILD \
-DLLVM_CONFIG_EXTRA_PATH_HINTS=$PATH_TO_LLVM_BUILD \
-DCPPINTEROP_DIR=$CPPINTEROP_BUILD_DIR \
-DLLVM_USE_LINKER=gold \
-DLLVM_REQUIRED_VERSION=${{ matrix.clang-runtime }} ..
make install
- 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 }}