Skip to content

Commit 116fa18

Browse files
Paillat-devLulalaby
authored andcommitted
refactor: 🔧 New test setup and modernize dev install (#3128)
* refactor: 🔥 Remove legacy test files and migrate dev dependencies to `pyproject.toml` * test: ✅ Add dummy test file * chore: 📄 License
1 parent bd64327 commit 116fa18

8 files changed

Lines changed: 86 additions & 319 deletions

File tree

.github/workflows/lib-checks.yml

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838
with:
3939
python-version: "3.13"
4040
cache: "pip"
41-
cache-dependency-path: "requirements/dev.txt"
41+
cache-dependency-path: "pyproject.toml"
4242
- name: "Install dependencies"
4343
run: |
4444
python -m pip install --upgrade pip
45-
pip install -r requirements/dev.txt
45+
pip install . --group dev
4646
- name: "Run codespell"
4747
run:
4848
codespell --ignore-words-list="groupt,nd,ot,ro,falsy,BU" \
@@ -58,11 +58,11 @@ jobs:
5858
with:
5959
python-version: "3.13"
6060
cache: "pip"
61-
cache-dependency-path: "requirements/dev.txt"
61+
cache-dependency-path: "pyproject.toml"
6262
- name: "Install dependencies"
6363
run: |
6464
python -m pip install --upgrade pip
65-
pip install -r requirements/dev.txt
65+
pip install . --group dev
6666
- name: "Run bandit"
6767
run: bandit --recursive --skip B101,B104,B105,B110,B307,B311,B404,B603,B607 .
6868
pylint:
@@ -76,11 +76,11 @@ jobs:
7676
with:
7777
python-version: "3.13"
7878
cache: "pip"
79-
cache-dependency-path: "requirements/dev.txt"
79+
cache-dependency-path: "pyproject.toml"
8080
- name: "Install dependencies"
8181
run: |
8282
python -m pip install --upgrade pip
83-
pip install -r requirements/dev.txt
83+
pip install . --group dev
8484
- name: "Setup cache"
8585
id: cache-pylint
8686
uses: actions/cache@v5
@@ -100,11 +100,11 @@ jobs:
100100
with:
101101
python-version: "3.13"
102102
cache: "pip"
103-
cache-dependency-path: "requirements/dev.txt"
103+
cache-dependency-path: "pyproject.toml"
104104
- name: "Install dependencies"
105105
run: |
106106
python -m pip install --upgrade pip
107-
pip install -r requirements/dev.txt
107+
pip install . --group dev
108108
- name: "Setup cache"
109109
id: cache-mypy
110110
uses: actions/cache@v5
@@ -116,39 +116,58 @@ jobs:
116116
run: mkdir -p -v .mypy_cache
117117
- name: "Run mypy"
118118
run: mypy --non-interactive discord/
119-
pytest:
120-
strategy:
121-
matrix:
122-
os: [ubuntu-latest, macos-latest, windows-latest]
123-
python-version: ["3.10", "3.11", "3.12", "3.13"]
124-
runs-on: ${{ matrix.os }}
125-
env:
126-
OS: ${{ matrix.os }}
127-
PYTHON: ${{ matrix.python-version }}
119+
flake8:
120+
runs-on: ubuntu-latest
128121
steps:
129122
- name: "Checkout Repository"
130123
uses: actions/checkout@v6
131124
- name: "Setup Python"
132125
uses: actions/setup-python@v6
133126
with:
134-
python-version: ${{ matrix.python-version }}
127+
python-version: "3.13"
135128
cache: "pip"
136-
cache-dependency-path: "requirements/dev.txt"
137-
check-latest: true
129+
cache-dependency-path: "pyproject.toml"
138130
- name: "Install dependencies"
139131
run: |
140132
python -m pip install --upgrade pip
141-
pip install flake8
142-
pip install -r requirements/dev.txt
143-
- name: "Setup cache"
144-
id: cache-pytest
145-
uses: actions/cache@v5
146-
with:
147-
path: .pytest_cache
148-
key: ${{ matrix.os }}-${{ matrix.python-version }}-pytest
133+
pip install . --group dev
149134
- name: "Lint with flake8"
150135
run: |
151-
# stop the build if there are Python syntax errors or undefined names
152136
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
153-
# exit-zero treats all errors as warnings.
154137
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
138+
tests:
139+
if: ${{ github.event_name != 'schedule' }}
140+
runs-on: ${{ matrix.os }}
141+
strategy:
142+
matrix:
143+
os: [ubuntu-latest, windows-latest, macos-latest]
144+
python-version: ["3.10", "3.11", "3.12", "3.13"]
145+
steps:
146+
- name: "Checkout Repository"
147+
uses: actions/checkout@v6
148+
149+
- name: "Setup Python"
150+
uses: actions/setup-python@v6
151+
with:
152+
python-version: "3.13"
153+
cache: "pip"
154+
cache-dependency-path: "pyproject.toml"
155+
156+
- name: "Install dependencies"
157+
run: |
158+
python -m pip install --upgrade pip
159+
pip install . --group dev
160+
161+
- name: "Run tests"
162+
run: tox
163+
tests-pass: # ref: https://github.com/orgs/community/discussions/4324#discussioncomment-3477871
164+
runs-on: ubuntu-latest
165+
needs: [tests]
166+
if: always() && github.event_name != 'schedule'
167+
steps:
168+
- name: Tests succeeded
169+
if: ${{ !(contains(needs.*.result, 'failure')) }}
170+
run: exit 0
171+
- name: Tests failed
172+
if: ${{ contains(needs.*.result, 'failure') }}
173+
run: exit 1

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ exclude .prettierrc
1717
exclude .readthedocs.yml
1818
exclude CHANGELOG.md
1919
exclude FUNDING.yml
20-
exclude requirements-dev.txt

pyproject.toml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ docs = { file = "requirements/docs.txt" }
6464
speed = { file = "requirements/speed.txt" }
6565
voice = { file = "requirements/voice.txt" }
6666

67+
[dependency-groups]
68+
dev = [
69+
"pylint~=3.3.8",
70+
"mypy~=1.19.1",
71+
"coverage~=7.10",
72+
"pre-commit==4.5.1",
73+
"codespell==2.4.1",
74+
"bandit==1.9.4",
75+
"flake8==7.3.0",
76+
"tox>=4.27.0",
77+
"tox-gh>=1.5.0"
78+
]
79+
test = [
80+
"pytest~=9.0.1",
81+
"pytest-asyncio~=1.3.0",
82+
]
6783
[tool.setuptools_scm]
6884

6985
[tool.black]
@@ -102,5 +118,22 @@ disable = [
102118
indent-string = ' '
103119
max-line-length = 120
104120

105-
[tool.pytest.ini_options]
121+
[tool.pytest]
106122
asyncio_mode = "auto"
123+
asyncio_default_fixture_loop_scope = "function"
124+
125+
[tool.tox]
126+
requires = ["tox>=4"]
127+
env_list = ["3.13", "3.12", "3.11", "3.10"]
128+
129+
[tool.tox.env_run_base]
130+
description = "run unit tests"
131+
commands = [["pytest", { replace = "posargs", default = ["tests"], extend = true }]]
132+
dependency_groups = ["test"]
133+
134+
# GitHub actions
135+
[tool.tox.gh.python]
136+
"3.13" = ["3.13"]
137+
"3.12" = ["3.12"]
138+
"3.11" = ["3.11"]
139+
"3.10" = ["3.10"]

requirements/all.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
-r dev.txt
21
-r docs.txt
32
-r speed.txt
43
-r voice.txt

requirements/dev.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/helpers.py renamed to tests/test_dummy.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
The MIT License (MIT)
33
4-
Copyright (c) 2015-2021 Rapptz
54
Copyright (c) 2021-present Pycord Development
65
76
Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,10 +22,8 @@
2322
DEALINGS IN THE SOFTWARE.
2423
"""
2524

26-
from typing import TypeVar
25+
import discord
2726

28-
V = TypeVar("V")
2927

30-
31-
async def coroutine(val: V) -> V:
32-
return val
28+
def test_dummy():
29+
assert True

tests/test_typing_annotated.py

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)