forked from exercism/v3
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (61 loc) · 2.54 KB
/
valid-files.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: CI
on:
push:
pull_request:
jobs:
max-file-size:
name: Check file sizes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Fetch everything
run: git fetch --prune --unshallow
- name: Error if any file is above 1 MB
run: |
# --diff-filter=d excludes deleted (d) files
# -z separates the files using NUL
git diff --diff-filter=d --name-only -z origin/master... | while read -r -d '' FILE; do
# Skip files that are allowed to have larger size
if [ "$FILE" == "languages/languages.json" ] ||
[ "$FILE" == "languages/README.md" ] ||
[ "$FILE" == "reference/references.json" ] ||
[ "$FILE" == "reference/README.md" ] ||
[ "$FILE" == "reference/stories/stories.json" ] ||
[ "$FILE" == "reference/stories/README.md" ] ||
[ "$FILE" == "languages/python/reference/README.md" ]; then
continue
fi
if [ "$(stat --printf="%s" "$FILE")" -gt 100000 ]; then
echo "$FILE is larger than 10 KB"
echo "Please ping @iHiD if you are sure that this file is required."
exit 1
fi
done
valid-filenames:
name: Check file names
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Fetch everything
run: git fetch --prune --unshallow
- name: Error if filenames contain illegal characters or words
run: |
# --diff-filter=d excludes deleted (d) files
# -z separates the files using NUL
git diff --diff-filter=d --name-only -z origin/master... | while read -r -d '' LINE; do
FILE=$(basename "$LINE")
if ! [[ "$FILE" =~ ^[a-zA-Z0-9._-]+$ ]]; then
echo "$FILE contains illegal characters."
echo "Filenames in this repo may only include the characters [a-zA-Z0-9._-] for security reasons."
echo "See https://github.com/exercism/v3/issues/1465#issuecomment-629873323 for more information."
exit 1
elif [[ "$FILE" =~ ^(AUX|NUL|PRN|CON|LPT[0-9]|COM[0-9])$ ]]; then
echo "$FILE is not a valid filename on Windows."
echo "See https://github.com/exercism/v3/issues/1369 for more information."
exit 1
fi
done