Files
meshcore-stats/.github/workflows/test.yml
2026-01-09 08:15:22 +01:00

120 lines
3.0 KiB
YAML

name: Tests
on:
push:
branches: [main, feat/*]
pull_request:
branches: [main]
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
uses: astral-sh/setup-uv@v7.2.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --locked --extra dev
- name: Set up matplotlib cache
run: |
echo "MPLCONFIGDIR=$RUNNER_TEMP/matplotlib" >> "$GITHUB_ENV"
mkdir -p "$RUNNER_TEMP/matplotlib"
- name: Run tests with coverage
run: |
uv run pytest \
--cov=src/meshmon \
--cov=scripts \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing \
--cov-fail-under=95 \
--junitxml=test-results.xml \
-n auto \
--tb=short \
-q
- name: Coverage summary
if: always()
run: |
{
echo "### Coverage (Python ${{ matrix.python-version }})"
if [ -f .coverage ]; then
uv run coverage report -m
else
echo "No coverage data found."
fi
echo ""
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
if: always() && matrix.python-version == '3.12'
with:
name: coverage-report-html-${{ matrix.python-version }}
path: htmlcov/
if-no-files-found: warn
retention-days: 7
- name: Upload coverage XML report
uses: actions/upload-artifact@v4
if: always() && matrix.python-version == '3.12'
with:
name: coverage-report-xml-${{ matrix.python-version }}
path: coverage.xml
if-no-files-found: warn
retention-days: 7
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.python-version }}
path: test-results.xml
if-no-files-found: warn
retention-days: 7
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Set up uv
uses: astral-sh/setup-uv@v7.2.0
with:
enable-cache: true
python-version: "3.12"
- name: Install linters
run: uv sync --locked --extra dev --no-install-project
- name: Run ruff
run: uv run ruff check src/ tests/ scripts/
- name: Run mypy
run: uv run mypy src/meshmon --ignore-missing-imports --no-error-summary