|
| 1 | +name: Main |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: [master] |
| 5 | + push: |
| 6 | + branches: [master] |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + schedule: |
| 10 | + - cron: '30 20 * * *' # Warning: Timezone dep - 20:00 is 1:00 |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: ${{ matrix.name }} |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - name: ubu22-gcc9-clang13 |
| 25 | + os: ubuntu-22.04 |
| 26 | + compiler: gcc-9 |
| 27 | + clang-runtime: '13' |
| 28 | +# - name: ubu22-gcc9-clang14 |
| 29 | +# os: ubuntu-22.04 |
| 30 | +# compiler: gcc-9 |
| 31 | +# clang-runtime: '14' |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v3 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + - name: Set up Python |
| 37 | + uses: actions/setup-python@v4 |
| 38 | + with: |
| 39 | + python-version: '3.10' |
| 40 | + - name: Save PR Info |
| 41 | + run: | |
| 42 | + mkdir -p ./pr |
| 43 | + echo ${{ github.event.number }} > ./pr/NR |
| 44 | + echo ${{ github.repository }} > ./pr/REPO |
| 45 | + |
| 46 | + export CLING_HASH=$(git ls-remote https://github.com/root-project/cling.git HEAD| tr '\t' '-') |
| 47 | + # FIXME: We need something like cling-llvm to bump automatically... |
| 48 | + export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm13 | tr '\t' '-') |
| 49 | + echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV |
| 50 | + echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV |
| 51 | + |
| 52 | + - uses: nelonoel/[email protected] |
| 53 | + - name: Setup compiler on Linux |
| 54 | + if: runner.os == 'Linux' |
| 55 | + run: | |
| 56 | + # https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html |
| 57 | + vers="${compiler#*-}" |
| 58 | + os_codename="`cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2`" |
| 59 | + sudo apt update |
| 60 | + if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then |
| 61 | + sudo apt install -y gcc-${vers} g++-${vers} lld |
| 62 | + echo "CC=gcc-${vers}" >> $GITHUB_ENV |
| 63 | + echo "CXX=g++-${vers}" >> $GITHUB_ENV |
| 64 | + else |
| 65 | + if ! sudo apt install -y clang-${vers}; then |
| 66 | + curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - |
| 67 | + echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-${vers} main" | sudo tee -a /etc/apt/sources.list |
| 68 | + sudo apt update |
| 69 | + sudo apt install -y clang-${vers} |
| 70 | + fi |
| 71 | + echo "CC=clang-${vers}" >> $GITHUB_ENV |
| 72 | + echo "CXX=clang++-${vers}" >> $GITHUB_ENV |
| 73 | + fi |
| 74 | + env: |
| 75 | + compiler: ${{ matrix.compiler }} |
| 76 | + - name: Install deps on Linux |
| 77 | + if: runner.os == 'Linux' |
| 78 | + run: | |
| 79 | + # Install deps |
| 80 | + sudo apt-get update |
| 81 | + sudo apt-get install git g++ debhelper devscripts gnupg python3 |
| 82 | + conda install -y -q -c conda-forge \ |
| 83 | + distro \ |
| 84 | + pytest |
| 85 | + - name: Restore Cache LLVM/Clang runtime build directory |
| 86 | + uses: actions/cache/restore@v3 |
| 87 | + id: cache |
| 88 | + with: |
| 89 | + path: | |
| 90 | + llvm-project/ |
| 91 | + cling/ |
| 92 | + #key: ...-.x-patch-${{ hashFiles('patches/llvm/*') }} |
| 93 | + #key: ${{ env.CLING_HASH }}-${{ env.LLVM_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x |
| 94 | + key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x |
| 95 | + - name: Build Cling on Linux if the cache is invalid |
| 96 | + if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' }} |
| 97 | + run: | |
| 98 | + #if [[ "${{ steps.cling-build-cache.outputs.cache-hit }}" != "true" ]]; then |
| 99 | + git clone --depth=1 https://github.com/root-project/cling.git |
| 100 | + git clone --depth=1 -b cling-llvm13 https://github.com/root-project/llvm-project.git |
| 101 | + cd llvm-project |
| 102 | + mkdir build |
| 103 | + cd build |
| 104 | + cmake -DLLVM_ENABLE_PROJECTS=clang \ |
| 105 | + -DLLVM_EXTERNAL_PROJECTS=cling \ |
| 106 | + -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \ |
| 107 | + -DLLVM_TARGETS_TO_BUILD="host;NVPTX" \ |
| 108 | + -DCMAKE_BUILD_TYPE=Release \ |
| 109 | + -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 110 | + -DLLVM_USE_LINKER=lld \ |
| 111 | + -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ |
| 112 | + -DCLANG_ENABLE_ARCMT=OFF \ |
| 113 | + -DCLANG_ENABLE_FORMAT=OFF \ |
| 114 | + -DCLANG_ENABLE_BOOTSTRAP=OFF \ |
| 115 | + ../llvm |
| 116 | + cmake --build . --target clang --parallel $(nproc --all) |
| 117 | + cmake --build . --target cling --parallel $(nproc --all) |
| 118 | + cmake --build . --target libcling --parallel $(nproc --all) |
| 119 | + # Now build gtest.a and gtest_main for InterOp to run its tests. |
| 120 | + cmake --build . --target gtest_main --parallel $(nproc --all) |
| 121 | + cd ../../ |
| 122 | + #fi |
| 123 | + - name: Save Cache LLVM/Clang runtime build directory |
| 124 | + uses: actions/cache/save@v3 |
| 125 | + if: ${{ steps.cache.outputs.cache-hit != 'true' }} |
| 126 | + with: |
| 127 | + path: | |
| 128 | + llvm-project/ |
| 129 | + cling/ |
| 130 | + key: ${{ steps.cache.outputs.cache-primary-key }} |
| 131 | + - name: Build and Install InterOp on Linux |
| 132 | + if: runner.os == 'Linux' |
| 133 | + run: | |
| 134 | + # Build InterOp next to cling and llvm-project. |
| 135 | + LLVM_DIR="$(realpath llvm-project)" |
| 136 | + LLVM_BUILD_DIR="$(realpath llvm-project/build)" |
| 137 | + CLING_DIR="$(realpath cling)" |
| 138 | + CLING_BUILD_DIR="$(realpath cling/build)" |
| 139 | + 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" |
| 140 | + git clone https://github.com/compiler-research/InterOp.git |
| 141 | + cd InterOp |
| 142 | + pwd |
| 143 | + mkdir build install |
| 144 | + export INTEROP_DIR="$(realpath install)" |
| 145 | + cd build |
| 146 | + cmake -DUSE_CLING=ON -DCling_DIR=$LLVM_BUILD_DIR -DCMAKE_INSTALL_PREFIX=$INTEROP_DIR ../ |
| 147 | + #cmake --build . --target check-interop --parallel $(nproc --all) |
| 148 | + cmake --build . --target install --parallel $(nproc --all) |
| 149 | + cd ../.. |
| 150 | + # We need INTEROP_DIR, LLVM_BUILD_DIR and CPLUS_INCLUDE_PATH later |
| 151 | + echo "INTEROP_DIR=$INTEROP_DIR" >> $GITHUB_ENV |
| 152 | + echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV |
| 153 | + echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV |
| 154 | + - name: Build and Install cppyy-backend on Linux |
| 155 | + if: runner.os == 'Linux' |
| 156 | + run: | |
| 157 | + # Install cppyy-backend |
| 158 | + mkdir python/cppyy_backend/lib build && cd build |
| 159 | + cmake -DInterOp_DIR=$INTEROP_DIR .. |
| 160 | + cmake --build . --parallel $(nproc --all) |
| 161 | + cp libcppyy-backend.so ../python/cppyy_backend/lib/ |
| 162 | + cp $LLVM_BUILD_DIR/lib/libcling.so ../python/cppyy_backend/lib/ |
| 163 | + # |
| 164 | + cd ../python |
| 165 | + export CB_PYTHON_DIR=$PWD |
| 166 | + cd ../.. |
| 167 | + # We need CB_PYTHON_DIR later |
| 168 | + echo "CB_PYTHON_DIR=$CB_PYTHON_DIR" >> $GITHUB_ENV |
| 169 | + - name: Install CPyCppyy on Linux |
| 170 | + if: runner.os == 'Linux' |
| 171 | + run: | |
| 172 | + # Setup virtual environment |
| 173 | + python3 -m venv .venv |
| 174 | + source .venv/bin/activate |
| 175 | + # Install CPyCppyy |
| 176 | + git clone https://github.com/compiler-research/CPyCppyy.git |
| 177 | + cd CPyCppyy |
| 178 | + mkdir build && cd build |
| 179 | + cmake .. |
| 180 | + cmake --build . --parallel $(nproc --all) |
| 181 | + # |
| 182 | + export CPYCPPYY_DIR=$PWD |
| 183 | + cd ../.. |
| 184 | + # We need CPYCPPYY_DIR later |
| 185 | + echo "CPYCPPYY_DIR=$CPYCPPYY_DIR" >> $GITHUB_ENV |
| 186 | + - name: Install cppyy on Linux |
| 187 | + if: runner.os == 'Linux' |
| 188 | + run: | |
| 189 | + # source virtual environment |
| 190 | + source .venv/bin/activate |
| 191 | + # Install cppyy |
| 192 | + git clone https://github.com/compiler-research/cppyy.git |
| 193 | + cd cppyy |
| 194 | + python -m pip install --upgrade . --no-deps |
| 195 | + cd .. |
| 196 | + - name: Run cppyy on Linux |
| 197 | + if: runner.os == 'Linux' |
| 198 | + run: | |
| 199 | + # Run cppyy |
| 200 | + source .venv/bin/activate |
| 201 | + export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR |
| 202 | + python -c "import cppyy" |
| 203 | + # We need PYTHONPATH later |
| 204 | + echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV |
| 205 | + - name: Run the tests on Linux |
| 206 | + continue-on-error: true |
| 207 | + if: runner.os == 'Linux' |
| 208 | + run: | |
| 209 | + # Run the tests |
| 210 | + source .venv/bin/activate |
| 211 | + cd cppyy/test |
| 212 | + make all || true |
| 213 | + python -m pip install --upgrade pip |
| 214 | + python -m pip install pytest |
| 215 | + python -m pip install pytest-xdist |
| 216 | + |
| 217 | + echo ::group::Test Logs |
| 218 | + python -m pytest -n auto -sv --max-worker-restart 512 | tee test.log 2>&1 |
| 219 | + echo ::endgroup:: |
| 220 | + |
| 221 | + echo "TEST SUMMARY: \n" |
| 222 | + tail -n1 test.log |
| 223 | + echo "OF TOTAL $(python3 -m pytest --collect-only -q | tail -n1)" |
| 224 | + - name: Setup tmate session |
| 225 | + if: ${{ failure() }} |
| 226 | + uses: mxschmitt/action-tmate@v3 |
| 227 | + # When debugging increase to a suitable value! |
0 commit comments