Files
olons_server/tests/test_actions_workflow.py
T
richjohnrambo 9bb479b506
Deploy olons-server production / deploy (push) Successful in 3m1s
feat: use floating customer service widget in pro
2026-10-21 13:15:15 +08:00

62 lines
3.0 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/olons_server", self.workflow)
self.assertIn("docker push", self.workflow)
self.assertIn(":pro", self.workflow)
self.assertIn("--build-arg VITE_CUSTOMER_SERVICE_PROVIDER=third_party", self.workflow)
def test_production_image_enables_customer_service_widget(self):
dockerfile = (WORKFLOW.parents[2] / "Dockerfile").read_text(encoding="utf-8")
self.assertIn("ARG VITE_CUSTOMER_SERVICE_PROVIDER=", dockerfile)
self.assertIn("ENV VITE_CUSTOMER_SERVICE_PROVIDER=${VITE_CUSTOMER_SERVICE_PROVIDER}", dockerfile)
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("pull olons-server", self.workflow)
self.assertIn("up -d --no-deps --wait olons-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)
def test_uses_internal_im_endpoints_for_server_calls(self):
self.assertIn('"$OLONS_IM_BASE_URL" = "http://im-server:6060"', self.workflow)
self.assertIn('"$OLONS_IM_HTTP_API_URL" = "http://im-server:6060/v1/im"', self.workflow)
self.assertIn('"$OLONS_IM_WS_URL" = "ws://im-server:6060/v0/channels"', self.workflow)
self.assertIn('"$OLONS_IM_FILE_URL" = "http://im-server:6060/v0/file"', self.workflow)
self.assertNotIn("OLONS_IM_BASE_URL=https://im-api.yuexuan.shop", self.workflow)
def test_deploy_uses_managed_compose_environment_without_secret_overlay(self):
self.assertNotIn(".env.olons-server", self.workflow)
self.assertNotIn("compose.olons-server-secret.yaml", self.workflow)
self.assertNotIn("INTERNAL_API_HOTGO_SECRET", self.workflow)
self.assertNotIn("OLONS_IM_API_KEY=", self.workflow)
self.assertIn("docker compose pull olons-server", self.workflow)
self.assertIn("docker compose up -d --no-deps --wait olons-server", self.workflow)
self.assertIn('test "$OLONS_IM_TENANT_CODE" = "default"', self.workflow)
self.assertIn('test "$OLONS_SERVER_DEFAULT_TENANT_ID" = "0"', self.workflow)
if __name__ == "__main__":
unittest.main()