40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
from pathlib import Path
|
|
import unittest
|
|
|
|
|
|
WORKFLOW = Path(__file__).resolve().parents[1] / ".gitea/workflows/deploy.yml"
|
|
|
|
|
|
class DeployWorkflowContractTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.workflow = WORKFLOW.read_text(encoding="utf-8")
|
|
|
|
def test_targets_pro_branch_and_single_runner(self):
|
|
self.assertIn("push:", self.workflow)
|
|
self.assertIn("- pro", self.workflow)
|
|
self.assertIn("workflow_dispatch:", self.workflow)
|
|
self.assertIn("runs-on: deploy-host", self.workflow)
|
|
self.assertIn("concurrency:", self.workflow)
|
|
|
|
def test_builds_and_pushes_pro_image(self):
|
|
self.assertIn("git.olns.shop/pro/im_server", self.workflow)
|
|
self.assertIn("docker push", self.workflow)
|
|
self.assertIn(":pro", self.workflow)
|
|
|
|
def test_deploys_compose_service_with_pinned_host_key(self):
|
|
self.assertIn("DEPLOY_SSH_KEY", self.workflow)
|
|
self.assertIn("DEPLOY_KNOWN_HOSTS", self.workflow)
|
|
self.assertIn("StrictHostKeyChecking=yes", self.workflow)
|
|
self.assertIn("docker compose pull im-server", self.workflow)
|
|
self.assertIn("docker compose up -d --no-deps --wait im-server", self.workflow)
|
|
|
|
def test_removes_old_kubernetes_and_registry_targets(self):
|
|
self.assertNotIn("kubectl", self.workflow)
|
|
self.assertNotIn("KUBECONFIG", self.workflow)
|
|
self.assertNotIn("git.118im.com", self.workflow)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|
|
|