Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a130f143f | ||
|
|
cce3e54e7f | ||
|
|
33f4ee960e | ||
|
|
6d054b0f8b | ||
|
|
9dba48a30d | ||
|
|
2b0326801f | ||
|
|
1e95d8cbdd | ||
|
|
47641ae01d | ||
|
|
c617bee02a | ||
|
|
f7da80b326 | ||
|
|
1029d8ecce | ||
|
|
535926b36e | ||
|
|
595f517b49 | ||
|
|
d732ac0a71 | ||
|
|
f62097a748 |
No files matched your search
@@ -6,6 +6,7 @@ profile: production
|
|||||||
exclude_paths:
|
exclude_paths:
|
||||||
- .gitea
|
- .gitea
|
||||||
- .venv
|
- .venv
|
||||||
|
- .venv-dev
|
||||||
- apm_modules
|
- apm_modules
|
||||||
- apm.lock.yaml
|
- apm.lock.yaml
|
||||||
- changelogs
|
- changelogs
|
||||||
|
|||||||
@@ -39,11 +39,14 @@ issue.
|
|||||||
while a content check must see the content it is given. *Held:* review (`CODEOWNERS`).
|
while a content check must see the content it is given. *Held:* review (`CODEOWNERS`).
|
||||||
- **A pull request from a `renovate/` branch changes only version, tag, digest and pin lines**
|
- **A pull request from a `renovate/` branch changes only version, tag, digest and pin lines**
|
||||||
(tool pins with their lock entries and hashes, hook `rev:` lines, Dockerfile `FROM` tags and
|
(tool pins with their lock entries and hashes, hook `rev:` lines, Dockerfile `FROM` tags and
|
||||||
digests, `job_image:` pins, consumer image pins).
|
digests, `job_image:` pins, consumer image pins). In `pyproject.toml` only a pin's version
|
||||||
|
moves; in `uv.lock` only apm-cli moves, to that pin, with its files from PyPI by sha256, and
|
||||||
|
every other package stays as it is.
|
||||||
*Why:* the bot's minor and patch pull requests automerge, so they must not be able to change
|
*Why:* the bot's minor and patch pull requests automerge, so they must not be able to change
|
||||||
anything else. *Held:* control: the Lint check's "Check a bot pull request only moves pins"
|
anything else; uv installs whatever `uv.lock` names, so it is parsed, not read line by line.
|
||||||
step, `scripts/check_bot_pr_diff.py` run from `main`'s copy. The branch name is chosen by the
|
*Held:* control: the Lint check's "Check a bot pull request only moves pins" step,
|
||||||
pusher, so this constrains only the bot's own pull requests.
|
`scripts/check_bot_pr_diff.py` with `scripts/check_uv_lock.py`, run from `main`'s copy. The
|
||||||
|
branch name is chosen by the pusher, so this constrains only the bot's own pull requests.
|
||||||
- **Workflows never mention the image namespace this repository's CI must not use** (the string
|
- **Workflows never mention the image namespace this repository's CI must not use** (the string
|
||||||
is in `scripts/check_image_versions.py`). *Why:* this repository's images are built and pulled
|
is in `scripts/check_image_versions.py`). *Why:* this repository's images are built and pulled
|
||||||
only under its own organisation's namespace. *Held:* control: the Lint check's "Check image
|
only under its own organisation's namespace. *Held:* control: the Lint check's "Check image
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84
|
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||||
env:
|
env:
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
steps:
|
steps:
|
||||||
@@ -94,13 +94,13 @@ jobs:
|
|||||||
# ansible-galaxy dereferences symlinks when it builds, so a symlink in the source tree
|
# ansible-galaxy dereferences symlinks when it builds, so a symlink in the source tree
|
||||||
# reaches the archive as a regular file with the target's content, where
|
# reaches the archive as a regular file with the target's content, where
|
||||||
# scripts/check_tarball.py cannot see it. Refuse them in the tree instead: this step
|
# scripts/check_tarball.py cannot see it. Refuse them in the tree instead: this step
|
||||||
# is the only guard against a file symlink. The two -prune paths below (./.venv,
|
# is the only guard against a file symlink. The -prune paths below (./.git, ./.venv,
|
||||||
# ./.git) are skipped only because the build skips them too (galaxy.yml build_ignore,
|
# ./.venv-dev) are skipped only because the build skips them too (galaxy.yml build_ignore,
|
||||||
# and ansible-galaxy's own .git exclusion): the two lists must stay in step, and
|
# and ansible-galaxy's own .git exclusion): the two lists must stay in step, and
|
||||||
# tests/scripts/test_check_tarball.py fails when a pruned directory is not ignored.
|
# tests/scripts/test_check_tarball.py fails when a pruned directory is not ignored.
|
||||||
- name: Refuse symlinks in the source tree
|
- name: Refuse symlinks in the source tree
|
||||||
run: |
|
run: |
|
||||||
links="$(find . -path ./.git -prune -o -path ./.venv -prune -o -type l -print)"
|
links="$(find . -path ./.git -prune -o -path ./.venv -prune -o -path ./.venv-dev -prune -o -type l -print)"
|
||||||
if [ -n "$links" ]; then
|
if [ -n "$links" ]; then
|
||||||
echo "::error::symlinks in the source tree would be dereferenced into the Collection archive:"
|
echo "::error::symlinks in the source tree would be dereferenced into the Collection archive:"
|
||||||
echo "$links"
|
echo "$links"
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ jobs:
|
|||||||
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
|
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
|
||||||
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84
|
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||||
steps:
|
steps:
|
||||||
# The container has no Node, so JavaScript actions such as actions/checkout
|
# The container has no Node, so JavaScript actions such as actions/checkout
|
||||||
# cannot run; clone with git and the job token.
|
# cannot run; clone with git and the job token.
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
# The tag says which release, the digest is what is enforced (bump both together
|
# The tag says which release, the digest is what is enforced (bump both together
|
||||||
# when image.yml publishes a new version).
|
# when image.yml publishes a new version).
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84
|
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||||
env:
|
env:
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
PRE_COMMIT_HOME: /opt/pre-commit
|
PRE_COMMIT_HOME: /opt/pre-commit
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Built collection archives and local tooling
|
# Built collection archives and local tooling
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
/.venv/
|
/.venv/
|
||||||
|
/.venv-dev/
|
||||||
/venv/
|
/venv/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ extends: default
|
|||||||
|
|
||||||
ignore: |
|
ignore: |
|
||||||
.venv/**
|
.venv/**
|
||||||
|
.venv-dev/**
|
||||||
apm_modules/**
|
apm_modules/**
|
||||||
# Generated by apm install; its list indentation fails the rules below.
|
# Generated by apm install; its list indentation fails the rules below.
|
||||||
apm.lock.yaml
|
apm.lock.yaml
|
||||||
|
|||||||
@@ -4,6 +4,19 @@ mortis.kamino Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
v3.5.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- ufw - New input ``ufw_mask_nftables`` (default ``true``) and tag ``ufw_nftables``. Set the input to ``false`` on a host that loads its own ruleset through ``nftables.service``; the role never unmasks the unit.
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- ufw - An upgrade of the ``nftables`` package no longer deletes the firewall rules on hosts where ``nftables.service`` is enabled. The package's postinst restarts that unit, whose stock ``/etc/nftables.conf`` begins with ``flush ruleset``, so the rules ufw and Docker loaded were gone until they reloaded. The role now masks ``nftables.service`` without stopping it whenever ``ufw_enabled`` is true, also when the unit or the package is absent, so the first run reports ``changed`` once. A host that loads its own ruleset through ``nftables.service`` (NAT tables or sets, for example) would lose it at the next reboot without a warning, because a masked unit does not start: set ``ufw_mask_nftables: false`` on such a host before upgrading.
|
||||||
|
|
||||||
v3.4.0
|
v3.4.0
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|||||||
@@ -34,4 +34,6 @@ GLOSSARY\\.md @Defame1297
|
|||||||
\\.claude/.* @Defame1297
|
\\.claude/.* @Defame1297
|
||||||
apm\\.yml @Defame1297
|
apm\\.yml @Defame1297
|
||||||
apm\\.lock\\.yaml @Defame1297
|
apm\\.lock\\.yaml @Defame1297
|
||||||
|
pyproject\\.toml @Defame1297
|
||||||
|
uv\\.lock @Defame1297
|
||||||
\\.mcp\\.json @Defame1297
|
\\.mcp\\.json @Defame1297
|
||||||
@@ -5,7 +5,7 @@ An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
|
|||||||
`nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`,
|
`nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`,
|
||||||
`ufw` and `user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
|
`ufw` and `user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
|
||||||
|
|
||||||
Status: roles arrive in waves. Release 3.4.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
|
Status: roles arrive in waves. Release 3.5.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
|
||||||
|
|
||||||
## Consuming
|
## Consuming
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
|
|||||||
collections:
|
collections:
|
||||||
- name: https://git.rkdr.net/mortis/kamino.git
|
- name: https://git.rkdr.net/mortis/kamino.git
|
||||||
type: git
|
type: git
|
||||||
version: v3.4.0
|
version: v3.5.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
|
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
|
||||||
|
|||||||
+6
-6
@@ -1,6 +1,6 @@
|
|||||||
lockfile_version: '4'
|
lockfile_version: '4'
|
||||||
generated_at: '2026-11-29T13:12:37.842657+00:00'
|
generated_at: '2026-12-04T21:33:07.493501+00:00'
|
||||||
apm_version: 0.38.1
|
apm_version: 0.39.3
|
||||||
manifest_targets:
|
manifest_targets:
|
||||||
- claude
|
- claude
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -220,8 +220,8 @@ dependencies:
|
|||||||
.claude/agents/plan-researcher.md: sha256:eda0457d2007cf0c6cb4745383a0369d03a26ed252d7251a1f5250003a89ef85
|
.claude/agents/plan-researcher.md: sha256:eda0457d2007cf0c6cb4745383a0369d03a26ed252d7251a1f5250003a89ef85
|
||||||
.claude/agents/plan-validator.md: sha256:a56e7a710fd9e7a9dd9e2601f1f2701b98fd229f3e014bba4bda4dfe5977ecae
|
.claude/agents/plan-validator.md: sha256:a56e7a710fd9e7a9dd9e2601f1f2701b98fd229f3e014bba4bda4dfe5977ecae
|
||||||
.claude/commands/next.md: sha256:8e16330ec0f16dbbc86d44fca94699e33e393c9a8af76f45d3f3bd2b9c8bfa1f
|
.claude/commands/next.md: sha256:8e16330ec0f16dbbc86d44fca94699e33e393c9a8af76f45d3f3bd2b9c8bfa1f
|
||||||
.claude/commands/plan.md: sha256:2538b3dbb3860ebe93a39cad95cd5a1adcbeded19f404a84201b3e8aa7ce91c7
|
.claude/commands/plan.md: sha256:c5216fb6c443ca9de45ad5cb69351a4e3193bcb5ffca4d59567495fcb5d7ec71
|
||||||
.claude/commands/ship.md: sha256:f108f73e60a884f46285955027fba47d6309fed6a89812948f577e27be180af8
|
.claude/commands/ship.md: sha256:c3c9f516b9b01cb7f879d7d331187b12f697f73104b0eafdc813d64b73091284
|
||||||
.claude/skills/plan-track/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
|
.claude/skills/plan-track/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
|
||||||
.claude/skills/plan-track/SKILL.md: sha256:fee5062c8c63b49f66368b290c8ebd8cfff744137670d0c037da1a49c455c047
|
.claude/skills/plan-track/SKILL.md: sha256:fee5062c8c63b49f66368b290c8ebd8cfff744137670d0c037da1a49c455c047
|
||||||
.claude/skills/research-docs/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
|
.claude/skills/research-docs/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
|
||||||
@@ -843,7 +843,7 @@ deployments:
|
|||||||
owners:
|
owners:
|
||||||
- git.rkdr.net/Mortis/Holocron/plugins/plan
|
- git.rkdr.net/Mortis/Holocron/plugins/plan
|
||||||
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
|
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
|
||||||
content_hash: sha256:2538b3dbb3860ebe93a39cad95cd5a1adcbeded19f404a84201b3e8aa7ce91c7
|
content_hash: sha256:c5216fb6c443ca9de45ad5cb69351a4e3193bcb5ffca4d59567495fcb5d7ec71
|
||||||
- kind: project-relative
|
- kind: project-relative
|
||||||
target: claude
|
target: claude
|
||||||
value: .claude/commands/ship.md
|
value: .claude/commands/ship.md
|
||||||
@@ -852,7 +852,7 @@ deployments:
|
|||||||
owners:
|
owners:
|
||||||
- git.rkdr.net/Mortis/Holocron/plugins/plan
|
- git.rkdr.net/Mortis/Holocron/plugins/plan
|
||||||
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
|
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
|
||||||
content_hash: sha256:f108f73e60a884f46285955027fba47d6309fed6a89812948f577e27be180af8
|
content_hash: sha256:c3c9f516b9b01cb7f879d7d331187b12f697f73104b0eafdc813d64b73091284
|
||||||
- kind: project-relative
|
- kind: project-relative
|
||||||
target: claude
|
target: claude
|
||||||
value: .claude/skills/code-review
|
value: .claude/skills/code-review
|
||||||
|
|||||||
@@ -93,4 +93,4 @@ plugins:
|
|||||||
strategy: {}
|
strategy: {}
|
||||||
test: {}
|
test: {}
|
||||||
vars: {}
|
vars: {}
|
||||||
version: 3.4.0
|
version: 3.5.0
|
||||||
@@ -599,3 +599,24 @@ releases:
|
|||||||
- 511-system-baseline-icmp-redirects.yml
|
- 511-system-baseline-icmp-redirects.yml
|
||||||
- 511-system-baseline-sysctl-wildcard.yml
|
- 511-system-baseline-sysctl-wildcard.yml
|
||||||
release_date: '2026-12-03'
|
release_date: '2026-12-03'
|
||||||
|
3.5.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- 'ufw - An upgrade of the ``nftables`` package no longer deletes the firewall
|
||||||
|
rules on hosts where ``nftables.service`` is enabled. The package''s postinst
|
||||||
|
restarts that unit, whose stock ``/etc/nftables.conf`` begins with ``flush
|
||||||
|
ruleset``, so the rules ufw and Docker loaded were gone until they reloaded.
|
||||||
|
The role now masks ``nftables.service`` without stopping it whenever ``ufw_enabled``
|
||||||
|
is true, also when the unit or the package is absent, so the first run reports
|
||||||
|
``changed`` once. A host that loads its own ruleset through ``nftables.service``
|
||||||
|
(NAT tables or sets, for example) would lose it at the next reboot without
|
||||||
|
a warning, because a masked unit does not start: set ``ufw_mask_nftables:
|
||||||
|
false`` on such a host before upgrading.'
|
||||||
|
minor_changes:
|
||||||
|
- ufw - New input ``ufw_mask_nftables`` (default ``true``) and tag ``ufw_nftables``.
|
||||||
|
Set the input to ``false`` on a host that loads its own ruleset through ``nftables.service``;
|
||||||
|
the role never unmasks the unit.
|
||||||
|
fragments:
|
||||||
|
- ufw-mask-nftables-input.yml
|
||||||
|
- ufw-mask-nftables.yml
|
||||||
|
release_date: '2026-12-06'
|
||||||
@@ -9,7 +9,7 @@ held by review until an offline link check exists.
|
|||||||
## The clone
|
## The clone
|
||||||
|
|
||||||
- **Run `scripts/dev-setup.sh` once per clone, and again after a change to `requirements-dev.txt`, its
|
- **Run `scripts/dev-setup.sh` once per clone, and again after a change to `requirements-dev.txt`, its
|
||||||
lock `requirements-dev.lock`, `requirements.yml` or the hook types.** It creates `.venv` with the
|
lock `requirements-dev.lock`, `requirements.yml` or the hook types.** It creates `.venv-dev` with the
|
||||||
pinned tools on the Python named in `.python-version`, installs the collections of `requirements.yml`
|
pinned tools on the Python named in `.python-version`, installs the collections of `requirements.yml`
|
||||||
into `.ansible/collections`, and installs the git hooks (pre-commit, commit-msg, pre-push) with the
|
into `.ansible/collections`, and installs the git hooks (pre-commit, commit-msg, pre-push) with the
|
||||||
virtualenv first on their `PATH`.
|
virtualenv first on their `PATH`.
|
||||||
@@ -63,6 +63,12 @@ held by review until an offline link check exists.
|
|||||||
pushed on an unmerged branch lets that branch's commands run without a prompt before anyone has
|
pushed on an unmerged branch lets that branch's commands run without a prompt before anyone has
|
||||||
reviewed it, while a `deny` or `ask` rule can only add prompts.
|
reviewed it, while a `deny` or `ask` rule can only add prompts.
|
||||||
*Held by:* review (`.claude/` is under `CODEOWNERS`).
|
*Held by:* review (`.claude/` is under `CODEOWNERS`).
|
||||||
|
- **Install [uv](https://docs.astral.sh/uv/getting-started/installation/), run `uv sync --frozen` once per
|
||||||
|
clone and again after a change to `uv.lock`, and run apm only as `uv run --frozen apm ...`** (for example
|
||||||
|
`uv run --frozen apm install`). uv keeps apm in `.venv`, apart from the tools in `.venv-dev`.
|
||||||
|
*Reason:* a bare `apm` is whatever version your machine has, and versions differ in which
|
||||||
|
`apm.lock.yaml` they accept and in what they deploy.
|
||||||
|
*Held by:* aspirational.
|
||||||
- **Every hook in the tracked `.claude/settings.json` arrives through apm; personal hooks go in
|
- **Every hook in the tracked `.claude/settings.json` arrives through apm; personal hooks go in
|
||||||
`.claude/settings.local.json`.**
|
`.claude/settings.local.json`.**
|
||||||
*Reason:* a hook nobody owns is checked by nothing.
|
*Reason:* a hook nobody owns is checked by nothing.
|
||||||
|
|||||||
+4
-1
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
namespace: mortis
|
namespace: mortis
|
||||||
name: kamino
|
name: kamino
|
||||||
version: 3.4.0
|
version: 3.5.0
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- Defame1297
|
- Defame1297
|
||||||
@@ -46,6 +46,7 @@ build_ignore:
|
|||||||
- .python-version
|
- .python-version
|
||||||
- .ruff_cache
|
- .ruff_cache
|
||||||
- .venv
|
- .venv
|
||||||
|
- .venv-dev
|
||||||
- .yamllint
|
- .yamllint
|
||||||
- docs
|
- docs
|
||||||
- .ansible-lint
|
- .ansible-lint
|
||||||
@@ -59,6 +60,7 @@ build_ignore:
|
|||||||
- images
|
- images
|
||||||
- scripts
|
- scripts
|
||||||
- tests/scripts
|
- tests/scripts
|
||||||
|
- pyproject.toml
|
||||||
- renovate.json
|
- renovate.json
|
||||||
- ruff.toml
|
- ruff.toml
|
||||||
- requirements-dev.txt
|
- requirements-dev.txt
|
||||||
@@ -66,6 +68,7 @@ build_ignore:
|
|||||||
- requirements-molecule.txt
|
- requirements-molecule.txt
|
||||||
- requirements-molecule.lock
|
- requirements-molecule.lock
|
||||||
- requirements.yml
|
- requirements.yml
|
||||||
|
- uv.lock
|
||||||
- gitleaks-report.json
|
- gitleaks-report.json
|
||||||
- importer_result.json
|
- importer_result.json
|
||||||
- 'roles/*/molecule'
|
- 'roles/*/molecule'
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
# distribution's python3 and ca-certificates.
|
# distribution's python3 and ca-certificates.
|
||||||
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
|
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
|
||||||
# antsibull-changelog, galaxy-importer, reuse, molecule, proxmoxer), on the Python of
|
# antsibull-changelog, galaxy-importer, reuse, molecule, proxmoxer), on the Python of
|
||||||
# .python-version (PYTHON_VERSION below), the one the lock was resolved on and a clone's .venv uses.
|
# .python-version (PYTHON_VERSION below), the one the lock was resolved on and a clone's .venv-dev uses.
|
||||||
# molecule is there for Lint's "Test the repository scripts" step, whose molecule tests import it; its
|
# molecule is there for Lint's "Test the repository scripts" step, whose molecule tests import it; its
|
||||||
# Docker driver and community.docker are not: Molecule runs in the molecule-controller image.
|
# Docker driver and community.docker are not: Molecule runs in the molecule-controller image.
|
||||||
# - /opt/collections: the collections of requirements.yml (the versions the roles are
|
# - /opt/collections: the collections of requirements.yml (the versions the roles are
|
||||||
@@ -71,7 +71,7 @@ COPY requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-con
|
|||||||
|
|
||||||
# The interpreters come first: /opt/venv is built from the pinned one (PYTHON_VERSION, kept equal to
|
# The interpreters come first: /opt/venv is built from the pinned one (PYTHON_VERSION, kept equal to
|
||||||
# .python-version and to the lock header by `check_image_versions.py pins`), not from the distribution's
|
# .python-version and to the lock header by `check_image_versions.py pins`), not from the distribution's
|
||||||
# python3, so the tools run on the Python the lock was resolved on and a clone's .venv uses.
|
# python3, so the tools run on the Python the lock was resolved on and a clone's .venv-dev uses.
|
||||||
# uv only lives in the build stage (its own venv): the final image keeps the interpreters it
|
# uv only lives in the build stage (its own venv): the final image keeps the interpreters it
|
||||||
# downloaded, not the installer. The distribution's python3 only bootstraps uv.
|
# downloaded, not the installer. The distribution's python3 only bootstraps uv.
|
||||||
RUN python3 -m venv /opt/uv-venv \
|
RUN python3 -m venv /opt/uv-venv \
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Pins apm for contributors (docs/contributing/setup.md). The Lint and Build tools are pinned in requirements-dev.txt.
|
||||||
|
[project]
|
||||||
|
name = "kamino"
|
||||||
|
version = "0"
|
||||||
|
# ruff reads this floor too: a higher one makes it reformat existing files.
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
dev = ["apm-cli==0.39.3"]
|
||||||
|
|
||||||
|
[tool.uv]
|
||||||
|
package = false
|
||||||
+37
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit. Updates open on Mondays (UTC), so any Monday run can act; the own image pins and vulnerability fixes found on osv.dev open at any time. The weekly window and the groups bound the volume, so there is no hourly pull request limit. Vulnerability fixes skip the release-age wait, so they are never automerged: a person checks a fix that had no time to be pulled as a compromised release. Base-image bumps are manual: every Dockerfile is FROM ubuntu, grouped with the job containers.",
|
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines, and in uv.lock only the apm-cli bump to the pin in pyproject.toml (scripts/check_uv_lock.py). Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit. Updates open on Mondays (UTC), so any Monday run can act; the own image pins and vulnerability fixes found on osv.dev open at any time. The weekly window and the groups bound the volume, so there is no hourly pull request limit. Vulnerability fixes skip the release-age wait, so they are never automerged: a person checks a fix that had no time to be pulled as a compromised release. Base-image bumps are manual: every Dockerfile is FROM ubuntu, grouped with the job containers.",
|
||||||
"extends": [
|
"extends": [
|
||||||
"config:recommended",
|
"config:recommended",
|
||||||
":enablePreCommit"
|
":enablePreCommit"
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
"semanticCommitScope": "deps",
|
"semanticCommitScope": "deps",
|
||||||
"enabledManagers": [
|
"enabledManagers": [
|
||||||
"pip-compile",
|
"pip-compile",
|
||||||
|
"pep621",
|
||||||
"ansible-galaxy",
|
"ansible-galaxy",
|
||||||
"pre-commit",
|
"pre-commit",
|
||||||
"github-actions",
|
"github-actions",
|
||||||
@@ -35,6 +36,11 @@
|
|||||||
"/^requirements-molecule\\.lock$/"
|
"/^requirements-molecule\\.lock$/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"pep621": {
|
||||||
|
"managerFilePatterns": [
|
||||||
|
"/^pyproject\\.toml$/"
|
||||||
|
]
|
||||||
|
},
|
||||||
"pre-commit": {
|
"pre-commit": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"managerFilePatterns": [
|
"managerFilePatterns": [
|
||||||
@@ -196,7 +202,6 @@
|
|||||||
"pypi"
|
"pypi"
|
||||||
],
|
],
|
||||||
"matchPackageNames": [
|
"matchPackageNames": [
|
||||||
"apm-cli",
|
|
||||||
"antsibull-changelog",
|
"antsibull-changelog",
|
||||||
"galaxy-importer",
|
"galaxy-importer",
|
||||||
"reuse",
|
"reuse",
|
||||||
@@ -211,6 +216,36 @@
|
|||||||
"pre-commit"
|
"pre-commit"
|
||||||
],
|
],
|
||||||
"groupName": "pre-commit hooks"
|
"groupName": "pre-commit hooks"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "requires-python in pyproject.toml is the floor ruff formats for, not a pin: never updated by the bot.",
|
||||||
|
"matchManagers": [
|
||||||
|
"pep621"
|
||||||
|
],
|
||||||
|
"matchDepTypes": [
|
||||||
|
"requires-python"
|
||||||
|
],
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "No lock file maintenance for uv.lock: scripts/check_uv_lock.py refuses any change to a package other than apm-cli, so a person refreshes uv.lock by hand.",
|
||||||
|
"matchManagers": [
|
||||||
|
"pep621"
|
||||||
|
],
|
||||||
|
"matchUpdateTypes": [
|
||||||
|
"lockFileMaintenance"
|
||||||
|
],
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "apm-cli (pyproject.toml and uv.lock) gets its own pull request, never automerged: CI never runs apm, so a green run says nothing about a new version. Placed last so no rule above turns automerge back on.",
|
||||||
|
"matchManagers": [
|
||||||
|
"pep621"
|
||||||
|
],
|
||||||
|
"matchPackageNames": [
|
||||||
|
"apm-cli"
|
||||||
|
],
|
||||||
|
"automerge": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"lockFileMaintenance": {
|
"lockFileMaintenance": {
|
||||||
|
|||||||
+6
-1180
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
|||||||
# Pinned tooling for Lint and Build, used by CI (.gitea/workflows) and locally:
|
# Pinned tooling for Lint and Build, used by CI (.gitea/workflows) and locally:
|
||||||
# python3 -m venv .venv && . .venv/bin/activate && pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
# python3 -m venv .venv-dev && . .venv-dev/bin/activate && pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||||
# This file holds the direct pins; requirements-dev.lock is their hashed lock (every transitive
|
# This file holds the direct pins; requirements-dev.lock is their hashed lock (every transitive
|
||||||
# package too, with the sha256 of each release file) and is what gets installed; pip refuses an
|
# package too, with the sha256 of each release file) and is what gets installed; pip refuses an
|
||||||
# install in which the two files disagree. Renovate bumps a pin here and regenerates the lock
|
# install in which the two files disagree. Renovate bumps a pin here and regenerates the lock
|
||||||
@@ -18,6 +18,3 @@ molecule==26.11.1
|
|||||||
# proxmoxer: the controller-side library community.proxmox's modules import (they refuse anything below 2.3),
|
# proxmoxer: the controller-side library community.proxmox's modules import (they refuse anything below 2.3),
|
||||||
# so lint runs where a consumer's controller would.
|
# so lint runs where a consumer's controller would.
|
||||||
proxmoxer==2.3.0
|
proxmoxer==2.3.0
|
||||||
# apm-cli: for changing apm.yml (run apm install, commit the lock). Keep it at 0.36.1 or later (#252):
|
|
||||||
# before 0.29.0, `apm audit --ci` compares the whole .claude/settings.json and fails on any hand-written key.
|
|
||||||
apm-cli==0.39.1
|
|
||||||
+5
-2
@@ -29,6 +29,7 @@ Main entry point:
|
|||||||
| `ufw_manage_rules` | `true` | no | Skip the `ufw_rules` schema check, the lock-out guard and rule application when false. Before-rules validation and `before.rules`, defaults and enable still run (gated on `ufw_enabled`). |
|
| `ufw_manage_rules` | `true` | no | Skip the `ufw_rules` schema check, the lock-out guard and rule application when false. Before-rules validation and `before.rules`, defaults and enable still run (gated on `ufw_enabled`). |
|
||||||
| `ufw_defaults` | `incoming: deny`, `outgoing: allow`, `routed: deny` | no | Default policies. All three keys are read, so override all of them. |
|
| `ufw_defaults` | `incoming: deny`, `outgoing: allow`, `routed: deny` | no | Default policies. All three keys are read, so override all of them. |
|
||||||
| `ufw_logging` | `"on"` | no | UFW logging level. |
|
| `ufw_logging` | `"on"` | no | UFW logging level. |
|
||||||
|
| `ufw_mask_nftables` | `true` | no | Mask `nftables.service` without stopping it, so a package upgrade cannot flush the rules ufw loaded (see Notes). Set false on a host that loads its own ruleset through that unit. Gated on `ufw_enabled`. |
|
||||||
| `ufw_require_ssh_allow` | `true` | no | Enable the SSH lock-out guard. |
|
| `ufw_require_ssh_allow` | `true` | no | Enable the SSH lock-out guard. |
|
||||||
| `ufw_ssh_port` | `ansible_port` or 22 | no | TCP port the guard looks for. |
|
| `ufw_ssh_port` | `ansible_port` or 22 | no | TCP port the guard looks for. |
|
||||||
| `ufw_rules` | `[]` | no | Base rule list: `rule` (allow, deny, reject, limit), `port`, `proto`, `from`, `to`, `interface`, `direction`, `comment`, `delete` (see Notes). |
|
| `ufw_rules` | `[]` | no | Base rule list: `rule` (allow, deny, reject, limit), `port`, `proto`, `from`, `to`, `interface`, `direction`, `comment`, `delete` (see Notes). |
|
||||||
@@ -117,7 +118,7 @@ An **orphan** is a rule tagged `ansible-ufw[<owner>:<key>]` whose owner is neith
|
|||||||
|
|
||||||
## Tags
|
## Tags
|
||||||
|
|
||||||
`ufw` (everything), `ufw_install`, `ufw_sysctl`, `ufw_aggregate`, `ufw_validate`, `ufw_before_rules`, `ufw_defaults`, `ufw_rules`, `ufw_enable`.
|
`ufw` (everything), `ufw_install`, `ufw_sysctl`, `ufw_aggregate`, `ufw_validate`, `ufw_nftables`, `ufw_before_rules`, `ufw_defaults`, `ufw_rules`, `ufw_enable`.
|
||||||
|
|
||||||
Skipping `ufw_aggregate` leaves the lists the later tasks read (`ufw_aggregated_rules`, `ufw_aggregated_before_rules`) undefined or stale, so do not select a later tag alone.
|
Skipping `ufw_aggregate` leaves the lists the later tasks read (`ufw_aggregated_rules`, `ufw_aggregated_before_rules`) undefined or stale, so do not select a later tag alone.
|
||||||
|
|
||||||
@@ -144,10 +145,11 @@ The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_
|
|||||||
- Verify then reads `ufw status verbose` and `ufw show added`: ufw is active with default deny incoming, the base rules are loaded, the deleted rule is gone, the manual and SSH rules are untouched, the service rules carry their owner tag, stale and orphan rules are deleted only where purging was on and only when they cannot carry SSH.
|
- Verify then reads `ufw status verbose` and `ufw show added`: ufw is active with default deny incoming, the base rules are loaded, the deleted rule is gone, the manual and SSH rules are untouched, the service rules carry their owner tag, stale and orphan rules are deleted only where purging was on and only when they cannot carry SSH.
|
||||||
- Verify checks `before.rules`: the loopback accept, the INVALID-state drop behind its logging rule and in its place among the input rules.
|
- Verify checks `before.rules`: the loopback accept, the INVALID-state drop behind its logging rule and in its place among the input rules.
|
||||||
- Verify runs `service_rules` under the `check_mode` keyword and checks that the rule list did not change.
|
- Verify runs `service_rules` under the `check_mode` keyword and checks that the rule list did not change.
|
||||||
|
- Verify checks the nftables mask: prepare installs `nftables`, enables and starts its unit; after the converge the unit is masked and still active, ufw's chains survive `apt-get install --reinstall nftables` (whose postinst runs the upgrade restart), the same reinstall with the mask removed flushes them (the control), and after the package is purged and the mask removed the role masks the absent unit again without failing.
|
||||||
|
|
||||||
The scenario `molecule/check-absent/` runs on the same two platforms: prepare purges ufw and refreshes the APT cache, then `check` runs the main entry point and `service_rules` under `--check`, which must pass with ufw not installed. Nothing is applied.
|
The scenario `molecule/check-absent/` runs on the same two platforms: prepare purges ufw and refreshes the APT cache, then `check` runs the main entry point and `service_rules` under `--check`, which must pass with ufw not installed. Nothing is applied.
|
||||||
|
|
||||||
Not covered: `ufw_before_rules` entries and `ufw_sysctl_overrides` are never set, and `orphan_rules` runs in check mode only under `--check` (the `check` steps), not under the `check_mode` keyword.
|
Not covered: `ufw_mask_nftables: false` is never set, `ufw_before_rules` entries and `ufw_sysctl_overrides` are never set, and `orphan_rules` runs in check mode only under `--check` (the `check` steps), not under the `check_mode` keyword.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
@@ -158,5 +160,6 @@ Not covered: `ufw_before_rules` entries and `ufw_sysctl_overrides` are never set
|
|||||||
- Rule schema is asserted before anything changes: `rule` must be allow, deny, reject or limit, `port` a positive integer, `proto` tcp or udp, and each rule needs `port`, `from`, `to` or `interface`.
|
- Rule schema is asserted before anything changes: `rule` must be allow, deny, reject or limit, `port` a positive integer, `proto` tcp or udp, and each rule needs `port`, `from`, `to` or `interface`.
|
||||||
- UFW is only re-enabled when `ufw status verbose` shows it inactive or the logging line differs, because the module rewrites rules and re-applies sysctl on every call.
|
- UFW is only re-enabled when `ufw status verbose` shows it inactive or the logging line differs, because the module rewrites rules and re-applies sysctl on every call.
|
||||||
- The `Reload UFW` handler runs `ufw reload`.
|
- The `Reload UFW` handler runs `ufw reload`.
|
||||||
|
- nftables: when `nftables.service` is enabled (a preset can do that), the `nftables` package's postinst restarts it on upgrade (`dh_installsystemd --no-enable --no-start --restart-after-upgrade` emits `deb-systemd-invoke try-restart`), and both the restart and the unit's `ExecStop=/usr/sbin/nft flush ruleset` delete every rule ufw (and Docker) loaded, since the stock `/etc/nftables.conf` begins with `flush ruleset`. The role masks the unit and does not stop it, so nothing is flushed during the run. systemd refuses every job but a stop on a masked unit, so the postinst's restart fails before anything runs and the postinst ignores the failure (`|| true`); at boot the unit is not started either. The mask also applies when the unit or the package is absent, so a later install cannot enable it; the package's postinst removes only a mask its own helper created. The role never unmasks: with `ufw_mask_nftables: false` or `ufw_enabled: false` an existing mask stays. `--check` reports the mask without applying it. When `/etc/systemd/system/nftables.service` is a unit file of its own rather than a link, `systemctl mask` refuses with "already exists" and the play fails; set `ufw_mask_nftables: false` on such a host.
|
||||||
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host without ufw the preview reports the install and skips the configuration (`before.rules`, default policies, rules, enable), which needs the `ufw` binary.
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host without ufw the preview reports the install and skips the configuration (`before.rules`, default policies, rules, enable), which needs the `ufw` binary.
|
||||||
- `no_log` is not used: the role handles no secrets.
|
- `no_log` is not used: the role handles no secrets.
|
||||||
@@ -9,6 +9,10 @@ ufw_defaults:
|
|||||||
|
|
||||||
ufw_logging: "on"
|
ufw_logging: "on"
|
||||||
|
|
||||||
|
# Mask nftables.service (not stopped), so a restart by a package upgrade cannot flush the rules
|
||||||
|
# ufw loaded. false: leave the unit alone, for hosts that load their own ruleset through it.
|
||||||
|
ufw_mask_nftables: true
|
||||||
|
|
||||||
# Lock-out guard: with a deny/reject incoming default the play refuses to run
|
# Lock-out guard: with a deny/reject incoming default the play refuses to run
|
||||||
# unless an allow/limit rule for this TCP port is in the rule list, since the
|
# unless an allow/limit rule for this TCP port is in the rule list, since the
|
||||||
# default is applied before the rules and a missing rule cuts the SSH session.
|
# default is applied before the rules and a missing rule cuts the SSH session.
|
||||||
|
|||||||
@@ -49,6 +49,18 @@ argument_specs:
|
|||||||
choices: ["on", "off", low, medium, high, full]
|
choices: ["on", "off", low, medium, high, full]
|
||||||
description:
|
description:
|
||||||
- UFW logging setting. UFW is only re-enabled when it is inactive or its current logging line differs from this value.
|
- UFW logging setting. UFW is only re-enabled when it is inactive or its current logging line differs from this value.
|
||||||
|
ufw_mask_nftables:
|
||||||
|
type: bool
|
||||||
|
default: true
|
||||||
|
description:
|
||||||
|
- >-
|
||||||
|
When true (and C(ufw_enabled) is true) C(nftables.service) is masked, without being stopped, also when the
|
||||||
|
unit or the C(nftables) package is absent. A restart of the enabled unit, which the package runs on upgrade,
|
||||||
|
loads the stock C(/etc/nftables.conf) that begins with C(flush ruleset), and its stop flushes the ruleset,
|
||||||
|
which deletes the rules ufw loaded. A masked unit is never started, also not at boot.
|
||||||
|
- >-
|
||||||
|
Set false on hosts that load their own ruleset through C(nftables.service). The role never unmasks the unit,
|
||||||
|
so switching to false leaves an existing mask in place.
|
||||||
ufw_require_ssh_allow:
|
ufw_require_ssh_allow:
|
||||||
type: bool
|
type: bool
|
||||||
default: true
|
default: true
|
||||||
|
|||||||
@@ -84,3 +84,40 @@
|
|||||||
- {port: "40:50", comment: "ansible-ufw[svc_c:6666666663]: range"}
|
- {port: "40:50", comment: "ansible-ufw[svc_c:6666666663]: range"}
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: ufw_prepare_rule
|
loop_var: ufw_prepare_rule
|
||||||
|
|
||||||
|
# An enabled, active nftables.service with the stock /etc/nftables.conf, as a preset leaves
|
||||||
|
# it; verify.yml checks that the role's mask keeps a package upgrade from flushing ufw's rules.
|
||||||
|
- name: Install nftables
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: nftables
|
||||||
|
state: present
|
||||||
|
|
||||||
|
# A policy-rc.d that refuses actions would make the postinst skip the restart verify.yml tests.
|
||||||
|
- name: Let maintainer scripts act on units as on a host
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /usr/sbin/policy-rc.d
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
# ProtectSystem and ProtectHome need a mount namespace, which needs CAP_SYS_ADMIN; without
|
||||||
|
# it the unit fails with 226/NAMESPACE in this unprivileged container.
|
||||||
|
- name: Create the drop-in directory of nftables.service
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/systemd/system/nftables.service.d
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Disable the namespace-based sandboxing of nftables.service for the container
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/systemd/system/nftables.service.d/molecule.conf
|
||||||
|
mode: "0644"
|
||||||
|
content: |
|
||||||
|
[Service]
|
||||||
|
ProtectSystem=no
|
||||||
|
ProtectHome=no
|
||||||
|
|
||||||
|
- name: Enable and start nftables.service
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
daemon_reload: true
|
||||||
@@ -521,3 +521,110 @@
|
|||||||
- ufw_verify_chk_after.stdout_lines == ufw_verify_chk_before.stdout_lines
|
- ufw_verify_chk_after.stdout_lines == ufw_verify_chk_before.stdout_lines
|
||||||
- ufw_verify_chk_after.stdout_lines | select('search', 'svc_chk|7701') | list | length == 0
|
- ufw_verify_chk_after.stdout_lines | select('search', 'svc_chk|7701') | list | length == 0
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# prepare.yml left nftables.service enabled and active. The package's postinst runs
|
||||||
|
# `deb-systemd-invoke try-restart nftables.service` on upgrade (and on a reinstall, which passes
|
||||||
|
# the old version too); the stock config and ExecStop flush the ruleset. The masked case runs
|
||||||
|
# first, then a control without the mask proves the reinstall reaches the unit here, then the
|
||||||
|
# absent-package case. Last, because the control flushes ufw's rules.
|
||||||
|
- name: The nftables mask keeps a package upgrade from flushing the rules
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
ufw_verify_nft_reinstall:
|
||||||
|
- apt-get
|
||||||
|
- install
|
||||||
|
- --reinstall
|
||||||
|
- -y
|
||||||
|
- -o
|
||||||
|
- Dpkg::Options::=--force-confold
|
||||||
|
- nftables
|
||||||
|
tasks:
|
||||||
|
# A mask request in check mode changes nothing and returns the unit's properties.
|
||||||
|
- name: Read the state of nftables.service
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: true
|
||||||
|
check_mode: true
|
||||||
|
register: ufw_verify_nft_unit
|
||||||
|
|
||||||
|
- name: The role masked the unit and did not stop it
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ufw_verify_nft_unit is not changed
|
||||||
|
- ufw_verify_nft_unit.status.LoadState == 'masked'
|
||||||
|
- ufw_verify_nft_unit.status.ActiveState == 'active'
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Reinstall nftables while the unit is masked
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv: "{{ ufw_verify_nft_reinstall }}"
|
||||||
|
environment: {DEBIAN_FRONTEND: noninteractive}
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Read the iptables rules after the masked reinstall
|
||||||
|
ansible.builtin.command: iptables -S
|
||||||
|
register: ufw_verify_nft_masked_rules
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: The rules of ufw survived the reinstall
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ufw_verify_nft_masked_rules.stdout_lines | select('search', '^-N ufw-user-input$') | list | length == 1
|
||||||
|
- ufw_verify_nft_masked_rules.stdout_lines | select('search', '^-A ufw-user-input .*--dport 22 ') | list | length > 0
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Remove the mask for the control case
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: false
|
||||||
|
|
||||||
|
- name: Reinstall nftables while the unit is enabled and active
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv: "{{ ufw_verify_nft_reinstall }}"
|
||||||
|
environment: {DEBIAN_FRONTEND: noninteractive}
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Read the iptables rules after the unmasked reinstall
|
||||||
|
ansible.builtin.command: iptables -S
|
||||||
|
register: ufw_verify_nft_unmasked_rules
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Without the mask the reinstall flushed the rules of ufw
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: ufw_verify_nft_unmasked_rules.stdout_lines | select('search', '^-N ufw-user-input$') | list | length == 0
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Purge nftables
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: nftables
|
||||||
|
state: absent
|
||||||
|
purge: true
|
||||||
|
|
||||||
|
- name: Read the state of nftables.service with the package gone
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: true
|
||||||
|
check_mode: true
|
||||||
|
register: ufw_verify_nft_gone
|
||||||
|
|
||||||
|
- name: Run the role on a host without the nftables package
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.ufw
|
||||||
|
vars:
|
||||||
|
ufw_rules:
|
||||||
|
- {rule: allow, port: 22, proto: tcp, comment: ssh}
|
||||||
|
|
||||||
|
- name: Read the state of nftables.service after the role
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: true
|
||||||
|
check_mode: true
|
||||||
|
register: ufw_verify_nft_absent
|
||||||
|
|
||||||
|
- name: The role masked the absent unit without failing
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ufw_verify_nft_gone is changed
|
||||||
|
- ufw_verify_nft_absent is not changed
|
||||||
|
quiet: true
|
||||||
@@ -35,6 +35,10 @@
|
|||||||
ansible.builtin.import_tasks: validate.yml
|
ansible.builtin.import_tasks: validate.yml
|
||||||
tags: [ufw, ufw_validate]
|
tags: [ufw, ufw_validate]
|
||||||
|
|
||||||
|
- name: Import UFW nftables task
|
||||||
|
ansible.builtin.import_tasks: nftables.yml
|
||||||
|
tags: [ufw, ufw_nftables]
|
||||||
|
|
||||||
- name: Import UFW before rules task
|
- name: Import UFW before rules task
|
||||||
ansible.builtin.import_tasks: before_rules.yml
|
ansible.builtin.import_tasks: before_rules.yml
|
||||||
tags: [ufw, ufw_before_rules]
|
tags: [ufw, ufw_before_rules]
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
# A restart of nftables.service (on a package upgrade) flushes the rules ufw loaded. Mask only:
|
||||||
|
# a stop would flush them now. README Notes has the detail.
|
||||||
|
- name: Mask nftables.service without stopping it
|
||||||
|
become: true
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: true
|
||||||
|
when:
|
||||||
|
- ufw_enabled
|
||||||
|
- ufw_mask_nftables
|
||||||
@@ -19,7 +19,7 @@ cd "$root"
|
|||||||
|
|
||||||
for tool in ansible ansible-test; do
|
for tool in ansible ansible-test; do
|
||||||
if ! command -v "$tool" >/dev/null 2>&1; then
|
if ! command -v "$tool" >/dev/null 2>&1; then
|
||||||
echo "error: $tool is not on PATH; run scripts/dev-setup.sh and use its virtualenv (.venv/bin)" >&2
|
echo "error: $tool is not on PATH; run scripts/dev-setup.sh and use its virtualenv (.venv-dev/bin)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only
|
|||||||
`name==version` entries, `--hash=sha256:<64 hex>` lines and plain `# via` or prose comments,
|
`name==version` entries, `--hash=sha256:<64 hex>` lines and plain `# via` or prose comments,
|
||||||
nothing else; packages may be added or removed (a transitive dependency), but the
|
nothing else; packages may be added or removed (a transitive dependency), but the
|
||||||
`# pip-compile ...` command in the header, which Renovate runs again, must stay as it is;
|
`# pip-compile ...` command in the header, which Renovate runs again, must stay as it is;
|
||||||
|
* pyproject.toml: the version of a quoted `"name==version"` pin (the names, spelled as they
|
||||||
|
are, and every other line, stay), only together with uv.lock;
|
||||||
|
* uv.lock: the apm-cli bump to the pin of the new pyproject.toml, and nothing else
|
||||||
|
(check_uv_lock.py), only together with pyproject.toml;
|
||||||
* requirements.yml and extensions/molecule/requirements.yml: `version:` lines (the collection
|
* requirements.yml and extensions/molecule/requirements.yml: `version:` lines (the collection
|
||||||
names, and every other line, stay);
|
names, and every other line, stay);
|
||||||
* .pre-commit-config.yaml: `rev:` lines (a tag, or a commit SHA with its `# frozen: <tag>` comment);
|
* .pre-commit-config.yaml: `rev:` lines (a tag, or a commit SHA with its `# frozen: <tag>` comment);
|
||||||
@@ -50,6 +54,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import check_image_versions as civ
|
import check_image_versions as civ
|
||||||
|
import check_uv_lock
|
||||||
|
|
||||||
PREFIX = "renovate/"
|
PREFIX = "renovate/"
|
||||||
TAG = r"[A-Za-z0-9._-]+"
|
TAG = r"[A-Za-z0-9._-]+"
|
||||||
@@ -73,6 +78,7 @@ COLLECTION_PINS = {"requirements.yml", "extensions/molecule/requirements.yml"}
|
|||||||
# Lint's and the molecule-controller image's requirements, each with its pip-compile lock.
|
# Lint's and the molecule-controller image's requirements, each with its pip-compile lock.
|
||||||
REQUIREMENTS = {"requirements-dev.txt", "requirements-molecule.txt"}
|
REQUIREMENTS = {"requirements-dev.txt", "requirements-molecule.txt"}
|
||||||
LOCKS = {"requirements-dev.lock", "requirements-molecule.lock"}
|
LOCKS = {"requirements-dev.lock", "requirements-molecule.lock"}
|
||||||
|
UV_LOCK = "uv.lock"
|
||||||
CONSUMERS = {
|
CONSUMERS = {
|
||||||
".gitea/workflows/lint.yml",
|
".gitea/workflows/lint.yml",
|
||||||
".gitea/workflows/build.yml",
|
".gitea/workflows/build.yml",
|
||||||
@@ -144,6 +150,16 @@ def lock_problem(removed, added):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# A quoted `name==version` pin in a pyproject.toml dependency array.
|
||||||
|
PYPROJECT_PIN = re.compile(r'"([A-Za-z0-9][A-Za-z0-9._-]*)==[0-9][0-9A-Za-z.+!_-]*"')
|
||||||
|
|
||||||
|
|
||||||
|
def reduce_pyproject(line):
|
||||||
|
if not PYPROJECT_PIN.search(line):
|
||||||
|
return None
|
||||||
|
return PYPROJECT_PIN.sub(lambda m: f'"{m[1]}==X"', line)
|
||||||
|
|
||||||
|
|
||||||
def reduce_rev(line):
|
def reduce_rev(line):
|
||||||
return "rev" if REV_LINE.match(line) else None
|
return "rev" if REV_LINE.match(line) else None
|
||||||
|
|
||||||
@@ -178,6 +194,10 @@ def file_problem(path, removed, added):
|
|||||||
)
|
)
|
||||||
if path in LOCKS:
|
if path in LOCKS:
|
||||||
return lock_problem(removed, added)
|
return lock_problem(removed, added)
|
||||||
|
if path == "pyproject.toml":
|
||||||
|
return same_shape(
|
||||||
|
removed, added, reduce_pyproject, "a quoted `name==version` pin"
|
||||||
|
)
|
||||||
if path in COLLECTION_PINS:
|
if path in COLLECTION_PINS:
|
||||||
return same_shape(removed, added, reduce_version, "a `version:` line")
|
return same_shape(removed, added, reduce_version, "a `version:` line")
|
||||||
if path == ".pre-commit-config.yaml":
|
if path == ".pre-commit-config.yaml":
|
||||||
@@ -254,15 +274,22 @@ def moved_problem(removed, added):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def check(entries, patch_of):
|
def check(entries, patch_of, show=None):
|
||||||
"""One message per offending file; patch_of(path) returns that file's -U0 patch text."""
|
"""One message per offending file; patch_of(path) returns that file's -U0 patch text and
|
||||||
|
show(side, path) its text on the "base" or "head" side (needed for uv.lock)."""
|
||||||
problems = []
|
problems = []
|
||||||
|
# The pin and its lock move together, so neither can change what the other one locks.
|
||||||
|
partners = {"pyproject.toml": UV_LOCK, UV_LOCK: "pyproject.toml"}
|
||||||
|
paths = {path for unused, unused, unused, path in entries}
|
||||||
for old_mode, new_mode, status, path in entries:
|
for old_mode, new_mode, status, path in entries:
|
||||||
if status != "M" or old_mode != new_mode or new_mode != "100644":
|
if status != "M" or old_mode != new_mode or new_mode != "100644":
|
||||||
problems.append(
|
problems.append(
|
||||||
f"{path}: a bot pull request may not add, delete, rename or change the mode of a file"
|
f"{path}: a bot pull request may not add, delete, rename or change the mode of a file"
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
if path in partners and partners[path] not in paths:
|
||||||
|
problems.append(f"{path}: changes without {partners[path]}")
|
||||||
|
continue
|
||||||
patch = patch_of(path)
|
patch = patch_of(path)
|
||||||
if BINARY.search(patch):
|
if BINARY.search(patch):
|
||||||
problems.append(
|
problems.append(
|
||||||
@@ -276,9 +303,22 @@ def check(entries, patch_of):
|
|||||||
f"{len(removed)} removed and {len(added)} added (binary or empty change?)"
|
f"{len(removed)} removed and {len(added)} added (binary or empty change?)"
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
reason = file_problem(
|
if path == UV_LOCK:
|
||||||
path, [line for unused, line in removed], [line for unused, line in added]
|
reason = (
|
||||||
)
|
check_uv_lock.lock_problem(
|
||||||
|
show("base", path),
|
||||||
|
show("head", path),
|
||||||
|
show("head", "pyproject.toml"),
|
||||||
|
)
|
||||||
|
if show
|
||||||
|
else "is not a file a bot pull request may change"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
reason = file_problem(
|
||||||
|
path,
|
||||||
|
[line for unused, line in removed],
|
||||||
|
[line for unused, line in added],
|
||||||
|
)
|
||||||
if not reason and path == civ.MATRIX_FILE:
|
if not reason and path == civ.MATRIX_FILE:
|
||||||
reason = moved_problem(removed, added)
|
reason = moved_problem(removed, added)
|
||||||
if reason:
|
if reason:
|
||||||
@@ -336,8 +376,14 @@ def run(argv):
|
|||||||
path,
|
path,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def show(side, path):
|
||||||
|
rev = base if side == "base" else "HEAD"
|
||||||
|
return civ.git("cat-file", "blob", f"{rev}:{path}")
|
||||||
|
|
||||||
entries = parse_raw(raw)
|
entries = parse_raw(raw)
|
||||||
return check(entries, patch_of), f"{len(entries)} file(s) within the bot allowance"
|
return check(
|
||||||
|
entries, patch_of, show
|
||||||
|
), f"{len(entries)} file(s) within the bot allowance"
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ allow list. It fails the build for:
|
|||||||
ansible-galaxy dereferences FILE symlinks while building, so a symlink to a file reaches
|
ansible-galaxy dereferences FILE symlinks while building, so a symlink to a file reaches
|
||||||
the archive as a regular file with the target's content and this check cannot see it. The
|
the archive as a regular file with the target's content and this check cannot see it. The
|
||||||
`Refuse symlinks in the source tree` step of .gitea/workflows/build.yml is the only guard
|
`Refuse symlinks in the source tree` step of .gitea/workflows/build.yml is the only guard
|
||||||
against that. Its `find` prunes ./.venv and ./.git only because both are in galaxy.yml
|
against that. Its `find` prunes ./.git, ./.venv and ./.venv-dev only because they are in galaxy.yml
|
||||||
`build_ignore` (or excluded by ansible-galaxy itself, as .git is): the two lists must stay
|
`build_ignore` (or excluded by ansible-galaxy itself, as .git is): the two lists must stay
|
||||||
in step, and tests/scripts/test_check_tarball.py fails when a pruned directory is not
|
in step, and tests/scripts/test_check_tarball.py fails when a pruned directory is not
|
||||||
ignored by the build.
|
ignored by the build.
|
||||||
|
|||||||
@@ -0,0 +1,198 @@
|
|||||||
|
# SPDX-FileCopyrightText: Defame1297 and contributors
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
"""The uv.lock rule of check_bot_pr_diff.py: a bot may move apm-cli to its pin, nothing else.
|
||||||
|
|
||||||
|
Both locks are parsed. The top level stays as it is, except `revision`. The same packages are
|
||||||
|
locked, and every one but apm-cli and the root project is unchanged. The root project changes
|
||||||
|
only its apm-cli specifier, to the pin in pyproject.toml. apm-cli changes only its version, up
|
||||||
|
to that pin, and its files: the same kinds (an sdist if it had one, the same wheel tags), each
|
||||||
|
on PyPI's download host, named for apm-cli at the pin, by sha256. Versions are plain releases
|
||||||
|
compared as numbers. A bump that moves anything else fails, and a person makes it by hand.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import copy
|
||||||
|
import re
|
||||||
|
import tomllib
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
|
PACKAGE = "apm-cli"
|
||||||
|
REGISTRY = {"registry": "https://pypi.org/simple"}
|
||||||
|
ROOT_SOURCE = {"virtual": "."}
|
||||||
|
FILE_KEYS = {"url", "hash", "size", "upload-time"}
|
||||||
|
SHA256 = re.compile(r"sha256:[0-9a-f]{64}")
|
||||||
|
PIN = re.compile(rf"{re.escape(PACKAGE)}==([0-9][0-9A-Za-z.+!_-]*)")
|
||||||
|
# A plain release; pre-, post- and dev-releases, epochs and local versions are bumped by hand.
|
||||||
|
RELEASE = re.compile(r"[0-9]+(?:\.[0-9]+)*")
|
||||||
|
DIST = re.sub(r"[-_.]+", "_", PACKAGE).lower()
|
||||||
|
|
||||||
|
|
||||||
|
class Refused(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def parse(text, what):
|
||||||
|
try:
|
||||||
|
return tomllib.loads(text)
|
||||||
|
except tomllib.TOMLDecodeError as exc:
|
||||||
|
raise Refused(f"{what} is not valid TOML ({exc})") from None
|
||||||
|
|
||||||
|
|
||||||
|
def pinned_version(pyproject):
|
||||||
|
pins = [
|
||||||
|
m[1]
|
||||||
|
for entry in parse(pyproject, "pyproject.toml")
|
||||||
|
.get("dependency-groups", {})
|
||||||
|
.get("dev", [])
|
||||||
|
if isinstance(entry, str) and (m := PIN.fullmatch(entry))
|
||||||
|
]
|
||||||
|
if len(pins) != 1:
|
||||||
|
raise Refused(f"pyproject.toml does not pin {PACKAGE} once with ==")
|
||||||
|
return pins[0]
|
||||||
|
|
||||||
|
|
||||||
|
def by_name(lock):
|
||||||
|
packages = {}
|
||||||
|
for package in lock.get("package", []):
|
||||||
|
packages.setdefault(package.get("name"), []).append(package)
|
||||||
|
return packages
|
||||||
|
|
||||||
|
|
||||||
|
def only(packages, what):
|
||||||
|
if len(packages) != 1:
|
||||||
|
raise Refused(f"the lock does not hold exactly one {what}")
|
||||||
|
return packages[0]
|
||||||
|
|
||||||
|
|
||||||
|
def without_apm_specifier(root):
|
||||||
|
"""The root project with its apm-cli dev specifier blanked, and that specifier."""
|
||||||
|
root = copy.deepcopy(root)
|
||||||
|
entries = [
|
||||||
|
entry
|
||||||
|
for entry in root.get("metadata", {}).get("requires-dev", {}).get("dev", [])
|
||||||
|
if entry.get("name") == PACKAGE
|
||||||
|
]
|
||||||
|
entry = only(entries, f"{PACKAGE} dev requirement in the root project")
|
||||||
|
specifier = entry.pop("specifier", None)
|
||||||
|
return root, specifier
|
||||||
|
|
||||||
|
|
||||||
|
def release(version):
|
||||||
|
"""A plain release as a tuple of numbers without trailing zeros, or None."""
|
||||||
|
if not isinstance(version, str) or not RELEASE.fullmatch(version):
|
||||||
|
return None
|
||||||
|
parts = [int(part) for part in version.split(".")]
|
||||||
|
while len(parts) > 1 and parts[-1] == 0:
|
||||||
|
parts.pop()
|
||||||
|
return tuple(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def file_kinds(package):
|
||||||
|
"""The kinds of file a package locks: "sdist" and the tag of each wheel."""
|
||||||
|
version = package.get("version")
|
||||||
|
kinds = {"sdist"} if "sdist" in package else set()
|
||||||
|
for wheel in package.get("wheels", []):
|
||||||
|
name = urllib.parse.urlsplit(wheel.get("url", "")).path.rsplit("/", 1)[-1]
|
||||||
|
prefix = f"{DIST}-{version}-"
|
||||||
|
if not (name.startswith(prefix) and name.endswith(".whl")):
|
||||||
|
raise Refused(f"the {PACKAGE} wheel {name} is not {PACKAGE} {version}")
|
||||||
|
kinds.add(name[len(prefix) : -len(".whl")])
|
||||||
|
return kinds
|
||||||
|
|
||||||
|
|
||||||
|
def file_problem(pin, file):
|
||||||
|
url = urllib.parse.urlsplit(file.get("url", ""))
|
||||||
|
segments = url.path.split("/")
|
||||||
|
name = segments[-1]
|
||||||
|
if not (
|
||||||
|
set(file) <= FILE_KEYS
|
||||||
|
and url.scheme == "https"
|
||||||
|
and url.netloc == "files.pythonhosted.org"
|
||||||
|
and segments[:2] == ["", "packages"]
|
||||||
|
and not any(part in ("", ".", "..") for part in segments[1:])
|
||||||
|
and "%" not in url.path
|
||||||
|
and not (url.query or url.fragment)
|
||||||
|
):
|
||||||
|
return f"an {PACKAGE} file is not a plain download from files.pythonhosted.org"
|
||||||
|
if not (
|
||||||
|
name == f"{DIST}-{pin}.tar.gz"
|
||||||
|
or (name.startswith(f"{DIST}-{pin}-") and name.endswith(".whl"))
|
||||||
|
):
|
||||||
|
return f"the {PACKAGE} file {name} is not {PACKAGE} {pin}"
|
||||||
|
if not SHA256.fullmatch(str(file.get("hash", ""))):
|
||||||
|
return f"the {PACKAGE} file {name} has no sha256 hash"
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def apm_problem(old, new, pin):
|
||||||
|
if new.get("version") != pin:
|
||||||
|
return f"{PACKAGE} is locked at {new.get('version')}, not at the pin {pin}"
|
||||||
|
old_release, new_release = release(old.get("version")), release(pin)
|
||||||
|
if old_release is None or new_release is None:
|
||||||
|
return f"{PACKAGE} {old.get('version')} or {pin} is not a plain release"
|
||||||
|
if new_release <= old_release:
|
||||||
|
return f"{PACKAGE} does not move up from {old.get('version')} to {pin}"
|
||||||
|
rest = {"version", "sdist", "wheels"}
|
||||||
|
if {k: v for k, v in old.items() if k not in rest} != {
|
||||||
|
k: v for k, v in new.items() if k not in rest
|
||||||
|
}:
|
||||||
|
return f"changes the source or dependencies of {PACKAGE}"
|
||||||
|
files = ([new["sdist"]] if "sdist" in new else []) + new.get("wheels", [])
|
||||||
|
if not files:
|
||||||
|
return f"locks no file for {PACKAGE}"
|
||||||
|
for file in files:
|
||||||
|
reason = file_problem(pin, file)
|
||||||
|
if reason:
|
||||||
|
return reason
|
||||||
|
if file_kinds(old) != file_kinds(new):
|
||||||
|
return f"changes which kinds of file {PACKAGE} locks (sdist, wheel tags)"
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def compare(old, new, pin):
|
||||||
|
rest = {"revision", "package"}
|
||||||
|
if {k: v for k, v in old.items() if k not in rest} != {
|
||||||
|
k: v for k, v in new.items() if k not in rest
|
||||||
|
}:
|
||||||
|
return "changes a top-level setting other than revision"
|
||||||
|
if not isinstance(new.get("revision"), int):
|
||||||
|
return "the lock revision is not a number"
|
||||||
|
old_packages, new_packages = by_name(old), by_name(new)
|
||||||
|
if set(old_packages) != set(new_packages):
|
||||||
|
return "adds or removes a package"
|
||||||
|
roots = [
|
||||||
|
name
|
||||||
|
for name, entries in new_packages.items()
|
||||||
|
if any(e.get("source") == ROOT_SOURCE for e in entries)
|
||||||
|
]
|
||||||
|
root = only(roots, "root project")
|
||||||
|
for name in new_packages:
|
||||||
|
if name not in (PACKAGE, root) and old_packages[name] != new_packages[name]:
|
||||||
|
return f"changes the package {name}"
|
||||||
|
old_root, _unused = without_apm_specifier(only(old_packages[root], "root project"))
|
||||||
|
new_root, specifier = without_apm_specifier(
|
||||||
|
only(new_packages[root], "root project")
|
||||||
|
)
|
||||||
|
if old_root != new_root:
|
||||||
|
return "changes the root project beyond its apm-cli specifier"
|
||||||
|
if specifier != f"=={pin}":
|
||||||
|
return f"the root project's {PACKAGE} specifier is not =={pin}"
|
||||||
|
return apm_problem(
|
||||||
|
only(old_packages.get(PACKAGE, []), PACKAGE),
|
||||||
|
only(new_packages.get(PACKAGE, []), PACKAGE),
|
||||||
|
pin,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def lock_problem(old_lock, new_lock, pyproject):
|
||||||
|
"""None when new_lock differs from old_lock only by the apm-cli bump to the pin of
|
||||||
|
pyproject (the new pyproject.toml's text); else a one-line reason."""
|
||||||
|
try:
|
||||||
|
return compare(
|
||||||
|
parse(old_lock, "the old uv.lock"),
|
||||||
|
parse(new_lock, "the new uv.lock"),
|
||||||
|
pinned_version(pyproject),
|
||||||
|
)
|
||||||
|
except Refused as exc:
|
||||||
|
return str(exc)
|
||||||
|
except (AttributeError, TypeError):
|
||||||
|
return "the lock does not have the shape uv writes"
|
||||||
@@ -26,7 +26,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
# The repository is derived from this script's own location (symlinks resolved), never
|
# The repository is derived from this script's own location (symlinks resolved), never
|
||||||
# from the caller's working directory: running it from another repository must not
|
# from the caller's working directory: running it from another repository must not
|
||||||
# create or remove that repository's .venv.
|
# create or remove that repository's .venv-dev.
|
||||||
script="$(readlink -f "${BASH_SOURCE[0]}")"
|
script="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||||
root="$(git -C "$(dirname "$script")/.." rev-parse --show-toplevel)"
|
root="$(git -C "$(dirname "$script")/.." rev-parse --show-toplevel)"
|
||||||
cd "$root"
|
cd "$root"
|
||||||
@@ -122,19 +122,19 @@ if still="$(git -C "$root" config --get core.hooksPath)" && [ -n "$still" ]; the
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# A virtualenv made by an older Python is rebuilt rather than reused.
|
# A virtualenv made by an older Python is rebuilt rather than reused.
|
||||||
if [ -x .venv/bin/python ] && ! .venv/bin/python -c "$py_ok" 2>/dev/null; then
|
if [ -x .venv-dev/bin/python ] && ! .venv-dev/bin/python -c "$py_ok" 2>/dev/null; then
|
||||||
rm -rf "$root/.venv"
|
rm -rf "$root/.venv-dev"
|
||||||
fi
|
fi
|
||||||
[ -x .venv/bin/python ] || "$python" -m venv .venv
|
[ -x .venv-dev/bin/python ] || "$python" -m venv .venv-dev
|
||||||
.venv/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
.venv-dev/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||||
.venv/bin/pre-commit install --install-hooks
|
.venv-dev/bin/pre-commit install --install-hooks
|
||||||
|
|
||||||
# The collections of requirements.yml, exactly as pinned, into this clone (.ansible/ is ignored by
|
# The collections of requirements.yml, exactly as pinned, into this clone (.ansible/ is ignored by
|
||||||
# git and by the Collection build). ANSIBLE_COLLECTIONS_PATH is set to the target for the install:
|
# git and by the Collection build). ANSIBLE_COLLECTIONS_PATH is set to the target for the install:
|
||||||
# a copy found elsewhere (~/.ansible/collections) would be skipped as already installed.
|
# a copy found elsewhere (~/.ansible/collections) would be skipped as already installed.
|
||||||
collections="$root/.ansible/collections"
|
collections="$root/.ansible/collections"
|
||||||
mkdir -p "$collections"
|
mkdir -p "$collections"
|
||||||
ANSIBLE_COLLECTIONS_PATH="$collections" .venv/bin/ansible-galaxy collection install \
|
ANSIBLE_COLLECTIONS_PATH="$collections" .venv-dev/bin/ansible-galaxy collection install \
|
||||||
-r requirements.yml -p "$collections"
|
-r requirements.yml -p "$collections"
|
||||||
|
|
||||||
marker="# kamino-dev-setup: virtualenv first on PATH"
|
marker="# kamino-dev-setup: virtualenv first on PATH"
|
||||||
@@ -150,7 +150,7 @@ for hook in pre-commit commit-msg pre-push; do
|
|||||||
{
|
{
|
||||||
head -n 1 "$file"
|
head -n 1 "$file"
|
||||||
# %q shell-quotes the path: a repository path with spaces, quotes or $(...) is data.
|
# %q shell-quotes the path: a repository path with spaces, quotes or $(...) is data.
|
||||||
printf '%s\n' "$marker" "export PATH=$(printf '%q' "$root/.venv/bin"):\"\$PATH\""
|
printf '%s\n' "$marker" "export PATH=$(printf '%q' "$root/.venv-dev/bin"):\"\$PATH\""
|
||||||
tail -n +2 "$file"
|
tail -n +2 "$file"
|
||||||
} > "$tmp"
|
} > "$tmp"
|
||||||
cat "$tmp" > "$file" # keeps the file mode of the hook
|
cat "$tmp" > "$file" # keeps the file mode of the hook
|
||||||
@@ -179,4 +179,4 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Done: git commit now runs the hooks with the tools in $root/.venv/bin and the collections in $collections."
|
echo "Done: git commit now runs the hooks with the tools in $root/.venv-dev/bin and the collections in $collections."
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
# Needs the network (PyPI) and the Python of .python-version (python<MINOR>; KAMINO_PYTHON overrides it): the
|
# Needs the network (PyPI) and the Python of .python-version (python<MINOR>; KAMINO_PYTHON overrides it): the
|
||||||
# header of the lock records it, and check_image_versions.py pins fails when it differs.
|
# header of the lock records it, and check_image_versions.py pins fails when it differs.
|
||||||
# pip and pip-tools are installed, at the pinned versions below, into a throwaway virtualenv, never
|
# pip and pip-tools are installed, at the pinned versions below, into a throwaway virtualenv, never
|
||||||
# into the project's .venv. pip is pinned too: pip-tools breaks on newer pip releases (7.5.2 on pip 26). Commit
|
# into the project's .venv-dev. pip is pinned too: pip-tools breaks on newer pip releases (7.5.2 on pip 26). Commit
|
||||||
# the lock with its requirements file; pip refuses an install of the two when they disagree
|
# the lock with its requirements file; pip refuses an install of the two when they disagree
|
||||||
# (`pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`).
|
# (`pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`).
|
||||||
# The pins are not hash-checked themselves: they come from PyPI over TLS, like the pip that
|
# The pins are not hash-checked themselves: they come from PyPI over TLS, like the pip that
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ IGNORED = (
|
|||||||
"ruff.toml",
|
"ruff.toml",
|
||||||
"apm.yml",
|
"apm.yml",
|
||||||
"apm.lock.yaml",
|
"apm.lock.yaml",
|
||||||
|
"pyproject.toml",
|
||||||
|
"uv.lock",
|
||||||
".claude/*",
|
".claude/*",
|
||||||
"tests/sanity/*",
|
"tests/sanity/*",
|
||||||
"tests/scripts/*",
|
"tests/scripts/*",
|
||||||
@@ -105,6 +107,7 @@ IGNORED = (
|
|||||||
".gitea/workflows/renovate.yml",
|
".gitea/workflows/renovate.yml",
|
||||||
".gitea/workflows/gitea-release-key.yml",
|
".gitea/workflows/gitea-release-key.yml",
|
||||||
"scripts/check_bot_pr_diff.py",
|
"scripts/check_bot_pr_diff.py",
|
||||||
|
"scripts/check_uv_lock.py",
|
||||||
"scripts/check_image_versions.py",
|
"scripts/check_image_versions.py",
|
||||||
"scripts/next_image_version.py",
|
"scripts/next_image_version.py",
|
||||||
"scripts/check_tarball.py",
|
"scripts/check_tarball.py",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from unittest import mock
|
|||||||
SCRIPTS = pathlib.Path(__file__).resolve().parents[2] / "scripts"
|
SCRIPTS = pathlib.Path(__file__).resolve().parents[2] / "scripts"
|
||||||
sys.path.insert(0, str(SCRIPTS))
|
sys.path.insert(0, str(SCRIPTS))
|
||||||
import check_bot_pr_diff as cbd
|
import check_bot_pr_diff as cbd
|
||||||
|
from test_check_uv_lock import APM_NEW, APM_OLD, CLICK_OLD, UV_LOCK, uv_files
|
||||||
|
|
||||||
D1, D2 = "sha256:" + "a" * 64, "sha256:" + "b" * 64
|
D1, D2 = "sha256:" + "a" * 64, "sha256:" + "b" * 64
|
||||||
FILES = {
|
FILES = {
|
||||||
@@ -30,6 +31,7 @@ FILES = {
|
|||||||
".gitea/workflows/lint.yml": f"container:\n image: git.rkdr.net/mortis/ci:0.2.0@{D1}\nrun: echo a\n",
|
".gitea/workflows/lint.yml": f"container:\n image: git.rkdr.net/mortis/ci:0.2.0@{D1}\nrun: echo a\n",
|
||||||
".gitea/workflows/molecule.yml": f"env:\n MOLECULE_IMAGE: >-\n git.rkdr.net/mortis/mol:0.1.0@{D1}\n",
|
".gitea/workflows/molecule.yml": f"env:\n MOLECULE_IMAGE: >-\n git.rkdr.net/mortis/mol:0.1.0@{D1}\n",
|
||||||
"renovate.json": "{}\n",
|
"renovate.json": "{}\n",
|
||||||
|
"pyproject.toml": '[project]\nrequires-python = ">=3.11"\n\n[dependency-groups]\ndev = ["apm-cli==0.39.3"]\n',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ def run(cwd, *cmd):
|
|||||||
|
|
||||||
|
|
||||||
H1, H2 = "a" * 64, "b" * 64
|
H1, H2 = "a" * 64, "b" * 64
|
||||||
|
FILES["uv.lock"] = UV_LOCK
|
||||||
|
|
||||||
|
|
||||||
class LockRuleTest(unittest.TestCase):
|
class LockRuleTest(unittest.TestCase):
|
||||||
@@ -113,6 +116,69 @@ class LockRuleTest(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PyprojectRuleTest(unittest.TestCase):
|
||||||
|
def test_an_apm_cli_bump_is_allowed(self):
|
||||||
|
self.assertIsNone(
|
||||||
|
cbd.file_problem(
|
||||||
|
"pyproject.toml",
|
||||||
|
['dev = ["apm-cli==0.39.3"]'],
|
||||||
|
['dev = ["apm-cli==0.39.4"]'],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_a_new_dependency_is_refused(self):
|
||||||
|
old = 'dev = ["apm-cli==0.39.3"]'
|
||||||
|
for new in (
|
||||||
|
'dev = ["apm-cli==0.39.4", "evil==1.0"]',
|
||||||
|
'dev = ["evil==0.39.4"]',
|
||||||
|
'dev = ["apm-cli==0.39.4"]\nprod = ["evil==1.0"]',
|
||||||
|
):
|
||||||
|
with self.subTest(new=new):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
cbd.file_problem("pyproject.toml", [old], new.split("\n"))
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_a_pinned_name_keeps_its_spelling(self):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
cbd.file_problem(
|
||||||
|
"pyproject.toml",
|
||||||
|
['dev = ["apm-cli==0.39.3"]'],
|
||||||
|
['dev = ["APM-CLI==0.39.4"]'],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_an_edit_to_another_setting_is_refused(self):
|
||||||
|
for old, new in (
|
||||||
|
('requires-python = ">=3.11"', 'requires-python = ">=3.12"'),
|
||||||
|
("package = false", "package = true"),
|
||||||
|
(
|
||||||
|
'dev = ["apm-cli==0.39.3"]',
|
||||||
|
'dev = ["apm-cli @ https://evil.example/apm.tgz"]',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'dev = ["apm-cli==0.39.3"]',
|
||||||
|
'dev = ["apm-cli==0.39.4"] # index-url = "https://evil/simple"',
|
||||||
|
),
|
||||||
|
):
|
||||||
|
with self.subTest(new=new):
|
||||||
|
self.assertIsNotNone(cbd.file_problem("pyproject.toml", [old], [new]))
|
||||||
|
|
||||||
|
|
||||||
|
class UvLockTest(unittest.TestCase):
|
||||||
|
def test_uv_lock_is_refused_without_both_sides_to_parse(self):
|
||||||
|
entries = [
|
||||||
|
("100644", "100644", "M", "pyproject.toml"),
|
||||||
|
("100644", "100644", "M", "uv.lock"),
|
||||||
|
]
|
||||||
|
patches = {
|
||||||
|
"pyproject.toml": '@@ -1 +1 @@\n-dev = ["apm-cli==0.39.3"]\n+dev = ["apm-cli==0.39.4"]\n',
|
||||||
|
"uv.lock": "@@ -1 +1 @@\n-revision = 3\n+revision = 5\n",
|
||||||
|
}
|
||||||
|
problems = cbd.check(entries, patches.get)
|
||||||
|
self.assertEqual(len(problems), 1, problems)
|
||||||
|
self.assertTrue(problems[0].startswith("uv.lock: "), problems)
|
||||||
|
|
||||||
|
|
||||||
class RuleTest(unittest.TestCase):
|
class RuleTest(unittest.TestCase):
|
||||||
def problem(self, path, old, new):
|
def problem(self, path, old, new):
|
||||||
return cbd.file_problem(path, [old], [new])
|
return cbd.file_problem(path, [old], [new])
|
||||||
@@ -499,6 +565,109 @@ class RepoTest(unittest.TestCase):
|
|||||||
self.assertEqual(code, 0, err)
|
self.assertEqual(code, 0, err)
|
||||||
self.assertIn("5 file(s)", out)
|
self.assertIn("5 file(s)", out)
|
||||||
|
|
||||||
|
def bump_apm_cli(self):
|
||||||
|
"""The change Renovate makes for apm-cli 0.39.4, as uv 0.13.1 writes it."""
|
||||||
|
self.edit("pyproject.toml", "apm-cli==0.39.3", "apm-cli==0.39.4")
|
||||||
|
self.edit("uv.lock", 'version = "0.39.3"', 'version = "0.39.4"')
|
||||||
|
self.edit("uv.lock", '"==0.39.3"', '"==0.39.4"')
|
||||||
|
self.edit("uv.lock", "apm_cli-0.39.3", "apm_cli-0.39.4")
|
||||||
|
self.edit("uv.lock", APM_OLD, APM_NEW)
|
||||||
|
|
||||||
|
def assert_lock_refused(self):
|
||||||
|
self.commit("bot")
|
||||||
|
code, _unused, err = self.gate()
|
||||||
|
self.assertEqual(code, 1, err)
|
||||||
|
self.assertIn("uv.lock", err)
|
||||||
|
|
||||||
|
def test_an_apm_cli_bump_with_its_lock_passes(self):
|
||||||
|
self.bump_apm_cli()
|
||||||
|
self.commit("bot")
|
||||||
|
code, out, err = self.gate()
|
||||||
|
self.assertEqual(code, 0, err)
|
||||||
|
self.assertIn("2 file(s)", out)
|
||||||
|
|
||||||
|
def test_another_packages_file_under_the_apm_cli_entry_is_refused(self):
|
||||||
|
self.bump_apm_cli()
|
||||||
|
lock = (self.repo / "uv.lock").read_text()
|
||||||
|
start = lock.index('version = "0.39.4"')
|
||||||
|
end = lock.index("[[package]]", start)
|
||||||
|
six = (
|
||||||
|
'version = "1.17.0"\nsource = { registry = "https://pypi.org/simple" }\n'
|
||||||
|
'dependencies = [\n { name = "click" },\n { name = "watchdog" },\n]\n'
|
||||||
|
'wheels = [\n { url = "https://files.pythonhosted.org/packages/b7/ce/'
|
||||||
|
'149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", '
|
||||||
|
'hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", '
|
||||||
|
'size = 11050, upload-time = "2024-12-04T17:35:26.475Z" },\n]\n\n'
|
||||||
|
)
|
||||||
|
self.write("uv.lock", lock[:start] + six + lock[end:])
|
||||||
|
self.assert_lock_refused()
|
||||||
|
|
||||||
|
def test_a_new_package_is_refused(self):
|
||||||
|
self.bump_apm_cli()
|
||||||
|
self.edit(
|
||||||
|
"uv.lock",
|
||||||
|
'dev = [\n { name = "apm-cli" },\n]',
|
||||||
|
'dev = [\n { name = "apm-cli" },\n { name = "six" },\n]',
|
||||||
|
)
|
||||||
|
self.write(
|
||||||
|
"uv.lock",
|
||||||
|
(self.repo / "uv.lock").read_text()
|
||||||
|
+ '\n[[package]]\nname = "six"\nversion = "1.17.0"\n'
|
||||||
|
'source = { registry = "https://pypi.org/simple" }\n'
|
||||||
|
+ uv_files("six", "1.17.0", H2),
|
||||||
|
)
|
||||||
|
self.assert_lock_refused()
|
||||||
|
|
||||||
|
def test_a_marker_that_drops_a_dependency_is_refused(self):
|
||||||
|
self.bump_apm_cli()
|
||||||
|
self.edit(
|
||||||
|
"uv.lock",
|
||||||
|
' { name = "watchdog" },',
|
||||||
|
' { name = "watchdog", marker = "sys_platform == \'never\'" },',
|
||||||
|
)
|
||||||
|
self.assert_lock_refused()
|
||||||
|
|
||||||
|
def test_a_downgraded_transitive_package_is_refused(self):
|
||||||
|
self.bump_apm_cli()
|
||||||
|
self.edit("uv.lock", 'version = "8.5.1"', 'version = "8.5.0"')
|
||||||
|
self.edit("uv.lock", "click-8.5.1", "click-8.5.0")
|
||||||
|
self.edit("uv.lock", CLICK_OLD, H2)
|
||||||
|
self.assert_lock_refused()
|
||||||
|
|
||||||
|
def test_a_pyproject_change_without_its_lock_is_refused(self):
|
||||||
|
self.edit("pyproject.toml", "apm-cli==0.39.3", "apm-cli==0.39.4")
|
||||||
|
self.commit("bot")
|
||||||
|
code, _unused, err = self.gate()
|
||||||
|
self.assertEqual(code, 1, err)
|
||||||
|
self.assertIn("pyproject.toml", err)
|
||||||
|
|
||||||
|
def test_an_apm_cli_lock_change_without_pyproject_is_refused(self):
|
||||||
|
self.bump_apm_cli()
|
||||||
|
self.edit("pyproject.toml", "apm-cli==0.39.4", "apm-cli==0.39.3")
|
||||||
|
self.assert_lock_refused()
|
||||||
|
|
||||||
|
def test_a_changed_apm_cli_source_is_refused(self):
|
||||||
|
self.bump_apm_cli()
|
||||||
|
lock = (self.repo / "uv.lock").read_text()
|
||||||
|
start = lock.index('name = "apm-cli"')
|
||||||
|
self.write(
|
||||||
|
"uv.lock",
|
||||||
|
lock[:start]
|
||||||
|
+ lock[start:].replace(
|
||||||
|
"https://pypi.org/simple", "https://evil.example/simple", 1
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self.assert_lock_refused()
|
||||||
|
|
||||||
|
def test_a_changed_apm_cli_download_host_is_refused(self):
|
||||||
|
self.bump_apm_cli()
|
||||||
|
self.edit(
|
||||||
|
"uv.lock",
|
||||||
|
"https://files.pythonhosted.org/packages/ab/cd/apm_cli-0.39.4-py3",
|
||||||
|
"https://files.evil.example/packages/ab/cd/apm_cli-0.39.4-py3",
|
||||||
|
)
|
||||||
|
self.assert_lock_refused()
|
||||||
|
|
||||||
def test_each_violation_gets_one_line(self):
|
def test_each_violation_gets_one_line(self):
|
||||||
self.edit(".gitea/workflows/lint.yml", "echo a", "echo b")
|
self.edit(".gitea/workflows/lint.yml", "echo a", "echo b")
|
||||||
self.write("roles/x/main.yml", "a\n")
|
self.write("roles/x/main.yml", "a\n")
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ class CraftedTarballTest(unittest.TestCase):
|
|||||||
REPO,
|
REPO,
|
||||||
src,
|
src,
|
||||||
ignore=shutil.ignore_patterns(
|
ignore=shutil.ignore_patterns(
|
||||||
".git", ".venv", "__pycache__", "output", "*.tar.gz"
|
".git", ".venv", ".venv-dev", "__pycache__", "output", "*.tar.gz"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
out = pathlib.Path(self.tmp.name) / "dist"
|
out = pathlib.Path(self.tmp.name) / "dist"
|
||||||
|
|||||||
@@ -0,0 +1,321 @@
|
|||||||
|
# SPDX-FileCopyrightText: Defame1297 and contributors
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
"""Run with: python3 -m unittest discover -s tests/scripts"""
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
SCRIPTS = pathlib.Path(__file__).resolve().parents[2] / "scripts"
|
||||||
|
sys.path.insert(0, str(SCRIPTS))
|
||||||
|
import check_uv_lock as cul
|
||||||
|
|
||||||
|
APM_OLD, APM_NEW, CLICK_OLD, OTHER = "c" * 64, "d" * 64, "e" * 64, "f" * 64
|
||||||
|
PYPI_FILES = "https://files.pythonhosted.org/packages/ab/cd/"
|
||||||
|
|
||||||
|
|
||||||
|
def uv_files(dist, version, digest):
|
||||||
|
return (
|
||||||
|
f'sdist = {{ url = "{PYPI_FILES}{dist}-{version}.tar.gz", hash = "sha256:{digest}", '
|
||||||
|
f'size = 3132901, upload-time = "2026-12-01T18:11:22.037Z" }}\n'
|
||||||
|
f'wheels = [\n {{ url = "{PYPI_FILES}{dist}-{version}-py3-none-any.whl", '
|
||||||
|
f'hash = "sha256:{digest}", size = 3536708, upload-time = "2026-12-01T18:11:19.761Z" }},\n]\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# A uv.lock as uv 0.13.1 writes it: apm-cli, two of its dependencies and the root project.
|
||||||
|
UV_LOCK = (
|
||||||
|
'version = 1\nrevision = 5\nrequires-python = ">=3.11"\n\n'
|
||||||
|
'[[package]]\nname = "apm-cli"\nversion = "0.39.3"\n'
|
||||||
|
'source = { registry = "https://pypi.org/simple" }\n'
|
||||||
|
'dependencies = [\n { name = "click" },\n { name = "watchdog" },\n]\n'
|
||||||
|
+ uv_files("apm_cli", "0.39.3", APM_OLD)
|
||||||
|
+ '\n[[package]]\nname = "click"\nversion = "8.5.1"\n'
|
||||||
|
'source = { registry = "https://pypi.org/simple" }\n'
|
||||||
|
+ uv_files("click", "8.5.1", CLICK_OLD)
|
||||||
|
+ '\n[[package]]\nname = "kamino"\nversion = "0"\nsource = { virtual = "." }\n\n'
|
||||||
|
'[package.dev-dependencies]\ndev = [\n { name = "apm-cli" },\n]\n\n'
|
||||||
|
"[package.metadata]\n\n[package.metadata.requires-dev]\n"
|
||||||
|
'dev = [{ name = "apm-cli", specifier = "==0.39.3" }]\n'
|
||||||
|
'\n[[package]]\nname = "watchdog"\nversion = "7.1.1"\n'
|
||||||
|
'source = { registry = "https://pypi.org/simple" }\n'
|
||||||
|
+ uv_files("watchdog", "7.1.1", OTHER)
|
||||||
|
)
|
||||||
|
PYPROJECT = (
|
||||||
|
'[project]\nname = "kamino"\n\n[dependency-groups]\ndev = ["apm-cli==VERSION"]\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def bumped(lock=UV_LOCK):
|
||||||
|
"""The lock after Renovate's apm-cli 0.39.4 bump."""
|
||||||
|
return (
|
||||||
|
lock.replace('version = "0.39.3"', 'version = "0.39.4"')
|
||||||
|
.replace('"==0.39.3"', '"==0.39.4"')
|
||||||
|
.replace("apm_cli-0.39.3", "apm_cli-0.39.4")
|
||||||
|
.replace(APM_OLD, APM_NEW)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def problem(new, pin="0.39.4", old=UV_LOCK):
|
||||||
|
return cul.lock_problem(old, new, PYPROJECT.replace("VERSION", pin))
|
||||||
|
|
||||||
|
|
||||||
|
class AllowedTest(unittest.TestCase):
|
||||||
|
def test_an_apm_cli_bump_is_allowed(self):
|
||||||
|
self.assertIsNone(problem(bumped()))
|
||||||
|
|
||||||
|
def test_a_new_lock_revision_is_allowed(self):
|
||||||
|
old = UV_LOCK.replace("revision = 5", "revision = 3")
|
||||||
|
self.assertIsNone(problem(bumped(), old=old))
|
||||||
|
|
||||||
|
def test_a_package_without_an_sdist_is_allowed(self):
|
||||||
|
start = UV_LOCK.index("sdist = { url")
|
||||||
|
old = UV_LOCK[:start] + UV_LOCK[UV_LOCK.index("wheels = [", start) :]
|
||||||
|
self.assertIsNone(problem(bumped(old), old=old))
|
||||||
|
|
||||||
|
|
||||||
|
class RefusedTest(unittest.TestCase):
|
||||||
|
def assert_refused(self, new, **kwargs):
|
||||||
|
self.assertIsNotNone(problem(new, **kwargs))
|
||||||
|
|
||||||
|
def test_a_lock_that_is_not_toml_is_refused(self):
|
||||||
|
self.assert_refused(bumped() + "[[package\n")
|
||||||
|
|
||||||
|
def test_a_lock_of_another_shape_is_refused(self):
|
||||||
|
top = 'version = 1\nrevision = 5\nrequires-python = ">=3.11"\n'
|
||||||
|
for package in ('package = ["x"]\n', "package = 1\n"):
|
||||||
|
with self.subTest(package=package):
|
||||||
|
self.assertEqual(
|
||||||
|
problem(top + package), "the lock does not have the shape uv writes"
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_the_lock_version_must_be_the_pin(self):
|
||||||
|
self.assert_refused(bumped(), pin="0.39.5")
|
||||||
|
self.assert_refused(
|
||||||
|
bumped().replace('version = "0.39.4"', 'version = "0.39.5"')
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_the_dev_specifier_must_be_the_pin(self):
|
||||||
|
self.assert_refused(bumped().replace('"==0.39.4"', '"==0.39.3"'))
|
||||||
|
self.assert_refused(bumped().replace('"==0.39.4"', '">=0.39.4"'))
|
||||||
|
|
||||||
|
def test_a_pyproject_without_one_apm_cli_pin_is_refused(self):
|
||||||
|
for pyproject in (
|
||||||
|
'[dependency-groups]\ndev = ["apm-cli>=0.39.4"]\n',
|
||||||
|
'[dependency-groups]\ndev = ["apm-cli==0.39.4", "apm-cli==0.39.5"]\n',
|
||||||
|
"[dependency-groups]\ndev = [\n",
|
||||||
|
):
|
||||||
|
with self.subTest(pyproject=pyproject):
|
||||||
|
self.assertIsNotNone(cul.lock_problem(UV_LOCK, bumped(), pyproject))
|
||||||
|
|
||||||
|
def test_another_top_level_setting_is_refused(self):
|
||||||
|
for old, new in (
|
||||||
|
('requires-python = ">=3.11"', 'requires-python = ">=3.12"'),
|
||||||
|
("version = 1\n", "version = 2\n"),
|
||||||
|
("revision = 5", 'revision = "5"'),
|
||||||
|
(
|
||||||
|
"revision = 5",
|
||||||
|
'revision = 5\n[options]\nexclude-newer = "2026-01-01T00:00:00Z"',
|
||||||
|
),
|
||||||
|
):
|
||||||
|
with self.subTest(new=new):
|
||||||
|
self.assert_refused(bumped().replace(old, new, 1))
|
||||||
|
|
||||||
|
def test_an_apm_cli_dependency_change_is_refused(self):
|
||||||
|
for new in (
|
||||||
|
' { name = "click" },\n { name = "watchdog" },\n { name = "six" },\n',
|
||||||
|
' { name = "click" },\n',
|
||||||
|
' { name = "click", marker = "sys_platform == \'never\'" },\n { name = "watchdog" },\n',
|
||||||
|
' { name = "click", extra = ["evil"] },\n { name = "watchdog" },\n',
|
||||||
|
):
|
||||||
|
with self.subTest(new=new):
|
||||||
|
self.assert_refused(
|
||||||
|
bumped().replace(
|
||||||
|
' { name = "click" },\n { name = "watchdog" },\n', new, 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_a_changed_apm_cli_source_is_refused(self):
|
||||||
|
lock = bumped()
|
||||||
|
start = lock.index('name = "apm-cli"')
|
||||||
|
for source in (
|
||||||
|
'source = { registry = "https://evil.example/simple" }',
|
||||||
|
'source = { git = "https://evil.example/apm.git?rev=main#0123abc" }',
|
||||||
|
'source = { url = "https://evil.example/apm_cli-0.39.4.tar.gz" }',
|
||||||
|
):
|
||||||
|
with self.subTest(source=source):
|
||||||
|
self.assert_refused(
|
||||||
|
lock[:start]
|
||||||
|
+ lock[start:].replace(
|
||||||
|
'source = { registry = "https://pypi.org/simple" }', source, 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_a_file_that_is_not_the_pinned_apm_cli_from_pypi_is_refused(self):
|
||||||
|
wheel = f"{PYPI_FILES}apm_cli-0.39.4-py3-none-any.whl"
|
||||||
|
for old, new in (
|
||||||
|
(wheel, wheel.replace("files.pythonhosted.org", "files.evil.example")),
|
||||||
|
(wheel, wheel.replace("https://", "http://")),
|
||||||
|
(
|
||||||
|
wheel,
|
||||||
|
wheel.replace(
|
||||||
|
"files.pythonhosted.org", "files.pythonhosted.org.evil.example"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(wheel, wheel.replace("/packages/", "/other/")),
|
||||||
|
(wheel, wheel + "?x=/packages/apm_cli-0.39.4-py3-none-any.whl"),
|
||||||
|
(wheel, wheel.replace("apm_cli-0.39.4", "six-1.17.0")),
|
||||||
|
(wheel, wheel.replace("apm_cli-0.39.4", "apm_cli-0.39.3")),
|
||||||
|
(wheel, wheel.replace("apm_cli-0.39.4", "apm_cli-0.39.40")),
|
||||||
|
(wheel, wheel.replace(".whl", ".exe")),
|
||||||
|
(f"sha256:{APM_NEW}", "md5:" + "d" * 32),
|
||||||
|
(f"sha256:{APM_NEW}", "sha256:" + "d" * 63),
|
||||||
|
(f"sha256:{APM_NEW}", "sha256:" + "D" * 64),
|
||||||
|
):
|
||||||
|
with self.subTest(new=new):
|
||||||
|
self.assert_refused(bumped().replace(old, new))
|
||||||
|
|
||||||
|
def test_a_file_with_another_key_is_refused(self):
|
||||||
|
wheel = f'{{ url = "{PYPI_FILES}apm_cli-0.39.4-py3-none-any.whl", '
|
||||||
|
self.assert_refused(
|
||||||
|
bumped().replace(wheel, wheel + 'path = "../evil.whl", ', 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_an_apm_cli_without_files_is_refused(self):
|
||||||
|
lock = bumped()
|
||||||
|
start = lock.index("sdist = { url", lock.index('name = "apm-cli"'))
|
||||||
|
end = lock.index("]\n", start) + 2
|
||||||
|
self.assert_refused(lock[:start] + lock[end:])
|
||||||
|
|
||||||
|
def test_a_change_to_another_package_is_refused(self):
|
||||||
|
for old, new in (
|
||||||
|
('version = "8.5.1"', 'version = "8.5.0"'),
|
||||||
|
(CLICK_OLD, OTHER),
|
||||||
|
(
|
||||||
|
'name = "watchdog"\n',
|
||||||
|
'name = "watchdog"\ndependencies = [{ name = "click" }]\n',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'version = "0"\nsource = { virtual = "." }',
|
||||||
|
'version = "1"\nsource = { virtual = "." }',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'dev = [\n { name = "apm-cli" },\n]',
|
||||||
|
'dev = [\n { name = "apm-cli" },\n { name = "click" },\n]',
|
||||||
|
),
|
||||||
|
):
|
||||||
|
with self.subTest(new=new):
|
||||||
|
self.assert_refused(bumped().replace(old, new, 1))
|
||||||
|
|
||||||
|
def test_an_added_or_removed_package_is_refused(self):
|
||||||
|
six = (
|
||||||
|
'\n[[package]]\nname = "six"\nversion = "1.17.0"\n'
|
||||||
|
'source = { registry = "https://pypi.org/simple" }\n'
|
||||||
|
+ uv_files("six", "1.17.0", OTHER)
|
||||||
|
)
|
||||||
|
self.assert_refused(bumped() + six)
|
||||||
|
watchdog = bumped().index('\n[[package]]\nname = "watchdog"')
|
||||||
|
self.assert_refused(bumped()[:watchdog])
|
||||||
|
|
||||||
|
def test_a_second_apm_cli_or_root_entry_is_refused(self):
|
||||||
|
apm = bumped()
|
||||||
|
start = apm.index('[[package]]\nname = "apm-cli"')
|
||||||
|
end = apm.index("[[package]]", start + 1)
|
||||||
|
self.assert_refused(apm + "\n" + apm[start:end])
|
||||||
|
root = apm.index('[[package]]\nname = "kamino"')
|
||||||
|
self.assert_refused(
|
||||||
|
apm
|
||||||
|
+ '\n[[package]]\nname = "other"\nversion = "0"\nsource = { virtual = "." }\n',
|
||||||
|
old=UV_LOCK
|
||||||
|
+ '\n[[package]]\nname = "other"\nversion = "0"\nsource = { virtual = "." }\n',
|
||||||
|
)
|
||||||
|
self.assertGreater(root, 0)
|
||||||
|
|
||||||
|
|
||||||
|
def moved(lock, old, new):
|
||||||
|
"""lock with apm-cli moved from version old to new."""
|
||||||
|
return (
|
||||||
|
lock.replace(f'version = "{old}"', f'version = "{new}"')
|
||||||
|
.replace(f'"=={old}"', f'"=={new}"')
|
||||||
|
.replace(f"apm_cli-{old}", f"apm_cli-{new}")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def without_apm_wheels(lock):
|
||||||
|
start = lock.index("wheels = [", lock.index('name = "apm-cli"'))
|
||||||
|
return lock[:start] + lock[lock.index("]\n", start) + 2 :]
|
||||||
|
|
||||||
|
|
||||||
|
class FileKindsAndOrderTest(unittest.TestCase):
|
||||||
|
def test_dropped_wheels_without_a_version_change_are_refused(self):
|
||||||
|
new = without_apm_wheels(UV_LOCK).replace("size = 3132901", "size = 3132902", 1)
|
||||||
|
self.assertIsNotNone(problem(new, pin="0.39.3"))
|
||||||
|
|
||||||
|
def test_a_downgrade_is_refused(self):
|
||||||
|
self.assertIsNotNone(problem(UV_LOCK, pin="0.39.3", old=bumped()))
|
||||||
|
|
||||||
|
def test_the_version_must_rise(self):
|
||||||
|
self.assertIsNotNone(problem(UV_LOCK.replace(APM_OLD, APM_NEW), pin="0.39.3"))
|
||||||
|
|
||||||
|
def test_versions_are_compared_as_numbers(self):
|
||||||
|
old = moved(UV_LOCK, "0.39.3", "0.39.9")
|
||||||
|
self.assertIsNone(
|
||||||
|
problem(moved(old, "0.39.9", "0.39.10"), pin="0.39.10", old=old)
|
||||||
|
)
|
||||||
|
old = moved(UV_LOCK, "0.39.3", "0.9.0")
|
||||||
|
self.assertIsNone(problem(moved(old, "0.9.0", "0.10.0"), pin="0.10.0", old=old))
|
||||||
|
old = moved(UV_LOCK, "0.39.3", "0.40.0")
|
||||||
|
self.assertIsNotNone(
|
||||||
|
problem(moved(old, "0.40.0", "0.39.10"), pin="0.39.10", old=old)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_a_version_that_is_not_a_plain_release_is_refused(self):
|
||||||
|
for version in (
|
||||||
|
"0.40.0rc1",
|
||||||
|
"0.40.0.post1",
|
||||||
|
"0.40.0.dev1",
|
||||||
|
"1!0.1.0",
|
||||||
|
"0.40.0+local",
|
||||||
|
):
|
||||||
|
with self.subTest(version=version):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
problem(moved(UV_LOCK, "0.39.3", version), pin=version)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_the_kinds_of_file_stay_the_same(self):
|
||||||
|
self.assertIsNotNone(problem(without_apm_wheels(bumped())))
|
||||||
|
start = bumped().index("sdist = { url", bumped().index('name = "apm-cli"'))
|
||||||
|
no_sdist = bumped()[:start] + bumped()[bumped().index("wheels = [", start) :]
|
||||||
|
self.assertIsNotNone(problem(no_sdist))
|
||||||
|
old_no_sdist = (
|
||||||
|
UV_LOCK[: UV_LOCK.index("sdist = { url")]
|
||||||
|
+ UV_LOCK[UV_LOCK.index("wheels = [") :]
|
||||||
|
)
|
||||||
|
self.assertIsNotNone(problem(bumped(), old=old_no_sdist))
|
||||||
|
self.assertIsNone(problem(no_sdist, old=old_no_sdist))
|
||||||
|
for tag in ("cp311-cp311-manylinux_2_17_x86_64", "py2.py3-none-any"):
|
||||||
|
with self.subTest(tag=tag):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
problem(bumped().replace("0.39.4-py3-none-any", f"0.39.4-{tag}"))
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_a_path_that_leaves_packages_is_refused(self):
|
||||||
|
wheel = f"{PYPI_FILES}apm_cli-0.39.4-py3-none-any.whl"
|
||||||
|
for path in (
|
||||||
|
"/packages/../../simple/x/",
|
||||||
|
"/packages/ab/./cd/",
|
||||||
|
"/packages//ab/",
|
||||||
|
"/packages/%2e%2e/%2e%2e/simple/x/",
|
||||||
|
"/packages/ab/cd%2F/",
|
||||||
|
):
|
||||||
|
with self.subTest(path=path):
|
||||||
|
bad = (
|
||||||
|
"https://files.pythonhosted.org"
|
||||||
|
+ path
|
||||||
|
+ "apm_cli-0.39.4-py3-none-any.whl"
|
||||||
|
)
|
||||||
|
self.assertIsNotNone(problem(bumped().replace(wheel, bad)))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -192,7 +192,7 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
proc = self.run_setup(repo, KAMINO_PYTHON=str(wrong))
|
proc = self.run_setup(repo, KAMINO_PYTHON=str(wrong))
|
||||||
self.assertNotEqual(proc.returncode, 0)
|
self.assertNotEqual(proc.returncode, 0)
|
||||||
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
|
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
|
||||||
self.assertFalse((repo / ".venv").exists())
|
self.assertFalse((repo / ".venv-dev").exists())
|
||||||
|
|
||||||
def test_an_interpreter_of_another_minor_is_refused_and_the_pinned_one_accepted(
|
def test_an_interpreter_of_another_minor_is_refused_and_the_pinned_one_accepted(
|
||||||
self,
|
self,
|
||||||
@@ -201,10 +201,10 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
proc = self.run_setup(repo, STUB_PY_MINOR="3.12")
|
proc = self.run_setup(repo, STUB_PY_MINOR="3.12")
|
||||||
self.assertNotEqual(proc.returncode, 0)
|
self.assertNotEqual(proc.returncode, 0)
|
||||||
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
|
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
|
||||||
self.assertFalse((repo / ".venv").exists())
|
self.assertFalse((repo / ".venv-dev").exists())
|
||||||
proc = self.run_setup(repo, STUB_PY_MINOR="3.13")
|
proc = self.run_setup(repo, STUB_PY_MINOR="3.13")
|
||||||
self.assertEqual(proc.returncode, 0, proc.stderr)
|
self.assertEqual(proc.returncode, 0, proc.stderr)
|
||||||
self.assertTrue((repo / ".venv").is_dir())
|
self.assertTrue((repo / ".venv-dev").is_dir())
|
||||||
|
|
||||||
def test_a_missing_pin_file_is_refused_with_a_message(self) -> None:
|
def test_a_missing_pin_file_is_refused_with_a_message(self) -> None:
|
||||||
repo = self.make_repo()
|
repo = self.make_repo()
|
||||||
@@ -228,6 +228,30 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
text = self.hook(repo, name).read_text()
|
text = self.hook(repo, name).read_text()
|
||||||
self.assertIn("# kamino-dev-setup: virtualenv first on PATH", text)
|
self.assertIn("# kamino-dev-setup: virtualenv first on PATH", text)
|
||||||
self.assertEqual(self.hooks_z(repo), b"")
|
self.assertEqual(self.hooks_z(repo), b"")
|
||||||
|
self.assertFalse((repo / ".venv").exists())
|
||||||
|
|
||||||
|
def test_a_rerun_moves_the_hooks_of_an_older_setup_to_venv_dev(self) -> None:
|
||||||
|
repo = self.make_repo()
|
||||||
|
kept = repo / ".venv" / "kept"
|
||||||
|
kept.parent.mkdir()
|
||||||
|
kept.write_text("")
|
||||||
|
names = ("pre-commit", "commit-msg", "pre-push")
|
||||||
|
for name in names:
|
||||||
|
hook = self.hook(repo, name)
|
||||||
|
hook.parent.mkdir(exist_ok=True)
|
||||||
|
hook.write_text(
|
||||||
|
"#!/usr/bin/env bash\n"
|
||||||
|
"# kamino-dev-setup: virtualenv first on PATH\n"
|
||||||
|
f'export PATH={repo}/.venv/bin:"$PATH"\n'
|
||||||
|
)
|
||||||
|
hook.chmod(0o755)
|
||||||
|
result = self.run_setup(repo)
|
||||||
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
|
for name in names:
|
||||||
|
text = self.hook(repo, name).read_text()
|
||||||
|
self.assertIn(f'export PATH={repo}/.venv-dev/bin:"$PATH"\n', text)
|
||||||
|
self.assertNotIn("/.venv/bin", text)
|
||||||
|
self.assertTrue(kept.exists())
|
||||||
|
|
||||||
def test_a_missing_tea_warns_and_setup_succeeds(self) -> None:
|
def test_a_missing_tea_warns_and_setup_succeeds(self) -> None:
|
||||||
repo = self.make_repo()
|
repo = self.make_repo()
|
||||||
@@ -403,12 +427,12 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
self.git(other, "init", "--quiet")
|
self.git(other, "init", "--quiet")
|
||||||
result = self.run_setup(repo, cwd=other)
|
result = self.run_setup(repo, cwd=other)
|
||||||
self.assertEqual(result.returncode, 0, result.stderr)
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
self.assertFalse((other / ".venv").exists())
|
self.assertFalse((other / ".venv-dev").exists())
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
os.listdir(other / ".git" / "hooks"),
|
os.listdir(other / ".git" / "hooks"),
|
||||||
[n for n in os.listdir(other / ".git" / "hooks") if n.endswith(".sample")],
|
[n for n in os.listdir(other / ".git" / "hooks") if n.endswith(".sample")],
|
||||||
)
|
)
|
||||||
self.assertTrue((repo / ".venv").is_dir())
|
self.assertTrue((repo / ".venv-dev").is_dir())
|
||||||
self.assertTrue(self.hook(repo).exists())
|
self.assertTrue(self.hook(repo).exists())
|
||||||
|
|
||||||
def test_crafted_repository_path_is_not_executed(self) -> None:
|
def test_crafted_repository_path_is_not_executed(self) -> None:
|
||||||
@@ -428,7 +452,7 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
self.assertEqual(hook.returncode, 0, hook.stderr)
|
self.assertEqual(hook.returncode, 0, hook.stderr)
|
||||||
lines = hook.stdout.splitlines()
|
lines = hook.stdout.splitlines()
|
||||||
self.assertEqual(lines[0], "hook-ran")
|
self.assertEqual(lines[0], "hook-ran")
|
||||||
self.assertTrue(lines[1].startswith(f"{repo}/.venv/bin:"), lines[1])
|
self.assertTrue(lines[1].startswith(f"{repo}/.venv-dev/bin:"), lines[1])
|
||||||
for place in (workdir, repo, self.tmp, Path.cwd()):
|
for place in (workdir, repo, self.tmp, Path.cwd()):
|
||||||
self.assertFalse((place / "PWNED").exists(), place)
|
self.assertFalse((place / "PWNED").exists(), place)
|
||||||
self.assertFalse((place / "PWNED2").exists(), place)
|
self.assertFalse((place / "PWNED2").exists(), place)
|
||||||
|
|||||||
@@ -217,6 +217,16 @@ class SelectTest(unittest.TestCase):
|
|||||||
chosen, _reason = self.select(["requirements-dev.txt", "requirements-dev.lock"])
|
chosen, _reason = self.select(["requirements-dev.txt", "requirements-dev.lock"])
|
||||||
self.assertEqual(chosen, [])
|
self.assertEqual(chosen, [])
|
||||||
|
|
||||||
|
def test_the_apm_pin_selects_nothing(self):
|
||||||
|
chosen, _reason = self.select(["pyproject.toml", "uv.lock"])
|
||||||
|
self.assertEqual(chosen, [])
|
||||||
|
|
||||||
|
def test_the_bot_diff_check_selects_nothing(self):
|
||||||
|
chosen, _reason = self.select(
|
||||||
|
["scripts/check_bot_pr_diff.py", "scripts/check_uv_lock.py"]
|
||||||
|
)
|
||||||
|
self.assertEqual(chosen, [])
|
||||||
|
|
||||||
def test_molecule_requirements_select_everything(self):
|
def test_molecule_requirements_select_everything(self):
|
||||||
# An ansible-core or molecule bump there changes the tools every scenario runs with.
|
# An ansible-core or molecule bump there changes the tools every scenario runs with.
|
||||||
for path in ("requirements-molecule.txt", "requirements-molecule.lock"):
|
for path in ("requirements-molecule.txt", "requirements-molecule.lock"):
|
||||||
|
|||||||
Reference in new issue
Block a user