From badf4dab6e890e2f2b2f7ab884ec81e264dea623 Mon Sep 17 00:00:00 2001 From: Roxedus Date: Thu, 21 Jul 2022 20:59:13 +0200 Subject: [PATCH 1/5] Bump checkout --- .github/workflows/check_samples.yml | 80 ++++++++++++++--------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index af4c79b..3ff7c56 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -2,54 +2,54 @@ name: Check Samples on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: check-allowed-file-names: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Check Allowed File Names - run: | - 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 have extensions that are not allowed:" - echo "${NOT_SAMPLES}" - exit 1 - fi + - name: Check Allowed File Names + run: | + 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 have extensions that are not allowed:" + echo "${NOT_SAMPLES}" + exit 1 + fi - - name: Check Executable Bit - run: | - 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):" - echo "${EXECUTABLE_BIT}" - exit 1 - fi + - name: Check Executable Bit + run: | + 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):" + echo "${EXECUTABLE_BIT}" + exit 1 + fi - - name: Check Line Endings - run: | - 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):" - echo "${CRLF_ENDINGS}" - exit 1 - fi + - name: Check Line Endings + run: | + 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):" + echo "${CRLF_ENDINGS}" + exit 1 + fi - - name: Check Version Date Line Exists - run: | - # Date regex based on https://www.html5pattern.com/Dates - VERSION_LINE_MISSING=$(find . -not -path '*/\.*' -type f -name '*.conf.sample' -exec grep -H -c -P '^## Version (?:19|20|21)[0-9]{2}/(?:(?:0[1-9]|1[0-2])/(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])/(?:30))|(?:(?:0[13578]|1[02])/31))$' {} \; | grep 0$ | cut -d':' -f1) - VERSION_LINE_MISSING_COUNT=$(echo "${VERSION_LINE_MISSING}" | wc -w) - if (( VERSION_LINE_MISSING_COUNT > 0 )); then - echo "The following files are missing the version date line or it is not formatted correctly (YYYY/MM/DD):" - echo "${VERSION_LINE_MISSING}" - exit 1 - fi + - name: Check Version Date Line Exists + run: | + # Date regex based on https://www.html5pattern.com/Dates + VERSION_LINE_MISSING=$(find . -not -path '*/\.*' -type f -name '*.conf.sample' -exec grep -H -c -P '^## Version (?:19|20|21)[0-9]{2}/(?:(?:0[1-9]|1[0-2])/(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])/(?:30))|(?:(?:0[13578]|1[02])/31))$' {} \; | grep 0$ | cut -d':' -f1) + VERSION_LINE_MISSING_COUNT=$(echo "${VERSION_LINE_MISSING}" | wc -w) + if (( VERSION_LINE_MISSING_COUNT > 0 )); then + echo "The following files are missing the version date line or it is not formatted correctly (YYYY/MM/DD):" + echo "${VERSION_LINE_MISSING}" + exit 1 + fi From 4df1c8c537e1ebac539746d35d60a094bcd03624 Mon Sep 17 00:00:00 2001 From: Roxedus Date: Thu, 21 Jul 2022 21:24:21 +0200 Subject: [PATCH 2/5] Annotate files --- .github/workflows/check_samples.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index 3ff7c56..4c508dd 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -18,8 +18,9 @@ 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 have extensions that are not allowed:" - echo "${NOT_SAMPLES}" + for i in ${NOT_SAMPLES}; do + echo "::error file=${i},line=1,title=Disallowed filenames::This file extension is not allowed, only .sample is allowed" + done exit 1 fi From 75218de62a51cc7b4b5a2d6187b2d44abf483076 Mon Sep 17 00:00:00 2001 From: Roxedus Date: Thu, 21 Jul 2022 22:25:59 +0200 Subject: [PATCH 3/5] Annotate exec bit --- .github/workflows/check_samples.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index 4c508dd..1d5a3e7 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -29,8 +29,9 @@ jobs: 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):" - echo "${EXECUTABLE_BIT}" + for i in ${EXECUTABLE_BIT}; do + echo "::error file=${i},line=1,title=Executable Bit::This file is set as exectutable, which is not allowed" + done exit 1 fi From 39a4e158f88aa9e4b652554e7210c4832cbe4666 Mon Sep 17 00:00:00 2001 From: Roxedus Date: Thu, 21 Jul 2022 22:35:20 +0200 Subject: [PATCH 4/5] Annotate CRLF --- .github/workflows/check_samples.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index 1d5a3e7..4c7e928 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -40,8 +40,9 @@ jobs: 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):" - echo "${CRLF_ENDINGS}" + for i in ${CRLF_ENDINGS}; do + echo "::error file=${i},line=1,title=Line Endings::This file has CRLF (Windows) line endings, which is not allowed" + done exit 1 fi From 810ab47df1d9ded063226a045497e5336a922f08 Mon Sep 17 00:00:00 2001 From: Roxedus Date: Thu, 21 Jul 2022 22:35:53 +0200 Subject: [PATCH 5/5] Annotate Version Line --- .github/workflows/check_samples.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_samples.yml b/.github/workflows/check_samples.yml index 4c7e928..3a6c363 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -52,7 +52,8 @@ jobs: VERSION_LINE_MISSING=$(find . -not -path '*/\.*' -type f -name '*.conf.sample' -exec grep -H -c -P '^## Version (?:19|20|21)[0-9]{2}/(?:(?:0[1-9]|1[0-2])/(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])/(?:30))|(?:(?:0[13578]|1[02])/31))$' {} \; | grep 0$ | cut -d':' -f1) VERSION_LINE_MISSING_COUNT=$(echo "${VERSION_LINE_MISSING}" | wc -w) if (( VERSION_LINE_MISSING_COUNT > 0 )); then - echo "The following files are missing the version date line or it is not formatted correctly (YYYY/MM/DD):" - echo "${VERSION_LINE_MISSING}" + for i in ${VERSION_LINE_MISSING}; do + echo "::error file=${i},line=1,title=Version Line::This file is missing the version date line or it is not formatted correctly (YYYY/MM/DD)" + done exit 1 fi