From 65c79f0a29e3f3ef78467253b4d67b738e8ef132 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 29 Oct 2020 02:21:43 -0400 Subject: [PATCH] Update gitignore, CI script, and repo metadata --- .gitattributes | 2 ++ .github/FUNDING.yml | 2 -- .github/dependabot.yml | 6 ++++ .../workflows/{ci.yml => static_checks.yml} | 12 +++++--- .gitignore | 2 ++ format.sh => file_format.sh | 29 +++++++++++++------ 6 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 .gitattributes delete mode 100644 .github/FUNDING.yml create mode 100644 .github/dependabot.yml rename .github/workflows/{ci.yml => static_checks.yml} (51%) rename format.sh => file_format.sh (50%) diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 0820ab1..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -patreon: godotengine -custom: https://godotengine.org/donate diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1230149 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" 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 9551da8..b8e2d6c 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 (format.sh) + - 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/.gitignore b/.gitignore index 6fdb49c..a6bd447 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +# Godot 4+ specific ignores +.godot/ # Godot-specific ignores .import/ diff --git a/format.sh b/file_format.sh similarity index 50% rename from format.sh rename to file_format.sh index ae49748..fab029e 100755 --- a/format.sh +++ b/file_format.sh @@ -1,27 +1,38 @@ #!/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 continue fi - # Ensures that files are UTF-8 formatted. + # Ensure that files are UTF-8 formatted. recode UTF-8 "$f" 2> /dev/null - # Ensures that files have LF line endings. + # Ensure that files have LF line endings and do not contain a BOM. dos2unix "$f" 2> /dev/null - # Ensures that files do not contain a BOM. - sed -i '1s/^\xEF\xBB\xBF//' "$f" - # Ensures that files end with newline characters. - tail -c1 < "$f" | read -r _ || echo >> "$f"; - # Remove trailing space characters. - sed -z -i 's/\x20\x0A/\x0A/g' "$f" + # Remove trailing space characters and ensures that files end + # with newline characters. -l option handles newlines conveniently. + perl -i -ple 's/\s*$//g' "$f" + # Remove the character sequence "== true" if it has a leading space. + perl -i -pe '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