Adds duplication check for source files in CI

This commit is contained in:
George Xanthakis 2020-11-07 00:00:37 +02:00
parent fefa001bb6
commit 39e13bf530
No known key found for this signature in database
GPG Key ID: 41DF4D92B11E1073
2 changed files with 25 additions and 8 deletions

View File

@ -5,16 +5,13 @@ name: Check header guards
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
# Set the job key. The key is displayed as the job name build:
# when a job name is not provided
checkguard:
# Name the Job
name: Check include guard naming convention
# Set the type of machine to run on # Set the type of machine to run on
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2
- name: Checkout source code
uses: actions/checkout@v2
- name: Setup Dependencies - name: Setup Dependencies
uses: actions/setup-python@v2 uses: actions/setup-python@v2
@ -23,7 +20,8 @@ jobs:
- name: Install checkguard - name: Install checkguard
run: pip install guardonce run: pip install guardonce
- name: Run checkguard # Check include guard naming convention
- name: checkguard
run: | run: |
wrong_files=$(checkguard -r src/catch2/ -p "name | append _INCLUDED | upper") wrong_files=$(checkguard -r src/catch2/ -p "name | append _INCLUDED | upper")
if [[ $wrong_files ]]; then if [[ $wrong_files ]]; then
@ -31,3 +29,8 @@ jobs:
echo $wrong_files echo $wrong_files
exit 1 exit 1
fi fi
# Check duplicate files for include guard conflicts
- name: checknames
run: |
python tools/scripts/checkDuplicateFilenames.py

View File

@ -0,0 +1,14 @@
#!/usr/bin/env python3
import os
import sys
files_set = set()
for root, dir, files in os.walk("src/catch2"):
for file in files:
if file not in files_set:
files_set.add(file)
else:
print("File %s is duplicate" % file)
sys.exit(1)