mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-05 11:40:46 +08:00
Add cpplint to validate_filenames (#643)
* Add cpplint to validate_filenames * Update and rename Happy_number.cpp to happy_number.cpp * Update validate_new_filenames.yml * pip install cpplint * python3 -m pip install cpplint * python3 -m pip install --useer cpplint * python3 -m pip install --user cpplint * Update validate_new_filenames.yml * sudo python3 -m pip install cpplint * sudo python3 -m pip install cpplint * uses: actions/setup-python@v1 * Run cpplint first * cpp_exts * tuple * cpplint_modified_files
This commit is contained in:
@@ -1,21 +1,34 @@
|
||||
name: validate_new_filenames
|
||||
name: cpplint_modified_files
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
validate_new_filenames:
|
||||
cpplint_modified_files:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-python@v1
|
||||
- run: python -m pip install cpplint
|
||||
- run: git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
||||
- run: git diff origin/master --name-only > git_diff.txt
|
||||
- name: Validate new filenames
|
||||
- name: cpplint_modified_files
|
||||
shell: python
|
||||
run: |
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
print(sys.version_info) # legacy Python :-(
|
||||
|
||||
print("Python {}.{}.{}".format(*sys.version_info)) # legacy Python :-(
|
||||
with open("git_diff.txt") as in_file:
|
||||
cpp_files = sorted(line.strip() for line in in_file
|
||||
if line.strip().lower().endswith(".cpp"))
|
||||
modified_files = sorted(in_file.read().splitlines())
|
||||
print("{} files were modified.".format(len(modified_files)))
|
||||
|
||||
cpp_exts = tuple(".c .c++ .cc .cpp .cu .cuh .cxx .h .h++ .hh .hpp .hxx".split())
|
||||
cpp_files = [file for file in modified_files if file.lower().endswith(cpp_exts)]
|
||||
print("{} C++ files were modified.".format(len(cpp_files)))
|
||||
if not cpp_files:
|
||||
sys.exit(0)
|
||||
|
||||
print("cpplint:")
|
||||
print(subprocess.check_output(["cpplint"] + cpp_files).decode("utf-8"))
|
||||
|
||||
upper_files = [file for file in cpp_files if os.path.basename(file) != os.path.basename(file).lower()]
|
||||
if upper_files:
|
||||
Reference in New Issue
Block a user