Skip to content

Fix errors in script #220

Fix errors in script

Fix errors in script #220

Workflow file for this run

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