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
|
name: Code checker
on:
push:
pull_request:
jobs:
validate:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
env:
SRC_FOLDER: mill_local
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip_cache
- name: Install dependencies
run: |
pip install dlint flake8 flake8-bandit flake8-bugbear flake8-deprecated flake8-executable isort pylint
pip install -r requirements.txt
- name: isort
if: github.event.pull_request.head.repo.full_name == github.repository
run: |
isort **/*.py
- name: black
if: github.event.pull_request.head.repo.full_name == github.repository
uses: lgeiger/black-action@master
with:
args: .
- name: Check for modified files
if: github.event.pull_request.head.repo.full_name == github.repository
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Push changes
if: github.event.pull_request.head.repo.full_name == github.repository && steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Daniel Hoyer'
git config --global user.email 'mail@dahoiv.net'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git commit -am "fixup! Format Python code with black"
git push
- name: Flake8 Code Linter
run: |
flake8 $SRC_FOLDER --max-line-length=120
- name: isort
run: |
isort **/*.py
- name: Pylint Code Linter
run: |
pylint --disable=C,R --enable=unidiomatic-typecheck $SRC_FOLDER
- name: Run tests
run: |
pip install -r requirements-test.txt
pytest -v -p no:logging -s
|