lint #534
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: lint | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '34 17 * * *' | |
jobs: | |
clang_format_check: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
path: | |
- 'cpp' | |
- 'gtests' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: event name | |
run: | | |
echo "github.event_name: ${{ github.event_name }}" | |
- name: Run clang-format style check for C/C++/Protobuf programs. | |
uses: jidicula/[email protected] | |
with: | |
clang-format-version: '16' | |
check-path: ${{ matrix.path }} | |
fallback-style: 'LLVM' # optional | |
tidy_flake8_ubuntu: | |
if: ${{ github.event_name != '' || (github.event_name == '' && github.repository_owner == 'solvcon') }} | |
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 | |
strategy: | |
matrix: | |
os: [ubuntu-22.04] | |
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 }}" | |
- name: dependency by apt | |
run: | | |
VERSION_ID=$(bash -c 'source /etc/os-release ; echo $VERSION_ID') | |
if [ "20.04" == "$VERSION_ID" ] ; then CLANG_TIDY_VERSION=10 ; else CLANG_TIDY_VERSION=14 ; fi | |
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-${CLANG_TIDY_VERSION} \ | |
python3 python3-dev python3-venv | |
sudo ln -fs "$(which clang-tidy-${CLANG_TIDY_VERSION})" "$(dirname $(which clang-tidy-${CLANG_TIDY_VERSION}))/clang-tidy" | |
# Install qt6 only with ubuntu-22.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 out the correct lib path. | |
if [ "${{ matrix.os }}" == "ubuntu-22.04" ] ; then \ | |
sudo apt-get -qy install \ | |
qt6-3d-dev xvfb \ | |
libgl1-mesa-dev | |
fi | |
- name: dependency by pip | |
run: | | |
sudo pip3 install setuptools | |
sudo pip3 install numpy pytest flake8 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 "pip3 path: $(which pip3)" | |
python3 -c 'import numpy ; print("numpy.__version__:", numpy.__version__)' | |
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: make cinclude (check_include) | |
run: make cinclude | |
- name: make viewer | |
run: | | |
make viewer \ | |
${JOB_MAKE_ARGS} \ | |
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ | |
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)" | |
- name: make run_viewer_pytest | |
run: | | |
export LD_LIBRARY_PATH=$(python3 -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))") | |
make run_viewer_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)" | |
tidy_flake8_macos: | |
if: ${{ github.event_name != '' || (github.event_name == '' && github.repository_owner == 'solvcon') }} | |
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 | |
strategy: | |
matrix: | |
# https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md | |
os: [macos-12] | |
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 }}" | |
- name: dependency by homebrew | |
run: | | |
# brew update # No update because it is slow | |
# Force using python 3.10 from homebrew | |
brew unlink python | |
brew link --force --overwrite [email protected] | |
brew install llvm qt6 | |
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format" | |
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy" | |
- name: dependency by pip | |
run: | | |
echo "which python3: $(which python3)" | |
ls -al $(which python3) | |
python3 -m pip -v install --upgrade setuptools | |
python3 -m pip -v install --upgrade pip | |
python3 -m pip -v install --upgrade numpy pytest flake8 pyside6==$(qmake -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 "pip3 path: $(which pip3)" | |
python3 -c 'import numpy ; print("numpy.__version__:", numpy.__version__)' | |
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: make cinclude (check_include) | |
run: make cinclude | |
- name: make viewer | |
run: | | |
make viewer \ | |
${JOB_MAKE_ARGS} \ | |
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ | |
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)" | |
- name: make run_viewer_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_viewer_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)" |