v0.38.4 changes #11
Workflow file for this run
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
# GitHub Action that verifies C++ source compliance with cpplint | |
name: Code Guidelines | |
on: | |
push: | |
paths: | |
- .github/workflows/code_guidelines.yml | |
- src/**.cpp | |
- src/**.h | |
pull_request: | |
paths: | |
- .github/workflows/code_guidelines.yml | |
- src/**.cpp | |
- src/**.h | |
jobs: | |
cpplint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- run: python -m pip install cpplint | |
- name: cpplint | |
shell: python | |
run: | | |
import os | |
import re | |
import subprocess | |
import sys | |
import glob | |
print("Python {}.{}.{}".format(*sys.version_info)) | |
print("cpplint:") | |
result = subprocess.run(["cpplint", "--filter=-build/include_subdir,-build/c++11,-whitespace", "--linelength=120", "--root=src", "--recursive", "src"], text=True) | |
if result.returncode: | |
sys.exit(result.returncode) | |
source_files = glob.glob('src/**/*.*', recursive=True) | |
cpp_exts = tuple(".c .c++ .cc .cpp .cu .cuh .cxx .h .h++ .hh .hpp .hxx".split()) | |
cpp_files = [file for file in source_files if file.lower().endswith(cpp_exts)] | |
print(f"{len(cpp_files)} C++ files were found.") | |
space_files = [file for file in cpp_files if " " in file] | |
if space_files: | |
print(f"{len(space_files)} files contain space character:") | |
print("\n".join(space_files) + "\n") | |
bad_files = len(space_files) | |
if bad_files: | |
sys.exit(bad_files) |