Skip to content

Create script.py

Create script.py #200

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)
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_missing_script ]] || [[ $dirs_with_wrong_name ]]; then
exit 1
fi