-
Notifications
You must be signed in to change notification settings - Fork 0
371 lines (318 loc) · 11.2 KB
/
Copy pathci-python.yaml
File metadata and controls
371 lines (318 loc) · 11.2 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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
name: CI
on:
workflow_call:
secrets:
CODECOV_TOKEN:
required: false
jobs:
unit:
name: Unit Test
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12
cache: 'pip'
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libgpgme-dev libldap2-dev libsasl2-dev swig
cat requirements-dev.txt | grep tox | xargs pip install
- name: tox
run: |
tox -e py312-unit -- --cov=./ --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unit
sqlite:
name: SQLite Integration Test
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12
cache: 'pip'
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libgpgme-dev libldap2-dev libsasl2-dev swig
cat requirements-dev.txt | grep tox | xargs pip install
- name: tox (parallel)
run: |
tox -e py312-sqlite -- --cov=./ --cov-report=xml
- name: tox (legacy sequential)
run: |
tox -e py312-sqlite-legacy -- --cov=./ --cov-report=xml --cov-append
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: sqlite
types:
name: Types Test
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12
cache: 'pip'
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install libgpgme-dev libldap2-dev libsasl2-dev swig
- name: Check requirements.txt
run: |
pip install wheel # allow pip to use wheel instead of legacy 'setup.py install'
./hack/verify-requirements.sh
- name: Install dependencies
run: |
pip install -r ./requirements-dev.txt
- name: Check Types
run: make types-test
registry:
name: Registry Protocol Test
runs-on: quay-001-large-ubuntu-24-x64
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12
cache: 'pip'
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libgpgme-dev libldap2-dev libsasl2-dev swig libfreetype6-dev
python -m pip install --upgrade pip
cat requirements-dev.txt | grep tox | xargs pip install
- name: tox
run: |
tox -e py312-registry
postgres:
name: PostgreSQL Integration Test
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12
cache: 'pip'
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libgpgme-dev libldap2-dev libsasl2-dev swig
sudo systemctl unmask docker
sudo systemctl start docker
docker version
python -m pip install --upgrade pip
cat requirements-dev.txt | grep tox | xargs pip install
- name: tox
env:
TOX_DOCKER_GATEWAY: "0.0.0.0"
run: |
tox -e py312-psql
oci:
name: OCI Distribution Spec
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:16.4
env:
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: postgres_password
POSTGRES_DB: postgres_db
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7.4
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Enable pg_trgm extension
run: |
psql "postgresql://postgres_user:postgres_password@localhost:5432/postgres_db" \
--command="create extension if not exists pg_trgm;"
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
repository: opencontainers/distribution-spec
ref: v1.1.0-rc1
path: dist-spec
- name: Set up Go 1.18
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # zizmor: ignore[cache-poisoning] v6.4.0
with:
go-version: 1.18
- name: Build conformance.test binary
run: |
cd dist-spec/conformance
CGO_ENABLED=0 go test -c -o conformance.test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Build and export to Docker
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
load: true
tags: localhost/quay
cache-from: type=gha
cache-to: type=gha
- name: Start Quay
run: |
IP=$(ip addr show dev eth0 | sed -n 's: *inet \([0-9.]*\)/.*:\1:p')
mkdir -p /tmp/config
cat >/tmp/config/config.yaml <<EOF
BUILDLOGS_REDIS: {"host": "$IP", "port": 6379}
DATABASE_SECRET_KEY: anothercrazykey!
DB_URI: postgresql://postgres_user:postgres_password@$IP:5432/postgres_db
DISTRIBUTED_STORAGE_CONFIG: {"default": ["LocalStorage", {"storage_path": "/datastorage/registry"}]}
DISTRIBUTED_STORAGE_PREFERENCE: ["default"]
SERVER_HOSTNAME: localhost
SETUP_COMPLETE: true
USER_EVENTS_REDIS: {"host": "$IP", "port": 6379}
PULL_METRICS_REDIS: {"host": "$IP", "port": 6379}
DATA_MODEL_CACHE_CONFIG:
engine: memcached
endpoint: [127.0.0.1, 18080]
repository_blob_cache_ttl: 60s
catalog_page_cache_ttl: 60s
# OCI Conformance tests don't expect tags to be cached.
# If we implement cache invalidation, we can enable it back.
active_repo_tags_cache_ttl: 0s
EOF
# Run the Quay container. See also:
# https://access.redhat.com/documentation/en-us/red_hat_quay/3.8/html/deploy_red_hat_quay_-_high_availability/deploying_red_hat_quay
docker run \
--detach \
--health-cmd="curl -fsS http://localhost:8080/health/instance" \
--health-interval=10s \
--health-retries=5 \
--health-timeout=5s \
--name=quay \
--publish=127.0.0.1:443:8443/tcp \
--publish=127.0.0.1:80:8080/tcp \
--volume=/tmp/config:/conf/stack:Z \
localhost/quay
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
status=$(docker inspect -f '{{.State.Health.Status}}' quay)
printf "[%s] status: %s\n" "$(date -u +'%F %T')" "$status"
if [ "$status" == "healthy" ]; then
break
fi
sleep 10
done
docker inspect --format='{{json .State.Health}}' quay
docker exec -i quay python <<EOF
from app import app
from data import model
from data.database import configure
configure(app.config)
myuser = model.user.create_user("myuser", "p@ssw0rd", "admin@localhost.local", auto_verify=True)
myorg = model.organization.create_organization("myorg", "myorg@localhost.local", myuser)
EOF
- name: Run conformance tests
run: |
# Registry details
export OCI_ROOT_URL="http://localhost"
export OCI_NAMESPACE="myuser/myrepo"
export OCI_CROSSMOUNT_NAMESPACE="myorg/other"
export OCI_USERNAME="myuser"
export OCI_PASSWORD="p@ssw0rd"
# Which workflows to run
export OCI_TEST_PULL=1
export OCI_TEST_PUSH=1
export OCI_TEST_CONTENT_DISCOVERY=1
export OCI_TEST_CONTENT_MANAGEMENT=0
# Extra settings
export OCI_HIDE_SKIPPED_WORKFLOWS=0
export OCI_DEBUG=1
export OCI_DELETE_MANIFEST_BEFORE_BLOBS=0
./dist-spec/conformance/conformance.test
- name: Create report
run: |
mkdir -p .oci-test-results/ .logs/
mv report.html junit.xml .oci-test-results/ || true
docker logs quay >.logs/quay.log 2>&1 || true
if: always()
- name: Check logs
run: |
# Tracebacks should not appear in the logs under normal circumstances.
# Unfortunately, 3 trackbacks are logged immediately after the Quay
# container is started, and extra one is generated during OCI tests.
# To accommodate the current state and avoid further regressions until
# these issues are fixed, we allow a maximum of 4 trackbacks.
TRACEBACKS=$(grep Traceback .logs/quay.log | wc -l)
if [ "$TRACEBACKS" -gt 4 ]; then
echo >&2 ERROR: Traceback detected, check Quay logs.
exit 1
fi
if: always()
- name: Stop Quay
run: |
docker rm --force --volumes quay
if: always()
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: oci-test-results
path: .oci-test-results/
if: always()
- name: Upload Quay logs
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: logs
path: .logs/
if: always()