Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions .github/workflows/sync-cloud-run-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ jobs:
import os
import subprocess
import sys
from us_equity_strategies import resolve_canonical_profile
from pathlib import Path

from quant_platform_kit.common.strategies import derive_strategy_artifact_paths
from us_equity_strategies import get_strategy_catalog, resolve_canonical_profile

profile = os.environ.get("STRATEGY_PROFILE", "").strip().lower()
if not profile:
Expand All @@ -97,6 +100,16 @@ jobs:
if not selected.get("eligible") or not selected.get("enabled"):
raise SystemExit(f"STRATEGY_PROFILE={profile!r} is not eligible/enabled: {selected}")

artifact_paths = derive_strategy_artifact_paths(
get_strategy_catalog(),
canonical_profile,
repo_root=Path.cwd(),
)
has_bundled_strategy_config = bool(
artifact_paths.bundled_config_path is not None
and Path(artifact_paths.bundled_config_path).exists()
)

output_path = os.environ["GITHUB_OUTPUT"]
with open(output_path, "a", encoding="utf-8") as output:
output.write(
Expand All @@ -108,6 +121,9 @@ jobs:
output.write(
f"requires_strategy_config_path={str(bool(selected.get('requires_strategy_config_path'))).lower()}\n"
)
output.write(
f"has_bundled_strategy_config={str(has_bundled_strategy_config).lower()}\n"
)
PY

- name: Validate HK env sync inputs
Expand All @@ -116,6 +132,7 @@ jobs:
REQUIRES_SNAPSHOT_ARTIFACTS: ${{ steps.strategy_requirements.outputs.requires_snapshot_artifacts }}
REQUIRES_SNAPSHOT_MANIFEST_PATH: ${{ steps.strategy_requirements.outputs.requires_snapshot_manifest_path }}
REQUIRES_STRATEGY_CONFIG_PATH: ${{ steps.strategy_requirements.outputs.requires_strategy_config_path }}
HAS_BUNDLED_STRATEGY_CONFIG: ${{ steps.strategy_requirements.outputs.has_bundled_strategy_config }}
run: |
set -euo pipefail

Expand Down Expand Up @@ -155,7 +172,9 @@ jobs:
missing_vars+=("LONGBRIDGE_FEATURE_SNAPSHOT_MANIFEST_PATH")
fi

if [ "${REQUIRES_STRATEGY_CONFIG_PATH:-}" = "true" ] && [ -z "${LONGBRIDGE_STRATEGY_CONFIG_PATH:-}" ]; then
if [ "${REQUIRES_STRATEGY_CONFIG_PATH:-}" = "true" ] \
&& [ -z "${LONGBRIDGE_STRATEGY_CONFIG_PATH:-}" ] \
&& [ "${HAS_BUNDLED_STRATEGY_CONFIG:-}" != "true" ]; then
missing_vars+=("LONGBRIDGE_STRATEGY_CONFIG_PATH")
fi

Expand Down Expand Up @@ -355,7 +374,10 @@ jobs:
import os
import subprocess
import sys
from us_equity_strategies import resolve_canonical_profile
from pathlib import Path

from quant_platform_kit.common.strategies import derive_strategy_artifact_paths
from us_equity_strategies import get_strategy_catalog, resolve_canonical_profile

profile = os.environ.get("STRATEGY_PROFILE", "").strip().lower()
if not profile:
Expand All @@ -374,6 +396,16 @@ jobs:
if not selected.get("eligible") or not selected.get("enabled"):
raise SystemExit(f"STRATEGY_PROFILE={profile!r} is not eligible/enabled: {selected}")

artifact_paths = derive_strategy_artifact_paths(
get_strategy_catalog(),
canonical_profile,
repo_root=Path.cwd(),
)
has_bundled_strategy_config = bool(
artifact_paths.bundled_config_path is not None
and Path(artifact_paths.bundled_config_path).exists()
)

output_path = os.environ["GITHUB_OUTPUT"]
with open(output_path, "a", encoding="utf-8") as output:
output.write(
Expand All @@ -385,6 +417,9 @@ jobs:
output.write(
f"requires_strategy_config_path={str(bool(selected.get('requires_strategy_config_path'))).lower()}\n"
)
output.write(
f"has_bundled_strategy_config={str(has_bundled_strategy_config).lower()}\n"
)
PY

- name: Validate SG env sync inputs
Expand All @@ -393,6 +428,7 @@ jobs:
REQUIRES_SNAPSHOT_ARTIFACTS: ${{ steps.strategy_requirements.outputs.requires_snapshot_artifacts }}
REQUIRES_SNAPSHOT_MANIFEST_PATH: ${{ steps.strategy_requirements.outputs.requires_snapshot_manifest_path }}
REQUIRES_STRATEGY_CONFIG_PATH: ${{ steps.strategy_requirements.outputs.requires_strategy_config_path }}
HAS_BUNDLED_STRATEGY_CONFIG: ${{ steps.strategy_requirements.outputs.has_bundled_strategy_config }}
run: |
set -euo pipefail

Expand Down Expand Up @@ -432,7 +468,9 @@ jobs:
missing_vars+=("LONGBRIDGE_FEATURE_SNAPSHOT_MANIFEST_PATH")
fi

if [ "${REQUIRES_STRATEGY_CONFIG_PATH:-}" = "true" ] && [ -z "${LONGBRIDGE_STRATEGY_CONFIG_PATH:-}" ]; then
if [ "${REQUIRES_STRATEGY_CONFIG_PATH:-}" = "true" ] \
&& [ -z "${LONGBRIDGE_STRATEGY_CONFIG_PATH:-}" ] \
&& [ "${HAS_BUNDLED_STRATEGY_CONFIG:-}" != "true" ]; then
missing_vars+=("LONGBRIDGE_STRATEGY_CONFIG_PATH")
fi

Expand Down
7 changes: 5 additions & 2 deletions tests/test_sync_cloud_run_env_workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ grep -Fq 'uses: actions/setup-python@v5' "$workflow_file"
grep -Fq 'python -m pip install -r requirements.txt' "$workflow_file"
grep -Fq 'id: strategy_requirements' "$workflow_file"
grep -Fq 'scripts/print_strategy_profile_status.py' "$workflow_file"
grep -Fq 'from us_equity_strategies import resolve_canonical_profile' "$workflow_file"
grep -Fq 'from quant_platform_kit.common.strategies import derive_strategy_artifact_paths' "$workflow_file"
grep -Fq 'from us_equity_strategies import get_strategy_catalog, resolve_canonical_profile' "$workflow_file"
grep -Fq 'canonical_profile = resolve_canonical_profile(profile)' "$workflow_file"
grep -Fq 'requires_snapshot_artifacts=' "$workflow_file"
grep -Fq 'requires_snapshot_manifest_path=' "$workflow_file"
grep -Fq 'requires_strategy_config_path=' "$workflow_file"
grep -Fq 'has_bundled_strategy_config=' "$workflow_file"
grep -Fq 'Wait for Cloud Run deployment of current commit' "$workflow_file"
grep -Fq 'target_sha="${GITHUB_SHA}"' "$workflow_file"
grep -Fq "gcloud run services describe \"\${CLOUD_RUN_SERVICE}\" --region \"\${CLOUD_RUN_REGION}\" --format='value(spec.template.metadata.labels.commit-sha)'" "$workflow_file"
Expand Down Expand Up @@ -59,9 +61,10 @@ grep -Fq 'missing_vars+=("LONGBRIDGE_STRATEGY_CONFIG_PATH")' "$workflow_file"
grep -Fq 'REQUIRES_SNAPSHOT_ARTIFACTS: ${{ steps.strategy_requirements.outputs.requires_snapshot_artifacts }}' "$workflow_file"
grep -Fq 'REQUIRES_SNAPSHOT_MANIFEST_PATH: ${{ steps.strategy_requirements.outputs.requires_snapshot_manifest_path }}' "$workflow_file"
grep -Fq 'REQUIRES_STRATEGY_CONFIG_PATH: ${{ steps.strategy_requirements.outputs.requires_strategy_config_path }}' "$workflow_file"
grep -Fq 'HAS_BUNDLED_STRATEGY_CONFIG: ${{ steps.strategy_requirements.outputs.has_bundled_strategy_config }}' "$workflow_file"
grep -Fq 'if [ "${REQUIRES_SNAPSHOT_ARTIFACTS:-}" = "true" ] && [ -z "${LONGBRIDGE_FEATURE_SNAPSHOT_PATH:-}" ]; then' "$workflow_file"
grep -Fq 'if [ "${REQUIRES_SNAPSHOT_MANIFEST_PATH:-}" = "true" ] && [ -z "${LONGBRIDGE_FEATURE_SNAPSHOT_MANIFEST_PATH:-}" ]; then' "$workflow_file"
grep -Fq 'if [ "${REQUIRES_STRATEGY_CONFIG_PATH:-}" = "true" ] && [ -z "${LONGBRIDGE_STRATEGY_CONFIG_PATH:-}" ]; then' "$workflow_file"
grep -Fq '&& [ "${HAS_BUNDLED_STRATEGY_CONFIG:-}" != "true" ]; then' "$workflow_file"
grep -Fq 'secret_pairs+=("TELEGRAM_TOKEN=${TELEGRAM_TOKEN_SECRET_NAME}:latest")' "$workflow_file"
grep -Fq 'secret_pairs+=("LONGPORT_APP_KEY=${LONGPORT_APP_KEY_SECRET_NAME}:latest")' "$workflow_file"
grep -Fq 'secret_pairs+=("LONGPORT_APP_SECRET=${LONGPORT_APP_SECRET_SECRET_NAME}:latest")' "$workflow_file"
Expand Down