Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BjoernPetersen committed Nov 5, 2023
0 parents commit f282a0f
Show file tree
Hide file tree
Showing 23 changed files with 892 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
**/.dart_tool
.venv/
.*_cache
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.py]
indent_style = space
indent_size = 4
max_line_length = 88

[Makefile]
indent_style = tab
51 changes: 51 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Workflow

on:
push:
branches: [ main ]
pull_request: { }

jobs:
lint:
uses: BlindfoldedSurgery/actions-python/.github/workflows/lint.yml@v1
with:
python-version: '3.11'

test:
uses: BlindfoldedSurgery/actions-python/.github/workflows/test.yml@v1
with:
python-version: '3.11'

build-container-image:
needs:
- lint
- test
uses: BlindfoldedSurgery/actions-container/.github/workflows/build-image-docker.yml@v2
with:
push-image: ${{ github.ref_name == github.event.repository.default_branch }}

deploy:
runs-on: ubuntu-latest
needs:
- build-container-image
if: success() && github.ref_name == github.event.repository.default_branch
concurrency: production
steps:
- uses: actions/checkout@v4
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Substitute environment variables in values.yaml
run: "envsubst < values.yaml > values_sub.yaml && mv values_sub.yaml values.yaml"
env:
IMAGE_NAME: "ghcr.io/${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}"
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
- uses: WyriHaximus/github-action-helm3@v3
with:
exec: helm upgrade location-bot . --install --namespace=telegram-bots --atomic
kubeconfig: '${{ secrets.KUBECONFIG_RAW }}'

clean:
concurrency: cleanup
needs: [ deploy ]
uses: BlindfoldedSurgery/actions-container/.github/workflows/clean.yml@v2
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Files and directories created by conventional Python tools.
__pycache__
.venv
venv
.mypy_cache/
.ruff_cache/
.pytest_cache/

# IntelliJ IDEA
.idea/

.env

usages.db
state.json
downloads/
6 changes: 6 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: location-bot

type: application

version: 1.0.0
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM python:3.11-slim-bookworm AS base

RUN groupadd --system --gid 500 app
RUN useradd --system --uid 500 --gid app --create-home --home-dir /app -s /bin/bash app

RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
curl \
tini \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives

# renovate: datasource=pypi depName=poetry
ENV POETRY_VERSION=1.6.1
ENV POETRY_HOME="/opt/poetry"
ENV POETRY_VIRTUALENVS_IN_PROJECT=false
ENV PATH="$POETRY_HOME/bin:$PATH"

RUN curl -sSL https://install.python-poetry.org | python3 -

USER app
WORKDIR /app

COPY [ "poetry.toml", "poetry.lock", "pyproject.toml", "./" ]

RUN poetry install --no-interaction --ansi --only=main --no-root

FROM base AS prod

# We don't want the tests
COPY src/az ./src/az

RUN poetry install --no-interaction --ansi --only-root

ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION

ENTRYPOINT [ "tini", "--", "poetry", "run", "python", "-m", "app" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.PHONY: check
check: lint test

.PHONY: lint
lint:
poetry run black src/
poetry run ruff check --fix --show-fixes src/
poetry run mypy src/

.PHONY: test
test:
poetry run pytest src/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Location Bot
Loading

0 comments on commit f282a0f

Please sign in to comment.