Skip to content
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

get ci pipelines functional, and switch to ruff linter/formatter #264

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
83af112
excluded dirs from flake8 linting
Mar 22, 2024
7f5b69c
switched to autopep8
Mar 22, 2024
33c1af9
fixed pylint pipeline
Mar 22, 2024
4796edb
fixed linting command issues
Mar 22, 2024
a1d67f6
forgot xargs and removed venv from linting
Mar 22, 2024
4dcd723
fixed styling
Mar 22, 2024
64978ed
made flake8 play nice with black
rippleFCL May 3, 2024
2aa4653
version locked ci deps
rippleFCL May 3, 2024
ea5c37d
added black pre-commit hook
rippleFCL May 3, 2024
9dba346
added other linter/formaters and version locked deps
rippleFCL May 3, 2024
e4f5d04
reordered hooks and enabled fail fast
rippleFCL May 3, 2024
3d5bd99
changed docs
rippleFCL May 3, 2024
9bec303
moved requirements file
rippleFCL May 3, 2024
fbd724c
included vscode extention in tge readme and fixed typo
rippleFCL May 3, 2024
6390b4f
added missing dependencie
rippleFCL May 3, 2024
943acb6
fixed typo
rippleFCL May 3, 2024
22962e2
removed reduandant tasks
rippleFCL May 3, 2024
fecf411
return to form
rippleFCL May 3, 2024
7c4f66f
fixed typo in readme
rippleFCL May 3, 2024
641108f
removed my stupidity and improved logging
rippleFCL May 3, 2024
0798f58
removed hacky work around
rippleFCL May 3, 2024
9d7271a
added ppylint plugin for formatting logs into a actions understandabl…
rippleFCL May 3, 2024
3d9145c
switched to linter's actions
rippleFCL May 5, 2024
7a118e2
added mypi ci pipeline
rippleFCL May 13, 2024
9bb205b
switched to ruff
rippleFCL May 13, 2024
71a8068
removed fail fast
rippleFCL May 13, 2024
6cfa6e4
added extentions.json and removed pylint
rippleFCL Jul 24, 2024
d3c4832
added mypy
rippleFCL Jul 24, 2024
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
7 changes: 5 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[flake8]
max-line-length = 127
extend-ignore = E203, W503
max-complexity = 10
extend-ignore = E203, E701, W503
max-complexity = 10
exclude =
__pycache__
.venv
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
run: pip install --quiet --upgrade --requirement requirements.txt
- name: Install CI dependencies
shell: bash
run: pip install --quiet --upgrade --requirement requirements-ci.txt
run: pip install --quiet --upgrade --requirement .github/requirements-ci.txt
- name: Install cog dependencies
shell: bash
run: |
Expand Down
6 changes: 6 additions & 0 deletions .github/requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fastjsonschema==2.19.1
pytest==8.2.0
pytest-asyncio==0.23.6
pytest-aiohttp==1.0.5
mypy==1.10.0
ruff==0.4.4
35 changes: 5 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,24 @@ name: CI
on: [pull_request]

jobs:
lint-flake8:
ruff:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository at the current branch
uses: actions/checkout@v2
- name: Install dependencies
uses: ./.github/actions/setup
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings
flake8 . --format="::warning file=%(path)s,line=%(row)d,col=%(col)d::%(text)s" --exit-zero --max-complexity=10
- uses: chartboost/ruff-action@v1

lint-black:
lint-mypy:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository at the current branch
uses: actions/checkout@v2
- name: Install dependencies
uses: ./.github/actions/setup
- name: Lint with black
run: black --diff .

lint-pylint:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository at the current branch
uses: actions/checkout@v2
- name: Install dependencies
uses: ./.github/actions/setup
- name: Lint with pylint
run: pylint --msg-template='::warning file={path},line={line},col={column}::{msg}' */ || exit 0

lint-isort:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository at the current branch
uses: actions/checkout@v2
- name: Install dependencies
uses: ./.github/actions/setup
- name: Lint with isort
run: isort --check --diff .
- name: Lint with mypy
run: mypy --strict .

check-json:
runs-on: ubuntu-latest
Expand Down
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.4
hooks:
# Run the linter.
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix"]
# Run the formatter.
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.10.0' # Use the sha / tag you want to point at
hooks:
- id: mypy
args: [--strict, --ignore-missing-imports]
6 changes: 2 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"recommendations": [
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.pylint",
"ms-python.python",
"charliermarsh.ruff",
"ms-python.mypy-type-checker",
"ms-python.vscode-pylance",
]
}
109 changes: 0 additions & 109 deletions .vscode/tasks.json

This file was deleted.

11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ This cog displays the number of users banned in the guild with a random selectio
- `[p]bancount` - Displays the total ban count using a randomly selected message.
- `[p]bancount list` - Lists all the messages that can be used in the guild.
- `[p]bancount add <message>` - Add a message to the guild list. Use `$ban` to insert the ban count in the message.
- `[p]bancount remove <message index>` - Deletes (by index, from the list command) the message from the guild list.
- `[p]bancount remove <message index>` - Deletes (by index, from the list command) the message from the guild list.

### BetterPing

Expand Down Expand Up @@ -421,13 +421,12 @@ Copyright (c) 2018-2023 tigattack, contributors and original authors.
The CI will fail unless your code is [PEP8](https://www.python.org/dev/peps/pep-0008/) compliant.

```bash
pip install -r requirements-ci.txt
isort . # This will fix the order of imports
black . # This will auto-format and fix a lot of common mistakes
pylint * # This will show general pep8-violations
pip install -r requirements-dev.txt -r requirements.txt
pre-commit install
pre-commit run --all-files
```

If you use [VSCode](https://code.visualstudio.com/) you can use the tasks integrated into the repo to locally run the same tasks as our CI
rippleFCL marked this conversation as resolved.
Show resolved Hide resolved
If you use [VSCode](https://code.visualstudio.com/) you can use the [pre-commit-vscode](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode) extension to auto generate tasks for the pre-commit hooks

### Making changes

Expand Down
41 changes: 6 additions & 35 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
[tool.black]
line-length = 127
target-version = ["py38"]
exclude = "env"

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 127
skip = "env"
profile = "black"

[tool.pylint.MASTER]
disable = [
"C0114", # Missing module docstring
]
max-attributes = 12
max-branches = 20

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

[tool.pylint.SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines = 10
# Ignore comments when computing similarities.
ignore-comments = "yes"
# Ignore docstrings when computing similarities.
ignore-docstrings = "yes"
# Ignore imports when computing similarities.
ignore-imports = "yes"

[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.ruff.lint]
select = ["F", "E", "W", "I", "ASYNC", "PL", "RUF"]

[tool.ruff]
line-length = 127
8 changes: 0 additions & 8 deletions requirements-ci.txt

This file was deleted.

3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pre-commit==3.7.0
ruff==0.4.4
mypy==1.10.0
Loading