Skip to content

Commit

Permalink
add generic CI
Browse files Browse the repository at this point in the history
  • Loading branch information
hannob committed Dec 31, 2024
1 parent 0c67780 commit d07982f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/runpyci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# last update: 2024-12-07
# https://github.com/hannob/codingstyle
---
name: runpyci
"on":
- pull_request
- push

jobs:
build:
strategy:
matrix:
python-version: [3.9, 3.x, 3.14-dev]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} ${{ matrix.os }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies and linters
run: |
[ -e requirements.txt ] && pip install -r requirements.txt
pip install pycodestyle pyupgrade pyflakes dlint pylint ruff
- name: Run tests
env:
RUN_ONLINETESTS: 1
run: |
./runpyci.sh
22 changes: 22 additions & 0 deletions runpyci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# last update: 2024-12-07/2
# https://github.com/hannob/codingstyle
set -euo pipefail

PYLINTIG="consider-using-with,design,fixme,invalid-name,missing-docstring,modified-iterating-list,no-member,possibly-used-before-assignment,protected-access,too-many-lines,unused-argument,broad-exception-caught,c-extension-no-member,duplicate-code,global-statement,global-variable-not-assigned,import-error,import-outside-toplevel,inconsistent-return-statements,redefined-outer-name,unspecified-encoding"
RUFFIG="ANN,C90,D,FIX001,FIX002,ICN001,PLR0911,PLR0912,PLR0913,PLR0915,PTH,S314,S320,S501,S603,SLF001,T201,TD002,TD003,B008,BLE001,COM812,FBT002,I001,N802,N806,PERF203,PERF401,PLR2004,PLW0602,PLW0603,PT009,RET505,RUF100,S202,S310,S607,S608,SIM102,SIM105,SIM108,SIM113,SIM114,SIM115,TD001,TD004,TRY300"

pyfind=$(find -name \*.py)
pygrep=$(grep -rl --exclude-dir=.ruff_cache '^#!/usr/bin/python\|^#!/usr/bin/env python' .)
pyfiles=$(echo "$pyfind" "$pygrep" | sort -u)

pycodestyle --max-line-length=100 --ignore=W503,E203 $pyfiles
pyupgrade --py313-plus $pyfiles
pyflakes $pyfiles
flake8 --select=DUO --ignore=DUO107,DUO123,DUO131 $pyfiles
pylint --disable=$PYLINTIG $pyfiles
ruff check --line-length=100 --select=ALL --ignore=$RUFFIG $pyfiles

if [ -d tests ]; then
python -m unittest -v
fi

0 comments on commit d07982f

Please sign in to comment.