-
-
Notifications
You must be signed in to change notification settings - Fork 10
162 lines (140 loc) · 5.2 KB
/
Copy pathci.yaml
File metadata and controls
162 lines (140 loc) · 5.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
name: Tests And Linting
on:
push:
branches:
- main
pull_request:
concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true
env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
jobs:
test:
name: Python ${{ matrix.python-version }} - ${{ matrix.cdist-group }}/3
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
cdist-group: [1, 2, 3]
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Intall dependencies
run: uv sync --frozen --all-extras
# Pre-pull docker images with retry to absorb transient registry failures
# (MCR WAF blocks on mcr.microsoft.com, Docker Hub anonymous rate limits)
# before pytest starts spawning fixture subprocesses. Pull in parallel
# (-P 6) - sequential pulls of ~30 images cost 10+ min on a runner.
- name: Pre-pull docker images
run: |
set -u
images=(
"mcr.microsoft.com/azure-storage/azurite"
"mcr.microsoft.com/mssql/server:2022-latest"
"dolthub/dolt-sql-server:latest"
"postgres:11" "postgres:12" "postgres:13" "postgres:14"
"postgres:15" "postgres:16" "postgres:17" "postgres:18"
"pgvector/pgvector:pg15"
"paradedb/paradedb:0.21.5-pg16"
"google/alloydbomni:16"
"mysql:5.6" "mysql:5.7" "mysql:8"
"mariadb:11.3"
"gvenzl/oracle-free:23-slim-faststart"
"gvenzl/oracle-xe:18-slim-faststart"
"redis:latest"
"valkey/valkey:latest"
"mongo:latest"
"cockroachdb/cockroach:latest"
"software.yugabyte.com/yugabytedb/yugabyte:latest"
"quay.io/minio/minio"
"minio/mc:latest"
"rustfs/rustfs:latest"
"rustfs/rc:latest"
"gcr.io/cloud-spanner-emulator/emulator:latest"
"ghcr.io/goccy/bigquery-emulator:latest"
"gizmodata/gizmosql:latest"
)
printf '%s\n' "${images[@]}" | xargs -n1 -P6 -I{} bash -c '
image="$1"
for attempt in 1 2 3 4 5; do
if docker pull --quiet "$image"; then
exit 0
fi
[ "$attempt" -lt 5 ] && sleep $((attempt * attempt * 5))
done
echo "::warning::Failed to pull $image after 5 attempts"
' _ {}
- if: matrix.python-version == '3.12'
name: Run tests with coverage tracking
run: uv run pytest --cdist-group=${{ matrix.cdist-group }}/3 -k "not elasticsearch"
- if: matrix.python-version != '3.12'
name: Run tests without tracking coverage
run: uv run pytest --cdist-group=${{ matrix.cdist-group }}/3 -k "not elasticsearch"
- if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v7
with:
name: coverage-xml
path: coverage.xml
- if: matrix.python-version == '3.12'
name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: litestar-org/pytest-databases
# run elasticsearch in a separate step. it's too slow
test_elasticsearch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: 3.9
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Intall dependencies
run: uv sync --frozen --all-extras
- name: Pre-pull docker images
run: |
set -u
for image in "elasticsearch:7.17.19" "elasticsearch:8.13.0"; do
for attempt in 1 2 3 4 5; do
if docker pull --quiet "$image"; then
break
fi
[ "$attempt" -eq 5 ] && echo "::warning::Failed to pull $image" || sleep $((attempt * attempt * 5))
done
done
- name: Run tests with coverage tracking
run: uv run pytest -k elasticsearch
# sonar:
# needs:
# - test
# - test_elasticsearch
# if: github.event.pull_request.head.repo.fork == false && github.repository_owner == 'litestar-org'
# runs-on: ubuntu-latest
# steps:
# - name: Check out repository
# uses: actions/checkout@v7
# with:
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# - name: Download Artifacts
# uses: actions/download-artifact@v4
# with:
# name: coverage-xml
# - name: Fix coverage file for sonarcloud
# run: sed -i "s/home\/runner\/work\/pytest-databases\/pytest-databases/github\/workspace/g" coverage.xml
# - name: SonarCloud Scan
# uses: sonarsource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}