forked from iarv/meshcore-stats
120 lines
3.4 KiB
YAML
120 lines
3.4 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", "3.13", "3.14"]
|
|
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
|
|
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Set up uv
|
|
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
if: always() && matrix.python-version == '3.14'
|
|
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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
if: always() && matrix.python-version == '3.14'
|
|
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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
|
|
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
|
|
with:
|
|
python-version: "3.14"
|
|
|
|
- name: Set up uv
|
|
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
|
|
with:
|
|
enable-cache: true
|
|
python-version: "3.14"
|
|
|
|
- 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
|