summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-03-28 13:19:02 +0300
committerLars Wirzenius <liw@liw.fi>2021-03-28 16:26:45 +0300
commitc444c915fc349ee345080aa4d151f9416b5c0ab8 (patch)
treeea41a40f3e29db50758d1f9d3744b7b78702743b /subplot
parent81fa9799b1393f427e4095978285cabbaa809735 (diff)
downloadbumper-rs-c444c915fc349ee345080aa4d151f9416b5c0ab8.tar.gz
feat: create git tag for release
Diffstat (limited to 'subplot')
-rw-r--r--subplot/bumper.py41
-rw-r--r--subplot/bumper.yaml12
2 files changed, 53 insertions, 0 deletions
diff --git a/subplot/bumper.py b/subplot/bumper.py
index 66d2564..0e6a0ef 100644
--- a/subplot/bumper.py
+++ b/subplot/bumper.py
@@ -1,4 +1,6 @@
+import logging
import os
+import shlex
def install_bumper(ctx):
@@ -7,3 +9,42 @@ def install_bumper(ctx):
# Add the directory with built Rust binaries to the path.
runcmd_prepend_to_path(ctx, dirname=os.path.join(srcdir, "target", "debug"))
+
+
+def git_init_and_commit_everything(ctx, dirname=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_run(ctx, ["git", "init", dirname])
+ runcmd_run(ctx, ["git", "add", "."], cwd=dirname)
+ runcmd_run(ctx, ["git", "commit", "-minitial"], cwd=dirname)
+
+
+def remember_HEAD(ctx, dirname=None, varname=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_get_stdout = globals()["runcmd_get_stdout"]
+ runcmd_run(ctx, ["git", "rev-parse", "HEAD"], cwd=dirname)
+ ctx[varname] = runcmd_get_stdout(ctx).strip()
+
+
+def run_command_in_directory(ctx, dirname=None, argv0=None, args=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
+
+ argv = [shlex.quote(argv0)] + shlex.split(args)
+ runcmd_run(ctx, argv, cwd=dirname)
+ runcmd_exit_code_is_zero(ctx)
+
+
+def git_tag_points_at(ctx, dirname=None, tag=None, varname=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_get_stdout = globals()["runcmd_get_stdout"]
+ runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
+
+ runcmd_run(ctx, ["git", "show", "--raw", tag], cwd=dirname)
+ runcmd_exit_code_is_zero(ctx)
+
+ output = runcmd_get_stdout(ctx)
+ commit = ctx[varname]
+ logging.debug(f"expecting tag {tag} to point at {commit}")
+ logging.debug(f"tag: {output!r}")
+ assert output.startswith(f"tag {tag}\n")
+ assert f"\ncommit {commit}" in output
diff --git a/subplot/bumper.yaml b/subplot/bumper.yaml
index f74c28e..7b95dac 100644
--- a/subplot/bumper.yaml
+++ b/subplot/bumper.yaml
@@ -1,2 +1,14 @@
- given: "an installed Bumper"
function: install_bumper
+
+- given: "all files in {dirname} are committed to git"
+ function: git_init_and_commit_everything
+
+- given: "the HEAD commit in {dirname} is {varname}"
+ function: remember_HEAD
+
+- when: "I run, in {dirname}, {argv0}{args:text}"
+ function: run_command_in_directory
+
+- then: "in {dirname}, git tag {tag} is a signed tag pointing at <{varname}>"
+ function: git_tag_points_at