From e57d9cf65603f85344594f46e44638fe45a93c60 Mon Sep 17 00:00:00 2001 From: "Maxence G. de Montauzan" Date: Sat, 25 Nov 2023 23:41:52 +0100 Subject: [PATCH] Improve justfile init phase --- Justfile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Justfile b/Justfile index a74933a..609eeaf 100644 --- a/Justfile +++ b/Justfile @@ -1,21 +1,30 @@ # https://github.com/casey/just -vbin := "./venv/bin" -pip := vbin / "pip" -python := vbin / "python" +venv := "./venv" +pip := venv / "bin/pip" +python := venv / "bin/python" last_commit_sha1 := `git rev-parse --short HEAD` remote_image_name := "gitea.gdemontauzan.fr/maxenceg2m/github-release-notifier" remote_build_image := remote_image_name + ":" + last_commit_sha1 # Run the script -run: init +run: _ensure_venv_is_ok {{ python }} notifier.py # Init python virtual env init: python3 -m venv venv {{ 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 reinit: hclean init