From 9f3d105b2a1d4113653121a9d0f87697c0cd8ca5 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 3 Dec 2026 10:24:53 -0800 Subject: [PATCH 1/3] Run Each .NET Leg Over Only the Test Projects Declaring Its Line Skip and name a test project that does not declare the leg's netX.Y, and fail a leg where none does. Keep a timed-out uv export or property read from aborting the package consume checks before the summary. Part of #4609 Co-Authored-By: Claude Sonnet 5.5 --- .../references/d-guarantees.md | 2 +- .../.source-digests/workflow-ci-contract | 2 +- .../references/d-guarantees.md | 2 +- .../package_consume_nuget.py | 36 +++--- .../package_consume_pypi.py | 29 ++++- .../references/d-guarantees.md | 2 +- .github/workflows/validate-task.yml | 32 ++++-- WORKFLOW.md | 2 +- docs/reusable-workflows.md | 2 +- tests/test_package_consume_nuget.py | 12 ++ tests/test_package_consume_pypi.py | 65 ++++++++++- tests/test_release_guards.py | 107 ++++++++++++++++-- 12 files changed, 249 insertions(+), 44 deletions(-) diff --git a/.agents/skills/workflow-ci-contract/references/d-guarantees.md b/.agents/skills/workflow-ci-contract/references/d-guarantees.md index f7e3097b7..183140bf7 100644 --- a/.agents/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.agents/skills/workflow-ci-contract/references/d-guarantees.md @@ -18,7 +18,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. Unless the repository root holds exactly one solution or project, the hub's validator therefore runs the collection once per tracked `*Tests*.csproj` with `--project`. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* -- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* +- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* ### D2 - Input/State Validation at Entry diff --git a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract index 11468940c..10e9c3bc3 100644 --- a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract +++ b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract @@ -1 +1 @@ -48bde8411845cb66 +be0b8357951abdf6 diff --git a/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md b/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md index f7e3097b7..183140bf7 100644 --- a/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md @@ -18,7 +18,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. Unless the repository root holds exactly one solution or project, the hub's validator therefore runs the collection once per tracked `*Tests*.csproj` with `--project`. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* -- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* +- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* ### D2 - Input/State Validation at Entry diff --git a/.github/actions/package-consume-nuget/package_consume_nuget.py b/.github/actions/package-consume-nuget/package_consume_nuget.py index 6a66f0107..aed509f26 100755 --- a/.github/actions/package-consume-nuget/package_consume_nuget.py +++ b/.github/actions/package-consume-nuget/package_consume_nuget.py @@ -173,21 +173,27 @@ def global_json_line(path: Path) -> str | None: def project_properties(project: str) -> dict[str, str]: # The leaf packs Release on main and Debug elsewhere, and a property can be conditioned on it. configuration = "Release" if os.environ.get("BRANCH") == "main" else "Debug" - result = subprocess.run( - [ - "dotnet", - "msbuild", - project, - "-nologo", - f"-property:Configuration={configuration}", - "-getProperty:" + ",".join(PROPERTIES), - ], - capture_output=True, - text=True, - encoding="utf-8", - check=False, - timeout=COMMAND_TIMEOUT_SECONDS, - ) + try: + result = subprocess.run( + [ + "dotnet", + "msbuild", + project, + "-nologo", + f"-property:Configuration={configuration}", + "-getProperty:" + ",".join(PROPERTIES), + ], + capture_output=True, + text=True, + encoding="utf-8", + check=False, + timeout=COMMAND_TIMEOUT_SECONDS, + ) + except subprocess.TimeoutExpired as error: + # An uncaught timeout is a traceback with no annotation, so it is reported as the failure it is. + raise SystemExit( + f"Reading {project}'s properties timed out after {COMMAND_TIMEOUT_SECONDS} seconds." + ) from error if result.returncode != 0: raise SystemExit(f"Reading {project}'s properties failed:\n{result.stdout}{result.stderr}") return {k: str(v) for k, v in json.loads(result.stdout)["Properties"].items()} diff --git a/.github/actions/package-consume-pypi/package_consume_pypi.py b/.github/actions/package-consume-pypi/package_consume_pypi.py index 56aa287ad..327db8e8c 100755 --- a/.github/actions/package-consume-pypi/package_consume_pypi.py +++ b/.github/actions/package-consume-pypi/package_consume_pypi.py @@ -258,7 +258,7 @@ def consume( name: str, version: str, project: Path, - requirements: Sequence[str], + requirements: Sequence[str] | None, work: Path, env: Mapping[str, str], report: Report, @@ -275,8 +275,9 @@ def consume( if not report.add(target, "install", installed.returncode == 0, artifact.name): return # The project is excluded from the groups, so only its dependencies and tools are added to the artifact's. - groups = run(["uv", "pip", "install", "--python", python, *requirements], project, env) - report.add(target, "test dependencies", groups.returncode == 0, "locked groups, no project") + if requirements is not None: + groups = run(["uv", "pip", "install", "--python", python, *requirements], project, env) + report.add(target, "test dependencies", groups.returncode == 0, "locked groups, no project") files = run([python, "-I", "-c", FILES_PROBE, name], work, env) metadata = probe_rows(files.stdout) @@ -321,6 +322,15 @@ def consume( if not tests.is_dir(): report.add(target, "tests", True, f"{tests.name} folder is absent", skipped=True) return + if requirements is None: + # A pass would claim the tests ran against dependencies that were never installed. + report.add( + target, + "tests", + False, + "not run, the locked test dependencies could not be exported", + ) + return # The working directory is outside the project, so the source tree is not on sys.path. cache = f"cache_dir={work / '.pytest_cache'}" outcome = run([python, "-m", "pytest", str(tests), *PYTEST_ARGUMENTS, "-o", cache], work, env) @@ -335,11 +345,18 @@ def check(project: Path, version: str, lines: Sequence[str], work: Path) -> int: env = clean_environment() name = project_name(project / "pyproject.toml") artifacts = find_artifacts(project / "dist") + requirements: list[str] | None try: requirements = export_requirements(project, work / "requirements.txt", env) - except OSError as error: - report.add("all", "test dependencies", False, str(error)) - requirements = [] + except (OSError, subprocess.TimeoutExpired) as error: + # A timed-out export must still reach the per-artifact checks and the summary, and the step still fails. + detail = ( + f"uv export timed out after {COMMAND_TIMEOUT_SECONDS} seconds" + if isinstance(error, subprocess.TimeoutExpired) + else str(error) + ) + report.add("all", "test dependencies", False, detail) + requirements = None for line in lines: print(f"::group::{escape_command(f'consume py{line}')}") try: diff --git a/.github/skills/workflow-ci-contract/references/d-guarantees.md b/.github/skills/workflow-ci-contract/references/d-guarantees.md index f7e3097b7..183140bf7 100644 --- a/.github/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.github/skills/workflow-ci-contract/references/d-guarantees.md @@ -18,7 +18,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. Unless the repository root holds exactly one solution or project, the hub's validator therefore runs the collection once per tracked `*Tests*.csproj` with `--project`. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* -- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* +- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* ### D2 - Input/State Validation at Entry diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index 4ffcfcb0d..291e240ac 100644 --- a/.github/workflows/validate-task.yml +++ b/.github/workflows/validate-task.yml @@ -28,7 +28,7 @@ on: type: string default: '' dotnet-versions: - description: JSON array of the X.Y .NET lines a multi-targeted caller's projects build, one per target framework, for example ["11.0", "10.0"]. The first entry is the line the root global.json selects, which builds every target framework, and a first entry differing from it fails the run. Every listed line is installed in each .NET leg, and each entry is its own Unit test job (.NET X.Y) leg running dotnet test --framework netX.Y under that line's runtime. Quote each entry, since an unquoted one is a JSON number rather than a line. Empty installs the one line global.json selects, or the hub's fallback line where it carries none. + description: JSON array of the X.Y .NET lines a multi-targeted caller's projects build, one per target framework, for example ["11.0", "10.0"]. The first entry is the line the root global.json selects, which builds every target framework, and a first entry differing from it fails the run. Every listed line is installed in each .NET leg, and each entry is its own Unit test job (.NET X.Y) leg running dotnet test --framework netX.Y under that line's runtime. A leg runs only the test projects declaring netX.Y in their TargetFramework or TargetFrameworks, skips and names the others, and fails where no test project declares its line. Quote each entry, since an unquoted one is a JSON number rather than a line. Empty installs the one line global.json selects, or the hub's fallback line where it carries none. required: false type: string default: '' @@ -1093,13 +1093,31 @@ jobs: set -Eeuo pipefail rm -rf ./coverage # A solution holding no test project fails dotnet test with no test projects found, so the tests are named one project at a time. - if [ -z "$WORKSPACES" ]; then - dotnet test --framework "net$DOTNET_VERSION" --coverage --coverage-output-format cobertura --results-directory ./coverage + # An empty list means a bare dotnet test resolved the root's one workspace, so its test projects are listed here instead. + projects="$WORKSPACES" + if [ -z "$projects" ]; then + projects="$(git ls-files -- ':(glob)**/*Tests*.csproj')" fi - while IFS= read -r workspace; do - [ -n "$workspace" ] || continue - dotnet test --framework "net$DOTNET_VERSION" --project "$workspace" --coverage --coverage-output-format cobertura --results-directory ./coverage < /dev/null - done <<< "$WORKSPACES" + # A project not declaring the leg's line fails --framework, so it is skipped by name rather than failing the leg. + selected=() + while IFS= read -r project; do + [ -n "$project" ] || continue + properties="$(dotnet msbuild "$project" -nologo -getProperty:TargetFramework -getProperty:TargetFrameworks < /dev/null)" + declared="$(jq -r '.Properties | [.TargetFramework, .TargetFrameworks] | map(select(. != null)) | join(";")' <<< "$properties")" + if [[ ";$declared;" == *";net$DOTNET_VERSION;"* ]]; then + selected+=("$project") + else + echo "Skipping $project, which declares [$declared] and not net$DOTNET_VERSION." + fi + done <<< "$projects" + # A declared line must never pass by running nothing. + if [ "${#selected[@]}" -eq 0 ]; then + echo "::error::No test project declares net$DOTNET_VERSION in its TargetFramework or TargetFrameworks, so the .NET $DOTNET_VERSION leg would run no tests." + exit 1 + fi + for project in "${selected[@]}"; do + dotnet test --framework "net$DOTNET_VERSION" --project "$project" --coverage --coverage-output-format cobertura --results-directory ./coverage < /dev/null + done written=0 for report in ./coverage/*.cobertura.xml; do [ -e "$report" ] || continue diff --git a/WORKFLOW.md b/WORKFLOW.md index 4eadedb23..2416b1b58 100644 --- a/WORKFLOW.md +++ b/WORKFLOW.md @@ -147,7 +147,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. Unless the repository root holds exactly one solution or project, the hub's validator therefore runs the collection once per tracked `*Tests*.csproj` with `--project`. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* -- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* +- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* ### D2 - Input/State Validation at Entry diff --git a/docs/reusable-workflows.md b/docs/reusable-workflows.md index 6545bd982..3bd372c84 100644 --- a/docs/reusable-workflows.md +++ b/docs/reusable-workflows.md @@ -507,7 +507,7 @@ A caller carrying a .NET test project as well runs it in the separate `unit-test Each .NET upload carries the fixed `dotnet` flag and a `dotnet-X.Y` flag naming its line. A caller whose `.codecov.yml` configures flags names `dotnet` for the .NET unit-test share, beside the Python legs' own flags. It may also name a line's flag to read that line apart. A .NET caller's coverage reads as a `dotnet` series from its first pin bump onto a release carrying the flag, rather than unflagged. -A repo whose .NET projects multi-target names every line they build in `dotnet-versions`, such as `'["11.0", "10.0"]'` for `net10.0;net11.0`. It is the .NET counterpart of `python-versions`, and each entry is its own `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y`. One SDK builds every target framework, and each framework's tests run under that framework's own runtime. So every leg installs every listed line beside the selected one. A caller naming none runs the one leg for the line `global.json` selects, or the fallback line. The first entry is the `X.Y` line the root `global.json` selects, the highest target framework's, since the release builds on it. The `dotnet-sdk` action refuses a first entry naming another line, with a named cause. It also refuses an entry that is not a quoted `X.Y` line. The `Build test matrix job` runs that check first, before any job builds, as it does for `python-versions`. The `lint` job repeats it, since it does not wait on that job. A caller carrying no `global.json` `sdk.version` installs every entry instead of the fallback line. Without the input, the one leg runs `--framework` for the selected line alone, so a lower framework's tests never run. +A repo whose .NET projects multi-target names every line they build in `dotnet-versions`, such as `'["11.0", "10.0"]'` for `net10.0;net11.0`. It is the .NET counterpart of `python-versions`, and each entry is its own `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y`. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, and logs each project it skips by name. A leg where no test project declares its line fails with an error naming the line. One SDK builds every target framework, and each framework's tests run under that framework's own runtime. So every leg installs every listed line beside the selected one. A caller naming none runs the one leg for the line `global.json` selects, or the fallback line. The first entry is the `X.Y` line the root `global.json` selects, the highest target framework's, since the release builds on it. The `dotnet-sdk` action refuses a first entry naming another line, with a named cause. It also refuses an entry that is not a quoted `X.Y` line. The `Build test matrix job` runs that check first, before any job builds, as it does for `python-versions`. The `lint` job repeats it, since it does not wait on that job. A caller carrying no `global.json` `sdk.version` installs every entry instead of the fallback line. Without the input, the one leg runs `--framework` for the selected line alone, so a lower framework's tests never run. A PyPI repo names the lines its built package must work under in the `python-versions` input of `build-release-task.yml`, as it does for `validate-task.yml`. The two inputs hold the same value, so the lines its tests run under are the lines its wheel and sdist are consumed under. The input is validated like the unit-test one. Empty consumes under the one line the root `.python-version` selects. Where there is none it consumes under the hub's fallback line. After the hub default builds, the `build-pypi` job installs the wheel and, separately, the sdist into a fresh environment per line, outside the checkout. It then installs the project's locked dependency groups without the project. It asserts the installed version and that the package imports from site-packages. It runs the caller's `tests/` folder against the installed copy, from outside the project. The suite must read no path relative to the project root, and no tool setting from the working directory. It must import a sibling helper as part of a package. The project directory must hold its own `uv.lock`. A smoke run runs it unchanged and uploads nothing, and a caller's own `build-pypi` hook is outside it. WORKFLOW.md D1.8 states the guarantee. diff --git a/tests/test_package_consume_nuget.py b/tests/test_package_consume_nuget.py index 896d3468c..bbab59838 100755 --- a/tests/test_package_consume_nuget.py +++ b/tests/test_package_consume_nuget.py @@ -12,6 +12,7 @@ import contextlib import io import re +import subprocess import sys import tempfile import unittest @@ -273,6 +274,17 @@ def test_a_referenced_project_package_does_not_hide_the_projects_own(self) -> No pcn.find_package(directory, "Contoso.Missing") +class PropertyTimeoutTests(unittest.TestCase): + def test_a_timed_out_property_read_is_a_reported_failure_not_a_traceback(self) -> None: + timeout = subprocess.TimeoutExpired(["dotnet", "msbuild"], 900) + with ( + mock.patch.object(pcn.subprocess, "run", side_effect=timeout), + self.assertRaises(SystemExit) as raised, + ): + pcn.project_properties("src/Widget.csproj") + self.assertIn("timed out", str(raised.exception)) + + class InterruptTests(unittest.TestCase): def setUp(self) -> None: pcn.received.clear() diff --git a/tests/test_package_consume_pypi.py b/tests/test_package_consume_pypi.py index 1593cda31..0d80450a4 100755 --- a/tests/test_package_consume_pypi.py +++ b/tests/test_package_consume_pypi.py @@ -165,7 +165,11 @@ class ConsumeTests(unittest.TestCase): """consume() with its commands stubbed, so each early return and skip is driven.""" def drive( - self, project: Path, probes: dict[str, str], pytest_status: int = 0 + self, + project: Path, + probes: dict[str, str], + pytest_status: int = 0, + requirements: list[str] | None = None, ) -> dict[str, str]: def fake_run(command: list[str], cwd: Path, env: dict[str, str]) -> mock.Mock: self.cwds.append((command, cwd)) @@ -189,7 +193,7 @@ def fake_run(command: list[str], cwd: Path, env: dict[str, str]) -> mock.Mock: "contoso-widget", "1.2.3", project, - [], + [] if requirements is None else requirements, project, {}, report, @@ -242,6 +246,35 @@ def fake_run(command: list[str], cwd: Path, env: dict[str, str]) -> mock.Mock: FILES = 'VERSION\t1.2.3\nFILES\t["contoso_widget/__init__.py"]\n' GOOD = "ROOTS\t/venv/site\nIMPORT\tcontoso_widget\t/venv/site/contoso_widget/__init__.py\n" + def test_missing_exported_dependencies_fail_the_tests_row_and_skip_their_install(self) -> None: + installs: list[list[str]] = [] + report = pcp.Report() + + def fake_run(command: list[str], cwd: Path, env: dict[str, str]) -> mock.Mock: + installs.append(command) + if "-c" in command: + key = "files" if "dist.version" in command[command.index("-c") + 1] else "import" + return mock.Mock( + returncode=0, stdout={"files": self.FILES, "import": self.GOOD}[key], stderr="" + ) + return mock.Mock(returncode=0, stdout="", stderr="") + + with tempfile.TemporaryDirectory() as name: + project = Path(name) + (project / "tests").mkdir() + with mock.patch.object(pcp, "run", fake_run), contextlib.redirect_stdout(io.StringIO()): + pcp.consume( + "wheel", Path("w.whl"), "3.13", "contoso-widget", "1.2.3", + project, None, project, {}, report, + ) # fmt: skip + rows = {r.check: r for r in report.results} + self.assertNotIn("test dependencies", rows) + self.assertEqual(rows["import location"].ok, True) + self.assertFalse(rows["tests"].ok) + self.assertIn("could not be exported", rows["tests"].detail) + self.assertFalse([c for c in installs if "pytest" in c]) + self.assertEqual(len([c for c in installs if c[:3] == ["uv", "pip", "install"]]), 1) + def test_a_source_tree_import_fails_the_location_row(self) -> None: with tempfile.TemporaryDirectory() as name: rows = self.drive( @@ -288,6 +321,34 @@ def test_pytest_collecting_nothing_skips_and_a_failing_run_fails(self) -> None: self.assertEqual(self.drive(project, probes, 0)["tests"], "pass") +class CheckTests(unittest.TestCase): + def test_a_timed_out_export_still_runs_the_artifact_checks_and_writes_the_summary(self) -> None: + seen: list[object] = [] + + def fake_consume(*args: object) -> None: + seen.append(args[6]) + + with tempfile.TemporaryDirectory() as name: + root = Path(name) + (root / "dist").mkdir() + summary = root / "summary.md" + timeout = subprocess.TimeoutExpired(["uv", "export"], 900) + with ( + mock.patch.object(pcp, "project_name", return_value="contoso-widget"), + mock.patch.object(pcp, "find_artifacts", return_value={"wheel": root / "w.whl"}), + mock.patch.object(pcp, "export_requirements", side_effect=timeout), + mock.patch.object(pcp, "consume", fake_consume), + mock.patch.dict(os.environ, {"GITHUB_STEP_SUMMARY": str(summary)}), + contextlib.redirect_stdout(io.StringIO()), + ): + status = pcp.check(root, "1.2.3", ["3.13"], root) + text = summary.read_text(encoding="utf-8") + self.assertEqual(status, 1) + self.assertEqual(seen, [None]) + self.assertIn("timed out", text) + self.assertIn("| all | test dependencies | fail |", text) + + class ReportTests(unittest.TestCase): def test_a_failure_is_an_escaped_annotation_and_a_table_row(self) -> None: report = pcp.Report() diff --git a/tests/test_release_guards.py b/tests/test_release_guards.py index e1c3727f2..d3844bc05 100755 --- a/tests/test_release_guards.py +++ b/tests/test_release_guards.py @@ -2310,8 +2310,8 @@ def test_validator_runs_each_dotnet_line_and_python_line_as_its_own_leg(self) -> for line in script.splitlines() if re.match(r"\s*(?:\S.*\s)?dotnet test ", line) and not line.lstrip().startswith("#") ] - self.assertEqual(2, len(invocations)) - self.assertEqual(2, script.count('dotnet test --framework "net$DOTNET_VERSION" ')) + self.assertEqual(1, len(invocations)) + self.assertEqual(1, script.count('dotnet test --framework "net$DOTNET_VERSION" ')) run_step = yaml_step(dotnet_job, "Run unit tests step") self.assertEqual( "${{ matrix.dotnet-version }}", yaml_value(run_step, "env", "DOTNET_VERSION") @@ -2359,7 +2359,7 @@ def test_validator_runs_each_dotnet_line_and_python_line_as_its_own_leg(self) -> ) @unittest.skipUnless( - shutil.which("bash") and os.name == "posix", + shutil.which("bash") and shutil.which("git") and shutil.which("jq") and os.name == "posix", "the step runs under bash against a stand-in dotnet that only a POSIX host can execute", ) def test_validator_dotnet_leg_fails_when_no_report_was_written(self) -> None: @@ -2388,10 +2388,15 @@ def test_validator_dotnet_leg_fails_when_no_report_was_written(self) -> None: bin_dir = Path(scratch) / "bin" bin_dir.mkdir() stand_in = bin_dir / "dotnet" - stand_in.write_text(f"#!/usr/bin/env bash\n{writer}\n", encoding="utf-8") + stand_in.write_text( + f"#!/usr/bin/env bash\n{DOTNET_MSBUILD_STAND_IN}{writer}\n", encoding="utf-8" + ) stand_in.chmod(0o755) work = Path(scratch) / "work" (work / "coverage").mkdir(parents=True) + (work / "AppTests.csproj").write_text("net10.0", encoding="utf-8") + for command in (["git", "init", "-q"], ["git", "add", "."]): + run(command, cwd=work, env=without_git_location(), check=True, timeout=60) (work / "coverage/coverage-committed.cobertura.xml").write_text( "", encoding="utf-8" ) @@ -2401,6 +2406,7 @@ def test_validator_dotnet_leg_fails_when_no_report_was_written(self) -> None: env={ **without_git_location(), "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', os.defpath)}", + "STUB_LOG": os.devnull, "WORKSPACES": "", "DOTNET_VERSION": "10.0", }, @@ -2418,7 +2424,7 @@ def test_validator_dotnet_leg_fails_when_no_report_was_written(self) -> None: self.assertTrue((work / "coverage/coverage-0f1e2d3c.cobertura.xml").exists()) @unittest.skipUnless( - shutil.which("git") and shutil.which("bash") and os.name == "posix", + shutil.which("git") and shutil.which("bash") and shutil.which("jq") and os.name == "posix", "the action reads the tracked tree with git, and the steps run under bash against a stand-in dotnet", ) def test_validator_dotnet_steps_run_once_per_workspace(self) -> None: @@ -2480,12 +2486,12 @@ def named_style(*workspaces: str) -> list[str]: "a root solution": ( ["App.sln", "src/Lib/Lib.csproj", "tests/LibTests/LibTests.csproj"], bare_style, - [f"test --framework net10.0 {flags}"], + [f"test --framework net10.0 --project tests/LibTests/LibTests.csproj {flags}"], ), "a root project": ( ["App.csproj", "tests/AppTests/AppTests.csproj"], bare_style, - [f"test --framework net10.0 {flags}"], + [f"test --framework net10.0 --project tests/AppTests/AppTests.csproj {flags}"], ), "solutions below the root": ( [ @@ -2545,7 +2551,7 @@ def named_style(*workspaces: str) -> list[str]: output.write_text("", encoding="utf-8") stand_in = bin_dir / "dotnet" stand_in.write_text( - '#!/usr/bin/env bash\necho "$*" >> "$STUB_LOG"\n' + f'#!/usr/bin/env bash\n{DOTNET_MSBUILD_STAND_IN}echo "$*" >> "$STUB_LOG"\n' 'mkdir -p ./coverage && echo "" > "./coverage/$RANDOM.cobertura.xml"\n', encoding="utf-8", ) @@ -2595,6 +2601,83 @@ def named_style(*workspaces: str) -> list[str]: self.assertEqual(0, result.returncode, result.stdout + result.stderr) self.assertEqual(want, log.read_text(encoding="utf-8").splitlines()) + @unittest.skipUnless( + shutil.which("git") and shutil.which("bash") and shutil.which("jq") and os.name == "posix", + "the step reads the tracked tree with git and runs under bash against a stand-in dotnet", + ) + def test_validator_dotnet_leg_runs_only_the_projects_declaring_its_line(self) -> None: + """WORKFLOW.md D1.9: a project not declaring the leg's line is skipped by name, and no declarer fails the leg. + + The step's whole script is run, with the stand-in answering dotnet msbuild from each + project file's content, which stands for its TargetFramework or TargetFrameworks. + A filter that matched a prefix, ignored the plural property, or let an empty selection pass + would fail here as it would on a runner. + """ + workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") + job = workflow.split("\n unit-test-dotnet:\n", 1)[1].split("\n validate:\n", 1)[0] + script = step_script_text(job, "Run unit tests step") + self.assertIn("-getProperty:TargetFramework -getProperty:TargetFrameworks", script) + flags = "--coverage --coverage-output-format cobertura --results-directory ./coverage" + projects = {"A/ATests.csproj": "net10.0", "B/BTests.csproj": "net10.0;net11.0"} + cases = { + "11.0": (0, [f"test --framework net11.0 --project B/BTests.csproj {flags}"]), + "10.0": ( + 0, + [ + f"test --framework net10.0 --project A/ATests.csproj {flags}", + f"test --framework net10.0 --project B/BTests.csproj {flags}", + ], + ), + "9.0": (1, []), + "1.0": (1, []), + } + for line, (status, want) in cases.items(): + with self.subTest(line=line), tempfile.TemporaryDirectory() as scratch: + bin_dir, work, log = ( + Path(scratch) / "bin", + Path(scratch) / "work", + Path(scratch) / "log", + ) + bin_dir.mkdir() + stand_in = bin_dir / "dotnet" + stand_in.write_text( + f'#!/usr/bin/env bash\n{DOTNET_MSBUILD_STAND_IN}echo "$*" >> "$STUB_LOG"\n' + 'mkdir -p ./coverage && echo "" > "./coverage/$RANDOM.cobertura.xml"\n', + encoding="utf-8", + ) + stand_in.chmod(0o755) + for path, frameworks in projects.items(): + (work / path).parent.mkdir(parents=True, exist_ok=True) + (work / path).write_text(frameworks, encoding="utf-8") + for command in (["git", "init", "-q"], ["git", "add", "."]): + run(command, cwd=work, env=without_git_location(), check=True, timeout=60) + # An empty list is the root-solution case, and a named list is the workspace case. + for workspaces in ("", "\n".join(projects)): + log.write_text("", encoding="utf-8") + result = run( + [bash_or_skip(), "-c", script], + cwd=work, + env={ + **without_git_location(), + "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', os.defpath)}", + "STUB_LOG": str(log), + "WORKSPACES": workspaces, + "DOTNET_VERSION": line, + }, + capture_output=True, + text=True, + encoding="utf-8", + timeout=60, + check=False, + ) + output = result.stdout + result.stderr + self.assertEqual(status, result.returncode, output) + self.assertEqual(want, log.read_text(encoding="utf-8").splitlines()) + if status: + self.assertIn(f"::error::No test project declares net{line}", output) + if line == "11.0": + self.assertIn("Skipping A/ATests.csproj", output) + @unittest.skipUnless(shutil.which("jq"), "jq is what the step under test runs") def test_validator_refuses_a_python_versions_value_fromjson_would_admit(self) -> None: """fromJSON admits a JSON array of numbers, which is not a list of interpreter versions. @@ -2723,6 +2806,14 @@ def test_audit_bash_blocks_are_not_labeled_as_posix_shell(self) -> None: ) +# Answers the property read the way dotnet msbuild does, from a project file whose content stands for its frameworks. +DOTNET_MSBUILD_STAND_IN = ( + 'if [ "$1" = msbuild ]; then fw="$(cat "$2")"; ' + 'printf \'{"Properties":{"TargetFramework":"","TargetFrameworks":"%s"}}\\n\' "${fw:-net10.0}"; ' + "exit 0; fi\n" +) + + def run_step_script(script: str, workspace: Path, env: dict[str, str]) -> tuple[int, str, str, str]: """Run a step's `script` in `workspace`, with `env` added. From 615a6c465c3da7ee1aca767e20a0cc67ff20929d Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 3 Dec 2026 10:30:56 -0800 Subject: [PATCH 2/3] Match Declared Frameworks Like MSBuild and Drop the Workspace Hop Trim and case-fold each declared framework, read both properties in tests, and list every tracked test project directly, since the workspace resolver now gives the same list. Annotate the property read timeout. Part of #4609 Co-Authored-By: Claude Sonnet 5.5 --- .../references/d-guarantees.md | 4 +- .../.source-digests/workflow-ci-contract | 2 +- .../references/d-guarantees.md | 4 +- .../package_consume_nuget.py | 9 +- .../references/d-guarantees.md | 4 +- .github/workflows/validate-task.yml | 25 +--- WORKFLOW.md | 4 +- docs/reusable-workflows.md | 2 +- tests/test_package_consume_nuget.py | 4 +- tests/test_release_guards.py | 128 ++++++++++-------- 10 files changed, 97 insertions(+), 89 deletions(-) diff --git a/.agents/skills/workflow-ci-contract/references/d-guarantees.md b/.agents/skills/workflow-ci-contract/references/d-guarantees.md index 183140bf7..d379784c7 100644 --- a/.agents/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.agents/skills/workflow-ci-contract/references/d-guarantees.md @@ -15,10 +15,10 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.3 Smoke never publishes and never uploads.** Input: `smoke: true`. Output: full compile/lint/test, but no registry/image push, no release, and **no** artifact uploads. Every `upload-artifact`, including any aggregation job, is gated on smoke being false. That gate is written `!inputs.smoke` at the workflow layer and `inputs.smoke != 'true'` in a composite action, whose inputs are strings. *Prevents: a PR publishing, and orphaned artifacts churning the storage quota.* - **D1.4 Workflow-file changes are not smoke-built.** Input: a PR changing only `.github/workflows/**`. Output: the paths-filter marks no target, so smoke-build skips. An inclusion list satisfying D1.1 reaches this by leaving workflow paths out of every target's entry. *Implication: a workflow-only change is not smoke-built, but actionlint still validates it in CI.* - **D1.5 One required aggregator gates merge.** Input: any PR. Output: a single aggregator job must **succeed**. It must run under `if: always()`, so a failed or skipped dependency cannot skip the gate itself. It must also `needs:` the validation job, and the `changes` and `smoke-build` jobs too wherever the repo has a smoke build. It must treat a **skipped** smoke build as pass, and **block** on `failure`/`cancelled`. Its name is ruleset-bound: the job `name:` and the ruleset `context:` are the same string and MUST be renamed together, never independently. The workflow holding it MUST trigger on `pull_request`. A gate without a `pull_request` trigger never runs the validator's pull-request-only steps, the prose gate among them. A workflow any other event also triggers yields that name only when `github.event_name == 'pull_request'`, through an expression `name:`. Otherwise a dispatch or push run on a PR's head posts the required context without the PR run's gates. *Prevents: a paths-filter error letting a target-changing PR merge unbuilt.* -- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. Unless the repository root holds exactly one solution or project, the hub's validator therefore runs the collection once per tracked `*Tests*.csproj` with `--project`. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* +- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* -- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* +- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* ### D2 - Input/State Validation at Entry diff --git a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract index 10e9c3bc3..8ebcc94c6 100644 --- a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract +++ b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract @@ -1 +1 @@ -be0b8357951abdf6 +1095f19d684ee256 diff --git a/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md b/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md index 183140bf7..d379784c7 100644 --- a/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md @@ -15,10 +15,10 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.3 Smoke never publishes and never uploads.** Input: `smoke: true`. Output: full compile/lint/test, but no registry/image push, no release, and **no** artifact uploads. Every `upload-artifact`, including any aggregation job, is gated on smoke being false. That gate is written `!inputs.smoke` at the workflow layer and `inputs.smoke != 'true'` in a composite action, whose inputs are strings. *Prevents: a PR publishing, and orphaned artifacts churning the storage quota.* - **D1.4 Workflow-file changes are not smoke-built.** Input: a PR changing only `.github/workflows/**`. Output: the paths-filter marks no target, so smoke-build skips. An inclusion list satisfying D1.1 reaches this by leaving workflow paths out of every target's entry. *Implication: a workflow-only change is not smoke-built, but actionlint still validates it in CI.* - **D1.5 One required aggregator gates merge.** Input: any PR. Output: a single aggregator job must **succeed**. It must run under `if: always()`, so a failed or skipped dependency cannot skip the gate itself. It must also `needs:` the validation job, and the `changes` and `smoke-build` jobs too wherever the repo has a smoke build. It must treat a **skipped** smoke build as pass, and **block** on `failure`/`cancelled`. Its name is ruleset-bound: the job `name:` and the ruleset `context:` are the same string and MUST be renamed together, never independently. The workflow holding it MUST trigger on `pull_request`. A gate without a `pull_request` trigger never runs the validator's pull-request-only steps, the prose gate among them. A workflow any other event also triggers yields that name only when `github.event_name == 'pull_request'`, through an expression `name:`. Otherwise a dispatch or push run on a PR's head posts the required context without the PR run's gates. *Prevents: a paths-filter error letting a target-changing PR merge unbuilt.* -- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. Unless the repository root holds exactly one solution or project, the hub's validator therefore runs the collection once per tracked `*Tests*.csproj` with `--project`. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* +- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* -- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* +- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* ### D2 - Input/State Validation at Entry diff --git a/.github/actions/package-consume-nuget/package_consume_nuget.py b/.github/actions/package-consume-nuget/package_consume_nuget.py index aed509f26..ea725969d 100755 --- a/.github/actions/package-consume-nuget/package_consume_nuget.py +++ b/.github/actions/package-consume-nuget/package_consume_nuget.py @@ -190,10 +190,11 @@ def project_properties(project: str) -> dict[str, str]: timeout=COMMAND_TIMEOUT_SECONDS, ) except subprocess.TimeoutExpired as error: - # An uncaught timeout is a traceback with no annotation, so it is reported as the failure it is. - raise SystemExit( - f"Reading {project}'s properties timed out after {COMMAND_TIMEOUT_SECONDS} seconds." - ) from error + # An uncaught timeout is a bare traceback, so it is reported as the annotated failure it is. + print( + f"::error::{escape_command(f'Reading {project} properties timed out after {COMMAND_TIMEOUT_SECONDS} seconds.')}" + ) + raise SystemExit(1) from error if result.returncode != 0: raise SystemExit(f"Reading {project}'s properties failed:\n{result.stdout}{result.stderr}") return {k: str(v) for k, v in json.loads(result.stdout)["Properties"].items()} diff --git a/.github/skills/workflow-ci-contract/references/d-guarantees.md b/.github/skills/workflow-ci-contract/references/d-guarantees.md index 183140bf7..d379784c7 100644 --- a/.github/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.github/skills/workflow-ci-contract/references/d-guarantees.md @@ -15,10 +15,10 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.3 Smoke never publishes and never uploads.** Input: `smoke: true`. Output: full compile/lint/test, but no registry/image push, no release, and **no** artifact uploads. Every `upload-artifact`, including any aggregation job, is gated on smoke being false. That gate is written `!inputs.smoke` at the workflow layer and `inputs.smoke != 'true'` in a composite action, whose inputs are strings. *Prevents: a PR publishing, and orphaned artifacts churning the storage quota.* - **D1.4 Workflow-file changes are not smoke-built.** Input: a PR changing only `.github/workflows/**`. Output: the paths-filter marks no target, so smoke-build skips. An inclusion list satisfying D1.1 reaches this by leaving workflow paths out of every target's entry. *Implication: a workflow-only change is not smoke-built, but actionlint still validates it in CI.* - **D1.5 One required aggregator gates merge.** Input: any PR. Output: a single aggregator job must **succeed**. It must run under `if: always()`, so a failed or skipped dependency cannot skip the gate itself. It must also `needs:` the validation job, and the `changes` and `smoke-build` jobs too wherever the repo has a smoke build. It must treat a **skipped** smoke build as pass, and **block** on `failure`/`cancelled`. Its name is ruleset-bound: the job `name:` and the ruleset `context:` are the same string and MUST be renamed together, never independently. The workflow holding it MUST trigger on `pull_request`. A gate without a `pull_request` trigger never runs the validator's pull-request-only steps, the prose gate among them. A workflow any other event also triggers yields that name only when `github.event_name == 'pull_request'`, through an expression `name:`. Otherwise a dispatch or push run on a PR's head posts the required context without the PR run's gates. *Prevents: a paths-filter error letting a target-changing PR merge unbuilt.* -- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. Unless the repository root holds exactly one solution or project, the hub's validator therefore runs the collection once per tracked `*Tests*.csproj` with `--project`. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* +- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* -- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* +- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* ### D2 - Input/State Validation at Entry diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index 291e240ac..64053790b 100644 --- a/.github/workflows/validate-task.yml +++ b/.github/workflows/validate-task.yml @@ -28,7 +28,7 @@ on: type: string default: '' dotnet-versions: - description: JSON array of the X.Y .NET lines a multi-targeted caller's projects build, one per target framework, for example ["11.0", "10.0"]. The first entry is the line the root global.json selects, which builds every target framework, and a first entry differing from it fails the run. Every listed line is installed in each .NET leg, and each entry is its own Unit test job (.NET X.Y) leg running dotnet test --framework netX.Y under that line's runtime. A leg runs only the test projects declaring netX.Y in their TargetFramework or TargetFrameworks, skips and names the others, and fails where no test project declares its line. Quote each entry, since an unquoted one is a JSON number rather than a line. Empty installs the one line global.json selects, or the hub's fallback line where it carries none. + description: JSON array of the X.Y .NET lines a multi-targeted caller's projects build, one per target framework, for example ["11.0", "10.0"]. The first entry is the line the root global.json selects, which builds every target framework, and a first entry differing from it fails the run. Every listed line is installed in each .NET leg, and each entry is its own Unit test job (.NET X.Y) leg running dotnet test --framework netX.Y under that line's runtime. A leg runs only the tracked *Tests*.csproj projects declaring netX.Y in their TargetFramework or TargetFrameworks, skips and names the others, and fails where no test project declares its line. Quote each entry, since an unquoted one is a JSON number rather than a line. Empty installs the one line global.json selects, or the hub's fallback line where it carries none. required: false type: string default: '' @@ -1074,40 +1074,29 @@ jobs: with: versions: ${{ inputs.dotnet-versions }} - - name: Resolve .NET workspaces step - id: dotnet - if: hashFiles('**/*Tests*.csproj') != '' - uses: $/.github/actions/dotnet-workspaces - with: - projects: ':(glob)**/*Tests*.csproj' - # --coverage-output stays unset because pinning one filename gives every test project in the solution the same path, and the last to finish overwrites the rest. # The default .cobertura.xml written instead is a name codecov-cli's finder does not match. # Each report is therefore prefixed rather than renamed, keeping the guid that makes it unique. - name: Run unit tests step if: hashFiles('**/*Tests*.csproj') != '' env: - WORKSPACES: ${{ steps.dotnet.outputs.workspaces }} DOTNET_VERSION: ${{ matrix.dotnet-version }} run: | set -Eeuo pipefail rm -rf ./coverage - # A solution holding no test project fails dotnet test with no test projects found, so the tests are named one project at a time. - # An empty list means a bare dotnet test resolved the root's one workspace, so its test projects are listed here instead. - projects="$WORKSPACES" - if [ -z "$projects" ]; then - projects="$(git ls-files -- ':(glob)**/*Tests*.csproj')" - fi + # A solution holding no test project fails dotnet test with no test projects found, and a project not declaring the leg's line fails --framework. + # So every tracked test project is read and named one at a time, whatever the root holds. + projects="$(git ls-files -- ':(glob)**/*Tests*.csproj')" # A project not declaring the leg's line fails --framework, so it is skipped by name rather than failing the leg. selected=() while IFS= read -r project; do [ -n "$project" ] || continue properties="$(dotnet msbuild "$project" -nologo -getProperty:TargetFramework -getProperty:TargetFrameworks < /dev/null)" - declared="$(jq -r '.Properties | [.TargetFramework, .TargetFrameworks] | map(select(. != null)) | join(";")' <<< "$properties")" - if [[ ";$declared;" == *";net$DOTNET_VERSION;"* ]]; then + # MSBuild trims each list entry and compares a framework without regard to case, so the match does too. + if jq -e --arg line "net$DOTNET_VERSION" '[.Properties.TargetFramework, .Properties.TargetFrameworks] | map(select(. != null) | split(";")[] | gsub("\\s"; "") | ascii_downcase) | any(. == $line)' <<< "$properties" > /dev/null; then selected+=("$project") else - echo "Skipping $project, which declares [$declared] and not net$DOTNET_VERSION." + echo "Skipping $project, which does not declare net$DOTNET_VERSION." fi done <<< "$projects" # A declared line must never pass by running nothing. diff --git a/WORKFLOW.md b/WORKFLOW.md index 2416b1b58..119fd07f2 100644 --- a/WORKFLOW.md +++ b/WORKFLOW.md @@ -144,10 +144,10 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.3 Smoke never publishes and never uploads.** Input: `smoke: true`. Output: full compile/lint/test, but no registry/image push, no release, and **no** artifact uploads. Every `upload-artifact`, including any aggregation job, is gated on smoke being false. That gate is written `!inputs.smoke` at the workflow layer and `inputs.smoke != 'true'` in a composite action, whose inputs are strings. *Prevents: a PR publishing, and orphaned artifacts churning the storage quota.* - **D1.4 Workflow-file changes are not smoke-built.** Input: a PR changing only `.github/workflows/**`. Output: the paths-filter marks no target, so smoke-build skips. An inclusion list satisfying D1.1 reaches this by leaving workflow paths out of every target's entry. *Implication: a workflow-only change is not smoke-built, but actionlint still validates it in CI.* - **D1.5 One required aggregator gates merge.** Input: any PR. Output: a single aggregator job must **succeed**. It must run under `if: always()`, so a failed or skipped dependency cannot skip the gate itself. It must also `needs:` the validation job, and the `changes` and `smoke-build` jobs too wherever the repo has a smoke build. It must treat a **skipped** smoke build as pass, and **block** on `failure`/`cancelled`. Its name is ruleset-bound: the job `name:` and the ruleset `context:` are the same string and MUST be renamed together, never independently. The workflow holding it MUST trigger on `pull_request`. A gate without a `pull_request` trigger never runs the validator's pull-request-only steps, the prose gate among them. A workflow any other event also triggers yields that name only when `github.event_name == 'pull_request'`, through an expression `name:`. Otherwise a dispatch or push run on a PR's head posts the required context without the PR run's gates. *Prevents: a paths-filter error letting a target-changing PR merge unbuilt.* -- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. Unless the repository root holds exactly one solution or project, the hub's validator therefore runs the collection once per tracked `*Tests*.csproj` with `--project`. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* +- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* -- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* +- **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* ### D2 - Input/State Validation at Entry diff --git a/docs/reusable-workflows.md b/docs/reusable-workflows.md index 3bd372c84..0592c4601 100644 --- a/docs/reusable-workflows.md +++ b/docs/reusable-workflows.md @@ -507,7 +507,7 @@ A caller carrying a .NET test project as well runs it in the separate `unit-test Each .NET upload carries the fixed `dotnet` flag and a `dotnet-X.Y` flag naming its line. A caller whose `.codecov.yml` configures flags names `dotnet` for the .NET unit-test share, beside the Python legs' own flags. It may also name a line's flag to read that line apart. A .NET caller's coverage reads as a `dotnet` series from its first pin bump onto a release carrying the flag, rather than unflagged. -A repo whose .NET projects multi-target names every line they build in `dotnet-versions`, such as `'["11.0", "10.0"]'` for `net10.0;net11.0`. It is the .NET counterpart of `python-versions`, and each entry is its own `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y`. A leg runs only the test projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, and logs each project it skips by name. A leg where no test project declares its line fails with an error naming the line. One SDK builds every target framework, and each framework's tests run under that framework's own runtime. So every leg installs every listed line beside the selected one. A caller naming none runs the one leg for the line `global.json` selects, or the fallback line. The first entry is the `X.Y` line the root `global.json` selects, the highest target framework's, since the release builds on it. The `dotnet-sdk` action refuses a first entry naming another line, with a named cause. It also refuses an entry that is not a quoted `X.Y` line. The `Build test matrix job` runs that check first, before any job builds, as it does for `python-versions`. The `lint` job repeats it, since it does not wait on that job. A caller carrying no `global.json` `sdk.version` installs every entry instead of the fallback line. Without the input, the one leg runs `--framework` for the selected line alone, so a lower framework's tests never run. +A repo whose .NET projects multi-target names every line they build in `dotnet-versions`, such as `'["11.0", "10.0"]'` for `net10.0;net11.0`. It is the .NET counterpart of `python-versions`, and each entry is its own `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y`. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, and logs each project it skips by name. A leg where no test project declares its line fails with an error naming the line. One SDK builds every target framework, and each framework's tests run under that framework's own runtime. So every leg installs every listed line beside the selected one. A caller naming none runs the one leg for the line `global.json` selects, or the fallback line. The first entry is the `X.Y` line the root `global.json` selects, the highest target framework's, since the release builds on it. The `dotnet-sdk` action refuses a first entry naming another line, with a named cause. It also refuses an entry that is not a quoted `X.Y` line. The `Build test matrix job` runs that check first, before any job builds, as it does for `python-versions`. The `lint` job repeats it, since it does not wait on that job. A caller carrying no `global.json` `sdk.version` installs every entry instead of the fallback line. Without the input, the one leg runs `--framework` for the selected line alone, so a lower framework's tests never run. A PyPI repo names the lines its built package must work under in the `python-versions` input of `build-release-task.yml`, as it does for `validate-task.yml`. The two inputs hold the same value, so the lines its tests run under are the lines its wheel and sdist are consumed under. The input is validated like the unit-test one. Empty consumes under the one line the root `.python-version` selects. Where there is none it consumes under the hub's fallback line. After the hub default builds, the `build-pypi` job installs the wheel and, separately, the sdist into a fresh environment per line, outside the checkout. It then installs the project's locked dependency groups without the project. It asserts the installed version and that the package imports from site-packages. It runs the caller's `tests/` folder against the installed copy, from outside the project. The suite must read no path relative to the project root, and no tool setting from the working directory. It must import a sibling helper as part of a package. The project directory must hold its own `uv.lock`. A smoke run runs it unchanged and uploads nothing, and a caller's own `build-pypi` hook is outside it. WORKFLOW.md D1.8 states the guarantee. diff --git a/tests/test_package_consume_nuget.py b/tests/test_package_consume_nuget.py index bbab59838..2c99dc6e9 100755 --- a/tests/test_package_consume_nuget.py +++ b/tests/test_package_consume_nuget.py @@ -279,10 +279,12 @@ def test_a_timed_out_property_read_is_a_reported_failure_not_a_traceback(self) - timeout = subprocess.TimeoutExpired(["dotnet", "msbuild"], 900) with ( mock.patch.object(pcn.subprocess, "run", side_effect=timeout), + contextlib.redirect_stdout(io.StringIO()) as printed, self.assertRaises(SystemExit) as raised, ): pcn.project_properties("src/Widget.csproj") - self.assertIn("timed out", str(raised.exception)) + self.assertEqual(1, raised.exception.code) + self.assertIn("::error::Reading src/Widget.csproj properties timed out", printed.getvalue()) class InterruptTests(unittest.TestCase): diff --git a/tests/test_release_guards.py b/tests/test_release_guards.py index d3844bc05..dd60386fc 100755 --- a/tests/test_release_guards.py +++ b/tests/test_release_guards.py @@ -2428,9 +2428,10 @@ def test_validator_dotnet_leg_fails_when_no_report_was_written(self) -> None: "the action reads the tracked tree with git, and the steps run under bash against a stand-in dotnet", ) def test_validator_dotnet_steps_run_once_per_workspace(self) -> None: - """Only a root holding exactly one solution or project keeps the bare call. + """The style step keeps the bare call only at a root holding exactly one solution or project. - Every other tree gets each tracked solution, or each project, named instead. A root holding + Every other tree gets each tracked solution, or each project, named instead. The unit-test + step never keeps it, since each test project is read for the line it declares. A root holding several never takes a nested solution. It names its own solutions, or the projects where it holds none, so a nested one never hides the root's projects. Each job's resolver step is read from the workflow with the inputs it passes, and its output feeds that @@ -2449,7 +2450,7 @@ def wiring(job: str, consumer: str) -> tuple[str, dict[str, str]]: """The consumer's script and the inputs its job passes the resolver, held to one wiring. The two share one condition, since a resolver skipped where its consumer runs leaves the - list empty, which is the bare call. + list empty, which is the style step's bare call. """ resolve = yaml_step(job, "Resolve .NET workspaces step") self.assertEqual(yaml_value(resolve, "uses"), "$/.github/actions/dotnet-workspaces") @@ -2472,7 +2473,9 @@ def wiring(job: str, consumer: str) -> tuple[str, dict[str, str]]: return step_script_text(job, consumer), inputs style, style_inputs = wiring(lint, "Check C# style step") - tests, test_inputs = wiring(unit, "Run unit tests step") + tests = step_script_text(unit, "Run unit tests step") + self.assertNotIn("dotnet-workspaces", unit) + self.assertNotIn("WORKSPACES", tests) flags = "--coverage --coverage-output-format cobertura --results-directory ./coverage" bare_style = ["format style --verify-no-changes --severity=info --verbosity=detailed"] @@ -2538,7 +2541,7 @@ def named_style(*workspaces: str) -> list[str]: [f"test --framework net10.0 --project tests/AppTests/AppTests.csproj {flags}"], ), } - steps = ((style, style_inputs, 1), (tests, test_inputs, 2)) + steps = ((style, style_inputs, 1), (tests, None, 2)) for label, (tracked, want_style, want_tests) in trees.items(): for (script, inputs, which), want in zip(steps, (want_style, want_tests), strict=True): with ( @@ -2567,21 +2570,24 @@ def named_style(*workspaces: str) -> list[str]: check=True, timeout=60, ) - resolved = run( - [bash_or_skip(), "-c", resolver], - cwd=work, - env={**without_git_location(), **inputs, "GITHUB_OUTPUT": str(output)}, - capture_output=True, - text=True, - encoding="utf-8", - timeout=60, - check=False, - ) - self.assertEqual(0, resolved.returncode, resolved.stdout + resolved.stderr) - written = output.read_text(encoding="utf-8") - match = re.fullmatch(r"workspaces<<(\S+)\n((?:.+\n)*)\1\n", written) - self.assertIsNotNone(match, written) - assert match is not None + workspaces = "" + if inputs is not None: + resolved = run( + [bash_or_skip(), "-c", resolver], + cwd=work, + env={**without_git_location(), **inputs, "GITHUB_OUTPUT": str(output)}, + capture_output=True, + text=True, + encoding="utf-8", + timeout=60, + check=False, + ) + self.assertEqual(0, resolved.returncode, resolved.stdout + resolved.stderr) + written = output.read_text(encoding="utf-8") + match = re.fullmatch(r"workspaces<<(\S+)\n((?:.+\n)*)\1\n", written) + self.assertIsNotNone(match, written) + assert match is not None + workspaces = match.group(2).removesuffix("\n") result = run( [bash_or_skip(), "-c", script], cwd=work, @@ -2589,7 +2595,7 @@ def named_style(*workspaces: str) -> list[str]: **without_git_location(), "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', os.defpath)}", "STUB_LOG": str(log), - "WORKSPACES": match.group(2).removesuffix("\n"), + "WORKSPACES": workspaces, "DOTNET_VERSION": "10.0", }, capture_output=True, @@ -2609,18 +2615,29 @@ def test_validator_dotnet_leg_runs_only_the_projects_declaring_its_line(self) -> """WORKFLOW.md D1.9: a project not declaring the leg's line is skipped by name, and no declarer fails the leg. The step's whole script is run, with the stand-in answering dotnet msbuild from each - project file's content, which stands for its TargetFramework or TargetFrameworks. - A filter that matched a prefix, ignored the plural property, or let an empty selection pass - would fail here as it would on a runner. + project file's TargetFramework|TargetFrameworks content. + Five filter defects fail here as they would on a runner. + They are a prefix match, one property ignored, no trim, no case fold, and an empty selection passing. """ workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") job = workflow.split("\n unit-test-dotnet:\n", 1)[1].split("\n validate:\n", 1)[0] script = step_script_text(job, "Run unit tests step") self.assertIn("-getProperty:TargetFramework -getProperty:TargetFrameworks", script) flags = "--coverage --coverage-output-format cobertura --results-directory ./coverage" - projects = {"A/ATests.csproj": "net10.0", "B/BTests.csproj": "net10.0;net11.0"} + # A declares one framework singularly, B a list, and C a suffixed one beside a spaced, upper-case entry. + projects = { + "A/ATests.csproj": "net10.0|", + "B/BTests.csproj": "|net10.0;net11.0", + "C/CTests.csproj": "|net10.0-windows; NET11.0", + } cases = { - "11.0": (0, [f"test --framework net11.0 --project B/BTests.csproj {flags}"]), + "11.0": ( + 0, + [ + f"test --framework net11.0 --project B/BTests.csproj {flags}", + f"test --framework net11.0 --project C/CTests.csproj {flags}", + ], + ), "10.0": ( 0, [ @@ -2651,32 +2668,31 @@ def test_validator_dotnet_leg_runs_only_the_projects_declaring_its_line(self) -> (work / path).write_text(frameworks, encoding="utf-8") for command in (["git", "init", "-q"], ["git", "add", "."]): run(command, cwd=work, env=without_git_location(), check=True, timeout=60) - # An empty list is the root-solution case, and a named list is the workspace case. - for workspaces in ("", "\n".join(projects)): - log.write_text("", encoding="utf-8") - result = run( - [bash_or_skip(), "-c", script], - cwd=work, - env={ - **without_git_location(), - "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', os.defpath)}", - "STUB_LOG": str(log), - "WORKSPACES": workspaces, - "DOTNET_VERSION": line, - }, - capture_output=True, - text=True, - encoding="utf-8", - timeout=60, - check=False, - ) - output = result.stdout + result.stderr - self.assertEqual(status, result.returncode, output) - self.assertEqual(want, log.read_text(encoding="utf-8").splitlines()) - if status: - self.assertIn(f"::error::No test project declares net{line}", output) - if line == "11.0": - self.assertIn("Skipping A/ATests.csproj", output) + log.write_text("", encoding="utf-8") + result = run( + [bash_or_skip(), "-c", script], + cwd=work, + env={ + **without_git_location(), + "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', os.defpath)}", + "STUB_LOG": str(log), + "DOTNET_VERSION": line, + }, + capture_output=True, + text=True, + encoding="utf-8", + timeout=60, + check=False, + ) + output = result.stdout + result.stderr + self.assertEqual(status, result.returncode, output) + self.assertEqual(want, log.read_text(encoding="utf-8").splitlines()) + if status: + self.assertIn(f"::error::No test project declares net{line}", output) + if line == "11.0": + self.assertIn("Skipping A/ATests.csproj", output) + if line == "10.0": + self.assertIn("Skipping C/CTests.csproj", output) @unittest.skipUnless(shutil.which("jq"), "jq is what the step under test runs") def test_validator_refuses_a_python_versions_value_fromjson_would_admit(self) -> None: @@ -2806,11 +2822,11 @@ def test_audit_bash_blocks_are_not_labeled_as_posix_shell(self) -> None: ) -# Answers the property read the way dotnet msbuild does, from a project file whose content stands for its frameworks. +# Answers the property read the way dotnet msbuild does, from a project file holding TargetFramework|TargetFrameworks. DOTNET_MSBUILD_STAND_IN = ( - 'if [ "$1" = msbuild ]; then fw="$(cat "$2")"; ' - 'printf \'{"Properties":{"TargetFramework":"","TargetFrameworks":"%s"}}\\n\' "${fw:-net10.0}"; ' - "exit 0; fi\n" + 'if [ "$1" = msbuild ]; then fw="$(cat "$2")"; fw="${fw:-|net10.0}"; ' + 'printf \'{"Properties":{"TargetFramework":"%s","TargetFrameworks":"%s"}}\\n\' ' + '"${fw%%|*}" "${fw#*|}"; exit 0; fi\n' ) From aacbb8e0bd4fa87f7c9abdcacb62e0ed00d0d84f Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 3 Dec 2026 10:35:09 -0800 Subject: [PATCH 3/3] Drop a Dangling Case Reference From D1.6 The conditional that "that case" pointed to was removed, so the sentence now states the rule outright. Part of #4609 Co-Authored-By: Claude Sonnet 5.5 --- .agents/skills/workflow-ci-contract/references/d-guarantees.md | 2 +- .../fleet-skills/.source-digests/workflow-ci-contract | 2 +- .../skills/workflow-ci-contract/references/d-guarantees.md | 2 +- .github/skills/workflow-ci-contract/references/d-guarantees.md | 2 +- WORKFLOW.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.agents/skills/workflow-ci-contract/references/d-guarantees.md b/.agents/skills/workflow-ci-contract/references/d-guarantees.md index d379784c7..7496f7a98 100644 --- a/.agents/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.agents/skills/workflow-ci-contract/references/d-guarantees.md @@ -15,7 +15,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.3 Smoke never publishes and never uploads.** Input: `smoke: true`. Output: full compile/lint/test, but no registry/image push, no release, and **no** artifact uploads. Every `upload-artifact`, including any aggregation job, is gated on smoke being false. That gate is written `!inputs.smoke` at the workflow layer and `inputs.smoke != 'true'` in a composite action, whose inputs are strings. *Prevents: a PR publishing, and orphaned artifacts churning the storage quota.* - **D1.4 Workflow-file changes are not smoke-built.** Input: a PR changing only `.github/workflows/**`. Output: the paths-filter marks no target, so smoke-build skips. An inclusion list satisfying D1.1 reaches this by leaving workflow paths out of every target's entry. *Implication: a workflow-only change is not smoke-built, but actionlint still validates it in CI.* - **D1.5 One required aggregator gates merge.** Input: any PR. Output: a single aggregator job must **succeed**. It must run under `if: always()`, so a failed or skipped dependency cannot skip the gate itself. It must also `needs:` the validation job, and the `changes` and `smoke-build` jobs too wherever the repo has a smoke build. It must treat a **skipped** smoke build as pass, and **block** on `failure`/`cancelled`. Its name is ruleset-bound: the job `name:` and the ruleset `context:` are the same string and MUST be renamed together, never independently. The workflow holding it MUST trigger on `pull_request`. A gate without a `pull_request` trigger never runs the validator's pull-request-only steps, the prose gate among them. A workflow any other event also triggers yields that name only when `github.event_name == 'pull_request'`, through an expression `name:`. Otherwise a dispatch or push run on a PR's head posts the required context without the PR run's gates. *Prevents: a paths-filter error letting a target-changing PR merge unbuilt.* -- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* +- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* - **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* diff --git a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract index 8ebcc94c6..9c48c68be 100644 --- a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract +++ b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract @@ -1 +1 @@ -1095f19d684ee256 +75fec62441fc8729 diff --git a/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md b/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md index d379784c7..7496f7a98 100644 --- a/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/d-guarantees.md @@ -15,7 +15,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.3 Smoke never publishes and never uploads.** Input: `smoke: true`. Output: full compile/lint/test, but no registry/image push, no release, and **no** artifact uploads. Every `upload-artifact`, including any aggregation job, is gated on smoke being false. That gate is written `!inputs.smoke` at the workflow layer and `inputs.smoke != 'true'` in a composite action, whose inputs are strings. *Prevents: a PR publishing, and orphaned artifacts churning the storage quota.* - **D1.4 Workflow-file changes are not smoke-built.** Input: a PR changing only `.github/workflows/**`. Output: the paths-filter marks no target, so smoke-build skips. An inclusion list satisfying D1.1 reaches this by leaving workflow paths out of every target's entry. *Implication: a workflow-only change is not smoke-built, but actionlint still validates it in CI.* - **D1.5 One required aggregator gates merge.** Input: any PR. Output: a single aggregator job must **succeed**. It must run under `if: always()`, so a failed or skipped dependency cannot skip the gate itself. It must also `needs:` the validation job, and the `changes` and `smoke-build` jobs too wherever the repo has a smoke build. It must treat a **skipped** smoke build as pass, and **block** on `failure`/`cancelled`. Its name is ruleset-bound: the job `name:` and the ruleset `context:` are the same string and MUST be renamed together, never independently. The workflow holding it MUST trigger on `pull_request`. A gate without a `pull_request` trigger never runs the validator's pull-request-only steps, the prose gate among them. A workflow any other event also triggers yields that name only when `github.event_name == 'pull_request'`, through an expression `name:`. Otherwise a dispatch or push run on a PR's head posts the required context without the PR run's gates. *Prevents: a paths-filter error letting a target-changing PR merge unbuilt.* -- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* +- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* - **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* diff --git a/.github/skills/workflow-ci-contract/references/d-guarantees.md b/.github/skills/workflow-ci-contract/references/d-guarantees.md index d379784c7..7496f7a98 100644 --- a/.github/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.github/skills/workflow-ci-contract/references/d-guarantees.md @@ -15,7 +15,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.3 Smoke never publishes and never uploads.** Input: `smoke: true`. Output: full compile/lint/test, but no registry/image push, no release, and **no** artifact uploads. Every `upload-artifact`, including any aggregation job, is gated on smoke being false. That gate is written `!inputs.smoke` at the workflow layer and `inputs.smoke != 'true'` in a composite action, whose inputs are strings. *Prevents: a PR publishing, and orphaned artifacts churning the storage quota.* - **D1.4 Workflow-file changes are not smoke-built.** Input: a PR changing only `.github/workflows/**`. Output: the paths-filter marks no target, so smoke-build skips. An inclusion list satisfying D1.1 reaches this by leaving workflow paths out of every target's entry. *Implication: a workflow-only change is not smoke-built, but actionlint still validates it in CI.* - **D1.5 One required aggregator gates merge.** Input: any PR. Output: a single aggregator job must **succeed**. It must run under `if: always()`, so a failed or skipped dependency cannot skip the gate itself. It must also `needs:` the validation job, and the `changes` and `smoke-build` jobs too wherever the repo has a smoke build. It must treat a **skipped** smoke build as pass, and **block** on `failure`/`cancelled`. Its name is ruleset-bound: the job `name:` and the ruleset `context:` are the same string and MUST be renamed together, never independently. The workflow holding it MUST trigger on `pull_request`. A gate without a `pull_request` trigger never runs the validator's pull-request-only steps, the prose gate among them. A workflow any other event also triggers yields that name only when `github.event_name == 'pull_request'`, through an expression `name:`. Otherwise a dispatch or push run on a PR's head posts the required context without the PR run's gates. *Prevents: a paths-filter error letting a target-changing PR merge unbuilt.* -- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* +- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* - **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.* diff --git a/WORKFLOW.md b/WORKFLOW.md index 119fd07f2..e42103b7c 100644 --- a/WORKFLOW.md +++ b/WORKFLOW.md @@ -144,7 +144,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output - **D1.3 Smoke never publishes and never uploads.** Input: `smoke: true`. Output: full compile/lint/test, but no registry/image push, no release, and **no** artifact uploads. Every `upload-artifact`, including any aggregation job, is gated on smoke being false. That gate is written `!inputs.smoke` at the workflow layer and `inputs.smoke != 'true'` in a composite action, whose inputs are strings. *Prevents: a PR publishing, and orphaned artifacts churning the storage quota.* - **D1.4 Workflow-file changes are not smoke-built.** Input: a PR changing only `.github/workflows/**`. Output: the paths-filter marks no target, so smoke-build skips. An inclusion list satisfying D1.1 reaches this by leaving workflow paths out of every target's entry. *Implication: a workflow-only change is not smoke-built, but actionlint still validates it in CI.* - **D1.5 One required aggregator gates merge.** Input: any PR. Output: a single aggregator job must **succeed**. It must run under `if: always()`, so a failed or skipped dependency cannot skip the gate itself. It must also `needs:` the validation job, and the `changes` and `smoke-build` jobs too wherever the repo has a smoke build. It must treat a **skipped** smoke build as pass, and **block** on `failure`/`cancelled`. Its name is ruleset-bound: the job `name:` and the ruleset `context:` are the same string and MUST be renamed together, never independently. The workflow holding it MUST trigger on `pull_request`. A gate without a `pull_request` trigger never runs the validator's pull-request-only steps, the prose gate among them. A workflow any other event also triggers yields that name only when `github.event_name == 'pull_request'`, through an expression `name:`. Otherwise a dispatch or push run on a PR's head posts the required context without the PR run's gates. *Prevents: a paths-filter error letting a target-changing PR merge unbuilt.* -- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution in that case, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* +- **D1.6 Coverage is reported to Codecov (C# and Python).** Input: a C# or Python repo that has tests for that type. Output: the validation job runs those tests under coverage collection, and a `codecov/codecov-action` step uploads the report. The collection is `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, leaving `--coverage-output` unset so each test project writes its own report rather than overwriting a shared one. A bare call resolves one workspace from the working directory, so it fails at a root holding none or more than one. The hub's validator therefore runs the collection once per tracked `*Tests*.csproj` that declares the leg's line, with `--project`, whatever the root holds. A test project left out of a root solution, or a library whose name matches the glob, is therefore a test project here. It names no solution, since a solution holding no test project fails the run. Or it is `pytest --cov-report=xml` in a Python directory with its own `uv.lock` or `requirements*.txt`, whose own `pyproject.toml` selects what to measure. Or it is `coverage run -m unittest discover -s tests` then `coverage xml` in a `lint-only` one. The upload is **best-effort** (`continue-on-error` and/or `fail_ci_if_error: false`), so a Codecov outage or an absent token never reds the gate. Each leg **fails its test step when the run wrote no report**. The reason is that the best-effort upload reads a missing report exactly as it reads a healthy run. A second reason is that, on the Python leg, `--cov-report=xml` alone selects nothing to measure. The C# leg renames each report to `coverage-.cobertura.xml` before the upload step reads the directory, since `codecov-cli`'s own finder does not match the default name. A repo owning its validator rather than calling the hub's owes that rename itself. `CODECOV_TOKEN` lives in the repo's **actions** and **dependabot** secret stores. The token is in the second because a run triggered by a Dependabot pull request reads the Dependabot store. Without the token there, the upload would otherwise skip silently on every bot pull request. A caller reaching the reusable validator across repositories names the secret it passes (`secrets:` with `CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}`). It does so on its pull request path and its publisher path alike. That is because `secrets: inherit` is documented for a caller in the same organization or enterprise, which a personal account is not. A call by local path stays inside one repository, where the caller's own store is the one the callee reads. So `secrets: inherit` is available there instead of naming each secret. The repo ships a **`.codecov.yml`** at the repository root. It sets the project and patch statuses to **`informational: true`**, so a coverage delta never gates a pull request. A repo whose quality bar requires a threshold may turn that off. The same file excludes intentionally-untested, non-shipped code (an example or benchmark project) from the denominator via `ignore`. Codecov reads its configuration under several names, but `.codecov.yml` is the only one the fleet accepts. So a copy under any other name is drift to rename. Coverage output is a build artifact, so `.gitignore` excludes it. The C# invocation runs under **Microsoft.Testing.Platform**, and the runner declaration, package references, and version floor an MTP-based test project needs are `CODESTYLE.md`'s .NET side. The Python invocation needs **`pytest-cov`** and a coverage selector, which are `CODESTYLE.md`'s Python side. A Python directory declared in the validator's `python-directories` input owes a `tests/` suite whatever its profile, so the validator fails one that has none. N/A for a repo carrying no tests for that type. *Prevents: coverage silently going unreported, and a coverage regression blocking an unrelated pull request.* - **D1.7 A built NuGet package is consumed before it publishes.** Input: a repo whose `build-nuget` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf packs, the job restores, builds, and runs a throwaway console project against that exact `.nupkg`. It does so once per target framework the project declares. Each consumer lives outside the checkout, so the caller's `global.json` and `Directory.Build.props` do not apply. Its `nuget.config` resolves the package ID, and the ID of each sibling package in the folder holding the build output, only from that folder. Every other ID resolves from nuget.org. Its package cache is its own, so neither a cached nor a published copy can stand in for the artifact under test. The consumer loads the package assembly and calls `GetExportedTypes()`. The check asserts from `obj/project.assets.json` that the package resolved from the `lib//` folder of the consumer's own framework. It also asserts that the loaded assembly's `TargetFrameworkAttribute` matches that folder. A `netstandard` framework is consumed under the SDK line `global.json` selects, or the newest declared line where there is none. It is asserted against the folder it resolved. A framework the check does not consume is reported skipped. Examples are .NET Framework, `netcoreapp3.1`, and a platform-specific `netX.Y-windows`. The attribute row of a `netstandard` consumer resolving such a folder is skipped too. Four static assertions join them. The package's `lib//` folders equal the declared frameworks. The nuspec `` equals the build version. The nuspec holds a dependency group per framework. A symbol package exists where the project enables symbols. Every declared `netX.Y` and `netstandard` framework is consumed and reported with one summary row per assertion. A failed step ends that framework's rows rather than the run. The job fails at the end if any failed. The check covers a library package, whose assemblies sit under `lib//`. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-nuget` hook replaces the whole leaf and is outside the check. A caller's own `.github/actions/package-consume/action.yml` runs once after the default check. It receives the declared frameworks as JSON beside the package ID, version, and package folder. *Prevents: a defect that exists only in the packed form shipping. One example is one target framework's assembly packed under every `lib//` folder while the tests, which reach the library through a project reference, stay green.* - **D1.8 A built PyPI package is consumed before it publishes.** Input: a repo whose `build-pypi` job runs the hub's default leaf, in a smoke run or a publish run alike. Output: after the leaf builds, the job installs the wheel and, separately, the sdist into a fresh `uv venv`. It does so for each line of the `python-versions` input of `build-release-task.yml`. Empty runs the one line the root `.python-version` selects. Where there is none it runs the hub's fallback line. A caller that sets `python-versions` for both `validate-task.yml` and `build-release-task.yml` passes the same value to each. So the lines its tests run under are the lines its artifact is consumed under. Each environment lives outside the checkout. It installs the artifact, then the project's locked dependency groups from `uv.lock` without the project itself. The check asserts that `importlib.metadata` reports the version the leaf computed. It also asserts that every top-level name the installed distribution provides imports from the environment's site-packages, not the source tree. A distribution providing none, such as one of scripts only, reports that row skipped. It then runs the caller's `tests/` folder against the installed copy with pytest in `importlib` import mode. That run has the source tree off `sys.path` and the project's `pythonpath` setting cleared. Its working directory is outside the project. So the caller's suite must not read a path relative to the project root, or a tool setting read from the working directory. It must import a sibling helper as part of a package. The project directory holds its own `uv.lock`. A project with no `tests/` folder, or a run collecting no tests, is reported skipped rather than passed. Every line and artifact reports one summary row per assertion. A failed environment, install, or metadata read ends that artifact's rows rather than the run. The job fails at the end if any failed. The check uploads nothing, so it honors D1.3. It runs inside the build job, so a failure blocks the publish job that `needs:` that build. A caller's own `build-pypi` hook replaces the whole leaf and is outside the check. *Prevents: a defect that exists only in the built form shipping. One example is a module left out of the wheel while the tests, which import it from the source tree, stay green.* - **D1.9 Each declared test line runs as its own named unit-test leg.** Input: a repo declaring .NET lines in `dotnet-versions` of `validate-task.yml`, Python lines in `python-versions`, or both. Output: each declared .NET line runs as a `Unit test job (.NET X.Y)` leg running `dotnet test --framework netX.Y` under that line's runtime. A leg runs only the tracked `*Tests*.csproj` projects declaring `netX.Y` in their `TargetFramework` or `TargetFrameworks`, read with `dotnet msbuild`, and skips and names the rest. A leg where no test project declares its line fails, so a declared line never passes by running nothing. Each declared Python line runs as a `Unit test job (Python X.Y)` leg, or as the caller's named `test-matrix` legs where it sets one. A caller declaring neither runs the one line each of `global.json` and `.python-version` selects. The hub's fallback line stands in where a file is absent. The .NET legs run only where a `*Tests*.csproj` exists. The Python legs run only where a Python directory resolves. So a repo holding one kind reports no leg of the other. Each leg uploads its own coverage report, and the .NET upload carries a per-line flag beside `dotnet`. A failing leg does not cancel its siblings. *Prevents: a failing target framework or interpreter hiding inside a combined run naming none of them. A .NET-only repo reporting a Python line it never ran is the other.*