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
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ on:
push:
branches: [main]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
Expand All @@ -19,4 +23,3 @@ jobs:
python -m pip install -r requirements.txt
- name: Run tests
run: python -m pytest -q

1 change: 1 addition & 0 deletions .github/workflows/dependabot_auto_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
auto-merge:
if: github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'dependabot/')
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
pull-requests: write
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/execution-report-heartbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ env:
GCP_WORKLOAD_IDENTITY_PROVIDER: projects/1088907247379/locations/global/workloadIdentityPools/github-actions/providers/github-main
GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT: firstrade-platform-deploy@firstradequant.iam.gserviceaccount.com

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: false

jobs:
heartbeat:
name: Check execution report heartbeat
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/runtime-guard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ env:
GCP_WORKLOAD_IDENTITY_PROVIDER: projects/1088907247379/locations/global/workloadIdentityPools/github-actions/providers/github-main
GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT: firstrade-platform-deploy@firstradequant.iam.gserviceaccount.com

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: false

jobs:
guard:
name: Check Cloud Run runtime
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/sync-cloud-run-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ env:
GCP_ARTIFACT_REGISTRY_HOSTNAME: us-central1-docker.pkg.dev
GCP_ARTIFACT_REGISTRY_REPOSITORY: cloud-run-source-deploy

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: false

jobs:
deploy-cloud-run:
name: Deploy Cloud Run
runs-on: ubuntu-latest
timeout-minutes: 20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Raise the deploy job timeout above its wait budget

When ENABLE_GITHUB_ENV_SYNC=true, this job can enter the Wait for Cloud Run deployment of current commit loop, which intentionally waits until deadline=$((SECONDS + 1800)) before failing. The new 20-minute job timeout is shorter than that 30-minute wait, and it also has to cover checkout/auth/build/push/deploy before the loop, so a slow Cloud Run rollout will be killed by GitHub Actions before the workflow's own timeout/error handling can complete.

Useful? React with 👍 / 👎.

permissions:
contents: read
id-token: write
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
39 changes: 39 additions & 0 deletions tests/test_request_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,45 @@
import main


def route_methods():
methods_by_route = {}
for rule in main.app.url_map.iter_rules():
methods_by_route.setdefault(rule.rule, set()).update(rule.methods - {"HEAD", "OPTIONS"})
return {route: sorted(methods) for route, methods in methods_by_route.items()}


def test_cloud_run_route_contracts_are_registered():
assert route_methods() == {
"/": ["GET", "POST"],
"/profiles": ["GET"],
"/smoke": ["GET"],
"/session-check": ["GET", "POST"],
"/run": ["GET", "POST"],
"/precheck": ["GET", "POST"],
"/probe": ["GET", "POST"],
"/static/<path:filename>": ["GET"],
}


def test_health_route_returns_service_contract(monkeypatch):
monkeypatch.setenv("FIRSTRADE_RUN_SMOKE_ON_HTTP", "true")
monkeypatch.delenv("FIRSTRADE_RUN_SESSION_CHECK_ON_HTTP", raising=False)
monkeypatch.delenv("FIRSTRADE_RUN_STRATEGY_ON_HTTP", raising=False)
client = main.app.test_client()

response = client.get("/")

assert response.status_code == 200
payload = response.get_json()
assert payload["service"] == "firstrade-platform"
assert payload["api_kind"] == "unofficial-reverse-engineered"
assert payload["strategy_domain"] == "us_equity"
assert payload["smoke_on_http"] is True
assert payload["session_check_on_http"] is False
assert payload["strategy_run_on_http"] is False
assert "as_of" in payload


def test_run_endpoint_is_disabled_without_explicit_http_gate(monkeypatch):
monkeypatch.delenv("FIRSTRADE_RUN_STRATEGY_ON_HTTP", raising=False)
client = main.app.test_client()
Expand Down