From 131a081e083d20ed27114afc5a9f1420d556b362 Mon Sep 17 00:00:00 2001 From: Juan Ramos Date: Thu, 19 Oct 2023 11:25:22 -0600 Subject: [PATCH] scripts: Remove unused scripts Checking the CI logs these scripts have not been run properly on GitHub actions CI for a long time. I can't find a log in GitHub actions CI that shows these scripts working properly. --- .github/workflows/build.yml | 6 -- scripts/check_code_format.sh | 41 --------- scripts/check_commit_message_format.sh | 102 -------------------- scripts/clang-format-diff.py | 123 ------------------------- 4 files changed, 272 deletions(-) delete mode 100755 scripts/check_code_format.sh delete mode 100755 scripts/check_commit_message_format.sh delete mode 100644 scripts/clang-format-diff.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9bde99064..0bb028f59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,12 +86,6 @@ jobs: - name: Verify generated source files run: python scripts/generate_source.py --verify external/${{matrix.config}}/Vulkan-Headers/registry - - name: Verify code formatting with clang-format - run: ./scripts/check_code_format.sh - - - name: Verify commit message formatting - run: ./scripts/check_commit_message_format.sh - linux-no-asm: runs-on: ubuntu-22.04 diff --git a/scripts/check_code_format.sh b/scripts/check_code_format.sh deleted file mode 100755 index 2107fbdf2..000000000 --- a/scripts/check_code_format.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Copyright (c) 2017 Google Inc. - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Script to determine if source code in Pull Request is properly formatted. -# Exits with non 0 exit code if formatting is needed. -# -# This script assumes to be invoked at the project root directory. - -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' # No Color - -FILES_TO_CHECK=$(git diff --name-only main grep -E ".*\.(cpp|cc|c\+\+|cxx|c|h|hpp)$") - -if [ -z "${FILES_TO_CHECK}" ]; then - echo -e "${GREEN}No source code to check for formatting.${NC}" - exit 0 -fi - -FORMAT_DIFF=$(git diff -U0 main -- ${FILES_TO_CHECK} | python ./scripts/clang-format-diff.py -p1 -style=file) - -if [ -z "${FORMAT_DIFF}" ]; then - echo -e "${GREEN}All source code in PR properly formatted.${NC}" - exit 0 -else - echo -e "${RED}Found formatting errors!${NC}" - echo "${FORMAT_DIFF}" - exit 1 -fi diff --git a/scripts/check_commit_message_format.sh b/scripts/check_commit_message_format.sh deleted file mode 100755 index 29666356a..000000000 --- a/scripts/check_commit_message_format.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/bash -# Copyright (c) 2018 Valve Corporation -# Copyright (c) 2018 LunarG, Inc. - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Checks commit messages against project standards in CONTRIBUTING.md document -# Script to determine if commit messages in Pull Request are properly formatted. -# Exits with non 0 exit code if reformatting is needed. - -# Disable subshells -shopt -s lastpipe - -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' # No Color - -# TRAVIS_COMMIT_RANGE contains range of commits for this PR - -# Get user-supplied commit message text for applicable commits and insert -# a unique separator string identifier. The git command returns ONLY the -# subject line and body for each of the commits. -COMMIT_TEXT=$(git log ${TRAVIS_COMMIT_RANGE} --pretty=format:"XXXNEWLINEXXX"%n%B) - -# Bail if there are none -if [ -z "${COMMIT_TEXT}" ]; then - echo -e "${GREEN}No commit messgages to check for formatting.${NC}" - exit 0 -elif ! echo $TRAVIS_COMMIT_RANGE | grep -q "\.\.\."; then - echo -e "${GREEN}No commit messgages to check for formatting.${NC}" - exit 0 -fi - -# Process commit messages -success=1 -current_line=0 -prevline="" - -# Process each line of the commit message output, resetting counter on separator -printf %s "$COMMIT_TEXT" | while IFS='' read -r line; do - # echo "Count = $current_line = $line" - current_line=$((current_line+1)) - if [ "$line" = "XXXNEWLINEXXX" ]; then - current_line=0 - fi - chars=${#line} - if [ $current_line -eq 1 ]; then - # Subject line should be 50 chars or less (but give some slack here) - if [ $chars -gt 54 ]; then - echo "The following subject line exceeds 50 characters in length." - echo " '$line'" - success=0 - fi - i=$(($chars-1)) - last_char=${line:$i:1} - # Output error if last char of subject line is not alpha-numeric - if [[ ! $last_char =~ [0-9a-zA-Z] ]]; then - echo "For the following commit, the last character of the subject line must not be non-alphanumeric." - echo " '$line'" - success=0 - fi - # Checking if subject line doesn't start with 'module: ' - prefix=$(echo $line | cut -f1 -d " ") - if [ "${prefix: -1}" != ":" ]; then - echo "The following subject line must start with a single word specifying the functional area of the change, followed by a colon and space. I.e., 'layers: Subject line here'" - echo " '$line'" - success=0 - fi - elif [ $current_line -eq 2 ]; then - # Commit message must have a blank line between subject and body - if [ $chars -ne 0 ]; then - echo "The following subject line must be followed by a blank line." - echo " '$prevline'" - success=0 - fi - else - # Lines in a commit message body must be less than 72 characters in length (but give some slack) - if [ $chars -gt 76 ]; then - echo "The following commit message body line exceeds the 72 character limit." - echo "'$line\'" - success=0 - fi - fi - prevline=$line -done - -if [ $success -eq 1 ]; then - echo -e "${GREEN}All commit messages in pull request are properly formatted.${NC}" - exit 0 -else - exit 1 -fi diff --git a/scripts/clang-format-diff.py b/scripts/clang-format-diff.py deleted file mode 100644 index 122db49ff..000000000 --- a/scripts/clang-format-diff.py +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env python -# -#===- clang-format-diff.py - ClangFormat Diff Reformatter ----*- python -*--===# -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===------------------------------------------------------------------------===# - -""" -This script reads input from a unified diff and reformats all the changed -lines. This is useful to reformat all the lines touched by a specific patch. -Example usage for git/svn users: - - git diff -U0 --no-color HEAD^ | clang-format-diff.py -p1 -i - svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i - -""" -from __future__ import absolute_import, division, print_function - -import argparse -import difflib -import re -import subprocess -import sys - -if sys.version_info.major >= 3: - from io import StringIO -else: - from io import BytesIO as StringIO - - -def main(): - parser = argparse.ArgumentParser(description=__doc__, - formatter_class= - argparse.RawDescriptionHelpFormatter) - parser.add_argument('-i', action='store_true', default=False, - help='apply edits to files instead of displaying a diff') - parser.add_argument('-p', metavar='NUM', default=0, - help='strip the smallest prefix containing P slashes') - parser.add_argument('-regex', metavar='PATTERN', default=None, - help='custom pattern selecting file paths to reformat ' - '(case sensitive, overrides -iregex)') - parser.add_argument('-iregex', metavar='PATTERN', default= - r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hh|hpp|m|mm|inc|js|ts|proto' - r'|protodevel|java|cs)', - help='custom pattern selecting file paths to reformat ' - '(case insensitive, overridden by -regex)') - parser.add_argument('-sort-includes', action='store_true', default=False, - help='let clang-format sort include blocks') - parser.add_argument('-v', '--verbose', action='store_true', - help='be more verbose, ineffective without -i') - parser.add_argument('-style', - help='formatting style to apply (LLVM, Google, Chromium, ' - 'Mozilla, WebKit)') - parser.add_argument('-binary', default='clang-format', - help='location of binary to use for clang-format') - args = parser.parse_args() - - # Extract changed lines for each file. - filename = None - lines_by_file = {} - for line in sys.stdin: - match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line) - if match: - filename = match.group(2) - if filename == None: - continue - - if args.regex is not None: - if not re.match('^%s$' % args.regex, filename): - continue - else: - if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE): - continue - - match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line) - if match: - start_line = int(match.group(1)) - line_count = 1 - if match.group(3): - line_count = int(match.group(3)) - if line_count == 0: - continue - end_line = start_line + line_count - 1 - lines_by_file.setdefault(filename, []).extend( - ['-lines', str(start_line) + ':' + str(end_line)]) - - # Reformat files containing changes in place. - for filename, lines in lines_by_file.items(): - if args.i and args.verbose: - print('Formatting {}'.format(filename)) - command = [args.binary, filename] - if args.i: - command.append('-i') - if args.sort_includes: - command.append('-sort-includes') - command.extend(lines) - if args.style: - command.extend(['-style', args.style]) - p = subprocess.Popen(command, - stdout=subprocess.PIPE, - stderr=None, - stdin=subprocess.PIPE, - universal_newlines=True) - stdout, stderr = p.communicate() - if p.returncode != 0: - sys.exit(p.returncode) - - if not args.i: - with open(filename) as f: - code = f.readlines() - formatted_code = StringIO(stdout).readlines() - diff = difflib.unified_diff(code, formatted_code, - filename, filename, - '(before formatting)', '(after formatting)') - diff_string = ''.join(diff) - if len(diff_string) > 0: - sys.stdout.write(diff_string) - -if __name__ == '__main__': - main()