Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

dbbasic-object-server/tests/test_release_gate_script.py
Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 18 minutes ago History
test_release_gate_script.py · 1.6 KB · 39 lines
1"""scripts/release_gate.sh is the pre-push/pre-tag gate (see CONTRIBUTING.md, "Release gate").
2
3It needs Docker, so pytest never runs it; this only keeps it from rotting unnoticed: present, executable,
4syntactically valid bash, still offering its stages, and still cleaning up only what it created.
5"""
6import os
7import shutil
8import subprocess
9from pathlib import Path
10
11import pytest
12
13SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "release_gate.sh"
14
15
16def test_release_gate_script_exists_and_is_executable():
17 assert SCRIPT.is_file()
18 assert os.access(SCRIPT, os.X_OK)
19
20
21def test_release_gate_script_has_its_stages_and_safety_rails():
22 text = SCRIPT.read_text()
23 assert text.startswith("#!/usr/bin/env bash")
24 assert "set -euo pipefail" in text
25 for stage in ("fresh", "upgrade", "node", "all"):
26 assert f"{stage})" in text or f"|{stage}" in text or f"{stage}|" in text, stage
27 if stage != "all":
28 assert f"stage_{stage}()" in text
29 assert 'PREFIX="gate-' in text # everything it creates is named gate-...
30 assert "trap cleanup EXIT" in text # ...and removed on exit
31
32
33@pytest.mark.skipif(shutil.which("bash") is None, reason="bash not installed")
34def test_release_gate_script_is_valid_bash_and_rejects_an_unknown_stage():
35 assert subprocess.run(["bash", "-n", str(SCRIPT)]).returncode == 0
36 # an unknown stage is refused before it looks for Docker or creates anything
37 result = subprocess.run(["bash", str(SCRIPT), "nonsense"], capture_output=True, text=True)
38 assert result.returncode == 2
39 assert "usage" in result.stderr