Repository navigation
214 lines (191 loc) · 7.34 KB
/
Copy pathci.yml
File metadata and controls
214 lines (191 loc) · 7.34 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
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- name: Install (with Celery + Django adapters)
run: |
python -m pip install --upgrade pip
pip install -e ".[dev,celery,django,otel]" opentelemetry-sdk
- name: Run tests
run: pytest
lint:
name: Static analysis (ruff + mypy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Install (dev + all adapters for type context)
run: |
python -m pip install --upgrade pip
pip install -e ".[dev,celery,django,redis,amqp,sqs,azureservicebus,artemis,otel]" opentelemetry-sdk
- name: Ruff
run: ruff check src tests
- name: Mypy
run: mypy
integration:
name: Broker integration (Redis · RabbitMQ · SQS)
runs-on: ubuntu-latest
services:
redis:
image: redis:7
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 10
rabbitmq:
image: rabbitmq:3
ports:
- 5672:5672
options: >-
--health-cmd "rabbitmq-diagnostics -q ping"
--health-interval 10s
--health-timeout 5s
--health-retries 15
# Free, SQS-compatible broker for the SqsTransport round-trip. The native
# image is shell-less, so readiness is polled by a TCP-probe step below.
elasticmq:
image: softwaremill/elasticmq-native:1.6.11
ports:
- 9324:9324
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Install (all adapters — full coverage with brokers)
run: |
python -m pip install --upgrade pip
pip install -e ".[redis,amqp,sqs,azureservicebus,artemis,celery,django,dev,otel]" opentelemetry-sdk
- name: Wait for ElasticMQ
run: |
for i in $(seq 1 30); do
if (echo > /dev/tcp/localhost/9324) >/dev/null 2>&1; then
echo "ElasticMQ port 9324 open"; exit 0
fi
sleep 2
done
echo "ElasticMQ did not open port 9324"; exit 1
- name: Run full suite with coverage gate (>=90%)
env:
BABELQUEUE_TEST_REDIS: redis://localhost:6379/0
BABELQUEUE_TEST_AMQP: amqp://guest:guest@localhost:5672/
SQS_ENDPOINT: http://localhost:9324
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
run: pytest --cov=babelqueue --cov-report=term-missing --cov-fail-under=90
integration-live:
name: Integration (live Kafka)
# Opt-in, not a required check: runs on push to main and on demand, never on pull requests,
# and is deliberately NOT in ci-green's needs. (The `integration` job above is the required,
# coverage-gated one for Redis / RabbitMQ / SQS.)
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
timeout-minutes: 20
services:
kafka:
image: apache/kafka:3.9.0
ports:
- 9092:9092
env:
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
options: >-
--health-cmd "/opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092"
--health-interval 10s --health-timeout 10s --health-retries 12 --health-start-period 20s
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Install (kafka extra + dev)
run: |
python -m pip install --upgrade pip
pip install -e ".[kafka,dev]"
- name: Live Kafka tests
env:
BQ_INTEGRATION: "1"
BQ_KAFKA_BROKERS: localhost:9092
run: pytest tests/test_kafka_integration.py -v
conformance:
name: Conformance suite in sync + results.json
runs-on: ubuntu-latest
env:
# The pinned conformance release (ADR-0032). Bump together with tests/conformance/.
BQ_CONFORMANCE_VERSION: 1.5.0
# sha256 of that release's fetch.sh: the script runs on the runner, so it is pinned rather
# than trusted from a mutable tag. Bump together with BQ_CONFORMANCE_VERSION.
BQ_FETCH_SH_SHA256: 8bb6ba567b288fb0ac71a70fd17041b2503df119e01998d76fdad372570bf849
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Verify the vendored suite against the release asset
run: |
# fetch.sh comes from the pinned tag; it downloads babelqueue-conformance-<v>.tar.gz,
# verifies it against the release SHA256SUMS before unpacking, then diffs the vendor dir.
curl -fsSL -o "$RUNNER_TEMP/fetch.sh" \
"https://raw.githubusercontent.com/BabelQueue/conformance/v${BQ_CONFORMANCE_VERSION}/fetch.sh"
echo "${BQ_FETCH_SH_SHA256} $RUNNER_TEMP/fetch.sh" | sha256sum -c -
bash "$RUNNER_TEMP/fetch.sh" --check "$BQ_CONFORMANCE_VERSION" tests/conformance
test "$(tr -d '[:space:]' < tests/conformance/CONFORMANCE_VERSION)" = "$BQ_CONFORMANCE_VERSION"
echo "Vendored conformance is in sync with the v${BQ_CONFORMANCE_VERSION} release asset."
- name: Install
run: |
python -m pip install --upgrade pip
pip install -e ".[dev,celery,django,otel]" opentelemetry-sdk jsonschema
- name: Run the conformance suite and write results.json
env:
BQ_CONFORMANCE_RESULTS: ${{ runner.temp }}/results.json
run: pytest -q tests/test_conformance.py
- name: Validate results.json (schema, bindings, sections)
run: python scripts/check_conformance_results.py "$RUNNER_TEMP/results.json" tests/conformance
ci-green:
name: CI green
runs-on: ubuntu-latest
needs: [test, lint, integration, conformance]
if: ${{ always() }}
steps:
- name: Fail if any required job did not pass
run: |
if ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}; then
echo "A required job failed or was cancelled."
exit 1
fi