From d26fefa7d5459f99885dfb4ec5ebd63892d48548 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 22 Jan 2025 20:41:36 +0000 Subject: [PATCH 1/3] Split osx workflow into one for x86 and one for arm --- .github/workflows/MacOS-arm.yml | 610 ++++++++++++++++++++++++++++++++ .github/workflows/MacOS.yml | 106 +----- README.md | 2 + 3 files changed, 621 insertions(+), 97 deletions(-) create mode 100644 .github/workflows/MacOS-arm.yml diff --git a/.github/workflows/MacOS-arm.yml b/.github/workflows/MacOS-arm.yml new file mode 100644 index 000000000..a10c79a69 --- /dev/null +++ b/.github/workflows/MacOS-arm.yml @@ -0,0 +1,610 @@ +name: OSX-arm + +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_cache: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: osx15-arm-clang-clang-repl-19 + os: macos-15 + compiler: clang + clang-runtime: '19' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" + - name: osx15-arm-clang-clang-repl-18 + os: macos-15 + compiler: clang + clang-runtime: '18' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" + - name: osx15-arm-clang-clang-repl-17 + os: macos-15 + compiler: clang + clang-runtime: '17' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" + - name: osx15-arm-clang-clang-repl-16 + os: macos-15 + compiler: clang + clang-runtime: '16' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" + - name: osx15-arm-clang-clang13-cling + os: macos-15 + compiler: clang + clang-runtime: '13' + cling: On + cling-version: '1.0' + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" + - name: osx13-x86-clang-clang-repl-19 + os: macos-13 + compiler: clang + clang-runtime: '19' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" + - name: osx13-x86-clang-clang-repl-18 + os: macos-13 + compiler: clang + clang-runtime: '18' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" + - name: osx13-x86-clang-clang-repl-17 + os: macos-13 + compiler: clang + clang-runtime: '17' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" + - name: osx13-x86-clang-clang-repl-16 + os: macos-13 + compiler: clang + clang-runtime: '16' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" + - name: osx13-x86-clang-clang13-cling + os: macos-13 + compiler: clang + clang-runtime: '13' + cling: On + cling-version: '1.0' + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - 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 refs/tags/v${{ matrix.cling-version }} | tr '\t' '-') + export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm${{ matrix.clang-runtime}} | tr '\t' '-') + else + export CLING_HASH="Repl" + # May need to revert back to both having same llvm_hash, as below cause llvm to be rebuilt everytime commit is made to llvm/llvm-project for release a.x + # which could be quite often for new releases + export LLVM_HASH=$(git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x | tr '\t' '-') + fi + + echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV + echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV + + - name: Restore Cache LLVM/Clang runtime build directory + uses: actions/cache/restore@v4 + id: cache + with: + path: | + llvm-project + ${{ matrix.cling=='On' && 'cling' || '' }} + 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' }} + lookup-only: true + + - name: Setup default Build Type + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + run: | + echo "BUILD_TYPE=Release" >> $GITHUB_ENV + echo "CODE_COVERAGE=0" >> $GITHUB_ENV + echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV + + - name: Setup compiler + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + 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 + cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') + if [[ "${cling_on}" == "ON" ]]; then + brew install llvm@15 + brew remove llvm@18 + brew cleanup + #FIXME: Do not believe setting all these environment variables are necessary + # They were set to avoid using Xcodes libc++ and to stop CppInterOp using llvm@18 in tests + echo 'LDFLAGS="-L/opt/homebrew/opt/llvm@15/lib/ -L/opt/homebrew/opt/llvm@15/c++/"' >> $GITHUB_ENV + echo 'CPPFLAGS="-I/opt/homebrew/opt/llvm@15/include"' >> $GITHUB_ENV + echo 'CPATH="/opt/homebrew/include/"' >> $GITHUB_ENV + echo 'LIBRARY_PATH="/opt/homebrew/lib/"' >> $GITHUB_ENV + echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV + else + echo "CC=$(brew --prefix llvm@18)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@18)/bin/clang++" >> $GITHUB_ENV + fi + fi + echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV + env: + compiler: ${{ matrix.compiler }} + + - name: Install deps + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + run: | + brew update + brew remove unxip + # workaround for https://github.com/actions/setup-python/issues/577 + for pkg in $(brew list | grep '^python@'); do + brew unlink "$pkg" + brew link --overwrite "$pkg" + done + brew upgrade openssl >/dev/null 2>&1 + brew upgrade + brew install ninja + + - name: Build LLVM/Cling if the cache is invalid + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + run: | + 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 + # Build + mkdir build + if [[ "${cling_on}" == "ON" ]]; then + cd build + cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \ + -DLLVM_EXTERNAL_PROJECTS=cling \ + -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \ + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \ + -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 \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_ENABLE_TERMINFO=OFF \ + -DLLVM_ENABLE_LIBXML2=OFF \ + -G Ninja \ + ../llvm + ninja clang -j ${{ env.ncpus }} + ninja cling -j ${{ env.ncpus }} + # Now build gtest.a and gtest_main for CppInterOp to run its tests. + ninja gtest_main -j ${{ env.ncpus }} + else + # Apply patches + llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]') + if [[ "${llvm_vers}" == "16" ]]||[[ "${llvm_vers}" == "17" ]]; then + git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch + echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" + fi + cd build + cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" \ + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \ + -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 \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_ENABLE_TERMINFO=OFF \ + -DLLVM_ENABLE_LIBXML2=OFF \ + -G Ninja \ + -DLLVM_INCLUDE_BENCHMARKS=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF \ + -DLLVM_INCLUDE_TESTS=OFF \ + ../llvm + ninja clang clangInterpreter clangStaticAnalyzerCore -j ${{ env.ncpus }} + cd ./tools/ + rm -rf $(find . -maxdepth 1 ! -name "clang" ! -name ".") + cd .. + rm compile_commands.json build.ninja + fi + cd ../ + rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".") + if [[ "${cling_on}" == "ON" ]]; then + cd ./llvm/ + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".") + cd ../clang/ + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".") + cd ../.. + else # repl + cd ./llvm/ + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") + cd ../clang/ + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") + cd ../.. + fi + + - name: Save Cache LLVM/Clang runtime build directory + uses: actions/cache/save@v4 + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + with: + path: | + llvm-project + ${{ matrix.cling=='On' && 'cling' || '' }} + key: ${{ steps.cache.outputs.cache-primary-key }} + + cppinterop_and_cppyy_build: + needs: [build_cache] + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: osx15-arm-clang-clang-repl-19-cppyy + os: macos-15 + compiler: clang + clang-runtime: '19' + cling: Off + cppyy: On + - name: osx15-arm-clang-clang-repl-18-cppyy + os: macos-15 + compiler: clang + clang-runtime: '18' + cling: Off + cppyy: On + - name: osx15-arm-clang-clang-repl-17-cppyy + os: macos-15 + compiler: clang + clang-runtime: '17' + cling: Off + cppyy: On + - name: osx15-arm-clang-clang-repl-16 + os: macos-15 + compiler: clang + clang-runtime: '16' + cling: Off + cppyy: Off + - name: osx15-arm-clang-clang13-cling-cppyy + os: macos-15 + compiler: clang + clang-runtime: '13' + cling: On + cling-version: '1.0' + cppyy: On + - name: osx13-x86-clang-clang-repl-19-cppyy + os: macos-13 + compiler: clang + clang-runtime: '19' + cling: Off + cppyy: On + - name: osx13-x86-clang-clang-repl-18-cppyy + os: macos-13 + compiler: clang + clang-runtime: '18' + cling: Off + cppyy: On + - 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-clang13-cling-cppyy + os: macos-13 + compiler: clang + clang-runtime: '13' + cling: On + cling-version: '1.0' + cppyy: On + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - 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 refs/tags/v${{ matrix.cling-version }} | tr '\t' '-') + export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm${{ matrix.clang-runtime}} | tr '\t' '-') + else + export CLING_HASH="Repl" + # May need to revert back to both having same llvm_hash, as below cause llvm to be rebuilt everytime commit is made to llvm/llvm-project for release a.x + # which could be quite often for new releases + export LLVM_HASH=$(git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x | tr '\t' '-') + fi + + echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV + echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV + + - name: Setup default Build Type + run: | + echo "BUILD_TYPE=Release" >> $GITHUB_ENV + echo "CODE_COVERAGE=0" >> $GITHUB_ENV + echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV + + - name: Setup compiler + 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 + cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') + if [[ "${cling_on}" == "ON" ]]; then + brew install llvm@15 + brew remove llvm@18 + brew cleanup + #FIXME: Do not believe setting all these environment variables are necessary + # They were set to avoid using Xcodes libc++ and to stop CppInterOp using llvm@18 in tests + echo 'LDFLAGS="-L/opt/homebrew/opt/llvm@15/lib/ -L/opt/homebrew/opt/llvm@15/c++/"' >> $GITHUB_ENV + echo 'CPPFLAGS="-I/opt/homebrew/opt/llvm@15/include"' >> $GITHUB_ENV + echo 'CPATH="/opt/homebrew/include/"' >> $GITHUB_ENV + echo 'LIBRARY_PATH="/opt/homebrew/lib/"' >> $GITHUB_ENV + echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV + else + echo "CC=$(brew --prefix llvm@18)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@18)/bin/clang++" >> $GITHUB_ENV + fi + fi + echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV + env: + compiler: ${{ matrix.compiler }} + + - name: Install deps + run: | + brew update --force + brew remove unxip + # workaround for https://github.com/actions/setup-python/issues/577 + for pkg in $(brew list | grep '^python@'); do + brew unlink "$pkg" + brew link --overwrite "$pkg" + done + brew upgrade --force + brew install eigen + brew install boost + brew install gnu-sed + pip install distro pytest + + + - name: Restore Cache LLVM/Clang runtime build directory + uses: actions/cache/restore@v4 + id: cache + with: + path: | + llvm-project + ${{ matrix.cling=='On' && 'cling' || '' }} + 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 and Test/Install CppInterOp + 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 \ + -DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \ + -DCling_DIR=$LLVM_BUILD_DIR/tools/cling \ + -DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \ + -DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \ + -DBUILD_SHARED_LIBS=ON \ + -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ + -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \ + -DLLVM_ENABLE_WERROR=On \ + ../ + else + cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \ + -DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \ + -DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \ + -DBUILD_SHARED_LIBS=ON \ + -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ + -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \ + -DLLVM_ENABLE_WERROR=On \ + ../ + fi + cmake --build . --target check-cppinterop --parallel ${{ env.ncpus }} + 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 + if: ${{ 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 ${{ env.ncpus }} ) + # Build and Install cppyy-backend + cmake -DCppInterOp_DIR=$CPPINTEROP_DIR .. + cmake --build . --parallel ${{ env.ncpus }} + cp libcppyy-backend.dylib $CPPINTEROP_DIR/lib/ + cd .. + + - name: Install CPyCppyy + if: ${{ matrix.cppyy == 'On' }} + run: | + 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 ${{ env.ncpus }} + # + export CPYCPPYY_DIR=$PWD + cd ../.. + # We need CPYCPPYY_DIR later + echo "CPYCPPYY_DIR=$CPYCPPYY_DIR" >> $GITHUB_ENV + - name: Install cppyy + if: ${{ 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 + if: ${{ 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 + if: ${{ 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 + python -m pip install numba + echo ::endgroup:: + echo ::group::Run complete test suite + set -o pipefail + python -m pytest -sv -ra | tee complete_testrun.log 2>&1 + set +o pipefail + 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 gsed -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \; + python -m pytest -n 1 -m "xfail" --runxfail -sv -ra --max-worker-restart 512 | tee test_crashed.log 2>&1 || true + 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 gsed -i -E 's/(^ *)@mark.xfail\(run=(.*)/\1@mark.skipif(condition=not \2/g' {} \; + # See if we don't have an xfail that went away + python -m pytest --runxfail -sv -ra | tee test_xfailed.log 2>&1 || true + git checkout . + echo ::endgroup:: + echo ::group::Passing Test Logs + + # Run the rest of the non-crashing tests. + declare -i RETCODE=0 + + set -o pipefail + export RETCODE=+$? + echo ::endgroup:: + + RETCODE=+$? + + echo "Complete Test Suite Summary: \n" + tail -n1 complete_testrun.log + 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() && runner.debug }} + uses: mxschmitt/action-tmate@v3 + # When debugging increase to a suitable value! + timeout-minutes: 30 diff --git a/.github/workflows/MacOS.yml b/.github/workflows/MacOS.yml index ada89fe84..d882ed748 100644 --- a/.github/workflows/MacOS.yml +++ b/.github/workflows/MacOS.yml @@ -1,4 +1,4 @@ -name: OSX +name: OSX-x86 on: pull_request: @@ -22,42 +22,6 @@ jobs: fail-fast: false matrix: include: - - name: osx15-arm-clang-clang-repl-19 - os: macos-15 - compiler: clang - clang-runtime: '19' - cling: Off - llvm_enable_projects: "clang" - llvm_targets_to_build: "host" - - name: osx15-arm-clang-clang-repl-18 - os: macos-15 - compiler: clang - clang-runtime: '18' - cling: Off - llvm_enable_projects: "clang" - llvm_targets_to_build: "host" - - name: osx15-arm-clang-clang-repl-17 - os: macos-15 - compiler: clang - clang-runtime: '17' - cling: Off - llvm_enable_projects: "clang" - llvm_targets_to_build: "host" - - name: osx15-arm-clang-clang-repl-16 - os: macos-15 - compiler: clang - clang-runtime: '16' - cling: Off - llvm_enable_projects: "clang" - llvm_targets_to_build: "host" - - name: osx15-arm-clang-clang13-cling - os: macos-15 - compiler: clang - clang-runtime: '13' - cling: On - cling-version: '1.0' - llvm_enable_projects: "clang" - llvm_targets_to_build: "host;NVPTX" - name: osx13-x86-clang-clang-repl-19 os: macos-13 compiler: clang @@ -151,29 +115,8 @@ jobs: echo "CC=gcc-${vers}" >> $GITHUB_ENV echo "CXX=g++-${vers}" >> $GITHUB_ENV else - export ARCHITECHURE=$(uname -m) - if [[ "$ARCHITECHURE" == "arm64" ]]; then - cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') - if [[ "${cling_on}" == "ON" ]]; then - brew install llvm@15 - brew remove llvm@18 - brew cleanup - #FIXME: Do not believe setting all these environment variables are necessary - # They were set to avoid using Xcodes libc++ and to stop CppInterOp using llvm@18 in tests - echo 'LDFLAGS="-L/opt/homebrew/opt/llvm@15/lib/ -L/opt/homebrew/opt/llvm@15/c++/"' >> $GITHUB_ENV - echo 'CPPFLAGS="-I/opt/homebrew/opt/llvm@15/include"' >> $GITHUB_ENV - echo 'CPATH="/opt/homebrew/include/"' >> $GITHUB_ENV - echo 'LIBRARY_PATH="/opt/homebrew/lib/"' >> $GITHUB_ENV - echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV - else - echo "CC=$(brew --prefix llvm@18)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@18)/bin/clang++" >> $GITHUB_ENV - fi - else - echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV - fi + echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV fi echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV env: @@ -183,12 +126,7 @@ jobs: if: ${{ steps.cache.outputs.cache-hit != 'true' }} run: | brew update - export ARCHITECHURE=$(uname -m) - if [[ "$ARCHITECHURE" != "x86_64" ]]; then - brew remove unxip - else - brew remove ruby@3.0 - fi + brew remove ruby@3.0 # workaround for https://github.com/actions/setup-python/issues/577 for pkg in $(brew list | grep '^python@'); do brew unlink "$pkg" @@ -405,44 +343,18 @@ jobs: echo "CC=gcc-${vers}" >> $GITHUB_ENV echo "CXX=g++-${vers}" >> $GITHUB_ENV else - echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV - export ARCHITECHURE=$(uname -m) - if [[ "$ARCHITECHURE" == "arm64" ]]; then - cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') - if [[ "${cling_on}" == "ON" ]]; then - brew install llvm@15 - brew remove llvm@18 - brew cleanup - #FIXME: Do not believe setting all these environment variables are necessary - # They were set to avoid using Xcodes libc++ and to stop CppInterOp using llvm@18 in tests - echo 'LDFLAGS="-L/opt/homebrew/opt/llvm@15/lib/ -L/opt/homebrew/opt/llvm@15/c++/"' >> $GITHUB_ENV - echo 'CPPFLAGS="-I/opt/homebrew/opt/llvm@15/include"' >> $GITHUB_ENV - echo 'CPATH="/opt/homebrew/include/"' >> $GITHUB_ENV - echo 'LIBRARY_PATH="/opt/homebrew/lib/"' >> $GITHUB_ENV - echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV - else - echo "CC=$(brew --prefix llvm@18)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@18)/bin/clang++" >> $GITHUB_ENV - fi - else - echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV - fi + echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV fi + echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV env: compiler: ${{ matrix.compiler }} - name: Install deps run: | brew update --force - export ARCHITECHURE=$(uname -m) - if [[ "$ARCHITECHURE" == "x86_64" ]]; then - brew remove ruby@3.0 - brew remove swiftlint - else - brew remove unxip - fi + brew remove ruby@3.0 + brew remove swiftlint # workaround for https://github.com/actions/setup-python/issues/577 for pkg in $(brew list | grep '^python@'); do brew unlink "$pkg" diff --git a/README.md b/README.md index 65fc70381..a040179d8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ [![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS.yml) +[![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS-arm.yml) + [![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/Windows.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/Windows.yml) [![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/emscripten.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/emscripten.yml) From bdd538646ceb1a6daca3bc120f56f01fcfdec781 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 22 Jan 2025 20:44:23 +0000 Subject: [PATCH 2/3] Remove jobs for other architechtures from each MacOS workflow --- .github/workflows/MacOS-arm.yml | 67 --------------------------------- .github/workflows/MacOS.yml | 31 --------------- 2 files changed, 98 deletions(-) diff --git a/.github/workflows/MacOS-arm.yml b/.github/workflows/MacOS-arm.yml index a10c79a69..352faa9bf 100644 --- a/.github/workflows/MacOS-arm.yml +++ b/.github/workflows/MacOS-arm.yml @@ -58,42 +58,6 @@ jobs: cling-version: '1.0' llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" - - name: osx13-x86-clang-clang-repl-19 - os: macos-13 - compiler: clang - clang-runtime: '19' - cling: Off - llvm_enable_projects: "clang" - llvm_targets_to_build: "host" - - name: osx13-x86-clang-clang-repl-18 - os: macos-13 - compiler: clang - clang-runtime: '18' - cling: Off - llvm_enable_projects: "clang" - llvm_targets_to_build: "host" - - name: osx13-x86-clang-clang-repl-17 - os: macos-13 - compiler: clang - clang-runtime: '17' - cling: Off - llvm_enable_projects: "clang" - llvm_targets_to_build: "host" - - name: osx13-x86-clang-clang-repl-16 - os: macos-13 - compiler: clang - clang-runtime: '16' - cling: Off - llvm_enable_projects: "clang" - llvm_targets_to_build: "host" - - name: osx13-x86-clang-clang13-cling - os: macos-13 - compiler: clang - clang-runtime: '13' - cling: On - cling-version: '1.0' - llvm_enable_projects: "clang" - llvm_targets_to_build: "host;NVPTX" steps: - uses: actions/checkout@v4 @@ -318,37 +282,6 @@ jobs: cling: On cling-version: '1.0' cppyy: On - - name: osx13-x86-clang-clang-repl-19-cppyy - os: macos-13 - compiler: clang - clang-runtime: '19' - cling: Off - cppyy: On - - name: osx13-x86-clang-clang-repl-18-cppyy - os: macos-13 - compiler: clang - clang-runtime: '18' - cling: Off - cppyy: On - - 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-clang13-cling-cppyy - os: macos-13 - compiler: clang - clang-runtime: '13' - cling: On - cling-version: '1.0' - cppyy: On steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/MacOS.yml b/.github/workflows/MacOS.yml index d882ed748..5777a5619 100644 --- a/.github/workflows/MacOS.yml +++ b/.github/workflows/MacOS.yml @@ -236,37 +236,6 @@ jobs: fail-fast: false matrix: include: - - name: osx15-arm-clang-clang-repl-19-cppyy - os: macos-15 - compiler: clang - clang-runtime: '19' - cling: Off - cppyy: On - - name: osx15-arm-clang-clang-repl-18-cppyy - os: macos-15 - compiler: clang - clang-runtime: '18' - cling: Off - cppyy: On - - name: osx15-arm-clang-clang-repl-17-cppyy - os: macos-15 - compiler: clang - clang-runtime: '17' - cling: Off - cppyy: On - - name: osx15-arm-clang-clang-repl-16 - os: macos-15 - compiler: clang - clang-runtime: '16' - cling: Off - cppyy: Off - - name: osx15-arm-clang-clang13-cling-cppyy - os: macos-15 - compiler: clang - clang-runtime: '13' - cling: On - cling-version: '1.0' - cppyy: On - name: osx13-x86-clang-clang-repl-19-cppyy os: macos-13 compiler: clang From 0c2e4d45176617b59ba4b2fbbfa8053018c8d936 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Thu, 23 Jan 2025 08:56:00 +0000 Subject: [PATCH 3/3] Fix MacOS-arm badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a040179d8..fe5fdc33d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS.yml) -[![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS-arm.yml) +[![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS-arm.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/MacOS-arm.yml) [![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/Windows.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/Windows.yml)