-
Notifications
You must be signed in to change notification settings - Fork 7
203 lines (173 loc) · 6.66 KB
/
Copy pathpython-ci.yml
File metadata and controls
203 lines (173 loc) · 6.66 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Python CI
permissions:
contents: read
on:
push:
branches: [ main ]
pull_request:
defaults:
run:
working-directory: ./python
jobs:
changes:
name: Determine if Python files changed
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
python: ${{ steps.filter.outputs.python }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- id: filter
uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
with:
filters: |
python:
- 'python/**'
- '.github/workflows/python-ci.yml'
lint-and-format:
name: Python Lint and Format Check
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python 3.13
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Load cached venv
id: cached-uv-dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ./python/.venv
key: venv-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}
- name: Install dependencies
run: uv sync
- name: Run formatting check with tox
run: uv run tox -e format
- name: Run linting with tox
run: uv run tox -e lint
test:
name: Test Python ${{ matrix.python-version }}
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Load cached venv
id: cached-uv-dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ./python/.venv
key: venv-${{ github.repository }}-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/uv.lock') }}
- name: Install dependencies
run: uv sync
- name: Run tests with tox
run: uv run tox -e py$(echo ${{ matrix.python-version }} | tr -d '.')
e2e:
name: Python E2E Tests
needs: [changes, lint-and-format, test]
# Internal runner: api.staging.render.com is only reachable from inside the network.
runs-on: render-mgmt-arc-runner-2cpu
timeout-minutes: 10
environment:
name: Staging
deployment: false
if: needs.changes.outputs.python == 'true'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: '3.13'
- name: Load cached venv
id: cached-uv-dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ./python/.venv
key: venv-${{ github.repository }}-${{ runner.os }}-3.13-${{ hashFiles('**/uv.lock') }}
- name: Install dependencies
run: uv sync
- name: Verify e2e credentials are present
env:
RENDER_API_KEY: ${{ secrets.RENDER_E2E_API_KEY }}
RENDER_E2E_OWNER_ID: ${{ vars.RENDER_E2E_OWNER_ID }}
run: |
if [ -z "$RENDER_API_KEY" ] || [ -z "$RENDER_E2E_OWNER_ID" ]; then
echo "::error::e2e credentials are empty. The job is not wired to the Staging environment, or the secrets are missing. See SAN-374."
exit 1
fi
- name: Run E2E tests
run: uv run pytest -m "e2e and not sandbox_e2e" -v
env:
RENDER_API_KEY: ${{ secrets.RENDER_E2E_API_KEY }}
RENDER_BASE_URL: ${{ vars.RENDER_E2E_BASE_URL }}
RENDER_E2E_OWNER_ID: ${{ vars.RENDER_E2E_OWNER_ID }}
RENDER_E2E_PAGINATION_OWNER_ID: ${{ vars.RENDER_E2E_PAGINATION_OWNER_ID }}
RENDER_E2E_REGION: ${{ vars.RENDER_E2E_REGION }}
# Split out so a missing renderd fleet reports on its own check instead of
# gating everything else. Deliberately absent from the required checks
# aggregate below, so it is visible without blocking merges.
sandbox-e2e:
name: Python Sandbox E2E Tests
needs: [changes, lint-and-format, test]
# Internal runner: api.staging.render.com is only reachable from inside the network.
runs-on: render-mgmt-arc-runner-2cpu
timeout-minutes: 10
environment:
name: Staging
deployment: false
if: needs.changes.outputs.python == 'true'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: '3.13'
- name: Load cached venv
id: cached-uv-dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ./python/.venv
key: venv-${{ github.repository }}-${{ runner.os }}-3.13-${{ hashFiles('**/uv.lock') }}
- name: Install dependencies
run: uv sync
- name: Verify e2e credentials are present
env:
RENDER_API_KEY: ${{ secrets.RENDER_E2E_API_KEY }}
RENDER_E2E_OWNER_ID: ${{ vars.RENDER_E2E_OWNER_ID }}
run: |
if [ -z "$RENDER_API_KEY" ] || [ -z "$RENDER_E2E_OWNER_ID" ]; then
echo "::error::e2e credentials are empty. The job is not wired to the Staging environment, or the secrets are missing. See SAN-374."
exit 1
fi
- name: Run sandbox E2E tests
run: uv run pytest -m "e2e and sandbox_e2e" -v
env:
RENDER_API_KEY: ${{ secrets.RENDER_E2E_API_KEY }}
RENDER_BASE_URL: ${{ vars.RENDER_E2E_BASE_URL }}
RENDER_E2E_OWNER_ID: ${{ vars.RENDER_E2E_OWNER_ID }}
RENDER_E2E_REGION: ${{ vars.RENDER_E2E_REGION }}
# Fixed name so branch rules can require one check that survives matrix expansion and skips.
required:
name: Python CI Required Checks
needs: [changes, lint-and-format, test, e2e]
if: always()
runs-on: ubuntu-latest
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1