ci(deps): pin hook revisions by SHA and install dev tools from a hashed lock
Refs #113. - .pre-commit-config.yaml: every hook repo is pinned by commit SHA with the release in a `# frozen:` comment, so a moved tag cannot change the code a hook environment is built from. - requirements-dev.lock: hashed lock of requirements-dev.txt. Installs use `pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt` (dev-setup.sh, the ci image, the fallback install of Lint and Build): pip refuses an unhashed package and any disagreement between the two files. - scripts/lock-requirements.sh regenerates the lock (pinned pip and pip-tools, --upgrade mode). - renovate.json: the pip-compile manager replaces pip_requirements for the lock, plus a weekly, never automerged lock-file maintenance PR for transitive packages. Not yet dry-run on Renovate. - check_bot_pr_diff.py accepts `rev: <sha> # frozen: <tag>` and lock entries, hashes and plain comments, but not a changed pip-compile header command. - ci image 0.2.18 -> 0.2.19 (image inputs changed).
This commit is contained in:
1 parent
7fa6c6754d
commit
4058978353
20 files changed
+1546
-46
No files matched your search
@@ -35,7 +35,11 @@ fi
|
||||
exit 2
|
||||
"""
|
||||
|
||||
PIP_STUB = "#!/bin/sh\nexit 0\n"
|
||||
# Records the arguments of each call, one line per call.
|
||||
PIP_STUB = """#!/bin/sh
|
||||
printf '%s\\n' "$*" >> "$STUB_DIR/pip.log"
|
||||
exit 0
|
||||
"""
|
||||
|
||||
# Records the collections path and the arguments of each call, one line per call.
|
||||
GALAXY_STUB = """#!/bin/sh
|
||||
@@ -110,6 +114,7 @@ class DevSetupTest(unittest.TestCase):
|
||||
(repo / "scripts").mkdir(parents=True)
|
||||
shutil.copy(SCRIPT, repo / "scripts" / "dev-setup.sh")
|
||||
(repo / "requirements-dev.txt").write_text("")
|
||||
(repo / "requirements-dev.lock").write_text("")
|
||||
(repo / "requirements.yml").write_text("---\ncollections: []\n")
|
||||
self.git(repo, "init", "--quiet")
|
||||
return repo
|
||||
@@ -148,6 +153,18 @@ class DevSetupTest(unittest.TestCase):
|
||||
self.assertIn("# kamino-dev-setup: virtualenv first on PATH", text)
|
||||
self.assertEqual(self.hooks_z(repo), b"")
|
||||
|
||||
def test_tools_are_installed_from_the_hashed_lock_with_its_pins(self) -> None:
|
||||
repo = self.make_repo()
|
||||
self.assertEqual(self.run_setup(repo).returncode, 0)
|
||||
calls = (self.stubs / "pip.log").read_text().splitlines()
|
||||
self.assertEqual(len(calls), 1, calls)
|
||||
# --require-hashes, the lock, and the direct pins next to it (pip refuses a disagreement).
|
||||
self.assertIn("--require-hashes", calls[0].split())
|
||||
self.assertTrue(
|
||||
calls[0].endswith("-r requirements-dev.lock -r requirements-dev.txt"),
|
||||
calls[0],
|
||||
)
|
||||
|
||||
def galaxy_calls(self) -> list[str]:
|
||||
return (self.stubs / "galaxy.log").read_text().splitlines()
|
||||
|
||||
|
||||
Reference in new issue
Block a user