39 lines
947 B
YAML
39 lines
947 B
YAML
name: Python syntax & lint
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
pull_request:
|
|
branches: ["**"]
|
|
|
|
jobs:
|
|
syntax-lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.x'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
pip install flake8
|
|
|
|
- name: Run Python syntax check
|
|
run: |
|
|
set -e
|
|
files=$(git ls-files '*.py')
|
|
if [ -z "$files" ]; then echo "No Python files to check"; exit 0; fi
|
|
python -m py_compile $files
|
|
|
|
- name: Run flake8 lint
|
|
run: |
|
|
files=$(git ls-files '*.py')
|
|
if [ -z "$files" ]; then echo "No Python files to lint"; exit 0; fi
|
|
flake8 $files
|