Compare commits

...
12 Commits
Author SHA1 Message Date
devx-ci-bot 663572768b release: v0.19.2
Post-merge / detect-type (push) Successful in 41s
Post-merge / validate-commit-msg (push) Has been skipped
Post-merge / release (push) Has been skipped
Post-merge / sync-wiki (push) Has been skipped
Post-merge / vikunja (push) Has been skipped
Post-merge / configure-repo (push) Has been skipped
Post-merge / publish (push) Has been skipped
Post-merge / badges (push) Successful in 52s
2026-06-27 01:38:41 +02:00
emil 1f2533872d DEVX-66: fix: calibrate molecule weights from actual CI execution times
Post-merge / detect-type (push) Successful in 31s
Post-merge / sync-wiki (push) Successful in 48s
Post-merge / vikunja (push) Successful in 49s
Post-merge / validate-commit-msg (push) Successful in 45s
Post-merge / configure-repo (push) Successful in 52s
Post-merge / release (push) Successful in 1m9s
Post-merge / badges (push) Successful in 1m24s
Post-merge / publish (push) Successful in 52s
2026-06-26 23:36:58 +00:00
gitea-actions-bot cb7e9dbc7e chore: update badge URLs to commit 0ab8d43a [skip ci] 2026-06-26 21:39:38 +02:00
devx-ci-bot f5081e10b1 release: v0.19.1
Post-merge / detect-type (push) Successful in 42s
Post-merge / validate-commit-msg (push) Has been skipped
Post-merge / release (push) Has been skipped
Post-merge / sync-wiki (push) Has been skipped
Post-merge / vikunja (push) Has been skipped
Post-merge / configure-repo (push) Has been skipped
Post-merge / publish (push) Has been skipped
Post-merge / badges (push) Successful in 55s
2026-06-26 21:36:46 +02:00
gitea-actions-bot cabc0d1adc chore: update badge URLs to commit 816fbbbb [skip ci] 2026-06-26 19:36:16 +00:00
emil 7c1ecd6ff9 DEVX-65: refactor: consolidate publish.yml into post-merge.yml
Post-merge / detect-type (push) Successful in 30s
Post-merge / vikunja (push) Successful in 46s
Post-merge / sync-wiki (push) Successful in 48s
Post-merge / validate-commit-msg (push) Successful in 51s
Post-merge / badges (push) Successful in 59s
Post-merge / release (push) Successful in 1m30s
Post-merge / configure-repo (push) Successful in 1m34s
Post-merge / publish (push) Successful in 54s
2026-06-26 19:34:45 +00:00
gitea-actions-bot 5063f659bc chore: update badge URLs to commit f977a79e [skip ci] 2026-06-26 21:04:44 +02:00
gitea-actions-bot 96c77a0ba4 chore: update badge URLs to commit c9a5f623 [skip ci] 2026-06-26 19:03:18 +00:00
devx-ci-bot 40dd578d89 release: v0.19.0
Post-merge / detect-type (push) Successful in 37s
Post-merge / release (push) Has been skipped
Post-merge / validate-commit-msg (push) Has been skipped
Post-merge / sync-wiki (push) Has been skipped
Post-merge / vikunja (push) Has been skipped
Post-merge / configure-repo (push) Has been skipped
Publish Release / publish (push) Successful in 48s
Post-merge / badges (push) Successful in 48s
2026-06-26 19:03:14 +00:00
emil 7ea9b4a96b DEVX-64: feat: add skip_ref_prefixes config to check_agent_docs
Post-merge / detect-type (push) Successful in 38s
Post-merge / validate-commit-msg (push) Successful in 45s
Post-merge / sync-wiki (push) Successful in 51s
Post-merge / release (push) Successful in 57s
Post-merge / badges (push) Successful in 59s
Post-merge / configure-repo (push) Successful in 1m1s
Post-merge / vikunja (push) Successful in 1m22s
2026-06-26 19:01:39 +00:00
gitea-actions-bot 08ceaf484f chore: update badge URLs to commit c003531a [skip ci] 2026-06-26 20:52:05 +02:00
gitea-actions-bot fb6b0fda1d chore: update badge URLs to commit c5811a72 [skip ci] 2026-06-26 18:50:24 +00:00
14 changed files with 234 additions and 89 deletions
+51 -5
View File
@@ -1,13 +1,13 @@
name: Post-merge
# Runs on every push to master. A single workflow with conditional jobs
# replaces separate workflows for release, wiki sync, badges, and
# Vikunja task updates.
# for release, publish, wiki sync, badges, and Vikunja task updates.
#
# Job dependency graph:
#
# detect-type ──┬── validate-commit-msg (skip if release commit)
# ├── release (skip if release commit)
# │ └── publish (needs release — builds & publishes to PyPI)
# ├── badges (ALWAYS runs — even on release commits)
# ├── configure-repo (independent — skip if release commit)
# ├── sync-wiki (skip if release commit — runs for ALL merges)
@@ -21,9 +21,10 @@ name: Post-merge
# runs on every push to master, including release commits. This ensures
# badges (tests, coverage, version, etc.) are always current.
#
# When release creates a "release: vX.Y.Z" commit, the release
# commit's post-merge run still updates badges (version badge picks
# up the new version). Other jobs skip. The tag push triggers publish.yml.
# When release creates a "release: vX.Y.Z" commit and tag, the publish
# job (which depends on release) builds and publishes the package to the
# Gitea PyPI registry. The release commit's post-merge run still updates
# badges (version badge picks up the new version). Other jobs skip.
on:
push:
@@ -74,6 +75,8 @@ jobs:
if: needs.detect-type.outputs.is-release == 'false'
runs-on: docker
timeout-minutes: 15
outputs:
tag: ${{ steps.release-tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
@@ -88,12 +91,20 @@ jobs:
git config user.name "devx-ci-bot"
git config user.email "devx-ci-bot@oblachno.fyi"
- name: Run release
id: release-tag
env:
PYTHONPATH: src
run: |
. .venv/bin/activate
export PATH="$HOME/.local/bin:$PATH"
python3 -m devx.ci.release
- name: Extract tag (fallback if GITHUB_OUTPUT not set)
if: steps.release-tag.outputs.tag == ''
run: |
tag=$(git describe --tags --abbrev=0 2>/dev/null || true)
if [ -n "$tag" ]; then
echo "tag=$tag" >> "$GITHUB_OUTPUT"
fi
- name: Notify on failure
if: failure()
env:
@@ -108,6 +119,41 @@ jobs:
--workflow "post-merge/release" \
--commit "${{ github.sha }}"
publish:
needs: [release]
if: needs.release.outputs.tag != ''
runs-on: docker
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up environment
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
run: make setup-release
- name: Build and publish release
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
PYTHONPATH: src
run: |
. .venv/bin/activate
export PATH="$HOME/.local/bin:$PATH"
python3 -m devx.ci.publish "${{ needs.release.outputs.tag }}" "${{ github.repository }}"
- name: Notify on failure
if: failure()
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
PYTHONPATH: src
run: |
. .venv/bin/activate 2>/dev/null || true
export PATH="$HOME/.local/bin:$PATH"
python3 -m devx.ci.notify_failure \
--repo "${{ github.repository }}" \
--run-id "${{ github.run_id }}" \
--workflow "post-merge/publish" \
--commit "${{ github.sha }}"
sync-wiki:
needs: [detect-type]
if: needs.detect-type.outputs.is-release == 'false'
-46
View File
@@ -1,46 +0,0 @@
name: Publish Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish (e.g. v0.9.11)'
required: true
type: string
jobs:
publish:
runs-on: docker
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up environment
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
run: make setup-release
- name: Build and publish release
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
PYTHONPATH: src
run: |
. .venv/bin/activate
export PATH="$HOME/.local/bin:$PATH"
python3 -m devx.ci.publish "${{ github.event.inputs.tag || github.ref_name }}" "${{ github.repository }}"
- name: Notify on failure
if: failure()
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
PYTHONPATH: src
run: |
. .venv/bin/activate 2>/dev/null || true
export PATH="$HOME/.local/bin:$PATH"
python3 -m devx.ci.notify_failure \
--repo "${{ github.repository }}" \
--run-id "${{ github.run_id }}" \
--workflow "publish" \
--commit "${{ github.sha }}"
+3 -2
View File
@@ -204,8 +204,9 @@ After a PR is merged to master, the **post-merge workflow**
non-release commits (not just when release succeeds), so infrastructure-only
changes still update the task tracker.
The tag push triggers the **publish workflow** (`.gitea/workflows/publish.yml`)
which builds and publishes the package to the Gitea PyPI registry.
6. **publish** — Runs after release succeeds (needs: release). Builds and
publishes the package to the Gitea PyPI registry. Gets the tag from the
release job's `tag` output (written via `GITHUB_OUTPUT`).
### Smart CI: User-Facing vs Workflow-Only Changes
+18
View File
@@ -2,6 +2,24 @@
All notable changes to this project will be documented in this file.
## [0.19.2] - 2026-06-26
### Bug Fixes
- Calibrate molecule weights from actual CI execution times
## [0.19.1] - 2026-06-26
### Refactor
- Consolidate publish.yml into post-merge.yml
## [0.19.0] - 2026-06-26
### Features
- Add skip_ref_prefixes config to check_agent_docs
## [0.18.0] - 2026-06-26
### Features
+6 -6
View File
@@ -16,12 +16,12 @@ quality badges.
[![CI](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions/workflows/ci.yml/badge.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![License: GPL-3.0](https://img.shields.io/badge/license-GPL--3.0-blue)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/src/branch/master/LICENSE)
[![Coverage](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/coverage.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Tests](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/tests.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Docs](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/docs.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/wiki)
[![Code Quality](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/quality.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Version](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/version.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/releases)
[![Python](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/python.svg)](https://www.python.org/downloads/)
[![Coverage](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/coverage.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Tests](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/tests.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Docs](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/docs.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/wiki)
[![Code Quality](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/quality.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Version](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/version.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/releases)
[![Python](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/python.svg)](https://www.python.org/downloads/)
## Why devx?
+6 -6
View File
@@ -12,12 +12,12 @@ project to be reusable across all oblachno-oss repositories.
[![CI](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions/workflows/ci.yml/badge.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![License: GPL-3.0](https://img.shields.io/badge/license-GPL--3.0-blue)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/src/branch/master/LICENSE)
[![Coverage](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/coverage.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Tests](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/tests.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Docs](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/docs.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/wiki)
[![Code Quality](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/quality.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Version](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/version.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/releases)
[![Python](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0a0adc8dce9a146068a35ade3e9f301c3a5e8cca/python.svg)](https://www.python.org/downloads/)
[![Coverage](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/coverage.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Tests](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/tests.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Docs](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/docs.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/wiki)
[![Code Quality](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/quality.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/actions)
[![Version](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/version.svg)](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/releases)
[![Python](https://git.oblachno.oblachno.fyi/oblachno-oss/devx/raw/commit/0ab8d43a57cbaf69c93d28df9e2ac5630da4148a/python.svg)](https://www.python.org/downloads/)
## Overview
+1 -1
View File
@@ -1,3 +1,3 @@
"""devx — reusable development and CI/CD tools for oblachno-oss projects."""
__version__ = "0.18.0"
__version__ = "0.19.2"
+18
View File
@@ -317,6 +317,21 @@ def run_tests() -> None:
click.echo(_("Tests passed."))
def _write_github_output(tag: str) -> None:
"""Write the release tag to GITHUB_OUTPUT for downstream jobs.
This allows a publish job (needs: release) to read the tag via
``${{ needs.release.outputs.tag }}`` instead of relying on
tag-push event triggering a separate workflow.
"""
github_output = os.environ.get("GITHUB_OUTPUT")
if not github_output:
return
with open(github_output, "a") as f: # noqa: PTH123
f.write(f"tag={tag}\n")
click.echo(_("Wrote tag {tag} to GITHUB_OUTPUT.", tag=tag))
def create_and_push_tag(new_version: str, changelog: str, dry_run: bool) -> bool:
"""Create an annotated tag with the changelog as message and push it.
@@ -345,6 +360,7 @@ def create_and_push_tag(new_version: str, changelog: str, dry_run: bool) -> bool
if not dry_run:
# Ensure the existing tag is pushed
run_cmd(["git", "push", "origin", f"refs/tags/{tag}"], check=False)
_write_github_output(tag)
return False
tag_msg = f"Release v{new_version}\n\n{changelog}"
if dry_run:
@@ -352,6 +368,7 @@ def create_and_push_tag(new_version: str, changelog: str, dry_run: bool) -> bool
return True
run_cmd(["git", "tag", "-a", tag, "-m", tag_msg])
run_cmd(["git", "push", "origin", f"refs/tags/{tag}"])
_write_github_output(tag)
return True
@@ -617,6 +634,7 @@ def main(dry_run: bool, skip_tests: bool, verify: bool) -> None:
tag=release_tag,
)
)
_write_github_output(release_tag)
return
# Tag is missing — recover by creating and pushing it
click.echo(
+60 -10
View File
@@ -135,24 +135,74 @@ def build_multi_role_pairs(
# Heuristic weights for known heavy molecule scenarios.
# These are estimated from CI run times — scenarios that pull large Docker
# images or run complex Ansible playbooks take longer.
#
# Weights are calibrated from actual CI execution times (converge→destroy):
# nextcloud: ~7.7m → 15
# restore/default: ~5.7m → 11
# customer-apps: ~5.5m → 11
# zitadel/default: ~5.0m → 10
# docker_base/default: ~3.9m → 8
# app_hardening/default: ~1.9m → 4
# app_container/default: ~1.8m → 3
# postgres-upgrade: ~1.7m → 3
# observability/default: ~1.7m → 3
# storage/default: ~1.5m → 3
# storage/object-storage: ~1.0m → 2
# vaultwarden: ~0.7m → 2
# simple-app: ~0.7m → 2
#
# Role-specific weights take priority over scenario-name weights.
# The (role, scenario) tuple is checked first, then the scenario name
# alone, then the default weight.
_ROLE_SCENARIO_WEIGHTS: dict[tuple[str, str], int] = {
("app_container", "nextcloud"): 15,
("app_container", "customer-apps"): 11,
("app_container", "vaultwarden"): 2,
("app_container", "simple-app"): 2,
("app_container", "postgres-upgrade"): 3,
("app_container", "default"): 3,
("restore", "default"): 11,
("zitadel", "default"): 10,
("docker_base", "default"): 8,
("observability", "default"): 3,
("app_hardening", "default"): 4,
("storage", "default"): 3,
("storage", "object-storage"): 2,
}
# Fallback weights by scenario name only (for single-role projects or
# scenarios not in the role-specific table).
_SCENARIO_WEIGHTS: dict[str, int] = {
"nextcloud": 10,
"nextcloud": 15,
"customer-apps": 11,
"restore": 11,
"zitadel": 10,
"docker-base": 8,
"postgresql": 3,
"postgres-upgrade": 3,
"gitea": 8,
"vaultwarden": 7,
"zitadel": 7,
"postgresql": 6,
"redis": 5,
"backup": 5,
"docker-base": 4,
"vaultwarden": 2,
"simple-app": 2,
"object-storage": 2,
"default": 3,
"binary": 2,
}
_DEFAULT_SCENARIO_WEIGHT = 3
def _scenario_weight(scenario: str) -> int:
"""Estimate a weight for a scenario based on its name."""
def _scenario_weight(scenario: str, role: str | None = None) -> int:
"""Estimate a weight for a scenario based on its name and optionally its role.
Role-specific weights take priority over scenario-name-only weights.
"""
s = scenario.lower()
if role is not None:
r = role.lower()
key = (r, s)
if key in _ROLE_SCENARIO_WEIGHTS:
return _ROLE_SCENARIO_WEIGHTS[key]
for key, weight in _SCENARIO_WEIGHTS.items():
if key in s:
return weight
@@ -181,11 +231,11 @@ def _lpt_distribute[T](items: list[T], weights: list[int], max_runners: int) ->
def distribute_multi_role(pairs: list[MultiRoleTestPair], max_runners: int) -> list[list[MultiRoleTestPair]]:
"""Split *pairs* into *max_runners* balanced groups using LPT scheduling.
Each pair is weighted by scenario name heuristics (e.g. ``nextcloud`` is
heavier than ``binary``). Pairs are sorted by weight descending and
Each pair is weighted by role+scenario heuristics (e.g. ``nextcloud`` is
heavier than ``simple-app``). Pairs are sorted by weight descending and
assigned to the runner with the least total weight.
"""
weights = [_scenario_weight(p.scenario) for p in pairs]
weights = [_scenario_weight(p.scenario, p.role) for p in pairs]
return _lpt_distribute(pairs, weights, max_runners)
+8
View File
@@ -117,6 +117,7 @@ def _check_file(
legitimate_indicators: list[str],
repo_path_prefixes: list[str],
min_path_ref_length: int,
skip_ref_prefixes: list[str],
) -> list[str]:
"""Check a single file for stale references."""
issues: list[str] = []
@@ -147,6 +148,9 @@ def _check_file(
# Only check references that look like repo paths
if not any(ref.startswith(prefix) for prefix in repo_path_prefixes):
continue
# Skip references matching configured skip prefixes (e.g. aspirational test files)
if any(ref.startswith(prefix) for prefix in skip_ref_prefixes):
continue
candidate = repo_root / ref
if not candidate.exists():
issues.append(f"{rel_path}:{lineno}: references non-existent file '{ref}'")
@@ -179,6 +183,9 @@ def cli() -> None:
min_len_raw = cfg.get("min_path_ref_length")
min_path_ref_length: int = int(min_len_raw) if isinstance(min_len_raw, int) else MIN_PATH_REF_LENGTH_DEFAULT
skip_prefixes_raw = cfg.get("skip_ref_prefixes", [])
skip_ref_prefixes: list[str] = [str(d) for d in skip_prefixes_raw] if isinstance(skip_prefixes_raw, list) else []
deleted_files: set[str] = set()
deleted_raw = cfg.get("deleted_files", [])
if isinstance(deleted_raw, list):
@@ -209,6 +216,7 @@ def cli() -> None:
legitimate_indicators,
repo_path_prefixes,
min_path_ref_length,
skip_ref_prefixes,
)
all_issues.extend(issues)
+8
View File
@@ -1846,5 +1846,13 @@
"pl": "[check-dep-docs] Passed: all dependencies are documented",
"ru": "[check-dep-docs] Passed: all dependencies are documented",
"zh": "[check-dep-docs] Passed: all dependencies are documented"
},
"Wrote tag {tag} to GITHUB_OUTPUT.": {
"bg": "Wrote tag {tag} to GITHUB_OUTPUT.",
"de": "Wrote tag {tag} to GITHUB_OUTPUT.",
"en": "Wrote tag {tag} to GITHUB_OUTPUT.",
"ru": "Wrote tag {tag} to GITHUB_OUTPUT.",
"zh": "Wrote tag {tag} to GITHUB_OUTPUT.",
"pl": "Wrote tag {tag} to GITHUB_OUTPUT."
}
}
+17 -8
View File
@@ -89,7 +89,7 @@ class TestCheckFile:
doc.parent.mkdir(parents=True)
doc.write_text("See scripts/old.py for details.\n")
issues = _check_file(
doc, tmp_path, {"scripts/old.py"}, [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT
doc, tmp_path, {"scripts/old.py"}, [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT, []
)
assert any("deleted file" in i for i in issues)
@@ -97,7 +97,7 @@ class TestCheckFile:
doc = tmp_path / "docs" / "guide.md"
doc.parent.mkdir(parents=True)
doc.write_text("See scripts/nonexistent.py for details.\n")
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT)
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT, [])
assert any("non-existent file" in i for i in issues)
def test_does_not_flag_existing_file(self, tmp_path: Path) -> None:
@@ -106,7 +106,7 @@ class TestCheckFile:
doc = tmp_path / "docs" / "guide.md"
doc.parent.mkdir(parents=True)
doc.write_text("See scripts/exists.py for details.\n")
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT)
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT, [])
assert issues == []
def test_detects_deprecated_pattern(self, tmp_path: Path) -> None:
@@ -115,7 +115,7 @@ class TestCheckFile:
doc.write_text("Use ansible/envs/prod/secrets.yml for config.\n")
patterns = [re.compile(r"ansible/envs/[^/]+/secrets\.yml")]
issues = _check_file(
doc, tmp_path, set(), patterns, [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT
doc, tmp_path, set(), patterns, [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT, []
)
assert any("deprecated pattern" in i for i in issues)
@@ -129,7 +129,7 @@ class TestCheckFile:
doc.write_text("The legacy ansible/envs/prod/secrets.yml is deprecated.\n")
patterns = [re.compile(r"ansible/envs/[^/]+/secrets\.yml")]
issues = _check_file(
doc, tmp_path, set(), patterns, ["deprecated"], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT
doc, tmp_path, set(), patterns, ["deprecated"], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT, []
)
assert issues == []
@@ -137,14 +137,14 @@ class TestCheckFile:
doc = tmp_path / "docs" / "guide.md"
doc.parent.mkdir(parents=True)
doc.write_bytes(b"\xff\xfe\x00\x00")
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT)
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT, [])
assert issues == []
def test_skips_short_ref(self, tmp_path: Path) -> None:
doc = tmp_path / "docs" / "guide.md"
doc.parent.mkdir(parents=True)
doc.write_text("See a.py for details.\n")
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, 5)
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, 5, [])
# "a.py" is only 4 chars, below min_path_ref_length
assert issues == []
@@ -152,10 +152,19 @@ class TestCheckFile:
doc = tmp_path / "docs" / "guide.md"
doc.parent.mkdir(parents=True)
doc.write_text("See vendor/some/long/path.py for details.\n")
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT)
issues = _check_file(doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT, [])
# "vendor/" is not in repo_path_prefixes
assert issues == []
def test_skip_ref_prefixes_skips_nonexistent(self, tmp_path: Path) -> None:
doc = tmp_path / "docs" / "guide.md"
doc.parent.mkdir(parents=True)
doc.write_text("See scripts/test_foo.py for details.\n")
issues = _check_file(
doc, tmp_path, set(), [], [], DEFAULT_REPO_PATH_PREFIXES, MIN_PATH_REF_LENGTH_DEFAULT, ["scripts/test_"]
)
assert issues == []
class TestCli:
def test_passes_when_no_issues(self, tmp_path: Path) -> None:
+22 -3
View File
@@ -483,7 +483,7 @@ class TestCliMultiRole:
class TestScenarioWeight:
def test_known_heavy_scenario(self) -> None:
assert _scenario_weight("nextcloud") == 10
assert _scenario_weight("nextcloud") == 15
assert _scenario_weight("gitea") == 8
def test_known_light_scenario(self) -> None:
@@ -493,13 +493,32 @@ class TestScenarioWeight:
assert _scenario_weight("unknown-scenario") == 3
def test_case_insensitive(self) -> None:
assert _scenario_weight("NextCloud") == 10
assert _scenario_weight("NextCloud") == 15
assert _scenario_weight("GITEA") == 8
def test_substring_match(self) -> None:
assert _scenario_weight("nextcloud-with-redis") == 10
assert _scenario_weight("nextcloud-with-redis") == 15
assert _scenario_weight("custom-gitea-setup") == 8
def test_role_specific_weight(self) -> None:
"""Role+scenario pairs take priority over scenario-name-only weights."""
assert _scenario_weight("default", "restore") == 11
assert _scenario_weight("default", "zitadel") == 10
assert _scenario_weight("default", "docker_base") == 8
assert _scenario_weight("default", "app_hardening") == 4
assert _scenario_weight("default", "app_container") == 3
assert _scenario_weight("default", "storage") == 3
assert _scenario_weight("default", "observability") == 3
def test_role_specific_overrides_scenario_name(self) -> None:
"""vaultwarden has a scenario-name weight of 2, but role-specific is also 2."""
assert _scenario_weight("vaultwarden", "app_container") == 2
assert _scenario_weight("vaultwarden") == 2
def test_customer_apps_weight(self) -> None:
assert _scenario_weight("customer-apps", "app_container") == 11
assert _scenario_weight("customer-apps") == 11
class TestLptDistribute:
def test_equal_weights_produce_even_split(self) -> None:
+16 -2
View File
@@ -1,5 +1,7 @@
"""Unit tests for scripts/ci/release.py."""
import os
from pathlib import Path
from unittest.mock import MagicMock, patch
import click
@@ -815,11 +817,23 @@ class TestCommitReleaseChanges:
class TestCreateAndPushTag:
@patch("devx.ci.release.tag_exists", return_value=False)
@patch("devx.ci.release.run_cmd")
def test_creates_tag(self, mock_run_cmd: MagicMock, mock_tag_exists: MagicMock) -> None:
create_and_push_tag("0.2.0", "changelog", dry_run=False)
def test_creates_tag(self, mock_run_cmd: MagicMock, mock_tag_exists: MagicMock, tmp_path: Path) -> None:
github_output = tmp_path / "output.txt"
with patch.dict(os.environ, {"GITHUB_OUTPUT": str(github_output)}):
create_and_push_tag("0.2.0", "changelog", dry_run=False)
calls = [c.args[0] for c in mock_run_cmd.call_args_list]
assert ["git", "tag", "-a", "v0.2.0", "-m", "Release v0.2.0\n\nchangelog"] in calls
assert ["git", "push", "origin", "refs/tags/v0.2.0"] in calls
assert github_output.read_text() == "tag=v0.2.0\n"
@patch("devx.ci.release.tag_exists", return_value=False)
@patch("devx.ci.release.run_cmd")
def test_no_github_output_skips_write(self, mock_run_cmd: MagicMock, mock_tag_exists: MagicMock) -> None:
with patch.dict(os.environ, {}, clear=True):
create_and_push_tag("0.2.0", "changelog", dry_run=False)
# Should still create tag, just not write GITHUB_OUTPUT
calls = [c.args[0] for c in mock_run_cmd.call_args_list]
assert ["git", "tag", "-a", "v0.2.0", "-m", "Release v0.2.0\n\nchangelog"] in calls
@patch("devx.ci.release.tag_exists", return_value=False)
@patch("devx.ci.release.run_cmd")