-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (49 loc) · 2.06 KB
/
lint.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
name: lint
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup Python
uses: actions/setup-python@v1
with:
python-version: '3.8'
architecture: x64
- name: black
uses: psf/black@stable
with:
options: '--verbose'
src: './scripts'
- uses: stefanzweifel/git-auto-commit-action@v4
name: commit
with:
commit_message: Auto-format python code
- name: run flake8
uses: julianwachholz/flake8-action@v2
with:
checkName: 'flake8' # NOTE: this needs to be the same as the job name
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: check all scripts follow the naming convention
run: |
dirs_with_missing_script=$(find scripts -maxdepth 1 -mindepth 1 -type d \! -exec test -f '{}'/script.py \; -print)
dirs_with_wrong_name=$(find scripts -maxdepth 1 -mindepth 1 -type d -regextype egrep \! -regex 'scripts/[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*' -print)
dirs_with_too_many_chars=$(find scripts -maxdepth 1 -mindepth 1 -type d -regextype egrep -regex 'scripts/.{41,}' -print)
if [[ $dirs_with_missing_script ]]; then
echo "::error::missing 'script.py' in ${dirs_with_missing_script//$'\n'/, }"
fi
if [[ $dirs_with_wrong_name ]]; then
echo "::error::incorrect script name in ${dirs_with_wrong_name//$'\n'/, } (must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character)"
fi
if [[ $dirs_with_too_many_chars ]]; then
echo "::error::incorrect script name in ${dirs_with_too_many_chars//$'\n'/, } (must contain at most 41 characters)"
fi
if [[ $dirs_with_missing_script ]] || [[ $dirs_with_wrong_name ]] || [[ $dirs_with_too_many_chars ]]; then
exit 1
fi