Skip to content

Commit

Permalink
Update deployment, pre-commit, and project configurations
Browse files Browse the repository at this point in the history
-  Update the GitHub Actions deployment workflow by adding a new `platforms` line
-  Bump up the versions of pre-commit hooks and change the source repo of `ruff`
-  Adjust the order of constants in `base.py` and update some of the dependencies in `pyproject.toml`
-  Modify the ignore rules in the ruff linter configuration
  • Loading branch information
jag-k committed Apr 9, 2024
1 parent ece866c commit 745bc11
Show file tree
Hide file tree
Showing 7 changed files with 443 additions and 403 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64,linux/arm/v7


release:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:

- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.1.6'
rev: 'v0.3.5'
hooks:
# Run the linter.
- id: ruff
Expand All @@ -17,7 +17,7 @@ repos:
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ FROM python:3.12-slim as base
LABEL org.opencontainers.image.source="https://github.com/jag-k/owntinfoil"
LABEL org.opencontainers.image.description="OwnTinfoil Image"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.authors="Jag_k"
LABEL org.opencontainers.image.url="https://github.com/jag-k/owntinfoil"
LABEL org.opencontainers.image.documentation="https://github.com/jag-k/owntinfoil/wiki"
LABEL org.opencontainers.image.vendor="Jag_k"

ENV PIP_DEFAULT_TIMEOUT=100 \
# Allow statements and log messages to immediately appear
Expand All @@ -16,15 +20,15 @@ WORKDIR $PYTHONPATH

FROM base as builder

ARG POETRY_VERSION=1.7.1
ARG POETRY_VERSION=1.8.2
RUN pip install "poetry==$POETRY_VERSION"

COPY pyproject.toml poetry.lock ./

# Set poetry config to install packages in /venv/project/lib/python3.12/site-packages
RUN poetry config virtualenvs.path "/venv" && \
poetry config virtualenvs.prompt "project" && \
RUN poetry config virtualenvs.create false && \
poetry install --no-root --only main
# poetry config virtualenvs.prompt "project" && \


FROM base as final
Expand All @@ -33,7 +37,8 @@ ENV NPS_DIR=/nps
ENV TORRENT_DIR=/torrents

# Copy python side-packages from builder
COPY --from=builder "/venv/project/lib/python3.12/site-packages" "/usr/local/lib/python3.11/site-packages"
# RUN mkdir -p "/usr/local/lib/python3.12/site-packages"
COPY --from=builder "/usr/local/lib/python3.12/site-packages" "/usr/local/lib/python3.12/site-packages"

COPY . $PYTHONPATH

Expand Down
8 changes: 4 additions & 4 deletions app/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

__all__ = (
"BASE_PATH",
"NPS_DIR",
"TORRENT_DIR",
"BOT_KEY",
"BOT_URL",
"OVERRIDE_TORRENTS",
"SUCCESS_MESSAGE",
"HOST",
"NPS_DIR",
"OVERRIDE_TORRENTS",
"PORT",
"SUCCESS_MESSAGE",
"TORRENT_DIR",
)
3 changes: 1 addition & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ async def run():


def main():
loop = asyncio.get_event_loop()
# noinspection HttpUrlsUsage
print(f"Server started at http://{HOST}:{PORT}", file=sys.stderr)
print("Press CTRL+C to exit", file=sys.stderr)
try:
loop.run_until_complete(run())
asyncio.run(run())
except KeyboardInterrupt:
print("Exiting...", file=sys.stderr)

Expand Down
805 changes: 420 additions & 385 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ packages = []

[tool.poetry.dependencies]
python = "^3.12"
python-dotenv = "^1.0.0"
aiohttp = "^3.9.1"
python-dotenv = "^1.0.1"
aiohttp = "^3.9.3"
aiofile = "^3.8.5"
aiohttp-basicauth = "^1.0.0"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.5.0"
ruff = "^0.1.6"
ruff-lsp = "^0.0.45"
ruff = "*"
ruff-lsp = "*"

[build-system]
requires = ["poetry-core"]
Expand Down Expand Up @@ -70,7 +70,7 @@ select = [

"RUF", # ruff
]
ignore = ["E501"]
ignore = ["E501", "COM812"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F403", "F405"]

0 comments on commit 745bc11

Please sign in to comment.