Skip to content

Commit 1da0c0c

Browse files
authored
Merge pull request #464 from Roxedus/master
Annotate files
2 parents dec4a83 + 810ab47 commit 1da0c0c

1 file changed

Lines changed: 44 additions & 40 deletions

File tree

.github/workflows/check_samples.yml

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,58 @@ name: Check Samples
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
check-allowed-file-names:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515

16-
- name: Check Allowed File Names
17-
run: |
18-
NOT_SAMPLES=$(find . -not -path '*/\.*' -type f ! \( -name '*.conf.sample' -o -name 'README.md' -o -name 'LICENSE' \))
19-
NOT_SAMPLES_COUNT=$(echo "${NOT_SAMPLES}" | wc -w)
20-
if (( NOT_SAMPLES_COUNT > 0 )); then
21-
echo "The following files have extensions that are not allowed:"
22-
echo "${NOT_SAMPLES}"
23-
exit 1
24-
fi
16+
- name: Check Allowed File Names
17+
run: |
18+
NOT_SAMPLES=$(find . -not -path '*/\.*' -type f ! \( -name '*.conf.sample' -o -name 'README.md' -o -name 'LICENSE' \))
19+
NOT_SAMPLES_COUNT=$(echo "${NOT_SAMPLES}" | wc -w)
20+
if (( NOT_SAMPLES_COUNT > 0 )); then
21+
for i in ${NOT_SAMPLES}; do
22+
echo "::error file=${i},line=1,title=Disallowed filenames::This file extension is not allowed, only .sample is allowed"
23+
done
24+
exit 1
25+
fi
2526
26-
- name: Check Executable Bit
27-
run: |
28-
EXECUTABLE_BIT=$(find . -not -path '*/\.*' -type f -executable)
29-
EXECUTABLE_BIT_COUNT=$(echo "${EXECUTABLE_BIT}" | wc -w)
30-
if (( EXECUTABLE_BIT_COUNT > 0 )); then
31-
echo "The following files have executable permissions (not allowed):"
32-
echo "${EXECUTABLE_BIT}"
33-
exit 1
34-
fi
27+
- name: Check Executable Bit
28+
run: |
29+
EXECUTABLE_BIT=$(find . -not -path '*/\.*' -type f -executable)
30+
EXECUTABLE_BIT_COUNT=$(echo "${EXECUTABLE_BIT}" | wc -w)
31+
if (( EXECUTABLE_BIT_COUNT > 0 )); then
32+
for i in ${EXECUTABLE_BIT}; do
33+
echo "::error file=${i},line=1,title=Executable Bit::This file is set as exectutable, which is not allowed"
34+
done
35+
exit 1
36+
fi
3537
36-
- name: Check Line Endings
37-
run: |
38-
CRLF_ENDINGS=$(find . -not -path '*/\.*' -type f -exec file "{}" ";" | grep CRLF || true)
39-
CRLF_ENDINGS_COUNT=$(echo "${CRLF_ENDINGS}" | wc -w)
40-
if (( CRLF_ENDINGS_COUNT > 0 )); then
41-
echo "The following files have CRLF line endings (not allowed):"
42-
echo "${CRLF_ENDINGS}"
43-
exit 1
44-
fi
38+
- name: Check Line Endings
39+
run: |
40+
CRLF_ENDINGS=$(find . -not -path '*/\.*' -type f -exec file "{}" ";" | grep CRLF || true)
41+
CRLF_ENDINGS_COUNT=$(echo "${CRLF_ENDINGS}" | wc -w)
42+
if (( CRLF_ENDINGS_COUNT > 0 )); then
43+
for i in ${CRLF_ENDINGS}; do
44+
echo "::error file=${i},line=1,title=Line Endings::This file has CRLF (Windows) line endings, which is not allowed"
45+
done
46+
exit 1
47+
fi
4548
46-
- name: Check Version Date Line Exists
47-
run: |
48-
# Date regex based on https://www.html5pattern.com/Dates
49-
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)
50-
VERSION_LINE_MISSING_COUNT=$(echo "${VERSION_LINE_MISSING}" | wc -w)
51-
if (( VERSION_LINE_MISSING_COUNT > 0 )); then
52-
echo "The following files are missing the version date line or it is not formatted correctly (YYYY/MM/DD):"
53-
echo "${VERSION_LINE_MISSING}"
54-
exit 1
55-
fi
49+
- name: Check Version Date Line Exists
50+
run: |
51+
# Date regex based on https://www.html5pattern.com/Dates
52+
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)
53+
VERSION_LINE_MISSING_COUNT=$(echo "${VERSION_LINE_MISSING}" | wc -w)
54+
if (( VERSION_LINE_MISSING_COUNT > 0 )); then
55+
for i in ${VERSION_LINE_MISSING}; do
56+
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)"
57+
done
58+
exit 1
59+
fi

0 commit comments

Comments
 (0)