From 39e13bf530def088c1f87a224de48fdc1ac5e834 Mon Sep 17 00:00:00 2001 From: George Xanthakis Date: Sat, 7 Nov 2020 00:00:37 +0200 Subject: [PATCH] Adds duplication check for source files in CI --- .github/workflows/validate-header-guards.yml | 19 +++++++++++-------- tools/scripts/checkDuplicateFilenames.py | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 tools/scripts/checkDuplicateFilenames.py diff --git a/.github/workflows/validate-header-guards.yml b/.github/workflows/validate-header-guards.yml index c57bd8f3..6aa905a3 100644 --- a/.github/workflows/validate-header-guards.yml +++ b/.github/workflows/validate-header-guards.yml @@ -5,16 +5,13 @@ name: Check header guards on: [push, pull_request] jobs: - # Set the job key. The key is displayed as the job name - # when a job name is not provided - checkguard: - # Name the Job - name: Check include guard naming convention + build: # Set the type of machine to run on runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + + - name: Checkout source code + uses: actions/checkout@v2 - name: Setup Dependencies uses: actions/setup-python@v2 @@ -23,7 +20,8 @@ jobs: - name: Install checkguard run: pip install guardonce - - name: Run checkguard + # Check include guard naming convention + - name: checkguard run: | wrong_files=$(checkguard -r src/catch2/ -p "name | append _INCLUDED | upper") if [[ $wrong_files ]]; then @@ -31,3 +29,8 @@ jobs: echo $wrong_files exit 1 fi + + # Check duplicate files for include guard conflicts + - name: checknames + run: | + python tools/scripts/checkDuplicateFilenames.py diff --git a/tools/scripts/checkDuplicateFilenames.py b/tools/scripts/checkDuplicateFilenames.py new file mode 100644 index 00000000..b46a2b4b --- /dev/null +++ b/tools/scripts/checkDuplicateFilenames.py @@ -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)