From 9da6b701538a254ba309080de15aab756cc40add Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 9 Dec 2020 16:19:24 -0600 Subject: [PATCH 1/2] Update workflow for version checks --- .../{allowed_names.yml => check_samples.yml} | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) rename .github/workflows/{allowed_names.yml => check_samples.yml} (52%) diff --git a/.github/workflows/allowed_names.yml b/.github/workflows/check_samples.yml similarity index 52% rename from .github/workflows/allowed_names.yml rename to .github/workflows/check_samples.yml index b32fad8..fd2c0a0 100644 --- a/.github/workflows/allowed_names.yml +++ b/.github/workflows/check_samples.yml @@ -1,4 +1,4 @@ -name: Check Allowed File Names +name: Check Samples on: push: @@ -22,3 +22,13 @@ jobs: echo "${NOT_SAMPLES}" exit 1 fi + + - name: Check Version Date Line Exists + run: | + VERSION_LINE_MISSING=$(find . -not -path '*/\.*' -type f -name '*.conf.sample' -exec grep -H -c -P '^## Version \d{4}/\d{2}/\d{2}$' {} \; | 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:" + echo "${VERSION_LINE_MISSING}" + exit 1 + fi From 9ab75fbe9e2f1ea49827db3614874886a5a919a1 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 9 Dec 2020 18:32:52 -0600 Subject: [PATCH 2/2] Advanced date regex with leap year detection --- .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 fd2c0a0..58d41ad 100644 --- a/.github/workflows/check_samples.yml +++ b/.github/workflows/check_samples.yml @@ -25,7 +25,7 @@ jobs: - name: Check Version Date Line Exists run: | - VERSION_LINE_MISSING=$(find . -not -path '*/\.*' -type f -name '*.conf.sample' -exec grep -H -c -P '^## Version \d{4}/\d{2}/\d{2}$' {} \; | grep 0$ | cut -d':' -f1) + VERSION_LINE_MISSING=$(find . -not -path '*/\.*' -type f -name '*.conf.sample' -exec grep -H -c -P '^## Version (?:19|20|21)(?:(?:[13579][26]|[02468][048])\/(?:(?: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))|(?:[0-9]{2}\/(?:0[1-9]|1[0-2])\/(?:0[1-9]|1[0-9]|2[0-8])|(?:(?!02)(?:0[1-9]|1[0-2])\/(?:29|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:"