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

Merged
merged 96 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
eb6c870
excluded dirs from flake8 linting
Mar 22, 2024
66f5035
switched to autopep8
Mar 22, 2024
16caeb4
fixed pylint pipeline
Mar 22, 2024
23411f5
fixed linting command issues
Mar 22, 2024
e6f40a2
forgot xargs and removed venv from linting
Mar 22, 2024
c8002d1
fixed styling
Mar 22, 2024
4f31f60
made flake8 play nice with black
rippleFCL May 3, 2024
0109510
version locked ci deps
rippleFCL May 3, 2024
88c685f
added black pre-commit hook
rippleFCL May 3, 2024
dc13087
added other linter/formaters and version locked deps
rippleFCL May 3, 2024
8767442
reordered hooks and enabled fail fast
rippleFCL May 3, 2024
06a2668
changed docs
rippleFCL May 3, 2024
00f479c
moved requirements file
rippleFCL May 3, 2024
12fed33
included vscode extention in tge readme and fixed typo
rippleFCL May 3, 2024
7618ff8
added missing dependencie
rippleFCL May 3, 2024
af78452
fixed typo
rippleFCL May 3, 2024
d19d65e
removed reduandant tasks
rippleFCL May 3, 2024
9a20f29
return to form
rippleFCL May 3, 2024
e91fc62
fixed typo in readme
rippleFCL May 3, 2024
e46fd31
removed my stupidity and improved logging
rippleFCL May 3, 2024
6679177
removed hacky work around
rippleFCL May 3, 2024
2308328
added ppylint plugin for formatting logs into a actions understandabl…
rippleFCL May 3, 2024
92cba7b
switched to linter's actions
rippleFCL May 5, 2024
82bbdf8
added mypi ci pipeline
rippleFCL May 13, 2024
e060274
switched to ruff
rippleFCL May 13, 2024
8d79a69
removed fail fast
rippleFCL May 13, 2024
b6c911b
added extentions.json and removed pylint
rippleFCL Jul 24, 2024
ac5e1bc
added mypy
rippleFCL Jul 24, 2024
d9dbd0b
ci(type-checking): switch to pyright
rippleFCL Feb 14, 2025
7143263
ci(pre-commit): switch to pyright precommit
rippleFCL Feb 14, 2025
c2bc5b5
refactor: blanket ruff format and ruff lint fixes
rippleFCL Feb 14, 2025
db202a9
refactor: get code complient with ruff ci
rippleFCL Feb 14, 2025
f88959a
ci(ruff): fix version-file path and bumped ruff version
rippleFCL Feb 14, 2025
3926b78
ci(pre-commit): bump ruff version
rippleFCL Feb 14, 2025
faf0f66
refactor: make the source complient with updated ruff
rippleFCL Feb 14, 2025
961a923
fix(pre-commit): fix pyproject
rippleFCL Feb 15, 2025
4e635f3
refactor(ci): refactor autoreact cog to complie with ci
rippleFCL Feb 15, 2025
1be1fa2
refactor(ci): refactor autoreply cog to complie with ci
rippleFCL Feb 15, 2025
61b0983
refactor(ci): refactored bancount cog to complie with ci
rippleFCL Feb 15, 2025
db584f0
refactor(ci): refactored betterping cog to complie with ci
rippleFCL Feb 15, 2025
2fffcd6
refactor(convert): refactor convert cog to comply with ci
rippleFCL Feb 15, 2025
49cc578
refactor(custom_msg): refactor custom_msg to comply with ci
rippleFCL Feb 15, 2025
2422099
refactor(enforcer): refactor enforcer cog to comply with ci
rippleFCL Feb 15, 2025
9ce894b
refactor(feed): refactor feed cog to comply with ci
rippleFCL Feb 15, 2025
65efd47
ci(pyproject): ignore cogs to be rewritten
rippleFCL Feb 15, 2025
ac7de20
ci(json_checker): fix not returning bool if errpr has addictional pro…
rippleFCL Feb 15, 2025
174e5a2
refactor(letters): refactor letters cog to be complient with ci
rippleFCL Feb 15, 2025
2bd8bb4
refactor(markov): refactor markov cog to comply with ci
rippleFCL Feb 15, 2025
6302058
refactor(phishingdetection): refactor the phishingdetection cog to co…
rippleFCL Feb 15, 2025
28d2dbf
refactor(prometheus_exporter): refactored prometheus_exporter cog to …
rippleFCL Feb 15, 2025
3e69870
ci(pyproject): remove prom_exp cog from being linted pending rewrite
rippleFCL Feb 15, 2025
dd5305e
refactor(role_welcome): refactor roll_welcome to comply with ci
rippleFCL Feb 15, 2025
2e4d6a9
refactor(purge): refactor purge cog to comply with ci
rippleFCL Feb 15, 2025
2f520fb
refactor(quotes): refactor quotes cog so it will comply with ci
rippleFCL Feb 15, 2025
b94c6fb
refactor(reactrole): refactor reactrole to comply with ci
rippleFCL Feb 15, 2025
9f407f1
refactor(report): refactor report cog to comply with ci
rippleFCL Feb 15, 2025
076cc74
refactor(roleinfo): refactor roleinfo to comply with ci
rippleFCL Feb 15, 2025
3f31ed8
refactor(sentry): refactor to make sentry cog comply with ci
rippleFCL Feb 15, 2025
bc96d38
refactor(test_phishingdetection): refactor test phishingdetection to …
rippleFCL Feb 15, 2025
38062b2
refactor(timeout): refactor timeout cog to comply with ci
rippleFCL Feb 15, 2025
9b84b09
refactor(topic): refactor topic cog to comply with ci
rippleFCL Feb 15, 2025
f8ec77d
refactor(verify): refactor verify cog to comply with ci
rippleFCL Feb 15, 2025
d849d0a
ci(setup): bump python version to 3.11
rippleFCL Feb 15, 2025
067c330
refactor(role_welcome): fix odd ruff tripup?
rippleFCL Feb 15, 2025
49b0ab9
refactor(role_welcome): fix ruff false positive via noqa
rippleFCL Feb 15, 2025
a20b26d
refactor(role_welcome): right this is getting annoying... fixed ruff …
rippleFCL Feb 15, 2025
9fa7922
refactor(role_welcome): fix ruff... again
rippleFCL Feb 15, 2025
3b05f49
ci(role_welcome): please fix ruff
rippleFCL Feb 15, 2025
b8fcb88
refactor(timeout): fix role possibly none
rippleFCL Feb 15, 2025
7e1e015
ci: bumped action version
rippleFCL Feb 15, 2025
14c8430
refactor(role_welcome): fix ci complience?
rippleFCL Feb 15, 2025
1ee7aaf
refactor(role_welcome): fix odd ruff tripup?
rippleFCL Feb 15, 2025
05692f2
refactor(role_welcome): fix ruff false positive via noqa
rippleFCL Feb 15, 2025
d8d3e1e
Revert "ci(role_welcome): please fix ruff"
rippleFCL Feb 15, 2025
b5b3a6c
refactor(role_welcome): made role_welcome cog complient with ci
rippleFCL Feb 15, 2025
0391258
ci(action): changed name to be generic to version
rippleFCL Feb 16, 2025
f4e5555
refactor(autoreact): dont import directly from ns when its avaliable
rippleFCL Feb 17, 2025
273ecfb
fix(autoreact): remove unused imports
rippleFCL Feb 17, 2025
e386afc
chore(flake8): remove unused flake8 config
rippleFCL Feb 17, 2025
379d45b
refactor: remove requirements-ci and merged it into requirements-dev
rippleFCL Feb 17, 2025
ed2d898
ci(ci): lock pyright to lint with python version 3.11
rippleFCL Feb 17, 2025
0ebf191
refactor(role_welcome): remove line breaks from doc strings
rippleFCL Feb 17, 2025
c8f034e
chore(extentions): removed mypy and added pre-commit extentions
rippleFCL Feb 17, 2025
768f731
refactor(enforcer): add error handling for invalid and missing channels
rippleFCL Feb 17, 2025
87f4a30
refactor(README): chang linting section to must pass ci befor merge
rippleFCL Feb 17, 2025
e3a9487
refactor(tags): add tag creation back
rippleFCL Feb 17, 2025
f29c293
refactor(pyproject): remove unnecessary comment
rippleFCL Feb 17, 2025
8624d25
refactor(quotes): add fixme to a bad implimentation
rippleFCL Feb 17, 2025
e4d01c7
refactor(reactrole): add error handling to reactrole list
rippleFCL Feb 17, 2025
a1cc584
refactor(report): log to logger out if no log channel is set
rippleFCL Feb 17, 2025
1adaa44
refactor(role_welcome): remove old note that no longer applies
rippleFCL Feb 17, 2025
c420a64
refactor(timeout): log to logger if channel not found
rippleFCL Feb 17, 2025
3c84357
refactor(verify): add fallback logging if channels are missing
rippleFCL Feb 17, 2025
f99406f
ci(ci): added fixmes notifier
rippleFCL Feb 17, 2025
e7f6e83
ci(ci): i have entered the pipeline
rippleFCL Feb 17, 2025
09087aa
refactor(custom_msg): removed slander
rippleFCL Feb 17, 2025
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
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

17 changes: 7 additions & 10 deletions .github/actions/check-json/json_checker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import re
import sys
from glob import glob
from typing import List, Tuple, Union

Expand All @@ -8,11 +9,7 @@

def format_output(*, level: str, file: str, line: int, col: int, message: str) -> str:
return "::{level} file={file},line={line},col={col}::{message}".format(
level=level,
file=file,
line=line,
col=col,
message=message
level=level, file=file, line=line, col=col, message=message
)


Expand All @@ -36,13 +33,13 @@ def validate(schema_name: str, filename: str) -> bool:
error_keys, msg_bounds = list_from_str(error.message)
for key in error_keys:
line, col = get_key_pos(filename, key)
message = f"{error.message[:msg_bounds[0] + 1]}{key}{error.message[msg_bounds[1] - 1:]}"
message = f"{error.message[: msg_bounds[0] + 1]}{key}{error.message[msg_bounds[1] - 1 :]}"
print(format_output(level="error", file=filename, line=line, col=col, message=message))
else:
key_name = error.path[1]
line, col = get_key_pos(filename, key_name)
print(format_output(level="warning", file=filename, line=line, col=col, message=error.message))
return False
return False


def get_key_pos(filename: str, key: str) -> Tuple[int, int]:
Expand Down Expand Up @@ -72,8 +69,8 @@ def list_from_str(set_str: str) -> Tuple[List[str], Tuple[int, int]]:
def main() -> int:
validation_success: List[bool] = []
for file_pattern, schema_path in {
"info.json": ".github/actions/check-json/repo.json",
"*/info.json": ".github/actions/check-json/cog.json"
"info.json": ".github/actions/check-json/repo.json",
"*/info.json": ".github/actions/check-json/cog.json",
}.items():
for filename in glob(file_pattern):
validation_success.append(validate(schema_path, filename))
Expand All @@ -83,4 +80,4 @@ def main() -> int:

if __name__ == "__main__":
exit_code = main()
exit(exit_code)
sys.exit(exit_code)
8 changes: 4 additions & 4 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ description: Installs project dependencies
runs:
using: composite
steps:
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.11"
- name: Install base dependencies
shell: bash
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 requirements-dev.txt
- name: Install cog dependencies
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/actions/setup/compile_requirements.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pipeline script for extracting imports from cogs"""

import json
from glob import glob
from typing import Set
Expand Down
57 changes: 23 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,33 @@ 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
uses: actions/checkout@v4
- 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: astral-sh/ruff-action@v3
with:
version-file: "./requirements-dev.txt"

lint-black:
pyright:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository at the current branch
uses: actions/checkout@v2
uses: actions/checkout@v4
- 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 .
- uses: jakebailey/pyright-action@v2
with:
python-version: "3.11"

check-json:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository at the current branch
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- name: Check cog and repo JSON files against schema
Expand All @@ -61,8 +39,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository at the current branch
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- name: Run unit tests
run: python3 -m pytest .

fixmes:
name: FIXME check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rippleFCL/[email protected]
with:
terms: 'WIP|FIXME'
case-sensitive: false
severity: "WARNING"
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.6
hooks:
# Run the linter.
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix"]
# Run the formatter.
- id: ruff-format

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.393
hooks:
- id: pyright
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.vscode-pylance",
"MarkLarah.pre-commit-vscode",
]
}
109 changes: 0 additions & 109 deletions .vscode/tasks.json

This file was deleted.

22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Cogs for the [Red-DiscordBot](https://github.com/Cog-Creators/Red-DiscordBot/)-b
- [Reactrole](#reactrole)
- [Report](#report)
- [role\_welcome](#role_welcome)
- [Welcome Message Templating](#welcome-message-templating)
- [Welcome Logic](#welcome-logic)
- [Commands](#commands)
- [Roleinfo](#roleinfo)
- [Sentry](#sentry)
- [Tags](#tags)
Expand Down Expand Up @@ -114,7 +117,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 @@ -206,14 +209,14 @@ Also availble as a slash command.
### Jail

This cog allows users to be "jailed" in their own personal cell (channel). Also archives the channel to disk for future
reference.
reference.

* `[p]jail setup <#category>` - Set the jail category where jail channels will be created in. (category is the channel
* `[p]jail setup <#category>` - Set the jail category where jail channels will be created in. (category is the channel
category ID of the jail category)
* `[p]jail <@user>` - Jail the specified user.
* `[p]jail free <@user>` - Frees the specified user and cleans up the jail channel & role, archives the channel content.
* `[p]jail archives` - Lists the archived jails with user, date, and jail UUID.
* `[p]jail archives fetch <export uuid>` - Sends the specified jail channel archive as a file in the current channel (be
* `[p]jail archives fetch <export uuid>` - Sends the specified jail channel archive as a file in the current channel (be
careful running this in public channels)

### Latex
Expand Down Expand Up @@ -477,16 +480,15 @@ If you're using VSCode, this repository also includes launch configs for the bot

### Linting your code

The CI will fail unless your code is [PEP8](https://www.python.org/dev/peps/pep-0008/) compliant.
Your code must be passed by our lint & type checkers to be merged:

```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
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
Loading