Skip to content

Commit a92a8ae

Browse files
committed
Prepare LongBridge platform runtime config
1 parent 228a046 commit a92a8ae

8 files changed

Lines changed: 195 additions & 16 deletions

File tree

.github/workflows/sync-cloud-run-env.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
CLOUD_RUN_SERVICE: ${{ vars.CLOUD_RUN_SERVICE }}
1717
ACCOUNT_PREFIX: ${{ vars.ACCOUNT_PREFIX }}
1818
SERVICE_NAME: ${{ vars.SERVICE_NAME }}
19+
STRATEGY_PROFILE: ${{ vars.STRATEGY_PROFILE || 'semiconductor_rotation_income' }}
20+
ACCOUNT_REGION: ${{ vars.ACCOUNT_REGION || 'HK' }}
1921
LONGPORT_SECRET_NAME: ${{ vars.LONGPORT_SECRET_NAME }}
2022
NOTIFY_LANG: ${{ vars.NOTIFY_LANG }}
2123
GLOBAL_TELEGRAM_CHAT_ID: ${{ vars.GLOBAL_TELEGRAM_CHAT_ID }}
@@ -88,7 +90,7 @@ jobs:
8890
gcloud run services update "${CLOUD_RUN_SERVICE}" \
8991
--region "${CLOUD_RUN_REGION}" \
9092
--remove-env-vars "TELEGRAM_CHAT_ID" \
91-
--update-env-vars "TELEGRAM_TOKEN=${TELEGRAM_TOKEN},GLOBAL_TELEGRAM_CHAT_ID=${GLOBAL_TELEGRAM_CHAT_ID},NOTIFY_LANG=${NOTIFY_LANG},LONGPORT_APP_KEY=${LONGPORT_APP_KEY},LONGPORT_APP_SECRET=${LONGPORT_APP_SECRET},LONGPORT_SECRET_NAME=${LONGPORT_SECRET_NAME},ACCOUNT_PREFIX=${ACCOUNT_PREFIX},SERVICE_NAME=${SERVICE_NAME}"
93+
--update-env-vars "TELEGRAM_TOKEN=${TELEGRAM_TOKEN},GLOBAL_TELEGRAM_CHAT_ID=${GLOBAL_TELEGRAM_CHAT_ID},NOTIFY_LANG=${NOTIFY_LANG},LONGPORT_APP_KEY=${LONGPORT_APP_KEY},LONGPORT_APP_SECRET=${LONGPORT_APP_SECRET},LONGPORT_SECRET_NAME=${LONGPORT_SECRET_NAME},ACCOUNT_PREFIX=${ACCOUNT_PREFIX},SERVICE_NAME=${SERVICE_NAME},STRATEGY_PROFILE=${STRATEGY_PROFILE},ACCOUNT_REGION=${ACCOUNT_REGION}"
9294
9395
sync-sg:
9496
name: Sync SG Cloud Run Env
@@ -101,6 +103,8 @@ jobs:
101103
CLOUD_RUN_SERVICE: ${{ vars.CLOUD_RUN_SERVICE }}
102104
ACCOUNT_PREFIX: ${{ vars.ACCOUNT_PREFIX }}
103105
SERVICE_NAME: ${{ vars.SERVICE_NAME }}
106+
STRATEGY_PROFILE: ${{ vars.STRATEGY_PROFILE || 'semiconductor_rotation_income' }}
107+
ACCOUNT_REGION: ${{ vars.ACCOUNT_REGION || 'SG' }}
104108
LONGPORT_SECRET_NAME: ${{ vars.LONGPORT_SECRET_NAME }}
105109
NOTIFY_LANG: ${{ vars.NOTIFY_LANG }}
106110
GLOBAL_TELEGRAM_CHAT_ID: ${{ vars.GLOBAL_TELEGRAM_CHAT_ID }}
@@ -173,4 +177,4 @@ jobs:
173177
gcloud run services update "${CLOUD_RUN_SERVICE}" \
174178
--region "${CLOUD_RUN_REGION}" \
175179
--remove-env-vars "TELEGRAM_CHAT_ID" \
176-
--update-env-vars "TELEGRAM_TOKEN=${TELEGRAM_TOKEN},GLOBAL_TELEGRAM_CHAT_ID=${GLOBAL_TELEGRAM_CHAT_ID},NOTIFY_LANG=${NOTIFY_LANG},LONGPORT_APP_KEY=${LONGPORT_APP_KEY},LONGPORT_APP_SECRET=${LONGPORT_APP_SECRET},LONGPORT_SECRET_NAME=${LONGPORT_SECRET_NAME},ACCOUNT_PREFIX=${ACCOUNT_PREFIX},SERVICE_NAME=${SERVICE_NAME}"
180+
--update-env-vars "TELEGRAM_TOKEN=${TELEGRAM_TOKEN},GLOBAL_TELEGRAM_CHAT_ID=${GLOBAL_TELEGRAM_CHAT_ID},NOTIFY_LANG=${NOTIFY_LANG},LONGPORT_APP_KEY=${LONGPORT_APP_KEY},LONGPORT_APP_SECRET=${LONGPORT_APP_SECRET},LONGPORT_SECRET_NAME=${LONGPORT_SECRET_NAME},ACCOUNT_PREFIX=${ACCOUNT_PREFIX},SERVICE_NAME=${SERVICE_NAME},STRATEGY_PROFILE=${STRATEGY_PROFILE},ACCOUNT_REGION=${ACCOUNT_REGION}"

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ BOXX: $34,000.00 Cash: $10,000.00
8383
| `LONGPORT_SECRET_NAME` | No | Secret Manager secret name for LongPort token (default: `longport_token`) |
8484
| `ACCOUNT_PREFIX` | No | Alert/log prefix for account/environment (default: `DEFAULT`) |
8585
| `SERVICE_NAME` | No | Alert/log prefix for service identity (default: `longbridge-quant`) |
86+
| `STRATEGY_PROFILE` | No | Strategy profile selector (default: `semiconductor_rotation_income`, currently the only supported value) |
87+
| `ACCOUNT_REGION` | No | Account region marker for platform-style deployment (e.g. `HK`, `SG`; defaults to `ACCOUNT_PREFIX` / service-name suffix / `DEFAULT`) |
8688
| `NOTIFY_LANG` | No | Notification language: `en` (English, default) or `zh` (Chinese) |
8789
| `GOOGLE_CLOUD_PROJECT` | No | GCP project ID (defaults to ADC project when unset) |
8890

@@ -95,6 +97,8 @@ Deploy the same codebase as multiple Cloud Run services (e.g. `HK` and `SG`) by
9597
- `LONGPORT_SECRET_NAME`: point to different secrets (e.g. `longport_token_hk`, `longport_token_sg`)
9698
- `ACCOUNT_PREFIX`: e.g. `HK`, `SG` (all Telegram/log alerts will include `[ACCOUNT_PREFIX/SERVICE_NAME]`)
9799
- `SERVICE_NAME`: e.g. `longbridge-quant-hk`, `longbridge-quant-sg`
100+
- `STRATEGY_PROFILE`: use `semiconductor_rotation_income` for the current LongBridge strategy profile
101+
- `ACCOUNT_REGION`: explicitly mark the deployed account region (`HK` / `SG`); if unset, the app falls back to `ACCOUNT_PREFIX` or the `-hk` / `-sg` service-name suffix
98102
- `NOTIFY_LANG`: set `en` or `zh` per deployment
99103

100104
### GitHub-managed env sync for HK / SG
@@ -105,16 +109,17 @@ Recommended setup:
105109

106110
- **Repository Variables (shared):**
107111
- `ENABLE_GITHUB_ENV_SYNC` = `true`
112+
- `STRATEGY_PROFILE` (recommended: `semiconductor_rotation_income`)
108113
- `NOTIFY_LANG`
109114
- `GLOBAL_TELEGRAM_CHAT_ID`
110115
- **Repository Secrets (shared):**
111116
- `GCP_SA_KEY`
112117
- `TELEGRAM_TOKEN`
113118
- **GitHub Environment: `longbridge-hk`**
114-
- Variables: `CLOUD_RUN_REGION`, `CLOUD_RUN_SERVICE`, `ACCOUNT_PREFIX`, `SERVICE_NAME`, `LONGPORT_SECRET_NAME`
119+
- Variables: `CLOUD_RUN_REGION`, `CLOUD_RUN_SERVICE`, `ACCOUNT_PREFIX`, `SERVICE_NAME`, `ACCOUNT_REGION`, `LONGPORT_SECRET_NAME`
115120
- Secrets: `LONGPORT_APP_KEY`, `LONGPORT_APP_SECRET`
116121
- **GitHub Environment: `longbridge-sg`**
117-
- Variables: `CLOUD_RUN_REGION`, `CLOUD_RUN_SERVICE`, `ACCOUNT_PREFIX`, `SERVICE_NAME`, `LONGPORT_SECRET_NAME`
122+
- Variables: `CLOUD_RUN_REGION`, `CLOUD_RUN_SERVICE`, `ACCOUNT_PREFIX`, `SERVICE_NAME`, `ACCOUNT_REGION`, `LONGPORT_SECRET_NAME`
118123
- Secrets: `LONGPORT_APP_KEY`, `LONGPORT_APP_SECRET`
119124

120125
On every push to `main`, the workflow updates both Cloud Run services with the shared and per-environment values above, and removes `TELEGRAM_CHAT_ID` from each Cloud Run service.
@@ -131,7 +136,7 @@ Important:
131136

132137
- `QuantPlatformKit` is only a shared dependency; Cloud Run still deploys `LongBridgeQuant` itself.
133138
- Recommended Cloud Run service names: `longbridge-quant-hk` and `longbridge-quant-sg`.
134-
- Keep using two triggers and two GitHub Environments. The split key is still `CLOUD_RUN_SERVICE + CLOUD_RUN_REGION`.
139+
- Keep using two triggers and two GitHub Environments. The split key is still `CLOUD_RUN_SERVICE + CLOUD_RUN_REGION`, and the runtime identity is now explicit through `STRATEGY_PROFILE + ACCOUNT_REGION`.
135140
- If you later rename or move this repository, rebuild the GitHub source binding in Google Cloud for both triggers instead of assuming the existing source binding will follow the rename.
136141
- For the shared deployment model and trigger migration checklist, see [`QuantPlatformKit/docs/deployment_model.md`](../QuantPlatformKit/docs/deployment_model.md).
137142

@@ -234,6 +239,8 @@ BOXX: $34,000.00 现金: $10,000.00
234239
| `LONGPORT_SECRET_NAME` || Secret Manager 中的密钥名称(默认: `longport_token`|
235240
| `ACCOUNT_PREFIX` || 通知/日志前缀,区分账户环境(默认: `DEFAULT`|
236241
| `SERVICE_NAME` || 通知/日志前缀,区分服务(默认: `longbridge-quant`|
242+
| `STRATEGY_PROFILE` || 策略档位选择(默认: `semiconductor_rotation_income`,当前仅支持这个值) |
243+
| `ACCOUNT_REGION` || 平台化部署时的账户区域标记(如 `HK``SG`;默认按 `ACCOUNT_PREFIX` / 服务名后缀 / `DEFAULT` 推断) |
237244
| `NOTIFY_LANG` || 通知语言: `en`(英文,默认)或 `zh`(中文) |
238245
| `GOOGLE_CLOUD_PROJECT` || GCP 项目 ID(未设置时使用 ADC 默认项目) |
239246

@@ -246,6 +253,8 @@ Secret Manager 中需存在 `LONGPORT_SECRET_NAME` 指定的密钥(默认: `lo
246253
- `LONGPORT_SECRET_NAME`: 指向不同密钥(如 `longport_token_hk``longport_token_sg`
247254
- `ACCOUNT_PREFIX`: 如 `HK``SG`(所有通知/日志将包含 `[ACCOUNT_PREFIX/SERVICE_NAME]`
248255
- `SERVICE_NAME`: 如 `longbridge-quant-hk``longbridge-quant-sg`
256+
- `STRATEGY_PROFILE`: 当前 LongBridge 策略档位使用 `semiconductor_rotation_income`
257+
- `ACCOUNT_REGION`: 显式标记部署账户区域(`HK` / `SG`);未设置时会回退到 `ACCOUNT_PREFIX` 或服务名里的 `-hk` / `-sg` 后缀
249258
- `NOTIFY_LANG`: 每个部署可独立设置 `en``zh`
250259

251260
### GitHub 统一管理 HK / SG 环境变量
@@ -256,16 +265,17 @@ Secret Manager 中需存在 `LONGPORT_SECRET_NAME` 指定的密钥(默认: `lo
256265

257266
- **仓库级 Variables(共享):**
258267
- `ENABLE_GITHUB_ENV_SYNC` = `true`
268+
- `STRATEGY_PROFILE`(建议设为 `semiconductor_rotation_income`
259269
- `NOTIFY_LANG`
260270
- `GLOBAL_TELEGRAM_CHAT_ID`
261271
- **仓库级 Secrets(共享):**
262272
- `GCP_SA_KEY`
263273
- `TELEGRAM_TOKEN`
264274
- **GitHub Environment: `longbridge-hk`**
265-
- Variables: `CLOUD_RUN_REGION``CLOUD_RUN_SERVICE``ACCOUNT_PREFIX``SERVICE_NAME``LONGPORT_SECRET_NAME`
275+
- Variables: `CLOUD_RUN_REGION``CLOUD_RUN_SERVICE``ACCOUNT_PREFIX``SERVICE_NAME``ACCOUNT_REGION``LONGPORT_SECRET_NAME`
266276
- Secrets: `LONGPORT_APP_KEY``LONGPORT_APP_SECRET`
267277
- **GitHub Environment: `longbridge-sg`**
268-
- Variables: `CLOUD_RUN_REGION``CLOUD_RUN_SERVICE``ACCOUNT_PREFIX``SERVICE_NAME``LONGPORT_SECRET_NAME`
278+
- Variables: `CLOUD_RUN_REGION``CLOUD_RUN_SERVICE``ACCOUNT_PREFIX``SERVICE_NAME``ACCOUNT_REGION``LONGPORT_SECRET_NAME`
269279
- Secrets: `LONGPORT_APP_KEY``LONGPORT_APP_SECRET`
270280

271281
每次 push 到 `main` 时,这个 workflow 会分别更新两个 Cloud Run 服务,把共享和各自隔离的变量同步进去,并删除旧的 `TELEGRAM_CHAT_ID`
@@ -282,7 +292,7 @@ Secret Manager 中需存在 `LONGPORT_SECRET_NAME` 指定的密钥(默认: `lo
282292

283293
- `QuantPlatformKit` 只是共享依赖,不单独部署;Cloud Run 继续只部署 `LongBridgeQuant`
284294
- 推荐 Cloud Run 服务名:`longbridge-quant-hk``longbridge-quant-sg`
285-
- 继续保留两个 trigger 和两个 GitHub Environment,区分键始终是 `CLOUD_RUN_SERVICE + CLOUD_RUN_REGION`
295+
- 继续保留两个 trigger 和两个 GitHub Environment,区分键始终是 `CLOUD_RUN_SERVICE + CLOUD_RUN_REGION`,运行身份再通过 `STRATEGY_PROFILE + ACCOUNT_REGION` 明确下来
286296
- 如果后面改 GitHub 仓库名或再次迁组织,Google Cloud 里的两个 trigger 都要重新选择 GitHub 来源,不要假设旧绑定会自动跟过去。
287297
- 统一部署模型和触发器迁移清单见 [`QuantPlatformKit/docs/deployment_model.md`](../QuantPlatformKit/docs/deployment_model.md)
288298

application/rebalance_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import os
56
import traceback
67
from datetime import datetime
78

main.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import google.auth
1414
from application.rebalance_service import run_strategy as run_rebalance_cycle
1515
from entrypoints.cloud_run import is_market_open_now
16+
from runtime_config_support import load_platform_runtime_settings
1617
from notifications.order_alerts import (
1718
is_filled_status as notifications_is_filled_status,
1819
is_partial_filled_status as notifications_is_partial_filled_status,
@@ -55,13 +56,16 @@ def get_project_id():
5556
except Exception:
5657
return os.getenv("GOOGLE_CLOUD_PROJECT")
5758

58-
PROJECT_ID = get_project_id()
59-
SECRET_NAME = os.getenv("LONGPORT_SECRET_NAME", "longport_token")
60-
ACCOUNT_PREFIX = os.getenv("ACCOUNT_PREFIX", "DEFAULT")
61-
SERVICE_NAME = os.getenv("SERVICE_NAME", "longbridge-quant")
62-
NOTIFY_LANG = os.getenv("NOTIFY_LANG", "en")
63-
TG_TOKEN = os.getenv("TELEGRAM_TOKEN")
64-
TG_CHAT_ID = os.getenv("GLOBAL_TELEGRAM_CHAT_ID")
59+
RUNTIME_SETTINGS = load_platform_runtime_settings(project_id_resolver=get_project_id)
60+
PROJECT_ID = RUNTIME_SETTINGS.project_id
61+
SECRET_NAME = RUNTIME_SETTINGS.secret_name
62+
ACCOUNT_PREFIX = RUNTIME_SETTINGS.account_prefix
63+
SERVICE_NAME = RUNTIME_SETTINGS.service_name
64+
STRATEGY_PROFILE = RUNTIME_SETTINGS.strategy_profile
65+
ACCOUNT_REGION = RUNTIME_SETTINGS.account_region
66+
NOTIFY_LANG = RUNTIME_SETTINGS.notify_lang
67+
TG_TOKEN = RUNTIME_SETTINGS.tg_token
68+
TG_CHAT_ID = RUNTIME_SETTINGS.tg_chat_id
6569

6670
# Execution: reserve ratio, minimum trade size (ratio of equity and absolute floor)
6771
CASH_RESERVE_RATIO = 0.03

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
flask
22
gunicorn
3-
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.3.1
3+
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.4.0
44
pandas
55
requests
66
pytz

runtime_config_support.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
from __future__ import annotations
2+
3+
import os
4+
from dataclasses import dataclass
5+
from typing import Callable
6+
7+
DEFAULT_STRATEGY_PROFILE = "semiconductor_rotation_income"
8+
SUPPORTED_STRATEGY_PROFILES = frozenset({DEFAULT_STRATEGY_PROFILE})
9+
DEFAULT_ACCOUNT_REGION = "DEFAULT"
10+
11+
12+
@dataclass(frozen=True)
13+
class PlatformRuntimeSettings:
14+
project_id: str | None
15+
secret_name: str
16+
account_prefix: str
17+
service_name: str
18+
strategy_profile: str
19+
account_region: str
20+
notify_lang: str
21+
tg_token: str | None
22+
tg_chat_id: str | None
23+
24+
25+
def resolve_strategy_profile(raw_value: str | None) -> str:
26+
value = (raw_value or DEFAULT_STRATEGY_PROFILE).strip().lower()
27+
if value not in SUPPORTED_STRATEGY_PROFILES:
28+
supported = ", ".join(sorted(SUPPORTED_STRATEGY_PROFILES))
29+
raise ValueError(
30+
f"Unsupported STRATEGY_PROFILE={raw_value!r}; supported values: {supported}"
31+
)
32+
return value
33+
34+
35+
def infer_account_region(
36+
raw_value: str | None,
37+
*,
38+
account_prefix: str,
39+
service_name: str,
40+
) -> str:
41+
for candidate in (
42+
raw_value,
43+
account_prefix,
44+
_infer_region_from_service_name(service_name),
45+
):
46+
normalized = _normalize_region(candidate)
47+
if normalized is not None:
48+
return normalized
49+
return DEFAULT_ACCOUNT_REGION
50+
51+
52+
def load_platform_runtime_settings(
53+
*,
54+
project_id_resolver: Callable[[], str | None],
55+
) -> PlatformRuntimeSettings:
56+
account_prefix = os.getenv("ACCOUNT_PREFIX", "DEFAULT")
57+
service_name = os.getenv("SERVICE_NAME", "longbridge-quant")
58+
return PlatformRuntimeSettings(
59+
project_id=project_id_resolver(),
60+
secret_name=os.getenv("LONGPORT_SECRET_NAME", "longport_token"),
61+
account_prefix=account_prefix,
62+
service_name=service_name,
63+
strategy_profile=resolve_strategy_profile(os.getenv("STRATEGY_PROFILE")),
64+
account_region=infer_account_region(
65+
os.getenv("ACCOUNT_REGION"),
66+
account_prefix=account_prefix,
67+
service_name=service_name,
68+
),
69+
notify_lang=os.getenv("NOTIFY_LANG", "en"),
70+
tg_token=os.getenv("TELEGRAM_TOKEN"),
71+
tg_chat_id=os.getenv("GLOBAL_TELEGRAM_CHAT_ID"),
72+
)
73+
74+
75+
def _normalize_region(raw_value: str | None) -> str | None:
76+
if raw_value is None:
77+
return None
78+
value = str(raw_value).strip()
79+
if not value:
80+
return None
81+
return value.upper()
82+
83+
84+
def _infer_region_from_service_name(service_name: str) -> str | None:
85+
name = str(service_name).strip().lower()
86+
if name.endswith("-hk"):
87+
return "HK"
88+
if name.endswith("-sg"):
89+
return "SG"
90+
return None
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import os
2+
import sys
3+
import unittest
4+
from pathlib import Path
5+
from unittest.mock import patch
6+
7+
8+
ROOT = Path(__file__).resolve().parents[1]
9+
if str(ROOT) not in sys.path:
10+
sys.path.insert(0, str(ROOT))
11+
12+
from runtime_config_support import (
13+
DEFAULT_ACCOUNT_REGION,
14+
DEFAULT_STRATEGY_PROFILE,
15+
infer_account_region,
16+
load_platform_runtime_settings,
17+
)
18+
19+
20+
class RuntimeConfigSupportTests(unittest.TestCase):
21+
def test_load_platform_runtime_settings_uses_defaults(self):
22+
with patch.dict(os.environ, {}, clear=True):
23+
settings = load_platform_runtime_settings(project_id_resolver=lambda: "project-1")
24+
25+
self.assertEqual(settings.project_id, "project-1")
26+
self.assertEqual(settings.secret_name, "longport_token")
27+
self.assertEqual(settings.account_prefix, "DEFAULT")
28+
self.assertEqual(settings.service_name, "longbridge-quant")
29+
self.assertEqual(settings.strategy_profile, DEFAULT_STRATEGY_PROFILE)
30+
self.assertEqual(settings.account_region, DEFAULT_ACCOUNT_REGION)
31+
self.assertEqual(settings.notify_lang, "en")
32+
self.assertIsNone(settings.tg_token)
33+
self.assertIsNone(settings.tg_chat_id)
34+
35+
def test_account_region_prefers_explicit_env(self):
36+
region = infer_account_region(
37+
"sg",
38+
account_prefix="HK",
39+
service_name="longbridge-quant-hk",
40+
)
41+
self.assertEqual(region, "SG")
42+
43+
def test_account_region_falls_back_to_account_prefix(self):
44+
region = infer_account_region(
45+
None,
46+
account_prefix="hk",
47+
service_name="longbridge-quant",
48+
)
49+
self.assertEqual(region, "HK")
50+
51+
def test_account_region_falls_back_to_service_name_suffix(self):
52+
region = infer_account_region(
53+
None,
54+
account_prefix="",
55+
service_name="longbridge-quant-sg",
56+
)
57+
self.assertEqual(region, "SG")
58+
59+
def test_unsupported_strategy_profile_fails_fast(self):
60+
with patch.dict(os.environ, {"STRATEGY_PROFILE": "balanced_income"}, clear=True):
61+
with self.assertRaisesRegex(ValueError, "Unsupported STRATEGY_PROFILE"):
62+
load_platform_runtime_settings(project_id_resolver=lambda: "project-1")
63+
64+
65+
if __name__ == "__main__":
66+
unittest.main()

tests/test_sync_cloud_run_env_workflow.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ grep -Fq 'GLOBAL_TELEGRAM_CHAT_ID: ${{ vars.GLOBAL_TELEGRAM_CHAT_ID }}' "$workfl
1111
grep -Fq 'GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}' "$workflow_file"
1212
grep -Fq 'TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}' "$workflow_file"
1313
grep -Fq 'LONGPORT_SECRET_NAME: ${{ vars.LONGPORT_SECRET_NAME }}' "$workflow_file"
14+
grep -Fq "STRATEGY_PROFILE: \${{ vars.STRATEGY_PROFILE || 'semiconductor_rotation_income' }}" "$workflow_file"
15+
grep -Fq "ACCOUNT_REGION: \${{ vars.ACCOUNT_REGION || 'HK' }}" "$workflow_file"
16+
grep -Fq "ACCOUNT_REGION: \${{ vars.ACCOUNT_REGION || 'SG' }}" "$workflow_file"
1417
grep -Fq 'credentials_json: ${{ env.GCP_SA_KEY }}' "$workflow_file"
1518
grep -Fq "echo \"enabled=false\" >> \"\$GITHUB_OUTPUT\"" "$workflow_file"
1619
grep -Fq "Skipping HK Cloud Run env sync because ENABLE_GITHUB_ENV_SYNC is not set to true." "$workflow_file"
@@ -21,3 +24,4 @@ grep -Fq "set CLOUD_RUN_REGION on the longbridge-hk Environment" "$workflow_file
2124
grep -Fq "set CLOUD_RUN_REGION on the longbridge-sg Environment" "$workflow_file"
2225
grep -Fq "if: steps.config.outputs.enabled == 'true'" "$workflow_file"
2326
grep -Fq -- '--remove-env-vars "TELEGRAM_CHAT_ID"' "$workflow_file"
27+
grep -Fq 'STRATEGY_PROFILE=${STRATEGY_PROFILE},ACCOUNT_REGION=${ACCOUNT_REGION}' "$workflow_file"

0 commit comments

Comments
 (0)