From db32366ec9f6b8c4c0e598b2174a1c08e88b422c Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Fri, 3 Jul 2020 23:12:01 -0400 Subject: [PATCH] Add a 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/static_checks.yml | 15 ++++++ format.sh | 46 +++++++++++++++++++ 5 files changed, 106 insertions(+) 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/static_checks.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..e6dace3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,30 @@ +--- +name: Bug Report +about: Report a bug with this repo. +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/static_checks.yml b/.github/workflows/static_checks.yml new file mode 100644 index 0000000..677cc88 --- /dev/null +++ b/.github/workflows/static_checks.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 repo + run: | + sudo apt-get update -qq + sudo apt-get install -qq dos2unix recode + bash ./format.sh diff --git a/format.sh b/format.sh new file mode 100755 index 0000000..8333cf8 --- /dev/null +++ b/format.sh @@ -0,0 +1,46 @@ +#!/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 + elif [[ "$f" == *"diff" ]]; 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