From 2c138bd75f78747c6008a8308897cb6fbd8b1822 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Fri, 24 Jul 2020 21:56:43 -0400 Subject: [PATCH] Tweak CI to more closely match the main repo --- .github/workflows/{ci.yml => static_checks.yml} | 12 ++++++++---- 2d/gd_paint/paint_control.gd | 2 +- format.sh => file_format.sh | 16 +++++++++++++++- mono/2.5d/addons/node25d-cs/Node25D.cs | 1 - mono/2.5d/addons/node25d-cs/ShadowMath25D.cs | 1 - 5 files changed, 24 insertions(+), 8 deletions(-) rename .github/workflows/{ci.yml => static_checks.yml} (51%) rename format.sh => file_format.sh (67%) diff --git a/.github/workflows/ci.yml b/.github/workflows/static_checks.yml similarity index 51% rename from .github/workflows/ci.yml rename to .github/workflows/static_checks.yml index 8cca122e..b8e2d6cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/static_checks.yml @@ -1,15 +1,19 @@ -name: Continuous integration +name: Static Checks on: [push, pull_request] jobs: - build: + format: + name: File formatting (file_format.sh) runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v2 - - name: Lint demo projects + - name: Install dependencies run: | sudo apt-get update -qq sudo apt-get install -qq dos2unix recode - bash ./format.sh + + - name: File formatting checks (file_format.sh) + run: | + bash ./file_format.sh diff --git a/2d/gd_paint/paint_control.gd b/2d/gd_paint/paint_control.gd index b97e5d02..8768a159 100644 --- a/2d/gd_paint/paint_control.gd +++ b/2d/gd_paint/paint_control.gd @@ -108,7 +108,7 @@ func check_if_mouse_is_inside_canvas(): if mouse_click_start_pos.x > TL_node.global_position.x: if mouse_click_start_pos.y > TL_node.global_position.y: # Make sure the current mouse position is inside the canvas. - if is_mouse_in_drawing_area == true: + if is_mouse_in_drawing_area: return true return false diff --git a/format.sh b/file_format.sh similarity index 67% rename from format.sh rename to file_format.sh index ae49748c..ae0cbc79 100755 --- a/format.sh +++ b/file_format.sh @@ -1,12 +1,14 @@ #!/usr/bin/env bash +# This script ensures proper POSIX text file formatting and a few other things. + set -uo pipefail IFS=$'\n\t' # Loops through all text files tracked by Git. git grep -zIl '' | while IFS= read -rd '' f; do - # Exclude csproj and hdr files. + # Exclude some types of files. if [[ "$f" == *"csproj" ]]; then continue elif [[ "$f" == *"hdr" ]]; then @@ -22,6 +24,18 @@ while IFS= read -rd '' f; do tail -c1 < "$f" | read -r _ || echo >> "$f"; # Remove trailing space characters. sed -z -i 's/\x20\x0A/\x0A/g' "$f" + # Remove the character sequence "== true" if it has a leading space. + sed -z -i 's/\x20== true//g' "$f" + # We don't want to change lines around braces in godot/tscn files. + if [[ "$f" == *"godot" ]]; then + continue + elif [[ "$f" == *"tscn" ]]; then + continue + fi + # Disallow empty lines after the opening brace. + sed -z -i 's/\x7B\x0A\x0A/\x7B\x0A/g' "$f" + # Disallow some empty lines before the closing brace. + sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f" done git diff > patch.patch diff --git a/mono/2.5d/addons/node25d-cs/Node25D.cs b/mono/2.5d/addons/node25d-cs/Node25D.cs index 229af0ee..506fe8fc 100644 --- a/mono/2.5d/addons/node25d-cs/Node25D.cs +++ b/mono/2.5d/addons/node25d-cs/Node25D.cs @@ -177,5 +177,4 @@ public class Node25D : Node2D, IComparable } return 0; } - } diff --git a/mono/2.5d/addons/node25d-cs/ShadowMath25D.cs b/mono/2.5d/addons/node25d-cs/ShadowMath25D.cs index 64b8061f..7f984b0b 100644 --- a/mono/2.5d/addons/node25d-cs/ShadowMath25D.cs +++ b/mono/2.5d/addons/node25d-cs/ShadowMath25D.cs @@ -50,5 +50,4 @@ public class ShadowMath25D : KinematicBody GlobalTransform = Transform; } } - }