test changed files CI in PR #225
This file contains hidden or 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: lint | |
| on: | |
| push: | |
| pull_request: | |
| schedule: | |
| - cron: '34 17 * * *' | |
| jobs: | |
| clang_format_check: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && vars.MMGH_NIGHTLY == 'enable') }} | |
| strategy: | |
| matrix: | |
| path: | |
| - 'cpp' | |
| - 'gtests' | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: event name | |
| run: | | |
| echo "github.event_name: ${{ github.event_name }}" | |
| - name: Add 8G swap (Ubuntu) | |
| # Prevent hitting runner's resource limits | |
| if: runner.os == 'Linux' | |
| run: | | |
| # Remove /swapfile first to avoid "fallocate: Text file busy" error | |
| sudo swapoff -a | |
| sudo rm -f /swapfile | |
| sudo fallocate -l 8G /swapfile | |
| sudo chmod 600 /swapfile | |
| sudo mkswap /swapfile | |
| sudo swapon /swapfile | |
| free -h | |
| - name: Run clang-format style check for C/C++/Protobuf programs. | |
| uses: jidicula/clang-format-action@v4.16.0 | |
| with: | |
| clang-format-version: '20' | |
| check-path: ${{ matrix.path }} | |
| fallback-style: 'LLVM' # optional | |
| tidy_flake8_ubuntu: | |
| if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && vars.MMGH_NIGHTLY == 'enable') }} | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| JOB_MAKE_ARGS: VERBOSE=1 BUILD_QT=ON USE_CLANG_TIDY=ON LINT_AS_ERRORS=ON | |
| QT_DEBUG_PLUGINS: 1 | |
| QT_QPA_PLATFORM: offscreen | |
| # Fix issue: https://github.com/solvcon/modmesh/issues/366 | |
| # Use custom config for jurplel/install-qt-action@v4 | |
| AQT_CONFIG: "thirdparty/aqt_settings.ini" | |
| strategy: | |
| matrix: | |
| os: [ubuntu-24.04] | |
| cmake_build_type: [Debug] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v1 | |
| if: github.event_name == 'pull_request' | |
| - uses: actions/checkout@v1 | |
| if: github.event_name != 'pull_request' | |
| with: | |
| fetch-depth: 1 | |
| - name: event name | |
| run: | | |
| echo "github.event_name: ${{ github.event_name }}" | |
| - name: Add 8G swap (Ubuntu) | |
| # Prevent hitting runner's resource limits when running clang-tidy | |
| if: runner.os == 'Linux' | |
| run: | | |
| # Remove /swapfile first to avoid "fallocate: Text file busy" error | |
| sudo swapoff -a | |
| sudo rm -f /swapfile | |
| sudo fallocate -l 8G /swapfile | |
| sudo chmod 600 /swapfile | |
| sudo mkswap /swapfile | |
| sudo swapon /swapfile | |
| free -h | |
| # Cache the downloaded/extracted Qt bits | |
| - name: Cache Qt download | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ github.workspace }}/Qt | |
| key: ${{ runner.os }}-qt-6.8.1-linux_gcc_64 | |
| # fallback to any previous Qt cache on this OS | |
| restore-keys: | | |
| ${{ runner.os }}-qt-6.8.1- | |
| - name: dependency by apt | |
| run: | | |
| # To update the cmake version > 4, install the latest cmake by kitware apt repository. | |
| # Reference: https://apt.kitware.com/ | |
| sudo apt-get -y update | |
| sudo apt-get -qy install ca-certificates gpg wget | |
| test -f /usr/share/doc/kitware-archive-keyring/copyright || \ | |
| wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \ | |
| gpg --dearmor - | \ | |
| sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null | |
| echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' | \ | |
| sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null | |
| sudo apt-get -qqy update | |
| test -f /usr/share/doc/kitware-archive-keyring/copyright || \ | |
| sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg | |
| sudo apt-get -qy install kitware-archive-keyring | |
| # The path of apt-get cmake is `/usr/bin/cmake`, | |
| # but the path of built-in cmake of runner image is `/usr/local/bin/cmake`. | |
| # We remove the built-in cmake. | |
| sudo rm -rf /usr/local/bin/cmake | |
| # Install clang-tidy-21 from LLVM repository for full C++23 support | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc | |
| echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" | sudo tee /etc/apt/sources.list.d/llvm.list | |
| sudo apt-get -qqy update | |
| sudo apt-get -qy install \ | |
| sudo curl git build-essential make cmake libc6-dev gcc g++ silversearcher-ag \ | |
| clang-tidy-21 \ | |
| python3 python3-dev python3-venv | |
| sudo ln -fs "$(which clang-tidy-21)" "/usr/local/bin/clang-tidy" | |
| # Install qt6 only with ubuntu-24.04 | |
| # This page explains why we need libgl1-mesa-dev | |
| # https://doc-snapshots.qt.io/qt6-dev/linux.html | |
| # | |
| # In short, OpenGL libraries and headers are required. Without | |
| # installing this package, cmake won't find the correct lib path. | |
| # This has been replaced by the 'install qt' section below to manage | |
| # qt6 versioning independently from the OS. | |
| # if [ "${{ matrix.os }}" == "ubuntu-24.04" ] ; then \ | |
| # sudo apt-get -qy install \ | |
| # qt6-3d-dev xvfb \ | |
| # libgl1-mesa-dev | |
| # fi | |
| - name: install and configure gcc-14 | |
| run: | | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | |
| sudo apt-get -qqy update | |
| sudo apt-get -qy install gcc-14 g++-14 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 | |
| sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 | |
| sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 100 | |
| sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-14 100 | |
| - name: install qt | |
| uses: jurplel/install-qt-action@v4 | |
| with: | |
| version: '6.8.1' | |
| host: 'linux' | |
| target: 'desktop' | |
| arch: 'linux_gcc_64' | |
| modules: 'qt3d' | |
| setup-python: 'false' | |
| cache: false | |
| - name: dependency by pip | |
| run: | | |
| sudo pip3 install setuptools | |
| sudo pip3 install numpy matplotlib pytest flake8 jsonschema pyside6==$(qmake6 -query QT_VERSION) | |
| - name: dependency (manual) | |
| run: sudo ${GITHUB_WORKSPACE}/contrib/dependency/install.sh pybind11 | |
| - name: show dependency | |
| # Copy the commands from contrib/dependency/showdep.sh | |
| run: | | |
| echo "gcc path: $(which gcc)" | |
| echo "gcc version: $(gcc --version)" | |
| echo "cmake path: $(which cmake)" | |
| echo "cmake version: $(cmake --version)" | |
| echo "python3 path: $(which python3)" | |
| echo "python3 version: $(python3 --version)" | |
| echo "python3-config --prefix: $(python3-config --prefix)" | |
| echo "python3-config --exec-prefix: $(python3-config --exec-prefix)" | |
| echo "python3-config --includes: $(python3-config --includes)" | |
| echo "python3-config --libs: $(python3-config --libs)" | |
| echo "python3-config --cflags: $(python3-config --cflags)" | |
| echo "python3-config --ldflags: $(python3-config --ldflags)" | |
| echo "pip3 path: $(which pip3)" | |
| python3 -c 'import numpy as np; print("np.__version__:", np.__version__, np.get_include())' | |
| echo "pytest path: $(which pytest)" | |
| echo "pytest version: $(pytest --version)" | |
| echo "clang-tidy path: $(which clang-tidy)" | |
| echo "clang-tidy version: $(clang-tidy -version)" | |
| echo "flake8 path: $(which flake8)" | |
| echo "flake8 version: $(flake8 --version)" | |
| - name: ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: ${{ runner.os }}-tidy-${{ matrix.cmake_build_type }} | |
| restore-keys: ${{ runner.os }}-tidy-${{ matrix.cmake_build_type }} | |
| create-symlink: true | |
| - name: make cinclude (check_include) | |
| run: make cinclude | |
| - name: make checkascii (check ASCII-only characters) | |
| run: make checkascii | |
| - name: make checktws (check trailing whitespace) | |
| run: make checktws | |
| - name: Run clang-tidy-diff.py only for changed files when making PR | |
| if: github.event_name == 'pull_request' | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| run: | | |
| git diff -U0 $BASE_SHA...HEAD | clang-tidy-diff.py -p1 | |
| - name: make run_pilot_pytest for clang-tidy all files when merging to master branch or on schedule | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| export LD_LIBRARY_PATH=$(python3 -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))") | |
| make run_pilot_pytest \ | |
| ${JOB_MAKE_ARGS} \ | |
| CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ | |
| CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON" | |
| - name: make flake8 | |
| run: | | |
| make flake8 \ | |
| ${JOB_MAKE_ARGS} \ | |
| CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ | |
| CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)" | |
| tidy_flake8_macos: | |
| if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && vars.MMGH_NIGHTLY == 'enable') }} | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| JOB_MAKE_ARGS: VERBOSE=1 BUILD_QT=ON USE_CLANG_TIDY=ON LINT_AS_ERRORS=ON | |
| QT_DEBUG_PLUGINS: 1 | |
| PIP_BREAK_SYSTEM_PACKAGES: 1 # disabling PEP668 | |
| # Fix issue: https://github.com/solvcon/modmesh/issues/366 | |
| # Use custom config for jurplel/install-qt-action@v4 | |
| AQT_CONFIG: "thirdparty/aqt_settings.ini" | |
| strategy: | |
| matrix: | |
| # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md | |
| # use macos-15-intel to have bigger 14 GB RAM; otherwise, macos-15 only has 7GB RAM | |
| os: [macos-15-intel] | |
| cmake_build_type: [Debug] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v1 | |
| with: | |
| fetch-depth: 1 | |
| - name: event name | |
| run: | | |
| echo "github.event_name: ${{ github.event_name }}" | |
| # Some mac runner does not have /usr/local/include and cmake sometimes crashes | |
| sudo mkdir -p /usr/local/include | |
| - name: dependency by homebrew | |
| run: | | |
| export HOMEBREW_NO_AUTO_UPDATE=1 | |
| export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 | |
| # This has been replaced by the 'install qt' section below to manage | |
| # qt6 versioning independently from the OS. | |
| # brew install llvm@21 qt6 | |
| brew install llvm@21 | |
| ln -s "$(brew --prefix llvm@21)/bin/clang-format" "/usr/local/bin/clang-format" | |
| ln -s "$(brew --prefix llvm@21)/bin/clang-tidy" "/usr/local/bin/clang-tidy" | |
| - name: install qt | |
| uses: jurplel/install-qt-action@v4 | |
| with: | |
| version: '6.8.1' | |
| host: 'mac' | |
| target: 'desktop' | |
| arch: 'clang_64' | |
| modules: 'qt3d' | |
| setup-python: 'false' | |
| cache: true | |
| - name: dependency by pip | |
| run: | | |
| echo "which python3: $(which python3)" | |
| ls -al $(which python3) | |
| # suppress the warning of pip because brew forces PEP668 since python3.12 | |
| python3 -m pip -v install --upgrade setuptools --break-system-packages | |
| python3 -m pip -v install --upgrade numpy matplotlib pytest flake8 jsonschema | |
| # For now (2024/10/22), pyside6 6.6.3 does not support Python 3.13. | |
| # Use --ignore-requires-python to force installation. | |
| python3 -m pip -v install --upgrade pyside6==$(qmake -query QT_VERSION) --ignore-requires-python | |
| - name: dependency (manual) | |
| run: sudo NO_INSTALL_PREFIX=1 ${GITHUB_WORKSPACE}/contrib/dependency/install.sh pybind11 | |
| - name: show dependency | |
| # Copy the commands from contrib/dependency/showdep.sh | |
| run: | | |
| echo "gcc path: $(which gcc)" | |
| echo "gcc version: $(gcc --version)" | |
| echo "cmake path: $(which cmake)" | |
| echo "cmake version: $(cmake --version)" | |
| echo "python3 path: $(which python3)" | |
| echo "python3 version: $(python3 --version)" | |
| echo "python3-config --prefix: $(python3-config --prefix)" | |
| echo "python3-config --exec-prefix: $(python3-config --exec-prefix)" | |
| echo "python3-config --includes: $(python3-config --includes)" | |
| echo "python3-config --libs: $(python3-config --libs)" | |
| echo "python3-config --cflags: $(python3-config --cflags)" | |
| echo "python3-config --ldflags: $(python3-config --ldflags)" | |
| echo "pip3 path: $(which pip3)" | |
| python3 -c 'import numpy as np; print("np.__version__:", np.__version__, np.get_include())' | |
| echo "pytest path: $(which pytest)" | |
| echo "pytest version: $(pytest --version)" | |
| echo "clang-tidy path: $(which clang-tidy)" | |
| echo "clang-tidy version: $(clang-tidy -version)" | |
| echo "flake8 path: $(which flake8)" | |
| echo "flake8 version: $(flake8 --version)" | |
| - name: ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: ${{ runner.os }}-tidy-${{ matrix.cmake_build_type }} | |
| restore-keys: ${{ runner.os }}-tidy-${{ matrix.cmake_build_type }} | |
| create-symlink: true | |
| - name: make cinclude (check_include) | |
| run: make cinclude | |
| - name: make checkascii (check ASCII-only characters) | |
| run: make checkascii | |
| - name: make pilot USE_PYTEST_HELPER_BINDING=OFF | |
| run: | | |
| make pilot \ | |
| ${JOB_MAKE_ARGS} \ | |
| CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ | |
| CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON" | |
| - name: make pilot USE_PYTEST_HELPER_BINDING=ON | |
| run: | | |
| rm -f build/*/Makefile | |
| make pilot \ | |
| ${JOB_MAKE_ARGS} \ | |
| CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ | |
| CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON" | |
| - name: make run_pilot_pytest | |
| run: | | |
| # PySide6 installed by pip will bundle with a prebuilt Qt, | |
| # this will cause duplicated symbol. | |
| # Solve this issue by removed PySide6 prebuilt Qt library | |
| rm -rf $(python3 -c "import sys, os, PySide6; sys.stdout.write(os.path.dirname(PySide6.__file__))")/Qt/lib/*.framework | |
| make run_pilot_pytest \ | |
| ${JOB_MAKE_ARGS} \ | |
| CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ | |
| CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)" | |
| - name: make flake8 | |
| run: | | |
| make flake8 \ | |
| ${JOB_MAKE_ARGS} \ | |
| CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ | |
| CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)" | |
| send_email_on_failure: | |
| needs: [clang_format_check, tidy_flake8_ubuntu, tidy_flake8_macos] | |
| # Run if any of the dependencies failed in master branch | |
| if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} | |
| uses: ./.github/workflows/send_email_on_fail.yml | |
| with: | |
| job_results: | | |
| - clang_format_check: ${{ needs.clang_format_check.result }} | |
| - tidy_flake8_ubuntu: ${{ needs.tidy_flake8_ubuntu.result }} | |
| - tidy_flake8_macos: ${{ needs.tidy_flake8_macos.result }} | |
| secrets: | |
| EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} | |
| EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} |