Skip to content
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

Repo refactor #57

Merged
merged 9 commits into from
Jun 24, 2023
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
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*{.yml,.yaml}]
indent_size = 2
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 120
per-file-ignores =
__init__.py: E402
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI
on:
workflow_dispatch:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
run_lints:
name: Run linters
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Python setup
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'pip'
- name: Install poetry
run: |
python -m pip install -U poetry
- id: cache-poetry
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
poetry install
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre_commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Pre-commit linters
run: |
poetry run pre-commit run --show-diff-on-failure --color=always --all-files
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v2

- name: Build image
run: |
run: |
echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
docker build . --file Dockerfile --tag $IMAGE_NAME --squash
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/lint_python.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ db.sqlite3
sentence_tokenizer.pickle

.vscode
.vscode/*
.vscode/*
42 changes: 42 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
repos:
- repo: https://github.com/psf/black
rev: bf7a162
hooks:
- id: black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: f71fa2c
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: debug-statements
language_version: python3

- repo: https://github.com/PyCQA/flake8
rev: b9a7794
hooks:
- id: flake8
language_version: python3

- repo: https://github.com/asottile/reorder-python-imports
rev: b5d69d1
hooks:
- id: reorder-python-imports

- repo: https://github.com/codespell-project/codespell
rev: ec0f41b
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/pre-commit/mirrors-mypy
rev: bd424e4
hooks:
- id: mypy
additional_dependencies:
- "types-PyYAML"
- "types-cachetools"
- "types-requests"
34 changes: 20 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.10-slim-bullseye

RUN apt-get update && \
apt-get install -y --no-install-recommends default-libmysqlclient-dev gcc git && \
pip install pipenv
FROM python:3.11-slim-bullseye as base

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Prevents poetry from creating a virtualenv
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1 \
POETRY_VERSION=1.5.1 \
POETRY_VIRTUALENVS_CREATE=false \
PYTHONDONTWRITEBYTECODE=1

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

RUN apt-get update && \
apt-get install -y --no-install-recommends default-libmysqlclient-dev gcc git && \
pip install "poetry==$POETRY_VERSION"

# Install pip requirements
COPY Pipfile* ./
RUN pipenv install --system --deploy --ignore-pipfile

RUN poetry install --without=dev --no-root --no-interaction --no-ansi

RUN apt-get autoremove gcc git --purge -y && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /root/.cache

COPY server-conf/beesite_uwsgi.ini /etc/uwsgi/uwsgi.ini

WORKDIR /beesite
COPY /src /beesite
WORKDIR /app
COPY /src /app

RUN gzip --keep --best --force --recursive /beesite/app/static/ && \
chown -R www-data:www-data /beesite
RUN gzip --keep --best --force --recursive /app/beesite/static/ && \
chown -R www-data:www-data /app

USER www-data:www-data

Expand Down
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

Loading