Skip to content

Commit

Permalink
Fix earthfile for twitch announcer
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnySc2 committed Nov 16, 2024
1 parent c976862 commit 72926a6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 43 deletions.
1 change: 1 addition & 0 deletions ansible/service_authelia/authelia_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
project_src: /home/{{ USERNAME }}
# Reload config files
state: stopped
ignore_errors: true

- name: Run `docker-compose up` again
community.docker.docker_compose_v2:
Expand Down
1 change: 1 addition & 0 deletions fastapi_server/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ format:
LOCALLY
# Requirements:
# pip install uv
# uv sync

# Convert single to double quotes
RUN uv run ruff check . --select Q --fix
Expand Down
24 changes: 0 additions & 24 deletions fastapi_server/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion twitch_stream_announcer/.pyre_configuration
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"site_package_search_strategy": "pep561",
"source_directories": [
"."
"src"
]
}
32 changes: 15 additions & 17 deletions twitch_stream_announcer/Earthfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
VERSION 0.6
# earthly +all --PYTHONVERSION=3.12
ARG PYTHONVERSION=3.12
FROM python:${PYTHONVERSION}-slim
FROM ghcr.io/astral-sh/uv:python${PYTHONVERSION}-bookworm-slim
WORKDIR /root/stream_announcer

install-dev:
RUN apt -y update
RUN pip install poetry --no-cache-dir
COPY poetry.lock pyproject.toml ./
RUN poetry install
COPY src /root/stream_announcer/src
COPY uv.lock pyproject.toml ./
RUN uv sync --frozen --no-cache --no-install-project
COPY src /root/fastapi_server/src

format:
# Run on host system instead of inside a container
LOCALLY
# Requirements:
# pip install poetry
# poetry install

# pip install uv
# uv sync
# Convert single to double quotes
RUN poetry run ruff check . --select Q --fix
RUN uv run ruff check . --select Q --fix
# Remove unused imports
RUN poetry run ruff check . --select F --fix
RUN uv run ruff check . --select F --fix
# Sort imports
RUN poetry run ruff check . --select I --fix
RUN uv run ruff check . --select I --fix
# Format code
RUN poetry run yapf -ir .
RUN uv run ruff format .

# Check if files are correctly formatted
format-check:
FROM +install-dev
RUN poetry run yapf -dr .
RUN uv run ruff format . --check --diff

# Ignore errors via "# noqa: F841"
lint:
FROM +install-dev
RUN poetry run ruff check .
RUN uv run ruff check .

# Ignore errors via "# pyre-fixme[11]"
pyre:
FROM +install-dev
COPY .pyre_configuration /root/stream_announcer/.pyre_configuration
RUN poetry run pyre
RUN uv run pyre

# pytest:
# FROM +install-dev
# RUN poetry run pytest test
# RUN uv run pytest test

pre-commit:
BUILD +format-check
Expand Down
5 changes: 4 additions & 1 deletion twitch_stream_announcer/src/stream_announcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ async def check_twitch(chunked_data: list[dict[str, OrderedDict]]):
)
session = aiohttp.ClientSession()
all_previously_online_streams: list[str] = [
db_entry["twitch_name"] for chunk in chunked_data for db_entries in chunk.values() for db_entry in db_entries
db_entry["twitch_name"]
for chunk in chunked_data
for db_entries in chunk.values()
for db_entry in db_entries
if db_entry.get("status") == "online"
]
all_online_streams: list[str] = []
Expand Down

0 comments on commit 72926a6

Please sign in to comment.