Skip to content

CI: python tests with uv & typing #466

CI: python tests with uv & typing

CI: python tests with uv & typing #466

Workflow file for this run

name: Build + tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build:
name: "Build + tests"
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: |
make build
- name: Run unit tests
run: |
go install github.com/kyoh86/[email protected]
set -o pipefail
make test | richgo testfilter
env:
RICHGO_FORCE_COLOR: 1
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: 0.5.24
enable-cache: true
cache-dependency-glob: "test/uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "test/.python-version"
- name: Install the project
working-directory: ./test
run: uv sync --all-extras --dev
- name: Install functional test dependencies
run: |
sudo apt update
sudo apt install -y nftables iptables ipset
docker network create net-test
- name: Run functional tests
env:
CROWDSEC_TEST_VERSION: dev
CROWDSEC_TEST_FLAVORS: full
CROWDSEC_TEST_NETWORK: net-test
CROWDSEC_TEST_TIMEOUT: 60
PYTEST_ADDOPTS: --durations=0 -vv --color=yes -m "not (deb or rpm)"
working-directory: ./test
run: |
# everything except for
# - install (requires root, ignored by default)
# - backends (requires root, ignored by default)
# - deb/rpm (on their own workflows)
uv run pytest
# these need root
sudo -E $(which uv) run pytest ./tests/backends
sudo -E $(which uv) run pytest ./tests/install/no_crowdsec
# these need a running crowdsec
docker run -d --name crowdsec -e CI_TESTING=true -e DISABLE_ONLINE_API=true -ti crowdsecurity/crowdsec
install -m 0755 /dev/stdin /usr/local/bin/cscli <<'EOT'
#!/bin/sh
docker exec crowdsec cscli "$@"
EOT
sleep 5
sudo -E $(which uv) run pytest ./tests/install/with_crowdsec
- name: Lint
working-directory: ./test
run: |
uv run ruff check
uv run basedpyright