From 76dda79d4af11ad2130db144ee9eea5da3763928 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 5 Oct 2021 14:12:37 -0500 Subject: [PATCH 1/4] Check for CRLF, add .editorconfig --- .editorconfig | 13 +++++++++++++ .github/workflows/check_samples.yml | 10 ++++++++++ .gitignore | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9d5c05a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +# trim_trailing_whitespace may cause unintended issues and should not be globally set true +trim_trailing_whitespace = false + +[{*.conf,*.conf.sample}] +indent_style = space +indent_size = 4 diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index 2fb698b..ec50270 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -23,6 +23,16 @@ jobs: exit 1 fi + - name: Check Line Endings + run: | + CRLF_ENDINGS=$(find . -not -type d -exec file "{}" ";" | grep CRLF) + CRLF_ENDINGS_COUNT=$(echo "${CRLF_ENDINGS}" | wc -w) + if (( CRLF_ENDINGS_COUNT > 0 )); then + echo "The following files are not allowed:" + echo "${CRLF_ENDINGS}" + exit 1 + fi + - name: Check Version Date Line Exists run: | # Date regex based on https://www.html5pattern.com/Dates diff --git a/.gitignore b/.gitignore index ea4eae9..70f62d6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,10 @@ * # Do NOT ignore allowed files -!*.conf.sample +!.editorconfig !.gitattributes !.github !.gitignore +!*.conf.sample !LICENSE !README.md From e05a5d0cb73e2e3780fb0fe7253fd510019da7ac Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 5 Oct 2021 14:15:41 -0500 Subject: [PATCH 2/4] Don't fail if no CRLF issues are found --- .github/workflows/check_samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index ec50270..2077a56 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -25,7 +25,7 @@ jobs: - name: Check Line Endings run: | - CRLF_ENDINGS=$(find . -not -type d -exec file "{}" ";" | grep CRLF) + CRLF_ENDINGS=$(find . -not -type d -exec file "{}" ";" | grep CRLF || true) CRLF_ENDINGS_COUNT=$(echo "${CRLF_ENDINGS}" | wc -w) if (( CRLF_ENDINGS_COUNT > 0 )); then echo "The following files are not allowed:" From aeaea85520c595a2256195b5cb768549cbea4624 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 5 Oct 2021 14:23:43 -0500 Subject: [PATCH 3/4] Add check for executable bit --- .github/workflows/check_samples.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index 2077a56..bcba90c 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -18,17 +18,27 @@ jobs: NOT_SAMPLES=$(find . -not -path '*/\.*' -type f ! \( -name '*.conf.sample' -o -name 'README.md' -o -name 'LICENSE' \)) NOT_SAMPLES_COUNT=$(echo "${NOT_SAMPLES}" | wc -w) if (( NOT_SAMPLES_COUNT > 0 )); then - echo "The following files are not allowed:" + echo "The following files have extensions that are not allowed:" echo "${NOT_SAMPLES}" exit 1 fi + - name: Check Executable Bit + run: | + EXECUTABLE_BIT=$(find . -not -type d -executable) + EXECUTABLE_BIT_COUNT=$(echo "${EXECUTABLE_BIT}" | wc -w) + if (( EXECUTABLE_BIT_COUNT > 0 )); then + echo "The following files have executable permissions (not allowed):" + echo "${EXECUTABLE_BIT}" + exit 1 + fi + - name: Check Line Endings run: | CRLF_ENDINGS=$(find . -not -type d -exec file "{}" ";" | grep CRLF || true) CRLF_ENDINGS_COUNT=$(echo "${CRLF_ENDINGS}" | wc -w) if (( CRLF_ENDINGS_COUNT > 0 )); then - echo "The following files are not allowed:" + echo "The following files have CRLF line endings (not allowed):" echo "${CRLF_ENDINGS}" exit 1 fi From 988d23a03f6db9b8b9cf2879cecdb4fa087becc0 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 5 Oct 2021 14:28:44 -0500 Subject: [PATCH 4/4] Use uniform find commands --- .github/workflows/check_samples.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index bcba90c..af4c79b 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -25,7 +25,7 @@ jobs: - name: Check Executable Bit run: | - EXECUTABLE_BIT=$(find . -not -type d -executable) + EXECUTABLE_BIT=$(find . -not -path '*/\.*' -type f -executable) EXECUTABLE_BIT_COUNT=$(echo "${EXECUTABLE_BIT}" | wc -w) if (( EXECUTABLE_BIT_COUNT > 0 )); then echo "The following files have executable permissions (not allowed):" @@ -35,7 +35,7 @@ jobs: - name: Check Line Endings run: | - CRLF_ENDINGS=$(find . -not -type d -exec file "{}" ";" | grep CRLF || true) + CRLF_ENDINGS=$(find . -not -path '*/\.*' -type f -exec file "{}" ";" | grep CRLF || true) CRLF_ENDINGS_COUNT=$(echo "${CRLF_ENDINGS}" | wc -w) if (( CRLF_ENDINGS_COUNT > 0 )); then echo "The following files have CRLF line endings (not allowed):"