Remove Travis CI style checks and unnecessary scripts
This commit is contained in:
parent
9986439352
commit
16f7b464b6
30
.travis.yml
30
.travis.yml
|
@ -19,16 +19,6 @@ cache:
|
|||
|
||||
matrix:
|
||||
include:
|
||||
- name: Static checks (clang-format) + Documentation checks
|
||||
stage: build
|
||||
env: STATIC_CHECKS=yes
|
||||
os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-format-8
|
||||
|
||||
- name: Linux editor (debug, GCC 9, with Mono)
|
||||
stage: build
|
||||
env: PLATFORM=linuxbsd TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-9 MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes"
|
||||
|
@ -130,10 +120,6 @@ install:
|
|||
./emsdk/emsdk install latest;
|
||||
./emsdk/emsdk activate --no-embedded latest;
|
||||
fi
|
||||
- if [ "$STATIC_CHECKS" = "yes" ]; then
|
||||
unset SCONS_CACHE;
|
||||
pip3 install --user black pygments;
|
||||
fi
|
||||
|
||||
before_script:
|
||||
- if [ "$PLATFORM" = "android" ]; then
|
||||
|
@ -142,15 +128,9 @@ before_script:
|
|||
fi
|
||||
|
||||
script:
|
||||
- if [ "$STATIC_CHECKS" = "yes" ]; then
|
||||
sh ./misc/travis/clang-format.sh &&
|
||||
sh ./misc/travis/black-format.sh &&
|
||||
doc/tools/makerst.py --dry-run doc/classes modules;
|
||||
else
|
||||
scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS &&
|
||||
if [ "$TEST_PROJECT" = "yes" ]; then
|
||||
git clone --depth 1 "https://github.com/godotengine/godot-tests.git";
|
||||
sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.linuxbsd.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg;
|
||||
godot-tests/tests/project_export/test_project.sh "bin/godot_server.linuxbsd.opt.tools.64";
|
||||
fi
|
||||
- scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS &&
|
||||
if [ "$TEST_PROJECT" = "yes" ]; then
|
||||
git clone --depth 1 "https://github.com/godotengine/godot-tests.git";
|
||||
sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.linuxbsd.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg;
|
||||
godot-tests/tests/project_export/test_project.sh "bin/godot_server.linuxbsd.opt.tools.64";
|
||||
fi
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
header = """\
|
||||
/*************************************************************************/
|
||||
/* $filename */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
"""
|
||||
|
||||
files = open("files", "r")
|
||||
|
||||
fname = files.readline()
|
||||
|
||||
while fname != "":
|
||||
|
||||
# Handle replacing $filename with actual filename and keep alignment
|
||||
fsingle = fname.strip()
|
||||
if fsingle.find("/") != -1:
|
||||
fsingle = fsingle[fsingle.rfind("/") + 1 :]
|
||||
rep_fl = "$filename"
|
||||
rep_fi = fsingle
|
||||
len_fl = len(rep_fl)
|
||||
len_fi = len(rep_fi)
|
||||
# Pad with spaces to keep alignment
|
||||
if len_fi < len_fl:
|
||||
for x in range(len_fl - len_fi):
|
||||
rep_fi += " "
|
||||
elif len_fl < len_fi:
|
||||
for x in range(len_fi - len_fl):
|
||||
rep_fl += " "
|
||||
if header.find(rep_fl) != -1:
|
||||
text = header.replace(rep_fl, rep_fi)
|
||||
else:
|
||||
text = header.replace("$filename", fsingle)
|
||||
text += "\n"
|
||||
|
||||
# We now have the proper header, so we want to ignore the one in the original file
|
||||
# and potentially empty lines and badly formatted lines, while keeping comments that
|
||||
# come after the header, and then keep everything non-header unchanged.
|
||||
# To do so, we skip empty lines that may be at the top in a first pass.
|
||||
# In a second pass, we skip all consecutive comment lines starting with "/*",
|
||||
# then we can append the rest (step 2).
|
||||
|
||||
fileread = open(fname.strip(), "r")
|
||||
line = fileread.readline()
|
||||
header_done = False
|
||||
|
||||
while line.strip() == "": # Skip empty lines at the top
|
||||
line = fileread.readline()
|
||||
|
||||
if line.find("/**********") == -1: # Godot header starts this way
|
||||
# Maybe starting with a non-Godot comment, abort header magic
|
||||
header_done = True
|
||||
|
||||
while not header_done: # Handle header now
|
||||
if line.find("/*") != 0: # No more starting with a comment
|
||||
header_done = True
|
||||
if line.strip() != "":
|
||||
text += line
|
||||
line = fileread.readline()
|
||||
|
||||
while line != "": # Dump everything until EOF
|
||||
text += line
|
||||
line = fileread.readline()
|
||||
|
||||
fileread.close()
|
||||
|
||||
# Write
|
||||
filewrite = open(fname.strip(), "w")
|
||||
filewrite.write(text)
|
||||
filewrite.close()
|
||||
|
||||
# Next file
|
||||
fname = files.readline()
|
||||
|
||||
files.close()
|
|
@ -1,78 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Command line arguments
|
||||
run_black=false
|
||||
run_clang_format=false
|
||||
run_fix_headers=false
|
||||
usage="Invalid argument. Usage:\n$0 <option>\n\t--black|-b\n\t--clang-format|-c\n\t--headers|-h\n\t--all|-a"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo -e $usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--black|-b)
|
||||
run_black=true
|
||||
;;
|
||||
--clang-format|-c)
|
||||
run_clang_format=true
|
||||
;;
|
||||
--headers|-h)
|
||||
run_fix_headers=true
|
||||
;;
|
||||
--all|-a)
|
||||
run_black=true
|
||||
run_clang_format=true
|
||||
run_fix_headers=true
|
||||
;;
|
||||
*)
|
||||
echo -e $usage
|
||||
exit 0
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo "Removing generated files, some have binary data and make clang-format freeze."
|
||||
find -name "*.gen.*" -delete
|
||||
|
||||
# Apply black
|
||||
if $run_black; then
|
||||
echo -e "Formatting Python files..."
|
||||
PY_FILES=$(find \( -path "./.git" \
|
||||
-o -path "./thirdparty" \
|
||||
\) -prune \
|
||||
-o \( -name "SConstruct" \
|
||||
-o -name "SCsub" \
|
||||
-o -name "*.py" \
|
||||
\) -print)
|
||||
black -l 120 $PY_FILES
|
||||
fi
|
||||
|
||||
# Apply clang-format
|
||||
if $run_clang_format; then
|
||||
# Sync list with pre-commit hook
|
||||
FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc .java .glsl"
|
||||
|
||||
for extension in ${FILE_EXTS}; do
|
||||
echo -e "Formatting ${extension} files..."
|
||||
find \( -path "./.git" \
|
||||
-o -path "./thirdparty" \
|
||||
-o -path "./platform/android/java/lib/src/com/google" \
|
||||
\) -prune \
|
||||
-o -name "*${extension}" \
|
||||
-exec clang-format -i {} \;
|
||||
done
|
||||
fi
|
||||
|
||||
# Add missing copyright headers
|
||||
if $run_fix_headers; then
|
||||
echo "Fixing copyright headers in Godot code files..."
|
||||
find \( -path "./.git" -o -path "./thirdparty" \) -prune \
|
||||
-o -regex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|m\|mm\|java\)' \
|
||||
> tmp-files
|
||||
cat tmp-files | grep -v ".git\|thirdparty\|theme_data.h\|platform/android/java/lib/src/com/google\|platform/android/java/lib/src/org/godotengine/godot/input/InputManager" > files
|
||||
python misc/scripts/fix_headers.py
|
||||
rm -f tmp-files files
|
||||
fi
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
BLACK=black
|
||||
BLACK_OPTIONS="-l 120"
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||
# Travis only clones the PR branch and uses its HEAD commit as detached HEAD,
|
||||
# so it's problematic when we want an exact commit range for format checks.
|
||||
# We fetch upstream to ensure that we have the proper references to resolve.
|
||||
# Ideally we would use $TRAVIS_COMMIT_RANGE but it doesn't play well with PR
|
||||
# updates, as it only includes changes since the previous state of the PR.
|
||||
if [ -z "$(git remote | grep upstream)" ]; then
|
||||
git remote add upstream https://github.com/godotengine/godot \
|
||||
--no-tags -f -t $TRAVIS_BRANCH
|
||||
fi
|
||||
RANGE="upstream/$TRAVIS_BRANCH HEAD"
|
||||
else
|
||||
# Test only the last commit, since $TRAVIS_COMMIT_RANGE wouldn't support
|
||||
# force pushes.
|
||||
RANGE=HEAD
|
||||
fi
|
||||
|
||||
FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/| grep -E "(SConstruct|SCsub|\.py)$")
|
||||
echo "Checking files:\n$FILES"
|
||||
|
||||
# create a random filename to store our generated patch
|
||||
prefix="static-check-black"
|
||||
suffix="$(date +%s)"
|
||||
patch="/tmp/$prefix-$suffix.patch"
|
||||
|
||||
for file in $FILES; do
|
||||
"$BLACK" "$BLACK_OPTIONS" --diff "$file" | \
|
||||
sed -e "1s|--- |--- a/|" -e "2s|+++ |+++ b/|" >> "$patch"
|
||||
done
|
||||
|
||||
# if no patch has been generated all is ok, clean up the file stub and exit
|
||||
if [ ! -s "$patch" ] ; then
|
||||
printf "Files in this commit comply with the black formatting rules.\n"
|
||||
rm -f "$patch"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# a patch has been created, notify the user and exit
|
||||
printf "\n*** The following differences were found between the code to commit "
|
||||
printf "and the black formatting rules:\n\n"
|
||||
pygmentize -l diff "$patch"
|
||||
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
||||
exit 1
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
CLANG_FORMAT=clang-format-8
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||
# Travis only clones the PR branch and uses its HEAD commit as detached HEAD,
|
||||
# so it's problematic when we want an exact commit range for format checks.
|
||||
# We fetch upstream to ensure that we have the proper references to resolve.
|
||||
# Ideally we would use $TRAVIS_COMMIT_RANGE but it doesn't play well with PR
|
||||
# updates, as it only includes changes since the previous state of the PR.
|
||||
if [ -z "$(git remote | grep upstream)" ]; then
|
||||
git remote add upstream https://github.com/godotengine/godot \
|
||||
--no-tags -f -t $TRAVIS_BRANCH
|
||||
fi
|
||||
RANGE="upstream/$TRAVIS_BRANCH HEAD"
|
||||
else
|
||||
# Test only the last commit, since $TRAVIS_COMMIT_RANGE wouldn't support
|
||||
# force pushes.
|
||||
RANGE=HEAD
|
||||
fi
|
||||
|
||||
FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -v platform/android/java/lib/src/com/ | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc|java|glsl)$")
|
||||
echo "Checking files:\n$FILES"
|
||||
|
||||
# create a random filename to store our generated patch
|
||||
prefix="static-check-clang-format"
|
||||
suffix="$(date +%s)"
|
||||
patch="/tmp/$prefix-$suffix.patch"
|
||||
|
||||
for file in $FILES; do
|
||||
"$CLANG_FORMAT" -style=file "$file" | \
|
||||
diff -u "$file" - | \
|
||||
sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch"
|
||||
done
|
||||
|
||||
# if no patch has been generated all is ok, clean up the file stub and exit
|
||||
if [ ! -s "$patch" ] ; then
|
||||
printf "Files in this commit comply with the clang-format rules.\n"
|
||||
rm -f "$patch"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# a patch has been created, notify the user and exit
|
||||
printf "\n*** The following differences were found between the code to commit "
|
||||
printf "and the clang-format rules:\n\n"
|
||||
pygmentize -l diff "$patch"
|
||||
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
||||
exit 1
|
Loading…
Reference in New Issue