-
Notifications
You must be signed in to change notification settings - Fork 15
287 lines (269 loc) · 9.43 KB
/
Copy pathci.yml
File metadata and controls
287 lines (269 loc) · 9.43 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: CI
on:
push:
branches:
- "**"
tags:
- "v*.*.*"
pull_request:
workflow_dispatch:
inputs:
confirm_publish:
description: "Type true to publish Docker images to GHCR"
required: true
default: "false"
permissions:
contents: read
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --extra dev --extra master
- name: Ruff
run: uv run ruff check .
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --extra dev --extra master
- name: Format
run: uv run ruff format --check .
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --extra dev --extra master
- name: Mypy
run: uv run mypy src tests
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --extra dev --extra master
- name: Coverage
run: uv run pytest --cov=platform_network --cov-report=term-missing --cov-fail-under=80
helm-kubeconform:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: azure/setup-helm@v4
- name: Install kubeconform
env:
KUBECONFORM_VERSION: v0.7.0
run: |
curl -fsSL "https://github.com/yannh/kubeconform/releases/download/${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" -o /tmp/kubeconform.tar.gz
tar -xzf /tmp/kubeconform.tar.gz -C /tmp kubeconform
sudo install /tmp/kubeconform /usr/local/bin/kubeconform
- name: Helm lint
run: helm lint deploy/helm/platform
- name: Helm template default values
run: helm template platform deploy/helm/platform > /tmp/platform-default.yaml
- name: kubeconform default values
run: kubeconform -strict -summary /tmp/platform-default.yaml
- name: Helm template production values
run: helm template platform deploy/helm/platform -f deploy/helm/platform/values.production.example.yaml > /tmp/platform-production.yaml
- name: kubeconform production values
run: kubeconform -strict -summary /tmp/platform-production.yaml
- name: Helm template master auto-upgrade values
run: >-
helm template platform-master deploy/helm/platform
--namespace platform-master
--set validator.enabled=false
--set autoUpgrade.enabled=true
> /tmp/platform-master-auto-upgrade.yaml
- name: kubeconform master auto-upgrade values
run: kubeconform -strict -summary /tmp/platform-master-auto-upgrade.yaml
- name: Helm template validator auto-upgrade values
run: >-
helm template platform-validator deploy/helm/platform
--namespace platform-validator
--set master.enabled=false
--set validator.enabled=true
--set autoUpgrade.enabled=true
--set validator.walletSecretName=platform-validator-wallet
> /tmp/platform-validator-auto-upgrade.yaml
- name: kubeconform validator auto-upgrade values
run: kubeconform -strict -summary /tmp/platform-validator-auto-upgrade.yaml
production-policy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- uses: azure/setup-helm@v4
- name: Install dependencies
run: uv sync --extra dev --extra master
- name: Helm production policy tests
run: uv run pytest tests/unit/test_helm_chart.py -q
- name: Runtime production policy tests
run: >-
uv run pytest
tests/unit/test_config_template_security.py
tests/unit/test_db_and_models.py
tests/unit/test_registry_extended.py
tests/unit/test_admin_registry_proxy.py
tests/unit/test_kubernetes_resources.py
-q
postgres-orm:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: platform
POSTGRES_PASSWORD: platform
POSTGRES_DB: platform_network_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U platform -d platform_network_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
PLATFORM_TEST_DATABASE_URL: postgresql+asyncpg://platform:platform@localhost:5432/platform_network_test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --extra dev --extra master
- name: PostgreSQL ORM integration tests
run: uv run pytest tests/integration -m postgres -q
docker-build:
needs:
- ruff
- format
- mypy
- coverage
- helm-kubeconform
- production-policy
- postgres-orm
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: platform
dockerfile: docker/Dockerfile.validator
- image: platform-master
dockerfile: docker/Dockerfile.master
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build ${{ matrix.image }} image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: false
tags: ghcr.io/platformnetwork/${{ matrix.image }}:ci-${{ github.sha }}
docker-publish:
if: >-
github.event_name != 'pull_request' &&
(github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/tags/v') ||
(github.event_name == 'workflow_dispatch' && inputs.confirm_publish == 'true'))
needs:
- docker-build
- postgres-orm
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- image: platform
dockerfile: docker/Dockerfile.validator
- image: platform-master
dockerfile: docker/Dockerfile.master
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/platformnetwork/${{ matrix.image }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{raw}}
type=sha,prefix=sha-
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Build and publish ${{ matrix.image }} image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
github-release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
- docker-publish
- postgres-orm
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Prepare release metadata
id: release
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Platform ${{ steps.release.outputs.version }}
generate_release_notes: true
append_body: true
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
make_latest: ${{ !contains(github.ref_name, '-') }}
body: |
## Container Images
- `ghcr.io/platformnetwork/platform:${{ steps.release.outputs.version }}`
- `ghcr.io/platformnetwork/platform:${{ github.ref_name }}`
- `ghcr.io/platformnetwork/platform:sha-${{ github.sha }}`
- `ghcr.io/platformnetwork/platform-master:${{ steps.release.outputs.version }}`
- `ghcr.io/platformnetwork/platform-master:${{ github.ref_name }}`
- `ghcr.io/platformnetwork/platform-master:sha-${{ github.sha }}`
## Deployment Notes
Production deployments should pin the SemVer image tag plus the immutable digest. The `latest` tag is published only from `main`, not from release tags.
## Documentation
See `docs/versioning.md` for the SemVer, Git tag, GHCR tag, GitHub Release, and production image policy.