Skip to content

Configured Building and linting workflow #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[flake8]
color=always
max-line-length=120
; TODO: Bring WAY down
max-complexity=55
; Auto generated
exclude=src/gen/
; TODO: We want to configure this
Expand All @@ -12,3 +10,6 @@ per-file-ignores =
; line too long
; mixed case
__init__.pyi:F401,E501,N816
; TODO: Bring WAY down
max-complexity=55
inline-quotes = "
111 changes: 111 additions & 0 deletions .github/workflows/build-and-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
name: Build and lint
on:
push:
branches:
- main
- master
- 2.0.0
pull_request:
branches:
- main
- master
- dev
- dev*
jobs:
Pyright:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r "scripts/requirements.txt"
npm install -g pyright
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
run: pyright
Pylint:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r "scripts/requirements.txt"
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py*')
Bandit:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r "scripts/requirements.txt"
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
run: bandit -n 1 --severity-level medium --recursive src
Flake8:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r "scripts/requirements.txt"
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
run: flake8
Build:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r "scripts/requirements.txt"
- run: scripts/build.bat
33 changes: 0 additions & 33 deletions .mypy.ini

This file was deleted.

23 changes: 0 additions & 23 deletions .pylintrc

This file was deleted.

9 changes: 5 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"recommendations": [
"ms-python.vscode-pylance",
"ms-python.python",
"sonarsource.sonarlint-vscode",
"bungcip.better-toml",
"davidanson.vscode-markdownlint",
"eamodio.gitlens",
"ms-python.python",
"ms-python.vscode-pylance",
"shardulm94.trailing-spaces",
"eamodio.gitlens"
"sonarsource.sonarlint-vscode"
],
"unwantedRecommendations": [
"ms-pyright.pyright",
Expand Down
16 changes: 8 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
"[python]": {
"editor.tabSize": 4,
"editor.rulers": [
79,
100,
120,
72, // PEP8-17 docstrings
// 79, // PEP8-17 default max
// 88, // Black default
99, // PEP8-17 acceptable max
120, // Our hard rule
]
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.fixAll.markdownlint": true,
},
// Set to trace when sending error reports to Pylance
// "python.analysis.logLevel": "Trace",
// https://code.visualstudio.com/docs/python/linting#_specific-linters
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintCategorySeverity.convention": "Warning",
"python.linting.pylintCategorySeverity.refactor": "Warning",
"python.linting.flake8Enabled": true,
"python.linting.flake8CategorySeverity.E": "Warning",
"python.linting.mypyEnabled": true,
// PyRight obsoletes mypy
"python.linting.mypyEnabled": false,
// Is already wrapped by Flake8, prospector and pylama
"python.linting.pycodestyleEnabled": false,
// Just another wrapper, use Flake8 OR this
Expand Down Expand Up @@ -66,5 +66,5 @@
"**/bower_components": true,
"**/*.code-search": true,
"typings": true,
}
},
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- markdownlint-disable-next-line MD033 -->
# <img src="res/icon.ico" alt="LiveSplit" height="42" width="42" align="top"/> AutoSplit
# <img src="res/icon.ico" alt="LiveSplit" height="42" width="42" align="top"/> AutoSplit [![Build and lint](/../../actions/workflows/build-and-lint.yml/badge.svg)](/../../actions/workflows/build-and-lint.yml) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=security_rating)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split) [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split)

Easy to use image comparison based auto splitter for speedrunning on console or PC.

Expand Down
96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file
[tool.black]
line-length = 120
# Auto generated
force-exclude = "src/gen/.*\\.py$"

# https://github.com/hhatto/autopep8#usage
# https://github.com/hhatto/autopep8#more-advanced-usage
[tool.autopep8]
max_line_length = 120
recursive = true
aggressive = 3

# https://github.com/microsoft/pyright/blob/main/docs/configuration.md#sample-pyprojecttoml-file
[tool.pyright]
pythonPlatform = "Windows"
typeCheckingMode = "strict"
stubPath = "typings/"
ignore = [
# Auto generated
"src/gen/",
"typings/",
]
reportMissingTypeStubs = "information"
# False positives with TYPE_CHECKING
reportImportCycles = "information"
# PyQt .connect
reportFunctionMemberAccess = "information"
# Extra runtime safety
reportUnnecessaryComparison = "warning"
# Flake8 does a better job
reportUnusedImport = "none"
# numpy has way too many complex types that triggers this
reportUnknownMemberType = "none"

# https://github.com/PyCQA/pylint/blob/main/examples/pylintrc
# https://pylint.pycqa.org/en/latest/technical_reference/features.html
[tool.pylint.REPORTS]
# Just like default but any error will make drop to 9 or less
evaluation="10.0 - error - ((float(warning + refactor + convention) / statement) * 10)"
[tool.pylint.MASTER]
fail-under=9.0
# https://pylint.pycqa.org/en/latest/technical_reference/extensions.html
load-plugins = [
"pylint.extensions.emptystring",
"pylint.extensions.confusing_elif",
"pylint.extensions.consider_ternary_expression",
"pylint.extensions.bad_builtin",
"pylint.extensions.mccabe",
"pylint.extensions.check_elif",
"pylint.extensions.redefined_variable_type",
"pylint.extensions.overlapping_exceptions",
"pylint.extensions.empty_comment",
"pylint.extensions.set_membership",
"pylint.extensions.typing",
# TODO: Maybe later
# "pylint.extensions.docparams",
# Not wanted/needed
# "pylint.extensions.broad_try_clause",
# "pylint.extensions.code_style",
# "pylint.extensions.comparetozero",
# "pylint.extensions.docstyle",
# "pylint.extensions.while_used",
# Didn't work
# "pylint.extensions.comparison_placement",
# "pylint.extensions.for_any_all",
]
ignore-paths = [
# Haven't looked into disabling specific rules per file
"^typings/.*$",
# Auto generated
"^src/gen/.*$",
]
# No need to mention the fixmes
disable=["fixme"]
extension-pkg-allow-list = ["PyQt6", "win32ui"]

[tool.pylint.FORMAT]
max-line-length = 120

[tool.pylint.'MESSAGES CONTROL']
disable = [
"missing-docstring",
# TODO: We want to configure this
# https://pylint.pycqa.org/en/latest/user_guide/options.html#naming-styles
"invalid-name",
# We group imports
"wrong-import-position",
# Already taken care of and grayed out. Also conflicts with Pylance reportIncompatibleMethodOverride
"unused-argument",
# Already taken care of by Flake8
"unused-import",
]

[tool.pylint.TYPECHECK]
generated-members = "cv2"
19 changes: 0 additions & 19 deletions pyrightconfig.json

This file was deleted.

Loading