Files
akyldash/infra/deploy/test_release_workflow.py
T
agent d428919b78
CI / tests-and-images (pull_request) Successful in 2m16s
Runner smoke test / runner-smoke (pull_request) Successful in 2s
fix: harden release artifact verification
2026-10-26 10:40:53 +03:00

50 lines
2.5 KiB
Python

import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
GITEA_UPLOAD_ARTIFACT = "https://gitea.com/actions/gitea-upload-artifact@055b8b3f04a4a7ed853f2c6ab04256f83e4874dc"
class ReleaseWorkflowTests(unittest.TestCase):
def test_publisher_is_manual_main_only_and_requires_registry_credentials(self):
workflow = (ROOT / ".gitea/workflows/release-images.yaml").read_text(encoding="utf-8")
self.assertIn("workflow_dispatch:", workflow)
self.assertIn("if: gitea.ref == 'refs/heads/main'", workflow)
self.assertNotIn("pull_request:", workflow)
self.assertIn("secrets.REGISTRY_USERNAME", workflow)
self.assertIn("secrets.REGISTRY_PASSWORD", workflow)
self.assertIn(GITEA_UPLOAD_ARTIFACT, workflow)
self.assertIn("release/release-manifest.json.sha256", workflow)
self.assertIn("retention-days: 90", workflow)
self.assertIn("if-no-files-found: error", workflow)
self.assertNotIn("github.run_attempt", workflow)
self.assertIn("${{ github.run_id }}", workflow)
self.assertIn("sha256sum -c release/release-manifest.json.sha256", workflow)
self.assertNotIn("docker compose", workflow)
def test_pr_ci_has_small_synthetic_artifact_upload_without_registry_secrets(self):
workflow = (ROOT / ".gitea/workflows/ci.yaml").read_text(encoding="utf-8")
self.assertIn("Verify Gitea runtime artifact upload", workflow)
self.assertIn(GITEA_UPLOAD_ARTIFACT, workflow)
self.assertIn("retention-days: 1", workflow)
self.assertIn("if-no-files-found: error", workflow)
self.assertNotIn("github.run_attempt", workflow)
self.assertIn("${{ github.run_id }}", workflow)
self.assertIn("artifact-smoke/marker.txt", workflow)
self.assertNotIn("REGISTRY_PASSWORD", workflow)
def test_pr_build_remains_no_push_and_push_action_has_no_engine_socket(self):
build_action = (ROOT / ".gitea/actions/kaniko-build/action.yml").read_text(encoding="utf-8")
push_action = (ROOT / ".gitea/actions/kaniko-push/release-build.sh").read_text(encoding="utf-8")
self.assertIn("--no-push", build_action)
self.assertIn("--no-push-cache", build_action)
self.assertIn("REGISTRY_USERNAME:?", push_action)
self.assertIn("REGISTRY_PASSWORD:?", push_action)
self.assertNotIn("docker.sock", push_action)
self.assertNotIn("DOCKER_HOST", push_action)
self.assertIn("--digest-file=", push_action)
if __name__ == "__main__":
unittest.main()