Skip to content

chore: Tests infra

chore: Tests infra #2

Workflow file for this run

name: Tests
on:
pull_request:
push:
branches: [master]
jobs:
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
services:
artemis:
image: apache/activemq-artemis:latest-alpine
env:
ANONYMOUS_LOGIN: "true"
ports:
- 1883:1883
options: >-
--security-opt no-new-privileges:true
mosquitto:
image: eclipse-mosquitto:2
ports:
- 1884:1883
options: >-
--security-opt no-new-privileges:true
hivemq:
image: hivemq/hivemq-ce:latest
ports:
- 1886:1883
options: >-
--security-opt no-new-privileges:true
nanomq:
image: emqx/nanomq:latest
ports:
- 1887:1883
options: >-
--security-opt no-new-privileges:true
steps:
- uses: actions/checkout@v4
- name: Setup mosquitto config
run: |
mkdir -p docker
if [ ! -f docker/mosquitto.conf ]; then
cat > docker/mosquitto.conf << EOF
listener 1883
allow_anonymous true
EOF
fi
- name: Copy mosquitto config
run: |
docker cp docker/mosquitto.conf $(docker ps -q --filter "label=com.github.actions.service=mosquitto"):/mosquitto/config/mosquitto.conf
docker exec $(docker ps -q --filter "label=com.github.actions.service=mosquitto") chmod 644 /mosquitto/config/mosquitto.conf
- name: Wait for brokers
run: |
echo "Waiting for brokers to be ready..."
sleep 15
# Test connections to brokers
for port in 1883 1884 1886 1887; do
nc -zv localhost $port || echo "Port $port not responding"
done
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- run: uv sync --group dev
- run: uv run pytest --cov=src/fastmqtt --cov-report=xml
- uses: codecov/codecov-action@v5
with:
files: coverage.xml
check:
name: All tests passed
if: always()
needs: [tests]
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}