Skip to content

lint

lint #1550

Workflow file for this run

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@v6
- 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:
name: Run clang-tidy and flake8 on ${{ matrix.os }}
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 # for Ubuntu runner
PIP_BREAK_SYSTEM_PACKAGES: 1 # disabling PEP668 (for MacOS runner)
# 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-26-Readme.md
# use macos-26-intel to have bigger 14 GB RAM; otherwise, macos-26-arm64 only has 7GB RAM
os: [ubuntu-24.04, macos-26-intel]
cmake_build_type: [Debug]
fail-fast: false
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: event name
run: |
echo "github.event_name: ${{ github.event_name }}"
- name: setup dependencies for Linux
if: runner.os == 'Linux'
uses: ./.github/actions/setup_linux
with:
workflow: 'lint'
- name: setup dependencies for macOS
if: runner.os == 'macOS'
uses: ./.github/actions/setup_macos
with:
workflow: 'lint'
- 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: make pilot
run: |
make pilot \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
- name: make run_pilot_pytest
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)"
- 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]
# 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: ${{ needs.tidy_flake8.result }}
secrets:
EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}