Skip to content

Bump poetry to 1.2.0 in CI & the example project #135

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 6 commits into from
Sep 18, 2022
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
13 changes: 2 additions & 11 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ concurrency:
group: docs-deployment-${{ github.ref }}
cancel-in-progress: true


jobs:
latest-build:
# We only need to verify that the docs build with no warnings here
Expand All @@ -22,16 +21,12 @@ jobs:
- uses: actions/checkout@v2

- name: Install Python Dependencies
uses: HassanAbouelela/actions/setup-python@setup-python_v1.1.0
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.1
with:
dev: true
python_version: "3.10"
install_args: "--extras async-rediscache"

# Undeclared dependency for `releases`... whoops
# https://github.com/bitprophet/releases/pull/82
- run: pip install six

- name: Generate HTML Site
run: sphinx-build -nW -j auto -b html docs docs/build

Expand All @@ -51,16 +46,12 @@ jobs:
fetch-depth: 0 # We need to check out the entire repository to find all tags

- name: Install Python Dependencies
uses: HassanAbouelela/actions/setup-python@setup-python_v1.1.0
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.1
with:
dev: true
python_version: "3.10"
install_args: "--extras async-rediscache"

# Undeclared dependency for `releases`... whoops
# https://github.com/bitprophet/releases/pull/82
- run: pip install six

- name: Build All Doc Versions
run: sphinx-multiversion docs docs/build -n -j auto
env:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@ jobs:
lint:
name: Run Linting & Test Suites
runs-on: ubuntu-latest

steps:
- name: Install Python Dependencies
uses: HassanAbouelela/actions/setup-python@setup-python_v1.1.0
uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.1
with:
# Set dev=true to run pre-commit which is a dev dependency
dev: true
python_version: "3.10"
install_args: "--extras async-rediscache"

# We will not run `flake8` here, as we will use a separate flake8
# action. As pre-commit does not support user installs, we set
# PIP_USER=0 to not do a user install.
# action.
- name: Run pre-commit hooks
run: export PIP_USER=0; SKIP=flake8 pre-commit run --all-files
run: SKIP=flake8 pre-commit run --all-files

# Run flake8 and have it format the linting errors in the format of
# the GitHub Workflow command to register error annotations. This
Expand Down
12 changes: 3 additions & 9 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
FROM python:3.10-slim
FROM --platform=linux/amd64 ghcr.io/chrislovering/python-poetry-base:3.10-slim

# Set pip to have no saved cache
ENV PIP_NO_CACHE_DIR=false \
POETRY_VIRTUALENVS_CREATE=false

# Install poetry
RUN pip install -U poetry

WORKDIR /app

# Install project dependencies
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-root

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

# Install again, this time with the root project
RUN poetry install

Expand Down
2 changes: 1 addition & 1 deletion dev/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Option 2
3. Configure the environment variables used by the program.
You can set them in an ``.env`` file in the project root directory. The variables are:

- ``TOKEN`` (required): Discord bot token, with all intents enabled
- ``BOT_TOKEN`` (required): Discord bot token, with all intents enabled
- ``GUILD_ID`` (required): The guild the bot should monitor
- ``PREFIX``: The prefix to use for invoking bot commands. Defaults to mentions and ``!``
- ``ALLOWED_ROLES``: A comma seperated list of role IDs which the bot is allowed to mention
Expand Down
2 changes: 1 addition & 1 deletion dev/bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ async def main() -> None:
"""Run the bot."""
bot.http_session = aiohttp.ClientSession()
async with bot:
await bot.start(os.getenv("TOKEN"))
await bot.start(os.getenv("BOT_TOKEN"))

asyncio.run(main())
23 changes: 21 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ services:
timeout: 1s
retries: 5

metricity:
restart: on-failure
depends_on:
postgres:
condition: service_healthy
image: ghcr.io/python-discord/metricity:latest
env_file:
- .env
environment:
DATABASE_URI: postgres://pysite:pysite@postgres/metricity
USE_METRICITY: ${USE_METRICITY-false}
volumes:
- .:/tmp/bot:ro

redis:
<< : *restart_policy
image: redis:5.0.9
Expand Down Expand Up @@ -46,15 +60,20 @@ services:
METRICITY_DB_URL: postgres://pysite:pysite@postgres:5432/metricity
SECRET_KEY: suitable-for-development-only
STATIC_ROOT: /var/www/static
depends_on:
- metricity

bot:
<< : *restart_policy
build:
context: .
dockerfile: dev/Dockerfile
volumes:
- .:/app:ro
volumes: # Don't do .:/app here to ensure project venv from host doens't overwrite venv in image
- ./botcore:/app/botcore:ro
- ./bot:/app/bot:ro
tty: true
depends_on:
- web
env_file:
- .env
environment:
Expand Down