From ee465ce45dda10c7d0c9aa336600d955dcd737e8 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Fri, 3 Jul 2020 22:58:58 -0400 Subject: [PATCH] Add formatting script for GitHub Actions and add GitHub metadata --- .github/FUNDING.yml | 2 + .github/ISSUE_TEMPLATE/bug-report.md | 30 +++++++++++++ .../feature---enhancement-request.md | 13 ++++++ .github/workflows/ci.yml | 15 +++++++ GodotAddinVS.sln.DotSettings | 2 +- GodotCompletionProviders.Test/packages.config | 2 +- format.sh | 44 +++++++++++++++++++ 7 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/feature---enhancement-request.md create mode 100644 .github/workflows/ci.yml create mode 100755 format.sh diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..0820ab1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +patreon: godotengine +custom: https://godotengine.org/donate diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..636a2f7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,30 @@ +--- +name: Bug Report +about: Report a bug with the extension. +title: '' +labels: bug +assignees: neikeq + +--- + + + +**OS/device including version:** + + + +**Issue description:** + + + +**Screenshots of issue:** + diff --git a/.github/ISSUE_TEMPLATE/feature---enhancement-request.md b/.github/ISSUE_TEMPLATE/feature---enhancement-request.md new file mode 100644 index 0000000..f341400 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature---enhancement-request.md @@ -0,0 +1,13 @@ +--- +name: Feature / Enhancement Request +about: Adding new features or improving existing ones. +title: '' +labels: enhancement +assignees: neikeq + +--- + + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e941dfc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,15 @@ +name: Continuous integration +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Lint extension + run: | + sudo apt-get update -qq + sudo apt-get install -qq dos2unix recode + bash ./format.sh diff --git a/GodotAddinVS.sln.DotSettings b/GodotAddinVS.sln.DotSettings index 05f4060..701d94a 100644 --- a/GodotAddinVS.sln.DotSettings +++ b/GodotAddinVS.sln.DotSettings @@ -4,4 +4,4 @@ True True True - True \ No newline at end of file + True diff --git a/GodotCompletionProviders.Test/packages.config b/GodotCompletionProviders.Test/packages.config index a413179..6c6febf 100644 --- a/GodotCompletionProviders.Test/packages.config +++ b/GodotCompletionProviders.Test/packages.config @@ -29,4 +29,4 @@ - \ No newline at end of file + diff --git a/format.sh b/format.sh new file mode 100755 index 0000000..ae49748 --- /dev/null +++ b/format.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +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. + if [[ "$f" == *"csproj" ]]; then + continue + elif [[ "$f" == *"hdr" ]]; then + continue + fi + # Ensures that files are UTF-8 formatted. + recode UTF-8 "$f" 2> /dev/null + # Ensures that files have LF line endings. + 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" +done + +git diff > patch.patch +FILESIZE="$(stat -c%s patch.patch)" +MAXSIZE=5 + +# If no patch has been generated all is OK, clean up, and exit. +if (( FILESIZE < MAXSIZE )); then + printf "Files in this commit comply with the formatting rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1