138 lines
3.9 KiB
YAML
138 lines
3.9 KiB
YAML
# Run the automated test gate when package or runtime inputs change on a PR
|
|
# or on push to main. Privileged self-hosted backends live in the manually
|
|
# dispatched pre-release-test workflow.
|
|
|
|
name: test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'bot_bottle/**'
|
|
- 'tests/**/*.py'
|
|
- 'cli.py'
|
|
- 'scripts/coverage.sh'
|
|
- 'scripts/critical-modules.txt'
|
|
- 'scripts/diff_coverage.py'
|
|
- 'scripts/tracker_policy.py'
|
|
- 'scripts/firecracker-netpool.sh'
|
|
- 'Dockerfile*'
|
|
- 'pyproject.toml'
|
|
- 'requirements-dev.txt'
|
|
- '.coveragerc'
|
|
- '.dockerignore'
|
|
- '.gitea/workflows/test.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'bot_bottle/**'
|
|
- 'tests/**/*.py'
|
|
- 'cli.py'
|
|
- 'scripts/coverage.sh'
|
|
- 'scripts/critical-modules.txt'
|
|
- 'scripts/diff_coverage.py'
|
|
- 'scripts/tracker_policy.py'
|
|
- 'scripts/firecracker-netpool.sh'
|
|
- 'Dockerfile*'
|
|
- 'pyproject.toml'
|
|
- 'requirements-dev.txt'
|
|
- '.coveragerc'
|
|
- '.dockerignore'
|
|
- '.gitea/workflows/test.yml'
|
|
|
|
jobs:
|
|
unit:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dev requirements
|
|
run: python3 -m pip install --break-system-packages -r requirements-dev.txt
|
|
|
|
- name: Run unit tests with coverage
|
|
env:
|
|
COVERAGE_FILE: ${{ github.workspace }}/.coverage.unit
|
|
run: python3 -m coverage run -m unittest discover -t . -s tests/unit -v
|
|
|
|
- name: Report unit coverage
|
|
env:
|
|
COVERAGE_FILE: ${{ github.workspace }}/.coverage.unit
|
|
run: python3 -m coverage report -m
|
|
|
|
- name: Stage unit coverage for upload
|
|
run: cp .coverage.unit coverage-unit.dat
|
|
|
|
- name: Upload unit coverage artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: coverage-unit
|
|
path: coverage-unit.dat
|
|
|
|
integration-docker:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install coverage
|
|
run: python3 -m pip install --break-system-packages coverage
|
|
|
|
- name: Preflight — Docker backend is ready
|
|
run: |
|
|
python3 --version
|
|
python3 cli.py backend status --backend=docker
|
|
|
|
- name: Run integration tests (docker) with coverage
|
|
env:
|
|
BOT_BOTTLE_BACKEND: docker
|
|
COVERAGE_FILE: ${{ github.workspace }}/.coverage.docker
|
|
run: python3 -m coverage run -m unittest discover -t . -s tests/integration -v
|
|
|
|
- name: Stage docker coverage for upload
|
|
run: cp .coverage.docker coverage-docker.dat
|
|
|
|
- name: Upload docker coverage artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: coverage-docker
|
|
path: coverage-docker.dat
|
|
|
|
coverage:
|
|
needs: [unit, integration-docker]
|
|
timeout-minutes: 15
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install coverage
|
|
run: python3 -m pip install --break-system-packages coverage
|
|
|
|
- name: Download unit coverage artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: coverage-unit
|
|
path: ${{ github.workspace }}
|
|
|
|
- name: Download docker coverage artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: coverage-docker
|
|
path: ${{ github.workspace }}
|
|
|
|
- name: Reassemble coverage data files
|
|
run: |
|
|
mv coverage-unit.dat .coverage.unit
|
|
mv coverage-docker.dat .coverage.docker
|
|
|
|
- name: Combined coverage (unit + docker integration)
|
|
run: PYTHON=python3 bash scripts/coverage.sh aggregate critical
|
|
|
|
- name: Diff-coverage gate (changed lines >= 90%)
|
|
run: |
|
|
git fetch --no-tags origin main:refs/remotes/origin/main
|
|
python3 scripts/diff_coverage.py --base origin/main --min 90
|