Add pre-commit hook to update version

This commit is contained in:
Lukáš Kucharczyk 2023-01-05 21:10:17 +01:00
parent 8efce77062
commit 2807c5e00e
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
5 changed files with 39 additions and 11 deletions

13
.githooks/pre-commit Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail
echo "----------------"
echo "Pre-commit hooks"
echo "================"
VERSION_NUMBER=$(git describe --tags)
echo "Updating "VERSION_NUMBER" in Dockerfile to $VERSION_NUMBER"
sed -i "s/^ENV VERSION_NUMBER.*$/ENV VERSION_NUMBER ${VERSION_NUMBER}/" Dockerfile
echo "Updating "version" in pyproject.toml to $VERSION_NUMBER"
sed -i "s/^version = \".*\"$/version = \"${VERSION_NUMBER}\"/" pyproject.toml
git add Dockerfile
git add pyproject.toml
echo "----------------"

View File

@ -1,4 +1,5 @@
## Unreleased ## Unreleased
* Add pre-commit hook to update version
* Improve the newcomer experience by guiding through each step * Improve the newcomer experience by guiding through each step
* Fix errors with empty database * Fix errors with empty database
* Fix negative playtimes being considered positive * Fix negative playtimes being considered positive

View File

@ -1,16 +1,23 @@
FROM node as css
COPY . /
RUN apt install -y npm && \
npm install && \
npx tailwindcss -i ./src/input.css -o ./src/web/tracker/static/base.css --minify
FROM python:3.10-slim-bullseye FROM python:3.10-slim-bullseye
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv pip $VIRTUAL_ENV ENV VERSION_NUMBER 0.1.0-34-g8efce77
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --no-cache-dir poetry RUN useradd --create-home --uid 1000 timetracker && \
RUN useradd --create-home --uid 1000 timetracker pip install --no-cache-dir poetry && \
poetry install --without dev
WORKDIR /home/timetracker/app WORKDIR /home/timetracker/app
COPY . /home/timetracker/app/ COPY . /home/timetracker/app/
RUN chown -R timetracker:timetracker /home/timetracker/app RUN chown -R timetracker:timetracker /home/timetracker/app
RUN poetry install --without dev
COPY entrypoint.sh / COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
USER timetracker USER timetracker
EXPOSE 8000 EXPOSE 8000
ENV VERSION_NUMBER 0.1.0-18-gb8a15e4
ENTRYPOINT [ "/entrypoint.sh" ] ENTRYPOINT [ "/entrypoint.sh" ]

View File

@ -2,7 +2,7 @@
all: css migrate all: css migrate
initialize: npm css migrate loadplatforms initialize: npm css migrate sethookdir loadplatforms
HTMLFILES := $(shell find src/web/tracker/templates -type f) HTMLFILES := $(shell find src/web/tracker/templates -type f)
@ -21,7 +21,7 @@ makemigrations:
migrate: makemigrations migrate: makemigrations
poetry run python src/web/manage.py migrate poetry run python src/web/manage.py migrate
dev: migrate dev: migrate sethookdir
TZ=Europe/Prague poetry run python src/web/manage.py runserver TZ=Europe/Prague poetry run python src/web/manage.py runserver
dumptracker: dumptracker:
@ -43,4 +43,7 @@ poetry.lock: pyproject.toml
poetry install poetry install
test: poetry.lock test: poetry.lock
poetry run pytest poetry run pytest
sethookdir:
git config core.hooksPath .githooks

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "timetracker" name = "timetracker"
version = "0.0.0" version = "0.1.0-34-g8efce77"
description = "A simple time tracker." description = "A simple time tracker."
authors = ["Lukáš Kucharczyk <lukas@kucharczyk.xyz>"] authors = ["Lukáš Kucharczyk <lukas@kucharczyk.xyz>"]
license = "GPL" license = "GPL"
@ -15,6 +15,10 @@ black = "^22.12.0"
mypy = "^0.991" mypy = "^0.991"
pyyaml = "^6.0" pyyaml = "^6.0"
pytest = "^7.2.0" pytest = "^7.2.0"
django-extensions = "^3.2.1"
werkzeug = "^2.2.2"
djlint = "^1.19.11"
djhtml = "^1.5.2"
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]