-
Notifications
You must be signed in to change notification settings - Fork 4
123 lines (111 loc) · 4.37 KB
/
Copy pathcoverage.yml
File metadata and controls
123 lines (111 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Python Tests
on:
pull_request:
paths:
- "packages/**"
- "apps/mewbo_api/**"
- "apps/mewbo_cli/**"
- "apps/mewbo_mcp/**"
- "apps/mewbo_ha_conversation/**"
- "tests/**"
- "demo/seeder/**"
# The generators under scripts/ci are the only other way a COMMITTED
# generated artifact drifts from its source, and both have a freshness
# test in tests/ — which cannot run on a change this filter excludes.
- "scripts/ci/**"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/coverage.yml"
workflow_dispatch:
inputs:
ref:
description: "Git ref (branch or tag) to test"
required: false
permissions:
contents: read
id-token: write
# One run per PR; a new commit cancels the superseded run.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
coverage:
name: pytest + coverage
runs-on: ubuntu-22.04
env:
COVERAGE_FILE: .coverage
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install uv
run: |
python -m pip install --upgrade pip
python -m pip install uv
- name: Install dependencies
run: |
uv sync --all-extras --group dev
# pytest-cov's own flags, NOT `coverage run -m pytest`. The bare form
# instruments only the outer process, so the moment this run is
# distributed the workers — spawned through execnet — go uncounted and the
# report silently collapses toward zero for everything they executed.
# pytest-cov starts coverage inside each worker and combines the data
# itself. `--cov-report=` suppresses its own terminal output; the report
# and xml steps below read ${COVERAGE_FILE} exactly as before.
- name: Run pytest with coverage
run: |
.venv/bin/python -m pytest \
--cov=mewbo_core \
--cov=mewbo_tools \
--cov=mewbo_ha_conversation \
--cov-report=
.venv/bin/coverage report --data-file "${COVERAGE_FILE}" --skip-covered
.venv/bin/coverage xml --data-file "${COVERAGE_FILE}" -o coverage.xml
- name: Generate core-only coverage report
run: |
.venv/bin/coverage xml \
--data-file "${COVERAGE_FILE}" \
--include "packages/mewbo_core/src/mewbo_core/*" \
--include "*/packages/mewbo_core/src/mewbo_core/*" \
-o coverage-core.xml
- name: Upload coverage artifact
# Same reason as the console workflow's artifact step: the v4 artifact
# API is a github.com service and the self-hosted runner answers it with
# a hard error, so a fully GREEN suite still reported a failed job — the
# worst possible signal, because the red says "tests" and means "upload".
if: github.server_url == 'https://github.com'
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: |
coverage.xml
coverage-core.xml
# Both Codecov steps are github.com-only, and `fail_ci_if_error: false` is
# NOT enough to make them safe elsewhere: `use_oidc` makes the action fetch
# an ID token FIRST, and Gitea Actions serves no OIDC endpoint, so it dies
# on "Unable to get ACTIONS_ID_TOKEN_REQUEST_URL" before the upload — and
# before the flag that was supposed to forgive an upload failure is ever
# consulted. A whole green suite (11,813 passed) therefore reported a red
# job, which is the worst kind of red: it says "tests" and means "telemetry".
- name: Upload overall coverage to Codecov
if: github.server_url == 'https://github.com'
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
use_oidc: true
- name: Upload core coverage to Codecov
if: github.server_url == 'https://github.com'
uses: codecov/codecov-action@v5
with:
files: ./coverage-core.xml
flags: core
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
use_oidc: true