Skip to content

Commit 9c728df

Browse files
Merge pull request #151 from python-discord/Python-3.11
Python 3.11 support
2 parents 3d53d05 + 79a2e87 commit 9c728df

File tree

10 files changed

+434
-475
lines changed

10 files changed

+434
-475
lines changed

.dockerignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
*
22

33
!pydis_core/
4-
!docs/
5-
!tests/
6-
4+
!dev/
75
!pyproject.toml
86
!poetry.lock
9-
!tox.ini
7+
!README.md

.github/workflows/docs.yaml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
name: Build Docs
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
84
workflow_dispatch:
9-
10-
concurrency:
11-
group: docs-deployment-${{ github.ref }}
12-
cancel-in-progress: true
5+
workflow_call:
136

147
jobs:
158
latest-build:
@@ -21,11 +14,11 @@ jobs:
2114
- uses: actions/checkout@v2
2215

2316
- name: Install Python Dependencies
24-
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.1
17+
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.2
2518
with:
2619
dev: true
27-
python_version: "3.10"
28-
install_args: "--extras async-rediscache"
20+
python_version: "3.11"
21+
install_args: "--extras async-rediscache --only main --only doc"
2922

3023
- name: Generate HTML Site
3124
run: sphinx-build -nW -j auto -b html docs docs/build
@@ -46,10 +39,10 @@ jobs:
4639
fetch-depth: 0 # We need to check out the entire repository to find all tags
4740

4841
- name: Install Python Dependencies
49-
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.1
42+
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.2
5043
with:
5144
dev: true
52-
python_version: "3.10"
45+
python_version: "3.11"
5346
install_args: "--extras async-rediscache"
5447

5548
- name: Build All Doc Versions

.github/workflows/lint-test.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
name: Lint & Test
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
9-
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref }}
11-
cancel-in-progress: true
4+
workflow_call:
125

136
jobs:
147
lint:
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
python_version: ["3.10", "3.11"]
1512
name: Run Linting & Test Suites
1613
runs-on: ubuntu-latest
1714
steps:
1815
- name: Install Python Dependencies
19-
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.1
16+
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.2
2017
with:
2118
# Set dev=true to run pre-commit which is a dev dependency
2219
dev: true
23-
python_version: "3.10"
24-
install_args: "--extras async-rediscache"
20+
python_version: ${{ matrix.python_version }}
21+
install_args: "--extras async-rediscache --only main --only lint --only test"
2522

2623
# We will not run `flake8` here, as we will use a separate flake8
2724
# action.
@@ -43,6 +40,9 @@ jobs:
4340
- name: Run tests and generate coverage report
4441
run: python -m pytest -n auto --cov pydis_core -q
4542

43+
- name: Build and dry run the example bot to ensure deps can be installed & imported
44+
run: docker run --rm --env GUILD_ID=1234 --env IN_CI=true $(docker build --build-arg python_version=${{ matrix.python_version }} -q -f ./dev/Dockerfile .) run python -m dev.bot
45+
4646
# Prepare the Pull Request Payload artifact. If this fails, we
4747
# we fail silently using the `continue-on-error` option. It's
4848
# nice if this succeeds, but if it fails for any reason, it

.github/workflows/main.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint-test:
15+
uses: ./.github/workflows/lint-test.yaml
16+
docs:
17+
uses: ./.github/workflows/docs.yaml

dev/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
FROM --platform=linux/amd64 ghcr.io/chrislovering/python-poetry-base:3.10-slim
1+
ARG python_version=3.11
22

3+
FROM --platform=linux/amd64 ghcr.io/chrislovering/python-poetry-base:$python_version-slim
34

45
# Install project dependencies
56
WORKDIR /app
67
COPY pyproject.toml poetry.lock ./
7-
RUN poetry install --no-root
8+
RUN poetry install --no-root --only dev,main
89

910
# Copy the source code in last to optimize rebuilding the image
1011
COPY . .
1112

1213
# Install again, this time with the root project
13-
RUN poetry install
14+
RUN poetry install --only-root
1415

15-
ENTRYPOINT ["python"]
16-
CMD ["-m", "bot"]
16+
ENTRYPOINT ["poetry"]
17+
CMD ["run", "python", "-m", "bot"]

dev/bot/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ async def main() -> None:
3131
async with bot:
3232
await bot.start(os.getenv("BOT_TOKEN"))
3333

34-
asyncio.run(main())
34+
if os.getenv("IN_CI", "").lower() != "true":
35+
asyncio.run(main())

docker-compose.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ services:
6868
build:
6969
context: .
7070
dockerfile: dev/Dockerfile
71-
volumes: # Don't do .:/app here to ensure project venv from host doens't overwrite venv in image
72-
- ./pydis_core:/app/pydis_core:ro
73-
- ./bot:/app/bot:ro
71+
volumes:
72+
- .:/app:ro
7473
tty: true
7574
depends_on:
7675
- web

docs/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
Changelog
55
=========
66

7+
- :release:`9.2.0 <17th November 2022>`
8+
- :support:`151` Add support for Python 3.11
9+
710
- :release:`9.1.1 <14th November 2022>`
811
- :bug:`162` Handle not being able to delete the interaction message on button press/timeout.
912

1013

1114
- :release:`9.1.0 <13th November 2022>`
1215
- :feature:`158` Bump Discord.py to :literal-url:`2.1.0 <https://github.com/Rapptz/discord.py/releases/tag/v2.1.0>`.
16+
- :feature:`88` Add a decorator that stops successive duplicate invocations of commands
1317

1418

1519
- :release:`9.0.0 <5th November 2022>`

0 commit comments

Comments
 (0)