From 797577639854c371d635b8718855eec0a1ac1e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20W=C3=B3jcik?= Date: Wed, 5 Jun 2024 07:10:16 +0000 Subject: [PATCH] v1.2.2 --- .gitea/workflows/cd.yaml | 11 --- .gitea/workflows/{checks.yaml => ci.yaml} | 18 ++--- CHANGELOG.md | 4 ++ Dockerfile | 88 +++++++++++++++++++++++ docs/source/conf.py | 4 +- keep_it_secret/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 1 + tasks.py | 16 ++++- 9 files changed, 121 insertions(+), 25 deletions(-) delete mode 100644 .gitea/workflows/cd.yaml rename .gitea/workflows/{checks.yaml => ci.yaml} (55%) create mode 100644 Dockerfile diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml deleted file mode 100644 index d63e3af..0000000 --- a/.gitea/workflows/cd.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: "CD" - -on: - push: - branches: - - "release" - -jobs: - checks: - name: "Checks" - uses: "./.gitea/workflows/checks.yaml" diff --git a/.gitea/workflows/checks.yaml b/.gitea/workflows/ci.yaml similarity index 55% rename from .gitea/workflows/checks.yaml rename to .gitea/workflows/ci.yaml index 02ae6ae..1c7e2ad 100644 --- a/.gitea/workflows/checks.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,20 +1,20 @@ -name: "Checks" +name: "CI" + on: - workflow_call: + push: + branches: + - "release" jobs: run-checks: - name: "Run checks" + name: "Checks" runs-on: "ubuntu-latest" steps: - - name: "Check out the code" - uses: "actions/checkout@v4" - - name: "Set up Python 3.10" - uses: "actions/setup-python@v5" + - uses: "actions/checkout@v4" + - uses: "actions/setup-python@v5" with: python-version: "3.10" - - name: "Set up poetry" - uses: "Gr1N/setup-poetry@v8" + - uses: "Gr1N/setup-poetry@v8" with: poetry-version: "1.7.1" - name: "Install deps" diff --git a/CHANGELOG.md b/CHANGELOG.md index cca3d79..aaa1535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Keep It Secret Changelog +#### v1.2.2 (2024-06-05) + +* TeamCity integration for private builds. + #### v1.2.1 (2024-05-29) * Gitea Actions integration. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..976cac1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,88 @@ +ARG APP_USER_UID=10001 +ARG APP_USER_GID=10001 +ARG IMAGE_TAG=development.000000 + +FROM python:3.10.14-slim-bookworm AS base + +ARG APP_USER_UID +ARG APP_USER_GID +ARG IMAGE_TAG + +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=off \ + PIP_DISABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 \ + PIP_INDEX_URL="https://nexus.bthlabs.pl/repository/pypi/simple/" \ + POETRY_VERSION=1.7.1 \ + POETRY_HOME="/srv/poetry" \ + POETRY_NO_INTERACTION=1 \ + VIRTUAL_ENV="/srv/venv" \ + KEEP_IT_SECRET_IMAGE_TAG=${IMAGE_TAG} + +RUN if [ ! $(getent group ${APP_USER_GID}) ];then groupadd -g ${APP_USER_GID} app; fi && \ + useradd -m -d /home/app -u ${APP_USER_UID} -g ${APP_USER_GID} app && \ + apt-get update && \ + apt-get install -y --no-install-recommends wait-for-it dumb-init curl && \ + (curl -sSL https://install.python-poetry.org | python -) && \ + python3.10 -m venv ${VIRTUAL_ENV} && \ + mkdir /srv/app /srv/bin /srv/lib /srv/log /srv/run && \ + chown -R ${APP_USER_UID}:${APP_USER_GID} /srv + +ENV PATH="${VIRTUAL_ENV}/bin:/srv/bin:/srv/poetry/bin:${PATH}" + +USER app +WORKDIR /srv/app + +FROM base AS development + +ARG APP_USER_UID +ARG APP_USER_GID +ARG IMAGE_TAG + +USER app +WORKDIR /srv/app + +FROM development AS deployment-build + +ARG APP_USER_UID +ARG APP_USER_GID +ARG IMAGE_TAG + +ADD --chown=$APP_USER_UID:$APP_USER_GID . /srv/app +RUN poetry install --no-dev + +FROM deployment-build AS ci + +ARG APP_USER_UID +ARG APP_USER_GID +ARG IMAGE_TAG + +RUN poetry install + +FROM base AS deployment + +ARG APP_USER_UID +ARG APP_USER_GID +ARG IMAGE_TAG + +COPY --from=deployment-build /srv/app /srv/app +COPY --from=deployment-build /srv/venv /srv/venv +RUN chown -R $APP_USER_UID:$APP_USER_GID /srv + +USER root + +RUN apt-get clean autoclean && \ + apt-get autoremove --yes && \ + rm -rf /var/lib/apt /var/lib/dpkg && \ + rm -rf /home/app/.cache + +USER app + +ENV PYTHONPATH="/srv/app" +ENV DJANGO_SETTINGS_MODULE="settings" + +EXPOSE 8000 + +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["echo NOOP"] diff --git a/docs/source/conf.py b/docs/source/conf.py index d81d0db..0b88459 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,10 +11,10 @@ project = 'Keep It Secret' copyright = '2023-present Tomek Wójcik' author = 'Tomek Wójcik' -version = '1.2.1' +version = '1.2.2' # The full version, including alpha/beta/rc tags -release = '1.2.1' +release = '1.2.2' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/keep_it_secret/__init__.py b/keep_it_secret/__init__.py index 4ba9e71..2573270 100644 --- a/keep_it_secret/__init__.py +++ b/keep_it_secret/__init__.py @@ -6,7 +6,7 @@ from .fields import ( # noqa: F401 ) from .secrets import Secrets # noqa: F401 -__version__ = '1.2.1' +__version__ = '1.2.2' __all__ = [ 'AbstractField', diff --git a/pyproject.toml b/pyproject.toml index 32c1191..a20c822 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "keep-it-secret" -version = "1.2.1" +version = "1.2.2" description = "Keep It Secret by BTHLabs" authors = ["Tomek Wójcik "] maintainers = ["BTHLabs "] diff --git a/setup.cfg b/setup.cfg index 001cbc1..e40df8a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,6 +6,7 @@ hang-closing = False [tool:pytest] addopts = --disable-warnings +junit_suite_name = keep_it_secret env = KEEP_IT_SECRET_TESTS_SPAM=spam AWS_ACCESS_KEY_ID=thisisntright diff --git a/tasks.py b/tasks.py index 7ee80a8..bc4a296 100644 --- a/tasks.py +++ b/tasks.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- # type: ignore +import os + from invoke import task try: @@ -20,13 +22,25 @@ def mypy(ctx, warn=False): @task def tests(ctx, warn=False): - return ctx.run('pytest -v', warn=warn) + pytest_command_line = [ + 'pytest', + '-v', + ] + + if 'KEEP_IT_SECRET_JUNIT_XML_PATH' in os.environ: + pytest_command_line.append( + f"--junit-xml={os.environ['KEEP_IT_SECRET_JUNIT_XML_PATH']}", + ) + + return ctx.run(' '.join(pytest_command_line), warn=warn) @task def ci(ctx): result = True + ctx.run('mkdir -p build') + if flake8(ctx, warn=True).exited != 0: result = False