-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
705 additions
and
308 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: Validation | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'master' | ||
paths: | ||
- '**.py' | ||
- '.github/workflows/validation.yml' | ||
pull_request: | ||
types: [ opened, synchronize, reopened ] | ||
branches: | ||
- 'master' | ||
paths: | ||
- '**.py' | ||
- '.github/workflows/validation.yml' | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Poetry install | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pypoetry | ||
key: poetry | ||
|
||
- name: Install Poetry | ||
run: | | ||
pipx install poetry | ||
- name: Setup Python | ||
id: setup_python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'poetry' | ||
cache-dependency-path: 'poetry.lock' | ||
|
||
- name: Cache venv | ||
uses: actions/cache@v4 | ||
id: cache-venv | ||
with: | ||
path: ./.venv/ | ||
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-app-${{ hashFiles('./poetry.lock') }} | ||
|
||
- name: Install App dependencies | ||
run: | | ||
poetry install --no-interaction --no-root | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
|
||
- name: Install App | ||
run: | | ||
poetry install --no-interaction | ||
- name: Ruff format | ||
if: success() || failure() | ||
run: | | ||
poetry run ruff format --check . --output-format github | ||
- name: Ruff lint | ||
if: success() || failure() | ||
run: | | ||
poetry run ruff check . --output-format github | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install -y poppler-utils tesseract-ocr-ces | ||
- name: Cache Poetry install | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pypoetry | ||
key: poetry | ||
|
||
- name: Install Poetry | ||
run: | | ||
pipx install poetry | ||
- name: Setup Python | ||
id: setup_python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'poetry' | ||
cache-dependency-path: 'poetry.lock' | ||
|
||
- name: Cache venv | ||
uses: actions/cache@v4 | ||
id: cache-venv | ||
with: | ||
path: ./.venv/ | ||
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-app-${{ hashFiles('./poetry.lock') }} | ||
|
||
- name: Install App dependencies | ||
run: | | ||
poetry install --no-interaction --no-root | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
|
||
- name: Install App | ||
run: | | ||
poetry install --no-interaction | ||
- name: Run tests | ||
run: | | ||
poetry run ./lunches.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.0.291 | ||
hooks: | ||
- id: ruff | ||
args: [--fix, --exit-non-zero-on-fix, --ignore, E501] | ||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.2.2 | ||
hooks: | ||
- id: codespell | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-yaml | ||
args: [--allow-multiple-documents] | ||
- id: check-case-conflict | ||
name: Check for files with names that would conflict on a case-insensitive filesystem | ||
entry: check-case-conflict | ||
- id: end-of-file-fixer | ||
name: Makes sure files end in a newline and only a newline. | ||
entry: end-of-file-fixer | ||
types: [text] | ||
- id: trailing-whitespace | ||
name: Trims trailing whitespace. | ||
entry: trailing-whitespace-fixer | ||
types: [text] | ||
- id: check-docstring-first | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.5.0 | ||
hooks: | ||
- id: ruff-format | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.5.0 | ||
hooks: | ||
- id: ruff | ||
args: [ --fix ] | ||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.3.0 | ||
hooks: | ||
- id: codespell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM python:3.12-slim-bookworm as build-stage | ||
|
||
RUN pip install poetry | ||
|
||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock* ./ | ||
RUN touch README.md | ||
|
||
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR | ||
|
||
FROM python:3.12-slim-bookworm as runtime | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build-stage /app . | ||
|
||
ENV PATH="/app/.venv/bin:$PATH" | ||
|
||
COPY templates ./templates | ||
|
||
COPY *.py . | ||
|
||
EXPOSE 443 | ||
|
||
CMD ["fastapi", "run", "--port", "443"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
services: | ||
redis: | ||
container_name: lunchmenu-redis | ||
image: redis:alpine | ||
restart: unless-stopped | ||
ports: | ||
- "6379:6379" | ||
command: "redis-server --save 20 1 --loglevel warning" | ||
volumes: | ||
- "redis_data:/data" | ||
extra_hosts: | ||
- host.docker.internal:host-gateway | ||
|
||
lunchmenu: | ||
container_name: lunchmenu | ||
depends_on: | ||
- redis | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
restart: unless-stopped | ||
ports: | ||
- "443:443" | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
|
||
volumes: | ||
redis_data: |
Oops, something went wrong.