-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (122 loc) · 5.52 KB
/
Copy pathmodal-deploy.reusable.yml
File metadata and controls
141 lines (122 loc) · 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Reusable Modal deploy workflow
on:
workflow_call:
inputs:
environment:
required: true
type: string
description: 'The environment to deploy to (e.g., beta, prod)'
modal_environment:
required: true
type: string
description: 'The Modal environment name (e.g., staging, main)'
outputs:
simulation_api_url:
description: 'The deployed simulation API URL'
value: ${{ jobs.deploy.outputs.simulation_api_url }}
policyengine_version:
description: 'The deployed policyengine.py package version'
value: ${{ jobs.deploy.outputs.policyengine_version }}
policyengine_core_version:
description: 'The deployed policyengine-core package version'
value: ${{ jobs.deploy.outputs.policyengine_core_version }}
us_version:
description: 'The deployed policyengine-us package version'
value: ${{ jobs.deploy.outputs.us_version }}
us_data_version:
description: 'The bundled policyengine-us-data version'
value: ${{ jobs.deploy.outputs.us_data_version }}
uk_version:
description: 'The deployed policyengine-uk package version'
value: ${{ jobs.deploy.outputs.uk_version }}
uk_data_version:
description: 'The bundled policyengine-uk-data version'
value: ${{ jobs.deploy.outputs.uk_data_version }}
jobs:
deploy:
name: Deploy to Modal
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
outputs:
simulation_api_url: ${{ steps.get-url.outputs.simulation_api_url }}
policyengine_version: ${{ steps.versions.outputs.policyengine_version }}
policyengine_core_version: ${{ steps.versions.outputs.policyengine_core_version }}
us_version: ${{ steps.versions.outputs.us_version }}
us_data_version: ${{ steps.versions.outputs.us_data_version }}
uk_version: ${{ steps.versions.outputs.uk_version }}
uk_data_version: ${{ steps.versions.outputs.uk_data_version }}
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
- name: Make scripts executable
run: chmod +x .github/scripts/*.sh
- name: Install dependencies
working-directory: projects/policyengine-api-simulation
run: uv sync
- name: Extract package versions
id: versions
run: .github/scripts/modal-extract-versions.sh projects/policyengine-api-simulation
- name: Sync Modal secrets from GitHub
working-directory: projects/policyengine-api-simulation
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
LOGFIRE_TOKEN: ${{ secrets.LOGFIRE_TOKEN }}
GCP_CREDENTIALS_JSON: ${{ secrets.GCP_CREDENTIALS_JSON }}
GATEWAY_AUTH_ISSUER: ${{ secrets.GATEWAY_AUTH_ISSUER }}
GATEWAY_AUTH_AUDIENCE: ${{ secrets.GATEWAY_AUTH_AUDIENCE }}
GATEWAY_AUTH_CLIENT_ID: ${{ secrets.GATEWAY_AUTH_CLIENT_ID }}
GATEWAY_AUTH_CLIENT_SECRET: ${{ secrets.GATEWAY_AUTH_CLIENT_SECRET }}
GATEWAY_AUTH_REQUIRED: ${{ vars.GATEWAY_AUTH_REQUIRED }}
run: ../../.github/scripts/modal-sync-secrets.sh "${{ inputs.modal_environment }}" "${{ inputs.environment }}"
- name: Deploy simulation API to Modal
working-directory: projects/policyengine-api-simulation
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
POLICYENGINE_VERSION: ${{ steps.versions.outputs.policyengine_version }}
POLICYENGINE_CORE_VERSION: ${{ steps.versions.outputs.policyengine_core_version }}
POLICYENGINE_US_VERSION: ${{ steps.versions.outputs.us_version }}
POLICYENGINE_UK_VERSION: ${{ steps.versions.outputs.uk_version }}
run: ../../.github/scripts/modal-deploy-app.sh "${{ inputs.modal_environment }}"
- name: Get deployed URL
id: get-url
working-directory: projects/policyengine-api-simulation
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
run: ../../.github/scripts/modal-get-url.sh "${{ inputs.modal_environment }}"
- name: Verify deployment health
run: .github/scripts/modal-health-check.sh "${{ steps.get-url.outputs.simulation_api_url }}"
integ_test:
name: Run integration tests
needs: [deploy]
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
- name: Make scripts executable
run: chmod +x .github/scripts/*.sh
- name: Generate API clients
run: ./scripts/generate-clients.sh
- name: Run simulation integration tests
env:
GATEWAY_AUTH_ISSUER: ${{ secrets.GATEWAY_AUTH_ISSUER }}
GATEWAY_AUTH_AUDIENCE: ${{ secrets.GATEWAY_AUTH_AUDIENCE }}
GATEWAY_AUTH_CLIENT_ID: ${{ secrets.GATEWAY_AUTH_CLIENT_ID }}
GATEWAY_AUTH_CLIENT_SECRET: ${{ secrets.GATEWAY_AUTH_CLIENT_SECRET }}
GATEWAY_AUTH_REQUIRED: ${{ vars.GATEWAY_AUTH_REQUIRED }}
run: .github/scripts/modal-run-integ-tests.sh "${{ inputs.environment }}" "${{ needs.deploy.outputs.simulation_api_url }}" "${{ needs.deploy.outputs.us_version }}" "${{ needs.deploy.outputs.uk_version }}"