Skip to content

Commit

Permalink
Update linting and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Domi04151309 committed Feb 14, 2024
1 parent 43b20ff commit ccfcbbb
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 48 deletions.
80 changes: 38 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
name: Code Checks
name: Continuous Integration

on:
push:
branches: [ main ]
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
code-checks:
name: Code Checks
pylint:
name: PyLint
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install
run: |
python3 -m pip install -U -r requirements.txt
- name: Run
run: |
echo -e "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY
pylint --ignore="=~,__pycache__,venv,.mypy_cache" . >> $GITHUB_STEP_SUMMARY
echo -e "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY
mypy:
name: MyPy
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install
run: |
python3 -m pip install -U -r requirements.txt
mkdir lint
- name: PyLint
run: pylint --recursive yes --ignore="__pycache__,venv,.mypy_cache" --output-format=text:lint/pylint.txt .
- name: MyPy
run: mypy pypu.py --strict --any-exprs-report ./lint --lineprecision-report ./lint
- name: Update Diagrams
- name: Run
run: |
python3 pypu.py -m ./ -f svg > ./example.svg
python3 pypu.py -m ./data/ -f svg > ./data/uml.svg
python3 pypu.py -m ./utils/ -f svg > ./utils/uml.svg
- name: PDoc
run: pdoc pypu.py utils data --favicon https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/code/default/48px.svg --logo https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/code/default/48px.svg -o ./docs
- name: Upload Lint Results
uses: actions/upload-artifact@v3
with:
name: Lint
path: ./lint/
- name: Upload PDoc
uses: actions/upload-pages-artifact@v1
with:
path: ./docs/
deploy:
name: Deploy Documentation
needs: code-checks
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v2
echo -e "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY
mypy >> $GITHUB_STEP_SUMMARY
echo -e "\n\`\`\`\n" >> $GITHUB_STEP_SUMMARY
53 changes: 53 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docs

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true

jobs:
generate:
name: Generate Documentation
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install
run: |
python3 -m pip install -U -r requirements.txt
- name: Update Diagrams
run: |
python3 pypu.py -m ./ -f svg > ./example.svg
python3 pypu.py -m ./data/ -f svg > ./data/uml.svg
python3 pypu.py -m ./utils/ -f svg > ./utils/uml.svg
- name: PDoc
run: pdoc pypu.py utils data --favicon https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/code/default/48px.svg --logo https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/code/default/48px.svg -o ./docs
- name: Upload PDoc
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/
deploy:
name: Deploy Documentation
needs: generate
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
49 changes: 45 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
[MAIN]
fail-on=I

check-quote-consistency=yes

jobs=0

recursive=yes

load-plugins=pylint.extensions.broad_try_clause,
pylint.extensions.code_style,
pylint.extensions.comparison_placement,
pylint.extensions.confusing_elif,
pylint.extensions.for_any_all,
pylint.extensions.consider_refactoring_into_while_condition,
pylint.extensions.consider_ternary_expression,
pylint.extensions.bad_builtin,
pylint.extensions.mccabe,
pylint.extensions.dict_init_mutate,
pylint.extensions.docstyle,
pylint.extensions.dunder,
pylint.extensions.check_elif,
pylint.extensions.empty_comment,
pylint.extensions.eq_without_hash,
pylint.extensions.private_import,
pylint.extensions.redefined_variable_type,
pylint.extensions.no_self_use,
pylint.extensions.overlapping_exceptions,
pylint.extensions.docparams,
pylint.extensions.redefined_loop_name,
pylint.extensions.set_membership,
pylint.extensions.typing,
pylint.extensions.while_used,

[REPORTS]
score=no

[BASIC]
module-naming-style=any

[MESSAGES CONTROL]
# C0103: Naming convention violation
# C0114: Missing module docstring
# R0903: Too few public methods
disable=C0103,C0114,R0903
disable=missing-module-docstring,
too-few-public-methods,
docstring-first-line-empty,
consider-using-assignment-expr,
while-used,
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ potential issues in the code.
To lint the entire repository, simply use the following command in a terminal:

```bash
pylint --recursive yes --ignore="__pycache__,venv,.mypy_cache" --output-format=colorized .
pylint --ignore="__pycache__,venv,.mypy_cache" --output-format=colorized .
```

This command will recursively search through all subdirectories of the current
Expand All @@ -75,7 +75,7 @@ project files. MyPy analyzes the code and provides feedback on type
inconsistencies, potential type errors, and other type-related issues.

```bash
mypy pypu.py --strict
mypy
```

Static type checking helps catch errors and improve code quality by ensuring
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[mypy]
files = pypu.py
strict = True
ignore_missing_imports = True

0 comments on commit ccfcbbb

Please sign in to comment.