Improve justfile init phase

This commit is contained in:
2023-11-25 23:41:52 +01:00
parent 8dba474e23
commit e57d9cf656

View File

@@ -1,21 +1,30 @@
# https://github.com/casey/just # https://github.com/casey/just
vbin := "./venv/bin" venv := "./venv"
pip := vbin / "pip" pip := venv / "bin/pip"
python := vbin / "python" python := venv / "bin/python"
last_commit_sha1 := `git rev-parse --short HEAD` last_commit_sha1 := `git rev-parse --short HEAD`
remote_image_name := "gitea.gdemontauzan.fr/maxenceg2m/github-release-notifier" remote_image_name := "gitea.gdemontauzan.fr/maxenceg2m/github-release-notifier"
remote_build_image := remote_image_name + ":" + last_commit_sha1 remote_build_image := remote_image_name + ":" + last_commit_sha1
# Run the script # Run the script
run: init run: _ensure_venv_is_ok
{{ python }} notifier.py {{ python }} notifier.py
# Init python virtual env # Init python virtual env
init: init:
python3 -m venv venv python3 -m venv venv
{{ pip }} install --requirement requirements.txt {{ pip }} install --requirement requirements.txt
sha256sum requirements.txt > {{ venv }}/requirements.sha
# Inspiration: https://github.com/behave/behave/blob/afb6b6716cd0f3e028829416475312db804a6aa9/justfile
_ensure_venv_is_ok:
#!/usr/bin/env python3
from subprocess import run
from os import path
if run("sha256sum -c {{ venv }}/requirements.sha", shell=True).returncode != 0:
run("just init", shell=True)
# Clean workspace - remove venv - and init # Clean workspace - remove venv - and init
reinit: hclean init reinit: hclean init