From 1a4ed932d8ffb5a8abeb90ee6a5a47cc111f20d6 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 3 Dec 2026 06:51:21 -0800 Subject: [PATCH 1/5] Run Each .NET Line as Its Own Unit Test Leg Split the .NET half out of the Python unit-test job into unit-test-dotnet, one leg per declared line running dotnet test --framework netX.Y. The Python job skips when no Python directory resolves. Co-Authored-By: Claude Sonnet 5.5 --- .agents/skills/dotnet-codestyle/SKILL.md | 6 +- .../references/d-guarantees.md | 1 + .../references/test-methodology.md | 2 + .../.source-digests/dotnet-codestyle | 2 +- .../.source-digests/workflow-ci-contract | 2 +- .../skills/dotnet-codestyle/SKILL.md | 6 +- .../references/d-guarantees.md | 1 + .../references/test-methodology.md | 2 + .github/actions/dotnet-sdk/action.yml | 16 ++ .github/skills/dotnet-codestyle/SKILL.md | 6 +- .../references/d-guarantees.md | 1 + .../references/test-methodology.md | 2 + .github/workflows/validate-task.yml | 192 ++++++++++-------- WORKFLOW.md | 3 + docs/reusable-workflows.md | 8 +- spec/project-types.json | 2 +- tests/test_release_guards.py | 170 ++++++++++++---- 17 files changed, 289 insertions(+), 133 deletions(-) diff --git a/.agents/skills/dotnet-codestyle/SKILL.md b/.agents/skills/dotnet-codestyle/SKILL.md index 873b071fe..a26a19ae0 100644 --- a/.agents/skills/dotnet-codestyle/SKILL.md +++ b/.agents/skills/dotnet-codestyle/SKILL.md @@ -127,9 +127,9 @@ Shared MSBuild configuration is centralized at the repository root, never duplic sets a singular `TargetFramework`, the multi-targeted `.csproj` clears it, since a singular value wins and builds one framework only. Its test projects run each framework under that framework's own runtime. So the repository passes the hub's `validate-task.yml` a `dotnet-versions` input - naming every line, the `global.json` line first, such as `'["11.0", "10.0"]'`. That installs - each line beside the selected one in the one unit-test job. An entry leading with another line - fails the run. + naming every line, the `global.json` line first, such as `'["11.0", "10.0"]'`. Each line then + runs as its own unit-test leg, with every line installed beside the selected one. An entry + leading with another line fails the run. A developer host now needs a release SDK on the repository's line, 10.0.x for the fleet default today. A host holding only another major, or only a 10.0 preview, fails with a clear error. It diff --git a/.agents/skills/workflow-ci-contract/references/d-guarantees.md b/.agents/skills/workflow-ci-contract/references/d-guarantees.md index e4a37f852..b339d4ba1 100644 --- a/.agents/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.agents/skills/workflow-ci-contract/references/d-guarantees.md @@ -18,6 +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. 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/.agents/skills/workflow-ci-contract/references/test-methodology.md b/.agents/skills/workflow-ci-contract/references/test-methodology.md index 2e88b46d5..3dddec7d4 100644 --- a/.agents/skills/workflow-ci-contract/references/test-methodology.md +++ b/.agents/skills/workflow-ci-contract/references/test-methodology.md @@ -18,6 +18,8 @@ D1.7 is read in the build job. A step after the default leaf plans the declared D1.8 is read in the build job. A step after the default leaf runs the consume check. It receives the build's computed version and the `python-versions` list. Empty becomes the one line the root `.python-version` selects, or the hub's fallback line where there is none. It uploads nothing. +D1.9 is read in the validate task's job list. The `Build test matrix job` outputs one matrix per kind, and each unit-test job's `matrix` reads its output. The .NET job's `dotnet test` carries `--framework` for its matrix line, and the Python job holds no .NET step. Each job's `if:` reads the output that says its kind exists. + Cite what each verdict rests on. That is `file:line` for a file in the audited repo. It is the evidence's own name where a setting, a ruleset, or a secret name rather than a file is the evidence. Where the guarantee binds a workflow or composite action the audited repo only reaches, it is `/@` plus the `file:line` in that repo. The callee is read at the SHA the caller pins. An **N/A** verdict names the absent construct instead, there being no line to cite. ### 5B. End-to-End Trace Scenarios (No Execution, Deterministic from the YAML) diff --git a/.claude-plugin/fleet-skills/.source-digests/dotnet-codestyle b/.claude-plugin/fleet-skills/.source-digests/dotnet-codestyle index 808eb791a..0e2bb1f4c 100644 --- a/.claude-plugin/fleet-skills/.source-digests/dotnet-codestyle +++ b/.claude-plugin/fleet-skills/.source-digests/dotnet-codestyle @@ -1 +1 @@ -4220137c3ae914a3 +f3639b6ba86a32a6 diff --git a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract index fd526bce3..cad0e7ec9 100644 --- a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract +++ b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract @@ -1 +1 @@ -23c6a153a42f8126 +e912db9d42d76e8d diff --git a/.claude-plugin/fleet-skills/skills/dotnet-codestyle/SKILL.md b/.claude-plugin/fleet-skills/skills/dotnet-codestyle/SKILL.md index 873b071fe..a26a19ae0 100644 --- a/.claude-plugin/fleet-skills/skills/dotnet-codestyle/SKILL.md +++ b/.claude-plugin/fleet-skills/skills/dotnet-codestyle/SKILL.md @@ -127,9 +127,9 @@ Shared MSBuild configuration is centralized at the repository root, never duplic sets a singular `TargetFramework`, the multi-targeted `.csproj` clears it, since a singular value wins and builds one framework only. Its test projects run each framework under that framework's own runtime. So the repository passes the hub's `validate-task.yml` a `dotnet-versions` input - naming every line, the `global.json` line first, such as `'["11.0", "10.0"]'`. That installs - each line beside the selected one in the one unit-test job. An entry leading with another line - fails the run. + naming every line, the `global.json` line first, such as `'["11.0", "10.0"]'`. Each line then + runs as its own unit-test leg, with every line installed beside the selected one. An entry + leading with another line fails the run. A developer host now needs a release SDK on the repository's line, 10.0.x for the fleet default today. A host holding only another major, or only a 10.0 preview, fails with a clear error. It 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 e4a37f852..b339d4ba1 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,6 +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. 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/skills/workflow-ci-contract/references/test-methodology.md b/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/test-methodology.md index 2e88b46d5..3dddec7d4 100644 --- a/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/test-methodology.md +++ b/.claude-plugin/fleet-skills/skills/workflow-ci-contract/references/test-methodology.md @@ -18,6 +18,8 @@ D1.7 is read in the build job. A step after the default leaf plans the declared D1.8 is read in the build job. A step after the default leaf runs the consume check. It receives the build's computed version and the `python-versions` list. Empty becomes the one line the root `.python-version` selects, or the hub's fallback line where there is none. It uploads nothing. +D1.9 is read in the validate task's job list. The `Build test matrix job` outputs one matrix per kind, and each unit-test job's `matrix` reads its output. The .NET job's `dotnet test` carries `--framework` for its matrix line, and the Python job holds no .NET step. Each job's `if:` reads the output that says its kind exists. + Cite what each verdict rests on. That is `file:line` for a file in the audited repo. It is the evidence's own name where a setting, a ruleset, or a secret name rather than a file is the evidence. Where the guarantee binds a workflow or composite action the audited repo only reaches, it is `/@` plus the `file:line` in that repo. The callee is read at the SHA the caller pins. An **N/A** verdict names the absent construct instead, there being no line to cite. ### 5B. End-to-End Trace Scenarios (No Execution, Deterministic from the YAML) diff --git a/.github/actions/dotnet-sdk/action.yml b/.github/actions/dotnet-sdk/action.yml index 5237f573c..4e00d8554 100644 --- a/.github/actions/dotnet-sdk/action.yml +++ b/.github/actions/dotnet-sdk/action.yml @@ -16,6 +16,11 @@ inputs: required: false default: 'true' +outputs: + lines: + description: JSON array of the X.Y lines the caller's tests run under, the versions input where set, else the one line global.json selects, else the fallback line as X.0. + value: ${{ steps.sdk-line.outputs.lines }} + runs: using: composite steps: @@ -68,6 +73,16 @@ runs: sdk = document.get("sdk") selected = isinstance(sdk, dict) and isinstance(sdk.get("version"), str) extra = lines + # The lines a caller tests under, one dotnet test leg each, are the entries it names, else the one line global.json selects, else the fallback. + reported = lines + if not lines and selected: + line = re.match(r"[0-9]+\.[0-9]+", sdk["version"]) + if line is None: + print("::error::The global.json sdk.version must start with an X.Y line, such as 10.0.100.") + sys.exit(1) + reported = [line.group(0)] + elif not lines: + reported = [fallback.replace(".x", ".0")] if selected and lines: line = re.match(r"[0-9]+\.[0-9]+", sdk["version"]) if line is None or lines[0] != line.group(0): @@ -75,6 +90,7 @@ runs: sys.exit(1) extra = lines[1:] with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output: + output.write("lines=" + json.dumps(reported) + "\n") if selected: output.write("global-json-file=global.json\n") if extra: diff --git a/.github/skills/dotnet-codestyle/SKILL.md b/.github/skills/dotnet-codestyle/SKILL.md index 873b071fe..a26a19ae0 100644 --- a/.github/skills/dotnet-codestyle/SKILL.md +++ b/.github/skills/dotnet-codestyle/SKILL.md @@ -127,9 +127,9 @@ Shared MSBuild configuration is centralized at the repository root, never duplic sets a singular `TargetFramework`, the multi-targeted `.csproj` clears it, since a singular value wins and builds one framework only. Its test projects run each framework under that framework's own runtime. So the repository passes the hub's `validate-task.yml` a `dotnet-versions` input - naming every line, the `global.json` line first, such as `'["11.0", "10.0"]'`. That installs - each line beside the selected one in the one unit-test job. An entry leading with another line - fails the run. + naming every line, the `global.json` line first, such as `'["11.0", "10.0"]'`. Each line then + runs as its own unit-test leg, with every line installed beside the selected one. An entry + leading with another line fails the run. A developer host now needs a release SDK on the repository's line, 10.0.x for the fleet default today. A host holding only another major, or only a 10.0 preview, fails with a clear error. It diff --git a/.github/skills/workflow-ci-contract/references/d-guarantees.md b/.github/skills/workflow-ci-contract/references/d-guarantees.md index e4a37f852..b339d4ba1 100644 --- a/.github/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.github/skills/workflow-ci-contract/references/d-guarantees.md @@ -18,6 +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. 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/skills/workflow-ci-contract/references/test-methodology.md b/.github/skills/workflow-ci-contract/references/test-methodology.md index 2e88b46d5..3dddec7d4 100644 --- a/.github/skills/workflow-ci-contract/references/test-methodology.md +++ b/.github/skills/workflow-ci-contract/references/test-methodology.md @@ -18,6 +18,8 @@ D1.7 is read in the build job. A step after the default leaf plans the declared D1.8 is read in the build job. A step after the default leaf runs the consume check. It receives the build's computed version and the `python-versions` list. Empty becomes the one line the root `.python-version` selects, or the hub's fallback line where there is none. It uploads nothing. +D1.9 is read in the validate task's job list. The `Build test matrix job` outputs one matrix per kind, and each unit-test job's `matrix` reads its output. The .NET job's `dotnet test` carries `--framework` for its matrix line, and the Python job holds no .NET step. Each job's `if:` reads the output that says its kind exists. + Cite what each verdict rests on. That is `file:line` for a file in the audited repo. It is the evidence's own name where a setting, a ruleset, or a secret name rather than a file is the evidence. Where the guarantee binds a workflow or composite action the audited repo only reaches, it is `/@` plus the `file:line` in that repo. The callee is read at the SHA the caller pins. An **N/A** verdict names the absent construct instead, there being no line to cite. ### 5B. End-to-End Trace Scenarios (No Execution, Deterministic from the YAML) diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index 54985abb4..dd0550efe 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 the one unit-test job, whose dotnet test runs each target framework under its own runtime, so it adds no matrix leg. 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. 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: '' @@ -70,15 +70,16 @@ jobs: matrix: ${{ steps.build.outputs.matrix }} legs: ${{ steps.check.outputs.legs }} versions: ${{ steps.build.outputs.versions }} + dotnet-matrix: ${{ steps.build.outputs.dotnet-matrix }} + dotnet-tests: ${{ steps.build.outputs.dotnet-tests }} + python-any: ${{ steps.python-directories.outputs.any }} steps: + # The whole tree is read, since the job reports whether a test project and a Python directory exist at all. - name: Checkout code step - if: ${{ inputs.test-matrix-file != '' || inputs.python-versions == '' || inputs.dotnet-versions != '' }} uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - sparse-checkout: ${{ inputs.test-matrix-file == '' && fromJSON('"/.python-version\n/global.json"') || '' }} - sparse-checkout-cone-mode: false # This job cannot tell whether the caller holds Python, so the lint job, which can, warns of a fallback instead. - name: Select Python version step @@ -88,13 +89,21 @@ jobs: with: warn: 'false' + # The action validates the input and reports the lines the .NET legs run, installing nothing here. - name: Validate dotnet-versions input step - if: ${{ inputs.dotnet-versions != '' }} + id: dotnet-sdk uses: $/.github/actions/dotnet-sdk with: versions: ${{ inputs.dotnet-versions }} install: 'false' + # The job-level condition of the Python job cannot read the tree, so the resolved answer travels as an output. + - name: Resolve Python directories step + id: python-directories + uses: $/.github/actions/python-directories + with: + directories: ${{ inputs.python-directories }} + # Either input lands in one file here, so the check below and the build step read the same bytes whichever input the caller set. - name: Validate test-matrix input step id: check @@ -172,6 +181,8 @@ jobs: env: LEGS: ${{ steps.check.outputs.legs }} PYTHON_VERSIONS: ${{ inputs.python-versions || format('["{0}"]', steps.python-version.outputs.version) }} + DOTNET_LINES: ${{ steps.dotnet-sdk.outputs.lines }} + DOTNET_TESTS: ${{ hashFiles('**/*Tests*.csproj') != '' }} run: | set -Eeuo pipefail if [[ "$LEGS" == "true" ]]; then @@ -179,8 +190,12 @@ jobs: else matrix=$(jq -c --argjson versions "$PYTHON_VERSIONS" -n '{"python-version": $versions}') fi - echo "matrix=$matrix" >> "$GITHUB_OUTPUT" - echo "versions=$(jq -c . <<< "$PYTHON_VERSIONS")" >> "$GITHUB_OUTPUT" + { + echo "matrix=$matrix" + echo "versions=$(jq -c . <<< "$PYTHON_VERSIONS")" + echo "dotnet-matrix=$(jq -c -n --argjson lines "$DOTNET_LINES" '{"dotnet-version": $lines}')" + echo "dotnet-tests=$DOTNET_TESTS" + } >> "$GITHUB_OUTPUT" lint: name: Lint sources job @@ -832,23 +847,16 @@ jobs: echo "The branching-and-release-model skill's references/branch-protection-and-promotion.md states the cut." exit 1 - # No job-level if: here, since GitHub Actions does not evaluate hashFiles in a job condition, only a step one. - # Every step below carries its own guard instead, a tree-detection one on the .NET half and the resolved Python directories on the Python half. - # A caller with no *Tests*.csproj and no Python directory runs every guard false. - # The job reports success having done nothing, which is the clean skip this job promises. - # See D1.6 for a declared Python directory with no tests/. - # See D1.2 for the undeclared root. + # A job-level if: cannot read the tree, so the Python directories are resolved in the test-matrix job and read here as an output. + # A .NET-only caller therefore reports no Python leg at all. # The matrix dimension is the interpreter, or the test-matrix leg when either matrix input is set. # A caller naming neither runs the single leg this job ran before the input existed. - # A python-versions leg names an interpreter whether or not one ran. - # So a .NET-only caller reports a Python version its Python steps never used. - # A caller naming several also repeats this job's .NET half once per leg. - # That spends runner minutes and re-uploads an identical report rather than measuring anything new. - # Splitting the two halves into jobs of their own is what that costs. - # The first repo to carry both a .NET test project and more than one interpreter owes it. + # See D1.6 for a declared Python directory with no tests/. + # See D1.2 for the undeclared root. unit-test: name: Unit test job (${{ matrix.label || format('Python {0}', matrix.python-version) }}) needs: test-matrix + if: ${{ needs.test-matrix.outputs.python-any == 'true' }} runs-on: ubuntu-latest permissions: contents: read @@ -875,68 +883,6 @@ jobs: exit 1 fi - # A system tool a .NET test shells out to must reach the runner before the tests, which no later hook can do. - - name: Run caller pre-test hook step - if: hashFiles('**/*Tests*.csproj') != '' && hashFiles('.github/actions/pre-test/action.yml') != '' - uses: ./.github/actions/pre-test - - # The caller's global.json selects the SDK line, or the dotnet-sdk action's fallback line where it carries none yet. - - name: Setup .NET SDK step - if: hashFiles('**/*Tests*.csproj') != '' - uses: $/.github/actions/dotnet-sdk - 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 }} - 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. - if [ -z "$WORKSPACES" ]; then - dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage - fi - while IFS= read -r workspace; do - [ -n "$workspace" ] || continue - dotnet test --project "$workspace" --coverage --coverage-output-format cobertura --results-directory ./coverage < /dev/null - done <<< "$WORKSPACES" - written=0 - for report in ./coverage/*.cobertura.xml; do - [ -e "$report" ] || continue - renamed="./coverage/coverage-$(basename "$report")" - mv "$report" "$renamed" - if [ -s "$renamed" ]; then - written=1 - fi - done - if [ "$written" -eq 0 ]; then - echo "::error::This run wrote no non-empty Cobertura report under ./coverage. Reference Microsoft.Testing.Extensions.CodeCoverage from each test project, per CODESTYLE.md's .NET side." - exit 1 - fi - - # Report-only: fail_ci_if_error is false so a Codecov hiccup or an absent token never fails the gate. - - name: Upload coverage to Codecov step - if: hashFiles('**/*Tests*.csproj') != '' - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 - with: - directory: ./coverage - flags: dotnet - fail_ci_if_error: false - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - name: Resolve Python directories step id: python uses: $/.github/actions/python-directories @@ -1095,6 +1041,90 @@ jobs: flags: python-${{ matrix.label || matrix.python-version }} fail_ci_if_error: false + # One leg per .NET line, so a failing target framework names itself rather than hiding in a combined run. + # The job-level if: reads the test-matrix job's tree detection, since a job condition cannot call hashFiles. + unit-test-dotnet: + name: Unit test job (.NET ${{ matrix.dotnet-version }}) + needs: test-matrix + if: ${{ needs.test-matrix.outputs.dotnet-tests == 'true' }} + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + # A failing framework must not cancel its siblings, since which of them fail is the whole point of running more than one. + fail-fast: false + matrix: ${{ fromJSON(needs.test-matrix.outputs.dotnet-matrix) }} + + steps: + + - name: Checkout code step + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + # A system tool a .NET test shells out to must reach the runner before the tests, which no later hook can do. + - name: Run caller pre-test hook step + if: hashFiles('**/*Tests*.csproj') != '' && hashFiles('.github/actions/pre-test/action.yml') != '' + uses: ./.github/actions/pre-test + + # The caller's global.json selects the SDK line, or the dotnet-sdk action's fallback line where it carries none yet. + - name: Setup .NET SDK step + if: hashFiles('**/*Tests*.csproj') != '' + uses: $/.github/actions/dotnet-sdk + 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. + if [ -z "$WORKSPACES" ]; then + dotnet test --framework "net$DOTNET_VERSION" --coverage --coverage-output-format cobertura --results-directory ./coverage + 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" + written=0 + for report in ./coverage/*.cobertura.xml; do + [ -e "$report" ] || continue + renamed="./coverage/coverage-$(basename "$report")" + mv "$report" "$renamed" + if [ -s "$renamed" ]; then + written=1 + fi + done + if [ "$written" -eq 0 ]; then + echo "::error::This run wrote no non-empty Cobertura report under ./coverage. Reference Microsoft.Testing.Extensions.CodeCoverage from each test project, per CODESTYLE.md's .NET side." + exit 1 + fi + + # Report-only: fail_ci_if_error is false so a Codecov hiccup or an absent token never fails the gate. + - name: Upload coverage to Codecov step + if: hashFiles('**/*Tests*.csproj') != '' + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 + with: + directory: ./coverage + flags: dotnet,dotnet-${{ matrix.dotnet-version }} + fail_ci_if_error: false + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + validate: name: Validate repository job runs-on: ubuntu-latest diff --git a/WORKFLOW.md b/WORKFLOW.md index 6bfd15ce0..8111fa577 100644 --- a/WORKFLOW.md +++ b/WORKFLOW.md @@ -146,6 +146,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. 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 @@ -229,6 +230,8 @@ D1.7 is read in the build job. A step after the default leaf plans the declared D1.8 is read in the build job. A step after the default leaf runs the consume check. It receives the build's computed version and the `python-versions` list. Empty becomes the one line the root `.python-version` selects, or the hub's fallback line where there is none. It uploads nothing. +D1.9 is read in the validate task's job list. The `Build test matrix job` outputs one matrix per kind, and each unit-test job's `matrix` reads its output. The .NET job's `dotnet test` carries `--framework` for its matrix line, and the Python job holds no .NET step. Each job's `if:` reads the output that says its kind exists. + Cite what each verdict rests on. That is `file:line` for a file in the audited repo. It is the evidence's own name where a setting, a ruleset, or a secret name rather than a file is the evidence. Where the guarantee binds a workflow or composite action the audited repo only reaches, it is `/@` plus the `file:line` in that repo. The callee is read at the SHA the caller pins. An **N/A** verdict names the absent construct instead, there being no line to cite. ### 5B. End-to-End Trace Scenarios (No Execution, Deterministic from the YAML) diff --git a/docs/reusable-workflows.md b/docs/reusable-workflows.md index 57a98124e..b3d8f39b0 100644 --- a/docs/reusable-workflows.md +++ b/docs/reusable-workflows.md @@ -155,7 +155,7 @@ Adoptable since `2.0.338`. Each repo replaces the whole of its `.github/workflow ### Stage 2: The Gates -Hub: `validate-task.yml` hosts a `lint` job (the fleet doc-lint block, language lint by tree detection, the prose gate, and the repo gate). It also hosts a generic `unit-test` job. That job runs a `dotnet test`, and a `pytest` or `unittest` suite under coverage in each Python directory. The job skips cleanly where the caller carries no test project. It fails a declared Python directory that has none. The task also hosts a `validate` job resolving the `validate` hook for a repo's own domain checks. The `lint` and `unit-test` jobs decide #729 in their `uvx` tool steps. There is no `test-pull-request-task.yml`: the ruleset-bound aggregator stays in the caller stub by design. A task wrapping one line that calls `validate-task.yml` hosts nothing generic, so the stub shapes live in [Adopting the Gates][adopting-the-gates] instead. The trigger shape, operational or release, settles #585 in that same section. This stage is where the hook fallback is first proven live. The hub carries its own `validate` hook. So a hub pull request exercises the override path. That hook is the hub's registry and spec check, script self-tests, fleet-skills check, and unclassified-character report. A repo with no hook of its own exercises the default. The repo gate also shellchecks and schema-checks every composite action under `.github/actions/`, so a downstream repo gets that check at its next pin bump. +Hub: `validate-task.yml` hosts a `lint` job (the fleet doc-lint block, language lint by tree detection, the prose gate, and the repo gate). It also hosts a `unit-test` job per kind. The `unit-test-dotnet` job runs a `dotnet test` per .NET line, and the `unit-test` job runs a `pytest` or `unittest` suite under coverage in each Python directory. Each skips cleanly where the caller carries no project of its kind. The Python job fails a declared Python directory that has no tests. The task also hosts a `validate` job resolving the `validate` hook for a repo's own domain checks. The `lint` and `unit-test` jobs decide #729 in their `uvx` tool steps. There is no `test-pull-request-task.yml`: the ruleset-bound aggregator stays in the caller stub by design. A task wrapping one line that calls `validate-task.yml` hosts nothing generic, so the stub shapes live in [Adopting the Gates][adopting-the-gates] instead. The trigger shape, operational or release, settles #585 in that same section. This stage is where the hook fallback is first proven live. The hub carries its own `validate` hook. So a hub pull request exercises the override path. That hook is the hub's registry and spec check, script self-tests, fleet-skills check, and unclassified-character report. A repo with no hook of its own exercises the default. The repo gate also shellchecks and schema-checks every composite action under `.github/actions/`, so a downstream repo gets that check at its next pin bump. - [x] Hub pull request on `develop` with the task, the hub's own hook and default, and the manifest contracts, [#760][pr-760]. The catalog snippets are left for the release that follows. - [x] Promoted to `main` in #774 (`0b07a59d`) and released as `2.0.352`, the first tag carrying `validate-task.yml`. @@ -503,11 +503,11 @@ The default is empty, so a caller naming nothing runs one leg, on the line its r Quote each entry, and give each one a version. The `Build test matrix job` runs first on every call and refuses an array holding an entry with no non-whitespace character. Such a value would otherwise run green on an interpreter nobody chose. That is because `setup-uv` trims what it reads and then reads an empty input as an absent one. A caller reaches that by interpolating an unset value of its own, or by leaving a stray space beside it. The job also refuses an unquoted entry, since `fromJSON` admits a JSON array of numbers. Some of those numbers `uv` resolves to a real interpreter, `'[3]'` among them, so an unquoted entry is a second silent pass. The job refuses an empty array, a non-array, and concatenated JSON values, each with a named cause. The `unit-test` job and its `Run Python tests step` never see a bad `python-versions`. -A caller carrying a .NET test project as well repeats that half of the job once per leg. The matrix is on the job rather than on its Python steps. So naming a second version there buys runner minutes rather than a second measurement. The `lint` job runs once, and its Python steps run under the first interpreter `python-versions` names, or the selected line where it names none. So a `uv.lock` whose `requires-python` floor is above the fallback line still syncs there. A caller carrying a `.python-version` names that line first, since the release builds on it, and the `lint` job refuses one that does not. The prose and repo gates beside them stay on 3.13, the floor the hub's own scripts declare. Its type check is performed at that interpreter alone. `mypy` and `pyright` each default their target to the one they run under. That holds where the repo's own `[tool.mypy]` or `[tool.pyright]` section does not name a version. Meanwhile `ruff` takes its target from `requires-python` where the `pyproject.toml` declares a `[project]` table and from its own default where it does not. A repo testing several interpreters and carrying no `.python-version` settles the type-check target in its own configuration. The `lint` job refuses a `python-versions` value whose first entry is not a quoted version string, with a named cause. +A caller carrying a .NET test project as well runs it in the separate `unit-test-dotnet` job, so the Python legs hold no .NET step. A repo holding no Python directory reports no Python leg. The `lint` job runs once, and its Python steps run under the first interpreter `python-versions` names, or the selected line where it names none. So a `uv.lock` whose `requires-python` floor is above the fallback line still syncs there. A caller carrying a `.python-version` names that line first, since the release builds on it, and the `lint` job refuses one that does not. The prose and repo gates beside them stay on 3.13, the floor the hub's own scripts declare. Its type check is performed at that interpreter alone. `mypy` and `pyright` each default their target to the one they run under. That holds where the repo's own `[tool.mypy]` or `[tool.pyright]` section does not name a version. Meanwhile `ruff` takes its target from `requires-python` where the `pyproject.toml` declares a `[project]` table and from its own default where it does not. A repo testing several interpreters and carrying no `.python-version` settles the type-check target in its own configuration. The `lint` job refuses a `python-versions` value whose first entry is not a quoted version string, with a named cause. -The .NET upload carries one fixed `dotnet` flag, the same in every leg. A caller whose `.codecov.yml` configures flags names `dotnet` for the .NET unit-test share, beside the Python legs' own flags. A .NET caller's coverage reads as a `dotnet` series from its first pin bump onto a release carrying the flag, rather than unflagged. +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 it adds no matrix leg. One SDK builds every target framework, and one `dotnet test` runs each framework's tests under that framework's own runtime. So the one `unit-test` job installs every listed line beside the selected one. 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, a lower framework's tests run only where the runner image happens to carry its runtime. +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, a lower framework's tests run only where the runner image happens to carry its runtime. 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/spec/project-types.json b/spec/project-types.json index 57fb41922..6ae40339a 100644 --- a/spec/project-types.json +++ b/spec/project-types.json @@ -12,7 +12,7 @@ { "id": "csharp.analyzers.zerowarnings", "verdict": "intent", "assert": "Analyzer severities are enforced; warnings are not relaxed or suppressed wholesale.", "intentRef": "CODESTYLE.md" }, { "id": "csharp.centralconfig.props", "verdict": "letter", "assert": "Shared MSBuild configuration is centralized at the repo root: Directory.Build.props carries the common analyzer and warning properties (the Zero Warnings set), and Directory.Packages.props enables ManagePackageVersionsCentrally with every dependency version declared once - a csproj carries only project-specific properties and versionless PackageReference items.", "intentRef": "CODESTYLE.md" }, { "id": "csharp.sdk.globaljson", "verdict": "letter", "assert": "A root global.json exists and carries an sdk block. Its version is exactly .0.100 for the repo's highest .NET TFM major, never a netstandard target's (10.0.100 alongside net10.0, and 11.0.100 alongside net10.0;net11.0). It sets rollForward latestFeature and allowPrerelease false, so the local dotnet host selects the SDK line CI installs. The line is the repository's own and need not be the hub baseline's. A carried .NET devcontainer's image tag names the same major. So does the first entry of any dotnet-versions value a caller passes the hub's validate-task.yml. No .props or .targets file the repository holds sets LangVersion, the SDK's own targets aside. Nor does any .csproj targeting a .NET TFM. A netstandard analyzer or source-generator .csproj may set a fixed number, the .NET TFM's C# version. No repository file sets LangVersion to latest, latestMajor, or preview, or sets EnablePreviewFeatures. Required for every C# repo.", "intentRef": "CODESTYLE.md" }, - { "id": "csharp.coverage.codecov", "verdict": "letter", "assert": "The unit-test job collects coverage (dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage, with the output filename left unset so each test project writes its own report rather than overwriting a shared one) and uploads it to Codecov via codecov/codecov-action, best-effort (fail_ci_if_error: false so a Codecov outage or an absent token never reds the gate). CODECOV_TOKEN is stored in both the repo actions and dependabot secrets stores, the second so the upload does not skip on a Dependabot PR, and the caller maps it to the reusable validator by name. The validator prefixes each report to coverage-.cobertura.xml before uploading, since codecov-cli does not match the default name. Where the repo's test project is MTP-based (xunit.v3 4.0.0 or later), it also carries a root global.json declaring test.runner as Microsoft.Testing.Platform, references Microsoft.Testing.Extensions.CodeCoverage at 18.9.0 or later rather than coverlet.collector, and drops xunit.runner.visualstudio. A test project not yet MTP-based keeps the VSTest collector and its existing pin, which is a migration owed rather than drift. Required for every C# repo with tests.", "intentRef": "WORKFLOW.md", "minProfile": "build" } + { "id": "csharp.coverage.codecov", "verdict": "letter", "assert": "The .NET unit-test legs collect coverage (dotnet test --framework net --coverage --coverage-output-format cobertura --results-directory ./coverage, with the output filename left unset so each test project writes its own report rather than overwriting a shared one) and uploads it to Codecov via codecov/codecov-action, best-effort (fail_ci_if_error: false so a Codecov outage or an absent token never reds the gate). CODECOV_TOKEN is stored in both the repo actions and dependabot secrets stores, the second so the upload does not skip on a Dependabot PR, and the caller maps it to the reusable validator by name. The validator prefixes each report to coverage-.cobertura.xml before uploading, since codecov-cli does not match the default name. Where the repo's test project is MTP-based (xunit.v3 4.0.0 or later), it also carries a root global.json declaring test.runner as Microsoft.Testing.Platform, references Microsoft.Testing.Extensions.CodeCoverage at 18.9.0 or later rather than coverlet.collector, and drops xunit.runner.visualstudio. A test project not yet MTP-based keeps the VSTest collector and its existing pin, which is a migration owed rather than drift. Required for every C# repo with tests.", "intentRef": "WORKFLOW.md", "minProfile": "build" } ] }, "nuget": { diff --git a/tests/test_release_guards.py b/tests/test_release_guards.py index 285798d66..080c37da7 100755 --- a/tests/test_release_guards.py +++ b/tests/test_release_guards.py @@ -1924,7 +1924,7 @@ def test_validator_python_leg_reaches_a_pip_dependency_repo(self) -> None: collected no coverage and never reached the missing-report failure either. """ workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") - job = workflow.split("\n unit-test:\n", 1)[1].split("\n validate:\n", 1)[0] + job = workflow.split("\n unit-test:\n", 1)[1].split("\n unit-test-dotnet:\n", 1)[0] # Every Python step keys on the resolved directories rather than on a root file, or a nested project is skipped. self.assertNotIn("hashFiles('pyproject.toml')", job) @@ -1967,7 +1967,7 @@ def test_validator_python_leg_reaches_a_pip_dependency_repo(self) -> None: def test_validator_pre_test_hook_runs_before_the_dotnet_tests(self) -> None: """A caller's system tools reach the runner before the .NET tests, and only where it carries the hook.""" workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") - job = workflow.split("\n unit-test:\n", 1)[1].split("\n validate:\n", 1)[0] + job = workflow.split("\n unit-test-dotnet:\n", 1)[1].split("\n validate:\n", 1)[0] order = [ job.index("name: Checkout code step"), job.index("name: Run caller pre-test hook step"), @@ -1986,7 +1986,7 @@ def test_validator_pre_test_hook_runs_before_the_dotnet_tests(self) -> None: def test_validator_test_matrix_hook_runs_between_install_and_pytest(self) -> None: """A dependency-version leg overrides installed versions after the base install and before pytest.""" workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") - job = workflow.split("\n unit-test:\n", 1)[1].split("\n validate:\n", 1)[0] + job = workflow.split("\n unit-test:\n", 1)[1].split("\n unit-test-dotnet:\n", 1)[0] order = [ job.index("name: Check caller install-test-deps hook step"), @@ -2096,12 +2096,10 @@ def test_validator_test_matrix_file_takes_the_inline_input_checks(self) -> None: job = workflow.split("\n test-matrix:\n", 1)[1].split("\n lint:\n", 1)[0] # A file needs the whole tree, and it has to be there before the check reads it. + # The job also reads the tree for its test projects and Python directories, so the checkout is whole and unconditional. checkout = yaml_step(job, "Checkout code step") - self.assertIn(" if: ${{ inputs.test-matrix-file != '' || ", checkout) - self.assertEqual( - "${{ inputs.test-matrix-file == '' && fromJSON('\"/.python-version\\n/global.json\"') || '' }}", - yaml_value(checkout, "with", "sparse-checkout"), - ) + self.assertIsNone(yaml_value(checkout, "if")) + self.assertIsNone(yaml_value(checkout, "with", "sparse-checkout")) self.assertEqual(yaml_value(checkout, "with", "persist-credentials"), "false") steps = re.findall(r"(?m)^ - name: (.*)$", job) self.assertLess( @@ -2135,6 +2133,8 @@ def step(script: str, **env: str) -> tuple[int, str, str]: "TEST_MATRIX": "", "TEST_MATRIX_FILE": "", "PYTHON_VERSIONS": '["3.13"]', + "DOTNET_LINES": '["10.0", "9.0"]', + "DOTNET_TESTS": "true", **env, }, ) @@ -2146,8 +2146,10 @@ def built(**env: str) -> object: self.assertEqual(0, status, log) status, log, lines = step(build, LEGS=output.removeprefix("legs=").strip()) self.assertEqual(0, status, log) - matrix, versions = lines.splitlines() + matrix, versions, dotnet_matrix, dotnet_tests = lines.splitlines() self.assertEqual('versions=["3.13"]', versions) + self.assertEqual('dotnet-matrix={"dotnet-version":["10.0","9.0"]}', dotnet_matrix) + self.assertEqual("dotnet-tests=true", dotnet_tests) return json.loads(matrix.removeprefix("matrix=")) # Each input builds the legs it holds, the inline one differing so a stale resolved file cannot pass for it. @@ -2190,7 +2192,7 @@ def test_validator_pytest_leg_fans_out_over_every_named_interpreter(self) -> Non claiming the rest. The fan-out is therefore asserted here rather than left to be read by eye. """ workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") - job = workflow.split("\n unit-test:\n", 1)[1].split("\n validate:\n", 1)[0] + job = workflow.split("\n unit-test:\n", 1)[1].split("\n unit-test-dotnet:\n", 1)[0] # Empty is the default, so a caller naming nothing runs the line its own .python-version selects. declaration = workflow.split(" python-versions:\n", 1)[1].split("\n secrets:", 1)[0] @@ -2228,12 +2230,14 @@ def test_validator_pytest_leg_fans_out_over_every_named_interpreter(self) -> Non def test_validator_dotnet_upload_carries_a_fixed_flag(self) -> None: """A path filter cannot tell the .NET upload from a Python leg's upload where their paths overlap. - The .NET upload therefore carries one fixed flag, the same in every leg, so a caller can name it. + The .NET upload therefore carries the fixed dotnet flag in every leg, so a caller can name it, and a per-line flag beside it. """ workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") - job = workflow.split("\n unit-test:\n", 1)[1].split("\n validate:\n", 1)[0] + job = workflow.split("\n unit-test-dotnet:\n", 1)[1].split("\n validate:\n", 1)[0] upload = yaml_step(job, "Upload coverage to Codecov step") - self.assertEqual(yaml_value(upload, "with", "flags"), "dotnet") + self.assertEqual( + yaml_value(upload, "with", "flags"), "dotnet,dotnet-${{ matrix.dotnet-version }}" + ) def test_validator_checks_out_the_triggering_commit(self) -> None: """A ref: on any checkout moves the gate off the commit a publisher releases. @@ -2247,6 +2251,64 @@ def test_validator_checks_out_the_triggering_commit(self) -> None: self.assertIn("actions/checkout@", workflow) self.assertNotRegex(workflow, r"(?m)(^[ \t-]*|[{,][ \t]*)[\"']?ref[\"']?[ \t]*:") + def test_validator_runs_each_dotnet_line_and_python_line_as_its_own_leg(self) -> None: + """WORKFLOW.md D1.9: a .NET line is a leg of its own, and the Python job carries no .NET step.""" + workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") + python_job = workflow.split("\n unit-test:\n", 1)[1].split("\n unit-test-dotnet:\n", 1)[0] + dotnet_job = workflow.split("\n unit-test-dotnet:\n", 1)[1].split("\n validate:\n", 1)[0] + builder = workflow.split("\n test-matrix:\n", 1)[1].split("\n lint:\n", 1)[0] + + # The name carries the line, so a failing framework reads from the check list. + self.assertIn(" name: Unit test job (.NET ${{ matrix.dotnet-version }})\n", dotnet_job) + self.assertIn(" needs: test-matrix\n", dotnet_job) + self.assertIn(" fail-fast: false\n", dotnet_job) + self.assertIn( + " matrix: ${{ fromJSON(needs.test-matrix.outputs.dotnet-matrix) }}\n", dotnet_job + ) + self.assertIn( + " if: ${{ needs.test-matrix.outputs.dotnet-tests == 'true' }}\n", dotnet_job + ) + self.assertIn(" contents: read\n", dotnet_job) + + # Each invocation names its framework, and the value reaches the script through env. + script = step_script_text(dotnet_job, "Run unit tests step") + self.assertEqual(2, len(re.findall(r"(?m)^\s*(?:\S.*\s)?dotnet test ", script)) - 1) + self.assertEqual(2, 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") + ) + self.assertNotIn("matrix.dotnet-version", script) + self.assertIn("wrote no non-empty Cobertura report", script) + + # The SDK still installs every listed line, and the upload names the line beside the fixed flag. + setup = yaml_step(dotnet_job, "Setup .NET SDK step") + self.assertEqual("${{ inputs.dotnet-versions }}", yaml_value(setup, "with", "versions")) + self.assertEqual( + "dotnet,dotnet-${{ matrix.dotnet-version }}", + yaml_value(yaml_step(dotnet_job, "Upload coverage to Codecov step"), "with", "flags"), + ) + self.assertIn("name: Checkout code step", dotnet_job) + + # The Python job holds no .NET step and skips when no Python directory resolves. + for needle in ( + "Setup .NET SDK step", + "Resolve .NET workspaces step", + "Run unit tests step", + "Run caller pre-test hook step", + "Tests*.csproj", + "dotnet test", + "actions/dotnet-sdk", + ): + self.assertNotIn(needle, python_job) + self.assertIn(" if: ${{ needs.test-matrix.outputs.python-any == 'true' }}\n", python_job) + self.assertIn("python-any: ${{ steps.python-directories.outputs.any }}", builder) + resolve = yaml_step(builder, "Resolve Python directories step") + self.assertEqual("$/.github/actions/python-directories", yaml_value(resolve, "uses")) + self.assertEqual( + "${{ inputs.python-directories }}", yaml_value(resolve, "with", "directories") + ) + @unittest.skipUnless( shutil.which("bash") and os.name == "posix", "the step runs under bash against a stand-in dotnet that only a POSIX host can execute", @@ -2260,7 +2322,7 @@ def test_validator_dotnet_leg_fails_when_no_report_was_written(self) -> None: counted it would therefore pass a run that measured nothing. """ workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") - job = workflow.split("\n unit-test:\n", 1)[1].split("\n validate:\n", 1)[0] + job = workflow.split("\n unit-test-dotnet:\n", 1)[1].split("\n validate:\n", 1)[0] marker = " - name: Run unit tests step\n" self.assertIn(marker, job) script = step_script_text(job, "Run unit tests step") @@ -2291,6 +2353,7 @@ def test_validator_dotnet_leg_fails_when_no_report_was_written(self) -> None: **without_git_location(), "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', os.defpath)}", "WORKSPACES": "", + "DOTNET_VERSION": "10.0", }, capture_output=True, text=True, @@ -2322,7 +2385,7 @@ def test_validator_dotnet_steps_run_once_per_workspace(self) -> None: """ workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") lint = workflow.split("\n lint:\n", 1)[1].split("\n unit-test:\n", 1)[0] - unit = workflow.split("\n unit-test:\n", 1)[1].split("\n validate:\n", 1)[0] + unit = workflow.split("\n unit-test-dotnet:\n", 1)[1].split("\n validate:\n", 1)[0] action = (REPO / ".github/actions/dotnet-workspaces/action.yml").read_text(encoding="utf-8") resolver = step_script_text(action, "Resolve .NET workspaces step") self.assertNotIn("dotnet_workspaces", workflow) @@ -2368,12 +2431,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 {flags}"], + [f"test --framework net10.0 {flags}"], ), "a root project": ( ["App.csproj", "tests/AppTests/AppTests.csproj"], bare_style, - [f"test {flags}"], + [f"test --framework net10.0 {flags}"], ), "solutions below the root": ( [ @@ -2383,39 +2446,41 @@ def named_style(*workspaces: str) -> list[str]: "src/LibTests/LibTests.csproj", ], named_style("src/App.sln", "tools/Tool.slnx"), - [f"test --project src/LibTests/LibTests.csproj {flags}"], + [f"test --framework net10.0 --project src/LibTests/LibTests.csproj {flags}"], ), "projects and no solution": ( ["FindInFile/FindInFile.csproj", "FindInFileTests/FindInFileTests.csproj"], named_style( "FindInFile/FindInFile.csproj", "FindInFileTests/FindInFileTests.csproj" ), - [f"test --project FindInFileTests/FindInFileTests.csproj {flags}"], + [ + f"test --framework net10.0 --project FindInFileTests/FindInFileTests.csproj {flags}" + ], ), "a root .sln beside the .slnx dotnet sln migrate writes": ( ["App.sln", "App.slnx", "src/Lib/Lib.csproj", "tests/LibTests/LibTests.csproj"], named_style("App.sln", "App.slnx"), - [f"test --project tests/LibTests/LibTests.csproj {flags}"], + [f"test --framework net10.0 --project tests/LibTests/LibTests.csproj {flags}"], ), "a root solution beside a root project": ( ["App.slnx", "Tool.csproj", "tests/AppTests/AppTests.csproj"], named_style("App.slnx"), - [f"test --project tests/AppTests/AppTests.csproj {flags}"], + [f"test --framework net10.0 --project tests/AppTests/AppTests.csproj {flags}"], ), "two root projects": ( ["App.csproj", "AppTests.csproj"], named_style("App.csproj", "AppTests.csproj"), - [f"test --project AppTests.csproj {flags}"], + [f"test --framework net10.0 --project AppTests.csproj {flags}"], ), "two root projects beside a nested solution": ( ["App.csproj", "AppTests.csproj", "sub/Tool.sln", "sub/Tool.csproj"], named_style("App.csproj", "AppTests.csproj", "sub/Tool.csproj"), - [f"test --project AppTests.csproj {flags}"], + [f"test --framework net10.0 --project AppTests.csproj {flags}"], ), "two root solutions beside a nested solution": ( ["App.sln", "App.slnx", "sub/Tool.sln", "tests/AppTests/AppTests.csproj"], named_style("App.sln", "App.slnx"), - [f"test --project tests/AppTests/AppTests.csproj {flags}"], + [f"test --framework net10.0 --project tests/AppTests/AppTests.csproj {flags}"], ), } steps = ((style, style_inputs, 1), (tests, test_inputs, 2)) @@ -2470,6 +2535,7 @@ def named_style(*workspaces: str) -> list[str]: "PATH": f"{bin_dir}{os.pathsep}{os.environ.get('PATH', os.defpath)}", "STUB_LOG": str(log), "WORKSPACES": match.group(2).removesuffix("\n"), + "DOTNET_VERSION": "10.0", }, capture_output=True, text=True, @@ -2494,7 +2560,7 @@ def test_validator_refuses_a_python_versions_value_fromjson_would_admit(self) -> """ workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") job = workflow.split("\n test-matrix:\n", 1)[1].split("\n lint:\n", 1)[0] - unit_test = workflow.split("\n unit-test:\n", 1)[1].split("\n validate:\n", 1)[0] + unit_test = workflow.split("\n unit-test:\n", 1)[1].split("\n unit-test-dotnet:\n", 1)[0] # The guard has to precede the build it guards, and the unit-test job runs only after this job. # Matched on the dash rather than on a name: key, or a step leading with uses: would slip in ahead unseen. @@ -2805,6 +2871,7 @@ class DotnetSdkLineCase(unittest.TestCase): ACTION = REPO / ".github/actions/dotnet-sdk/action.yml" SELECT = "Select .NET SDK line step" last_stdout = "" + last_lines: tuple[str, ...] = () def select(self, global_json: str | bytes | None, versions: str = "") -> list[str]: """The outputs the selection step writes in a workspace holding `global_json`, or none. @@ -2829,7 +2896,9 @@ def run_select(self, global_json: str | bytes | None, versions: str) -> tuple[in code, self.last_stdout, _, outputs = run_selection_step( self.ACTION, self.SELECT, "global.json", global_json, {"VERSIONS": versions} ) - return code, outputs + # The reported lines are asserted by their own test, so the install outputs read as they did. + self.last_lines = tuple(line for line in outputs if line.startswith("lines=")) + return code, [line for line in outputs if not line.startswith("lines=")] def test_versions_install_every_line_beside_the_selected_one(self) -> None: """A multi-targeted test project runs each framework under its own runtime, so each line installs.""" @@ -2886,8 +2955,8 @@ def test_validate_task_hands_dotnet_versions_to_every_sdk_step(self) -> None: users = sorted( job for job, body in jobs.items() if "uses: $/.github/actions/dotnet-sdk" in body ) - self.assertEqual(users, ["lint", "test-matrix", "unit-test"]) - for job in ("lint", "unit-test"): + self.assertEqual(users, ["lint", "test-matrix", "unit-test-dotnet"]) + for job in ("lint", "unit-test-dotnet"): with self.subTest(job=job): setup = yaml_step(jobs[job], "Setup .NET SDK step") self.assertEqual( @@ -2896,7 +2965,7 @@ def test_validate_task_hands_dotnet_versions_to_every_sdk_step(self) -> None: self.assertIsNone(yaml_value(setup, "with", "install")) def test_the_entry_job_validates_dotnet_versions_before_any_build(self) -> None: - """WORKFLOW.md D2.1: the cross-input check runs once in the job unit-test waits on, installing nothing.""" + """WORKFLOW.md D2.1: the cross-input check runs once in the job the unit-test jobs wait on, installing nothing.""" workflow = (REPO / ".github/workflows/validate-task.yml").read_text(encoding="utf-8") jobs = job_texts(workflow) entry = jobs["test-matrix"] @@ -2904,10 +2973,12 @@ def test_the_entry_job_validates_dotnet_versions_before_any_build(self) -> None: self.assertEqual(yaml_value(check, "uses"), "$/.github/actions/dotnet-sdk") self.assertEqual(yaml_value(check, "with", "versions"), "${{ inputs.dotnet-versions }}") self.assertEqual(yaml_value(check, "with", "install"), "'false'") + # The step runs whether or not the input is set, since it also reports the line a caller naming none tests under. + self.assertIsNone(yaml_value(check, "if")) checkout = yaml_step(entry, "Checkout code step") - self.assertIn("inputs.dotnet-versions != ''", yaml_value(checkout, "if") or "") - self.assertIn("/global.json", yaml_value(checkout, "with", "sparse-checkout") or "") + self.assertIsNone(yaml_value(checkout, "if")) self.assertIn("needs: test-matrix", jobs["unit-test"]) + self.assertIn("needs: test-matrix", jobs["unit-test-dotnet"]) action = self.ACTION.read_text(encoding="utf-8") setup = yaml_step(action, "Setup .NET SDK step") self.assertEqual(yaml_value(setup, "if"), "${{ inputs.install != 'false' }}") @@ -2923,6 +2994,37 @@ def test_a_caller_without_an_sdk_version_gets_10x(self) -> None: self.assertEqual(self.select(None), [fallback]) self.assertEqual(self.select(json.dumps({"sdk": None})), [fallback]) + def test_the_reported_lines_are_the_versions_else_the_selected_line_else_the_fallback( + self, + ) -> None: + """Each reported line becomes one dotnet test leg, so the selection and the legs cannot disagree.""" + selects = json.dumps({"sdk": {"version": "11.0.100", "rollForward": "latestFeature"}}) + runner_only = json.dumps({"test": {"runner": "Microsoft.Testing.Platform"}}) + fallback = baseline_line()[0] + for name, global_json, versions, want in ( + ("versions", selects, '["11.0", "10.0"]', ["11.0", "10.0"]), + ( + "versions without a selecting file", + runner_only, + '["11.0", "10.0"]', + ["11.0", "10.0"], + ), + ("the selected line", selects, "", ["11.0"]), + ("the fallback", runner_only, "", [f"{fallback}.0"]), + ("no file", None, "", [f"{fallback}.0"]), + ): + with self.subTest(case=name): + self.select(global_json, versions) + self.assertEqual(self.last_lines, ("lines=" + json.dumps(want),)) + + def test_a_selected_version_with_no_line_fails(self) -> None: + code, outputs = self.run_select(json.dumps({"sdk": {"version": "latest"}}), "") + self.assertNotEqual(code, 0) + self.assertEqual(outputs, []) + self.assertIn( + "::error::The global.json sdk.version must start with an X.Y line", self.last_stdout + ) + def test_comments_are_read_as_the_dotnet_host_reads_them(self) -> None: """The dotnet host accepts comments, so a file holding them still selects its line or the fallback.""" fallback = [f"dotnet-version={baseline_line()[0]}.x"] @@ -3206,11 +3308,7 @@ def test_each_python_job_reaches_the_selection(self) -> None: jobs = job_texts(validate) builder = jobs["test-matrix"] checkout = yaml_step(builder, "Checkout code step") - self.assertEqual( - "${{ inputs.test-matrix-file != '' || inputs.python-versions == '' || inputs.dotnet-versions != '' }}", - yaml_value(checkout, "if"), - ) - self.assertIn('"/.python-version\\n', yaml_value(checkout, "with", "sparse-checkout") or "") + self.assertIsNone(yaml_value(checkout, "if")) resolved = "${{ inputs.python-versions || format('[\"{0}\"]', steps.python-version.outputs.version) }}" for job, steps, condition in ( ( From 2724882f5d86313c17800040140cceaae7dc00fe Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 3 Dec 2026 06:56:09 -0800 Subject: [PATCH 2/5] Name the New Job in D1.2 and Drop Stale .NET-only Wording Co-Authored-By: Claude Sonnet 5.5 --- .../skills/workflow-ci-contract/references/d-guarantees.md | 4 ++-- .../fleet-skills/.source-digests/workflow-ci-contract | 2 +- .../skills/workflow-ci-contract/references/d-guarantees.md | 4 ++-- .../skills/workflow-ci-contract/references/d-guarantees.md | 4 ++-- WORKFLOW.md | 4 ++-- docs/reusable-workflows.md | 2 +- spec/project-types.json | 2 +- tests/test_release_guards.py | 7 ++++++- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.agents/skills/workflow-ci-contract/references/d-guarantees.md b/.agents/skills/workflow-ci-contract/references/d-guarantees.md index b339d4ba1..84bedcd87 100644 --- a/.agents/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.agents/skills/workflow-ci-contract/references/d-guarantees.md @@ -11,14 +11,14 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output ### D1 - PR Fast-Feedback (Smoke) - **D1.1 Only changed targets build.** Input: a PR touching some targets. Output: the paths-filter marks exactly those targets and only their smoke builds run. Unchanged targets skip. A repo's own targets MUST each have a filter entry, so a touched target is never silently skipped. That entry lists paths rather than negating them, so a change matching no entry marks nothing and every smoke build skips. *Prevents: rebuilding everything, and a changed target slipping through unbuilt.* -- **D1.2 A validation job always runs.** Input: any PR. Output: a validation job runs unconditionally and the aggregator `needs:` it. That job is the caller's own job reaching the reusable validator, named `validate` in every shipped stub. That name is what the aggregator's `needs:` carries. The validator's internal jobs (`test-matrix`, `lint`, `unit-test` and `validate` in the hub's `validate-task.yml`) are not addressable from a caller. So a `validate` in a caller's `needs:` list always names the caller's own job, never the validator's internal one. The validator detects the tree rather than the repo's language, so a non-.NET repo calls the same one rather than replacing it. It runs the doc and repo gates everywhere, and the `dotnet test` path only where a `*Tests*.csproj` project exists. It runs the Python path in each directory the caller declares in its `python-directories` input. Where the caller declares none and a root `pyproject.toml` is tracked, it runs that path at the root instead. At that undeclared root the test leg runs only where a `tests/` suite sits beside a `uv.lock` or `requirements*.txt`. A declared directory without `tests/`, by contrast, fails (D1.6). The declaration rather than discovery decides what is gated, since a stray or vendored `.py` file would otherwise change the gate silently. The validator warns about a tracked `.py` file no declared directory covers. It checks out the triggering commit, `github.sha`, with no `ref` input. It needs none, because a reusable workflow reads its caller's `github` context, so a publisher's call validates the same commit its publish job pins. A repo whose tests take another shape can run them from its own `.github/actions/validate/action.yml` hook, which the validator runs where that file exists. That hook receives no secret, so a repo whose other-shape tests owe D1.6's coverage upload is one whose validation the validator cannot express. A repo whose validation it cannot express **replaces** the call (not deletes it) with its own validator and re-points the aggregator's `needs:` to the replacement. `smoke-build` `needs:` the `changes` job rather than the validation job, so no second `needs:` moves with it. *Prevents: a PR merging with no validation, or a dangling `needs:` that stops the whole workflow from loading.* +- **D1.2 A validation job always runs.** Input: any PR. Output: a validation job runs unconditionally and the aggregator `needs:` it. That job is the caller's own job reaching the reusable validator, named `validate` in every shipped stub. That name is what the aggregator's `needs:` carries. The validator's internal jobs (`test-matrix`, `lint`, `unit-test`, `unit-test-dotnet` and `validate` in the hub's `validate-task.yml`) are not addressable from a caller. So a `validate` in a caller's `needs:` list always names the caller's own job, never the validator's internal one. The validator detects the tree rather than the repo's language, so a non-.NET repo calls the same one rather than replacing it. It runs the doc and repo gates everywhere, and the `dotnet test` path only where a `*Tests*.csproj` project exists. It runs the Python path in each directory the caller declares in its `python-directories` input. Where the caller declares none and a root `pyproject.toml` is tracked, it runs that path at the root instead. At that undeclared root the test leg runs only where a `tests/` suite sits beside a `uv.lock` or `requirements*.txt`. A declared directory without `tests/`, by contrast, fails (D1.6). The declaration rather than discovery decides what is gated, since a stray or vendored `.py` file would otherwise change the gate silently. The validator warns about a tracked `.py` file no declared directory covers. It checks out the triggering commit, `github.sha`, with no `ref` input. It needs none, because a reusable workflow reads its caller's `github` context, so a publisher's call validates the same commit its publish job pins. A repo whose tests take another shape can run them from its own `.github/actions/validate/action.yml` hook, which the validator runs where that file exists. That hook receives no secret, so a repo whose other-shape tests owe D1.6's coverage upload is one whose validation the validator cannot express. A repo whose validation it cannot express **replaces** the call (not deletes it) with its own validator and re-points the aggregator's `needs:` to the replacement. `smoke-build` `needs:` the `changes` job rather than the validation job, so no second `needs:` moves with it. *Prevents: a PR merging with no validation, or a dangling `needs:` that stops the whole workflow from loading.* - **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.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. 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. 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 cad0e7ec9..863de17e0 100644 --- a/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract +++ b/.claude-plugin/fleet-skills/.source-digests/workflow-ci-contract @@ -1 +1 @@ -e912db9d42d76e8d +b2dc0156763b090d 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 b339d4ba1..84bedcd87 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 @@ -11,14 +11,14 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output ### D1 - PR Fast-Feedback (Smoke) - **D1.1 Only changed targets build.** Input: a PR touching some targets. Output: the paths-filter marks exactly those targets and only their smoke builds run. Unchanged targets skip. A repo's own targets MUST each have a filter entry, so a touched target is never silently skipped. That entry lists paths rather than negating them, so a change matching no entry marks nothing and every smoke build skips. *Prevents: rebuilding everything, and a changed target slipping through unbuilt.* -- **D1.2 A validation job always runs.** Input: any PR. Output: a validation job runs unconditionally and the aggregator `needs:` it. That job is the caller's own job reaching the reusable validator, named `validate` in every shipped stub. That name is what the aggregator's `needs:` carries. The validator's internal jobs (`test-matrix`, `lint`, `unit-test` and `validate` in the hub's `validate-task.yml`) are not addressable from a caller. So a `validate` in a caller's `needs:` list always names the caller's own job, never the validator's internal one. The validator detects the tree rather than the repo's language, so a non-.NET repo calls the same one rather than replacing it. It runs the doc and repo gates everywhere, and the `dotnet test` path only where a `*Tests*.csproj` project exists. It runs the Python path in each directory the caller declares in its `python-directories` input. Where the caller declares none and a root `pyproject.toml` is tracked, it runs that path at the root instead. At that undeclared root the test leg runs only where a `tests/` suite sits beside a `uv.lock` or `requirements*.txt`. A declared directory without `tests/`, by contrast, fails (D1.6). The declaration rather than discovery decides what is gated, since a stray or vendored `.py` file would otherwise change the gate silently. The validator warns about a tracked `.py` file no declared directory covers. It checks out the triggering commit, `github.sha`, with no `ref` input. It needs none, because a reusable workflow reads its caller's `github` context, so a publisher's call validates the same commit its publish job pins. A repo whose tests take another shape can run them from its own `.github/actions/validate/action.yml` hook, which the validator runs where that file exists. That hook receives no secret, so a repo whose other-shape tests owe D1.6's coverage upload is one whose validation the validator cannot express. A repo whose validation it cannot express **replaces** the call (not deletes it) with its own validator and re-points the aggregator's `needs:` to the replacement. `smoke-build` `needs:` the `changes` job rather than the validation job, so no second `needs:` moves with it. *Prevents: a PR merging with no validation, or a dangling `needs:` that stops the whole workflow from loading.* +- **D1.2 A validation job always runs.** Input: any PR. Output: a validation job runs unconditionally and the aggregator `needs:` it. That job is the caller's own job reaching the reusable validator, named `validate` in every shipped stub. That name is what the aggregator's `needs:` carries. The validator's internal jobs (`test-matrix`, `lint`, `unit-test`, `unit-test-dotnet` and `validate` in the hub's `validate-task.yml`) are not addressable from a caller. So a `validate` in a caller's `needs:` list always names the caller's own job, never the validator's internal one. The validator detects the tree rather than the repo's language, so a non-.NET repo calls the same one rather than replacing it. It runs the doc and repo gates everywhere, and the `dotnet test` path only where a `*Tests*.csproj` project exists. It runs the Python path in each directory the caller declares in its `python-directories` input. Where the caller declares none and a root `pyproject.toml` is tracked, it runs that path at the root instead. At that undeclared root the test leg runs only where a `tests/` suite sits beside a `uv.lock` or `requirements*.txt`. A declared directory without `tests/`, by contrast, fails (D1.6). The declaration rather than discovery decides what is gated, since a stray or vendored `.py` file would otherwise change the gate silently. The validator warns about a tracked `.py` file no declared directory covers. It checks out the triggering commit, `github.sha`, with no `ref` input. It needs none, because a reusable workflow reads its caller's `github` context, so a publisher's call validates the same commit its publish job pins. A repo whose tests take another shape can run them from its own `.github/actions/validate/action.yml` hook, which the validator runs where that file exists. That hook receives no secret, so a repo whose other-shape tests owe D1.6's coverage upload is one whose validation the validator cannot express. A repo whose validation it cannot express **replaces** the call (not deletes it) with its own validator and re-points the aggregator's `needs:` to the replacement. `smoke-build` `needs:` the `changes` job rather than the validation job, so no second `needs:` moves with it. *Prevents: a PR merging with no validation, or a dangling `needs:` that stops the whole workflow from loading.* - **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.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. 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. 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/skills/workflow-ci-contract/references/d-guarantees.md b/.github/skills/workflow-ci-contract/references/d-guarantees.md index b339d4ba1..84bedcd87 100644 --- a/.github/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.github/skills/workflow-ci-contract/references/d-guarantees.md @@ -11,14 +11,14 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output ### D1 - PR Fast-Feedback (Smoke) - **D1.1 Only changed targets build.** Input: a PR touching some targets. Output: the paths-filter marks exactly those targets and only their smoke builds run. Unchanged targets skip. A repo's own targets MUST each have a filter entry, so a touched target is never silently skipped. That entry lists paths rather than negating them, so a change matching no entry marks nothing and every smoke build skips. *Prevents: rebuilding everything, and a changed target slipping through unbuilt.* -- **D1.2 A validation job always runs.** Input: any PR. Output: a validation job runs unconditionally and the aggregator `needs:` it. That job is the caller's own job reaching the reusable validator, named `validate` in every shipped stub. That name is what the aggregator's `needs:` carries. The validator's internal jobs (`test-matrix`, `lint`, `unit-test` and `validate` in the hub's `validate-task.yml`) are not addressable from a caller. So a `validate` in a caller's `needs:` list always names the caller's own job, never the validator's internal one. The validator detects the tree rather than the repo's language, so a non-.NET repo calls the same one rather than replacing it. It runs the doc and repo gates everywhere, and the `dotnet test` path only where a `*Tests*.csproj` project exists. It runs the Python path in each directory the caller declares in its `python-directories` input. Where the caller declares none and a root `pyproject.toml` is tracked, it runs that path at the root instead. At that undeclared root the test leg runs only where a `tests/` suite sits beside a `uv.lock` or `requirements*.txt`. A declared directory without `tests/`, by contrast, fails (D1.6). The declaration rather than discovery decides what is gated, since a stray or vendored `.py` file would otherwise change the gate silently. The validator warns about a tracked `.py` file no declared directory covers. It checks out the triggering commit, `github.sha`, with no `ref` input. It needs none, because a reusable workflow reads its caller's `github` context, so a publisher's call validates the same commit its publish job pins. A repo whose tests take another shape can run them from its own `.github/actions/validate/action.yml` hook, which the validator runs where that file exists. That hook receives no secret, so a repo whose other-shape tests owe D1.6's coverage upload is one whose validation the validator cannot express. A repo whose validation it cannot express **replaces** the call (not deletes it) with its own validator and re-points the aggregator's `needs:` to the replacement. `smoke-build` `needs:` the `changes` job rather than the validation job, so no second `needs:` moves with it. *Prevents: a PR merging with no validation, or a dangling `needs:` that stops the whole workflow from loading.* +- **D1.2 A validation job always runs.** Input: any PR. Output: a validation job runs unconditionally and the aggregator `needs:` it. That job is the caller's own job reaching the reusable validator, named `validate` in every shipped stub. That name is what the aggregator's `needs:` carries. The validator's internal jobs (`test-matrix`, `lint`, `unit-test`, `unit-test-dotnet` and `validate` in the hub's `validate-task.yml`) are not addressable from a caller. So a `validate` in a caller's `needs:` list always names the caller's own job, never the validator's internal one. The validator detects the tree rather than the repo's language, so a non-.NET repo calls the same one rather than replacing it. It runs the doc and repo gates everywhere, and the `dotnet test` path only where a `*Tests*.csproj` project exists. It runs the Python path in each directory the caller declares in its `python-directories` input. Where the caller declares none and a root `pyproject.toml` is tracked, it runs that path at the root instead. At that undeclared root the test leg runs only where a `tests/` suite sits beside a `uv.lock` or `requirements*.txt`. A declared directory without `tests/`, by contrast, fails (D1.6). The declaration rather than discovery decides what is gated, since a stray or vendored `.py` file would otherwise change the gate silently. The validator warns about a tracked `.py` file no declared directory covers. It checks out the triggering commit, `github.sha`, with no `ref` input. It needs none, because a reusable workflow reads its caller's `github` context, so a publisher's call validates the same commit its publish job pins. A repo whose tests take another shape can run them from its own `.github/actions/validate/action.yml` hook, which the validator runs where that file exists. That hook receives no secret, so a repo whose other-shape tests owe D1.6's coverage upload is one whose validation the validator cannot express. A repo whose validation it cannot express **replaces** the call (not deletes it) with its own validator and re-points the aggregator's `needs:` to the replacement. `smoke-build` `needs:` the `changes` job rather than the validation job, so no second `needs:` moves with it. *Prevents: a PR merging with no validation, or a dangling `needs:` that stops the whole workflow from loading.* - **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.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. 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. 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/WORKFLOW.md b/WORKFLOW.md index 8111fa577..5d3aa89e9 100644 --- a/WORKFLOW.md +++ b/WORKFLOW.md @@ -139,14 +139,14 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output ### D1 - PR Fast-Feedback (Smoke) - **D1.1 Only changed targets build.** Input: a PR touching some targets. Output: the paths-filter marks exactly those targets and only their smoke builds run. Unchanged targets skip. A repo's own targets MUST each have a filter entry, so a touched target is never silently skipped. That entry lists paths rather than negating them, so a change matching no entry marks nothing and every smoke build skips. *Prevents: rebuilding everything, and a changed target slipping through unbuilt.* -- **D1.2 A validation job always runs.** Input: any PR. Output: a validation job runs unconditionally and the aggregator `needs:` it. That job is the caller's own job reaching the reusable validator, named `validate` in every shipped stub. That name is what the aggregator's `needs:` carries. The validator's internal jobs (`test-matrix`, `lint`, `unit-test` and `validate` in the hub's `validate-task.yml`) are not addressable from a caller. So a `validate` in a caller's `needs:` list always names the caller's own job, never the validator's internal one. The validator detects the tree rather than the repo's language, so a non-.NET repo calls the same one rather than replacing it. It runs the doc and repo gates everywhere, and the `dotnet test` path only where a `*Tests*.csproj` project exists. It runs the Python path in each directory the caller declares in its `python-directories` input. Where the caller declares none and a root `pyproject.toml` is tracked, it runs that path at the root instead. At that undeclared root the test leg runs only where a `tests/` suite sits beside a `uv.lock` or `requirements*.txt`. A declared directory without `tests/`, by contrast, fails (D1.6). The declaration rather than discovery decides what is gated, since a stray or vendored `.py` file would otherwise change the gate silently. The validator warns about a tracked `.py` file no declared directory covers. It checks out the triggering commit, `github.sha`, with no `ref` input. It needs none, because a reusable workflow reads its caller's `github` context, so a publisher's call validates the same commit its publish job pins. A repo whose tests take another shape can run them from its own `.github/actions/validate/action.yml` hook, which the validator runs where that file exists. That hook receives no secret, so a repo whose other-shape tests owe D1.6's coverage upload is one whose validation the validator cannot express. A repo whose validation it cannot express **replaces** the call (not deletes it) with its own validator and re-points the aggregator's `needs:` to the replacement. `smoke-build` `needs:` the `changes` job rather than the validation job, so no second `needs:` moves with it. *Prevents: a PR merging with no validation, or a dangling `needs:` that stops the whole workflow from loading.* +- **D1.2 A validation job always runs.** Input: any PR. Output: a validation job runs unconditionally and the aggregator `needs:` it. That job is the caller's own job reaching the reusable validator, named `validate` in every shipped stub. That name is what the aggregator's `needs:` carries. The validator's internal jobs (`test-matrix`, `lint`, `unit-test`, `unit-test-dotnet` and `validate` in the hub's `validate-task.yml`) are not addressable from a caller. So a `validate` in a caller's `needs:` list always names the caller's own job, never the validator's internal one. The validator detects the tree rather than the repo's language, so a non-.NET repo calls the same one rather than replacing it. It runs the doc and repo gates everywhere, and the `dotnet test` path only where a `*Tests*.csproj` project exists. It runs the Python path in each directory the caller declares in its `python-directories` input. Where the caller declares none and a root `pyproject.toml` is tracked, it runs that path at the root instead. At that undeclared root the test leg runs only where a `tests/` suite sits beside a `uv.lock` or `requirements*.txt`. A declared directory without `tests/`, by contrast, fails (D1.6). The declaration rather than discovery decides what is gated, since a stray or vendored `.py` file would otherwise change the gate silently. The validator warns about a tracked `.py` file no declared directory covers. It checks out the triggering commit, `github.sha`, with no `ref` input. It needs none, because a reusable workflow reads its caller's `github` context, so a publisher's call validates the same commit its publish job pins. A repo whose tests take another shape can run them from its own `.github/actions/validate/action.yml` hook, which the validator runs where that file exists. That hook receives no secret, so a repo whose other-shape tests owe D1.6's coverage upload is one whose validation the validator cannot express. A repo whose validation it cannot express **replaces** the call (not deletes it) with its own validator and re-points the aggregator's `needs:` to the replacement. `smoke-build` `needs:` the `changes` job rather than the validation job, so no second `needs:` moves with it. *Prevents: a PR merging with no validation, or a dangling `needs:` that stops the whole workflow from loading.* - **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.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. 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. 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 b3d8f39b0..b9f199093 100644 --- a/docs/reusable-workflows.md +++ b/docs/reusable-workflows.md @@ -499,7 +499,7 @@ A repo whose package claims more than one interpreter names them all in `python- python-versions: '["3.13", "3.14"]' ``` -The default is empty, so a caller naming nothing runs one leg, on the line its root `.python-version` selects. A caller carrying no such file runs the hub's fallback line, 3.14, and its `lint` job warns that it did. So a caller whose `requires-python` or locked dependencies exclude 3.14 adds a `.python-version` before it moves its hub pin. A caller moving onto the fallback also moves its nested check name and its Codecov flag to 3.14. So a `.codecov.yml` naming the old flag stops matching it. Each leg uploads under a `python-` Codecov flag of its own. That keeps the legs apart in the dashboard rather than merging them into one number. And `fail-fast: false` reports a failing interpreter beside a passing one rather than cancelling the run at the first. Two things move on adoption. The nested check reads `Unit test job (Python )` rather than `Unit test job`, which binds no ruleset, only the caller's own aggregator being bound. The nested check reads that way whether or not a Python step ran, so a .NET-only caller reports a version it never used. And a repo that already uploaded Python coverage here uploaded it unflagged. So its series stops there and a `python-` one starts beside it. +The default is empty, so a caller naming nothing runs one leg, on the line its root `.python-version` selects. A caller carrying no such file runs the hub's fallback line, 3.14, and its `lint` job warns that it did. So a caller whose `requires-python` or locked dependencies exclude 3.14 adds a `.python-version` before it moves its hub pin. A caller moving onto the fallback also moves its nested check name and its Codecov flag to 3.14. So a `.codecov.yml` naming the old flag stops matching it. Each leg uploads under a `python-` Codecov flag of its own. That keeps the legs apart in the dashboard rather than merging them into one number. And `fail-fast: false` reports a failing interpreter beside a passing one rather than cancelling the run at the first. Two things move on adoption. The nested check reads `Unit test job (Python )` rather than `Unit test job`, which binds no ruleset, only the caller's own aggregator being bound. A .NET-only caller reports no Python leg, since the job skips where no Python directory resolves. And a repo that already uploaded Python coverage here uploaded it unflagged. So its series stops there and a `python-` one starts beside it. Quote each entry, and give each one a version. The `Build test matrix job` runs first on every call and refuses an array holding an entry with no non-whitespace character. Such a value would otherwise run green on an interpreter nobody chose. That is because `setup-uv` trims what it reads and then reads an empty input as an absent one. A caller reaches that by interpolating an unset value of its own, or by leaving a stray space beside it. The job also refuses an unquoted entry, since `fromJSON` admits a JSON array of numbers. Some of those numbers `uv` resolves to a real interpreter, `'[3]'` among them, so an unquoted entry is a second silent pass. The job refuses an empty array, a non-array, and concatenated JSON values, each with a named cause. The `unit-test` job and its `Run Python tests step` never see a bad `python-versions`. diff --git a/spec/project-types.json b/spec/project-types.json index 6ae40339a..3280d09bf 100644 --- a/spec/project-types.json +++ b/spec/project-types.json @@ -12,7 +12,7 @@ { "id": "csharp.analyzers.zerowarnings", "verdict": "intent", "assert": "Analyzer severities are enforced; warnings are not relaxed or suppressed wholesale.", "intentRef": "CODESTYLE.md" }, { "id": "csharp.centralconfig.props", "verdict": "letter", "assert": "Shared MSBuild configuration is centralized at the repo root: Directory.Build.props carries the common analyzer and warning properties (the Zero Warnings set), and Directory.Packages.props enables ManagePackageVersionsCentrally with every dependency version declared once - a csproj carries only project-specific properties and versionless PackageReference items.", "intentRef": "CODESTYLE.md" }, { "id": "csharp.sdk.globaljson", "verdict": "letter", "assert": "A root global.json exists and carries an sdk block. Its version is exactly .0.100 for the repo's highest .NET TFM major, never a netstandard target's (10.0.100 alongside net10.0, and 11.0.100 alongside net10.0;net11.0). It sets rollForward latestFeature and allowPrerelease false, so the local dotnet host selects the SDK line CI installs. The line is the repository's own and need not be the hub baseline's. A carried .NET devcontainer's image tag names the same major. So does the first entry of any dotnet-versions value a caller passes the hub's validate-task.yml. No .props or .targets file the repository holds sets LangVersion, the SDK's own targets aside. Nor does any .csproj targeting a .NET TFM. A netstandard analyzer or source-generator .csproj may set a fixed number, the .NET TFM's C# version. No repository file sets LangVersion to latest, latestMajor, or preview, or sets EnablePreviewFeatures. Required for every C# repo.", "intentRef": "CODESTYLE.md" }, - { "id": "csharp.coverage.codecov", "verdict": "letter", "assert": "The .NET unit-test legs collect coverage (dotnet test --framework net --coverage --coverage-output-format cobertura --results-directory ./coverage, with the output filename left unset so each test project writes its own report rather than overwriting a shared one) and uploads it to Codecov via codecov/codecov-action, best-effort (fail_ci_if_error: false so a Codecov outage or an absent token never reds the gate). CODECOV_TOKEN is stored in both the repo actions and dependabot secrets stores, the second so the upload does not skip on a Dependabot PR, and the caller maps it to the reusable validator by name. The validator prefixes each report to coverage-.cobertura.xml before uploading, since codecov-cli does not match the default name. Where the repo's test project is MTP-based (xunit.v3 4.0.0 or later), it also carries a root global.json declaring test.runner as Microsoft.Testing.Platform, references Microsoft.Testing.Extensions.CodeCoverage at 18.9.0 or later rather than coverlet.collector, and drops xunit.runner.visualstudio. A test project not yet MTP-based keeps the VSTest collector and its existing pin, which is a migration owed rather than drift. Required for every C# repo with tests.", "intentRef": "WORKFLOW.md", "minProfile": "build" } + { "id": "csharp.coverage.codecov", "verdict": "letter", "assert": "The unit-test job collects coverage (dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage, run once per declared .NET line, with the output filename left unset so each test project writes its own report rather than overwriting a shared one) and uploads it to Codecov via codecov/codecov-action, best-effort (fail_ci_if_error: false so a Codecov outage or an absent token never reds the gate). CODECOV_TOKEN is stored in both the repo actions and dependabot secrets stores, the second so the upload does not skip on a Dependabot PR, and the caller maps it to the reusable validator by name. The validator prefixes each report to coverage-.cobertura.xml before uploading, since codecov-cli does not match the default name. Where the repo's test project is MTP-based (xunit.v3 4.0.0 or later), it also carries a root global.json declaring test.runner as Microsoft.Testing.Platform, references Microsoft.Testing.Extensions.CodeCoverage at 18.9.0 or later rather than coverlet.collector, and drops xunit.runner.visualstudio. A test project not yet MTP-based keeps the VSTest collector and its existing pin, which is a migration owed rather than drift. Required for every C# repo with tests.", "intentRef": "WORKFLOW.md", "minProfile": "build" } ] }, "nuget": { diff --git a/tests/test_release_guards.py b/tests/test_release_guards.py index 080c37da7..83c124d3b 100755 --- a/tests/test_release_guards.py +++ b/tests/test_release_guards.py @@ -2272,7 +2272,12 @@ def test_validator_runs_each_dotnet_line_and_python_line_as_its_own_leg(self) -> # Each invocation names its framework, and the value reaches the script through env. script = step_script_text(dotnet_job, "Run unit tests step") - self.assertEqual(2, len(re.findall(r"(?m)^\s*(?:\S.*\s)?dotnet test ", script)) - 1) + invocations = [ + line + 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" ')) run_step = yaml_step(dotnet_job, "Run unit tests step") self.assertEqual( From 91ff5afcb5c771cb86c45329258d19aaf86726f8 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 3 Dec 2026 06:59:32 -0800 Subject: [PATCH 3/5] Assert the .NET Matrix Wiring and Fix Two Stale References Co-Authored-By: Claude Sonnet 5.5 --- docs/reusable-workflows.md | 2 +- spec/project-types.json | 2 +- tests/test_release_guards.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/reusable-workflows.md b/docs/reusable-workflows.md index b9f199093..92e36e1fe 100644 --- a/docs/reusable-workflows.md +++ b/docs/reusable-workflows.md @@ -56,7 +56,7 @@ A workflow whose job graph is identical across repos of a type is reached, not c ### The Hook Contract -A hook receives the fixed inputs [WORKFLOW.md "Reusable-Task Parameter Contract"][workflow-reusable-task-parameter-contract] gives a leaf today. Those are `ref`, `branch`, `smoke` where relevant, and the NBGV version outputs where a build needs them. It reports back through step outputs and, for a release target, through the existing artifact seam, `release-asset--`, which the hub's `github-release` job collects by pattern. Each task finds a hook by its `action.yml` alone, so a hook named `action.yaml` is never run. The `install-test-deps` hook is an exception, taking `leg` and `directories` inputs and reporting nothing back. It may also run a check that needs that leg's environment. A failure there fails the leg's `unit-test` job before its Python tests run. The `pre-test` hook is another, taking no inputs and reporting nothing back. Each `unit-test` leg runs it before the .NET SDK setup, where a .NET test project exists and the caller carries the hook. So a system tool a .NET test shells out to is installed before those tests run. The `build-release-asset` hook is another, writing its files into the `output-directory` it receives, on a smoke run too, and leaving the upload to the task. The task accepts only regular files at that directory's top level and refuses a subdirectory, a symlink, or a dot-prefixed name. A package hook also uploads the artifact its publish job consumes: a NuGet hook uploads `nuget-build-` as well as its `release-asset-*`. A PyPI hook uploads `pypi-build-` and no release asset at all. A NuGet or PyPI hook has to carry that exact package-artifact name or its publish job finds nothing. The `package-consume` hook is another, optional and taking `frameworks`, `package-id`, `version`, and `feed-dir` inputs while reporting nothing back. `build-nuget` runs it once after the hub default's own package consume check, in smoke and publish runs alike. So the hook loops over the JSON `frameworks` array itself. A caller carrying its own `build-nuget` hook gets neither check, since that hook's output location is unknown to the hub. The `validate` and `resolve-upstream` hooks can also take one string from their caller. `validate-task.yml` and `check-upstream-version-task.yml` each declare an optional `hook-input` input. Each passes a non-empty value on to its hook's own `hook-input` input. The task passes it from a step of its own, run only when the caller sets it. So a caller passing none runs a hook declaring no such input exactly as before. A caller that sets it needs a hook declaring `hook-input` as an optional input. The caller defines what the value means. It can name which of two callers runs the hook, or carry a change-gate result an expensive check skips on. The hub's no-op `validate-default` never receives it. A hook may use marketplace actions, which is the reason a hook is a composite action rather than a script. A toolchain setup, a Docker build, or a coverage upload is a `uses:` step, and a shell script cannot carry one. Action pins inside a hook follow the SHA-pinning rule like any other workflow content, and Dependabot bumps them in the repo that carries the hook. A hook runs with no persisted git credential, since every checkout ahead of a hook sets `persist-credentials: false`. A hook that runs git against the remote therefore passes its own credential to that call. +A hook receives the fixed inputs [WORKFLOW.md "Reusable-Task Parameter Contract"][workflow-reusable-task-parameter-contract] gives a leaf today. Those are `ref`, `branch`, `smoke` where relevant, and the NBGV version outputs where a build needs them. It reports back through step outputs and, for a release target, through the existing artifact seam, `release-asset--`, which the hub's `github-release` job collects by pattern. Each task finds a hook by its `action.yml` alone, so a hook named `action.yaml` is never run. The `install-test-deps` hook is an exception, taking `leg` and `directories` inputs and reporting nothing back. It may also run a check that needs that leg's environment. A failure there fails the leg's `unit-test` job before its Python tests run. The `pre-test` hook is another, taking no inputs and reporting nothing back. Each `unit-test-dotnet` leg runs it before the .NET SDK setup, where a .NET test project exists and the caller carries the hook. So a system tool a .NET test shells out to is installed before those tests run. The `build-release-asset` hook is another, writing its files into the `output-directory` it receives, on a smoke run too, and leaving the upload to the task. The task accepts only regular files at that directory's top level and refuses a subdirectory, a symlink, or a dot-prefixed name. A package hook also uploads the artifact its publish job consumes: a NuGet hook uploads `nuget-build-` as well as its `release-asset-*`. A PyPI hook uploads `pypi-build-` and no release asset at all. A NuGet or PyPI hook has to carry that exact package-artifact name or its publish job finds nothing. The `package-consume` hook is another, optional and taking `frameworks`, `package-id`, `version`, and `feed-dir` inputs while reporting nothing back. `build-nuget` runs it once after the hub default's own package consume check, in smoke and publish runs alike. So the hook loops over the JSON `frameworks` array itself. A caller carrying its own `build-nuget` hook gets neither check, since that hook's output location is unknown to the hub. The `validate` and `resolve-upstream` hooks can also take one string from their caller. `validate-task.yml` and `check-upstream-version-task.yml` each declare an optional `hook-input` input. Each passes a non-empty value on to its hook's own `hook-input` input. The task passes it from a step of its own, run only when the caller sets it. So a caller passing none runs a hook declaring no such input exactly as before. A caller that sets it needs a hook declaring `hook-input` as an optional input. The caller defines what the value means. It can name which of two callers runs the hook, or carry a change-gate result an expensive check skips on. The hub's no-op `validate-default` never receives it. A hook may use marketplace actions, which is the reason a hook is a composite action rather than a script. A toolchain setup, a Docker build, or a coverage upload is a `uses:` step, and a shell script cannot carry one. Action pins inside a hook follow the SHA-pinning rule like any other workflow content, and Dependabot bumps them in the repo that carries the hook. A hook runs with no persisted git credential, since every checkout ahead of a hook sets `persist-credentials: false`. A hook that runs git against the remote therefore passes its own credential to that call. ### Pinning diff --git a/spec/project-types.json b/spec/project-types.json index 3280d09bf..d90bf27c8 100644 --- a/spec/project-types.json +++ b/spec/project-types.json @@ -12,7 +12,7 @@ { "id": "csharp.analyzers.zerowarnings", "verdict": "intent", "assert": "Analyzer severities are enforced; warnings are not relaxed or suppressed wholesale.", "intentRef": "CODESTYLE.md" }, { "id": "csharp.centralconfig.props", "verdict": "letter", "assert": "Shared MSBuild configuration is centralized at the repo root: Directory.Build.props carries the common analyzer and warning properties (the Zero Warnings set), and Directory.Packages.props enables ManagePackageVersionsCentrally with every dependency version declared once - a csproj carries only project-specific properties and versionless PackageReference items.", "intentRef": "CODESTYLE.md" }, { "id": "csharp.sdk.globaljson", "verdict": "letter", "assert": "A root global.json exists and carries an sdk block. Its version is exactly .0.100 for the repo's highest .NET TFM major, never a netstandard target's (10.0.100 alongside net10.0, and 11.0.100 alongside net10.0;net11.0). It sets rollForward latestFeature and allowPrerelease false, so the local dotnet host selects the SDK line CI installs. The line is the repository's own and need not be the hub baseline's. A carried .NET devcontainer's image tag names the same major. So does the first entry of any dotnet-versions value a caller passes the hub's validate-task.yml. No .props or .targets file the repository holds sets LangVersion, the SDK's own targets aside. Nor does any .csproj targeting a .NET TFM. A netstandard analyzer or source-generator .csproj may set a fixed number, the .NET TFM's C# version. No repository file sets LangVersion to latest, latestMajor, or preview, or sets EnablePreviewFeatures. Required for every C# repo.", "intentRef": "CODESTYLE.md" }, - { "id": "csharp.coverage.codecov", "verdict": "letter", "assert": "The unit-test job collects coverage (dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage, run once per declared .NET line, with the output filename left unset so each test project writes its own report rather than overwriting a shared one) and uploads it to Codecov via codecov/codecov-action, best-effort (fail_ci_if_error: false so a Codecov outage or an absent token never reds the gate). CODECOV_TOKEN is stored in both the repo actions and dependabot secrets stores, the second so the upload does not skip on a Dependabot PR, and the caller maps it to the reusable validator by name. The validator prefixes each report to coverage-.cobertura.xml before uploading, since codecov-cli does not match the default name. Where the repo's test project is MTP-based (xunit.v3 4.0.0 or later), it also carries a root global.json declaring test.runner as Microsoft.Testing.Platform, references Microsoft.Testing.Extensions.CodeCoverage at 18.9.0 or later rather than coverlet.collector, and drops xunit.runner.visualstudio. A test project not yet MTP-based keeps the VSTest collector and its existing pin, which is a migration owed rather than drift. Required for every C# repo with tests.", "intentRef": "WORKFLOW.md", "minProfile": "build" } + { "id": "csharp.coverage.codecov", "verdict": "letter", "assert": "The .NET unit-test job collects coverage (dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage, run once per declared .NET line, with the output filename left unset so each test project writes its own report rather than overwriting a shared one) and uploads it to Codecov via codecov/codecov-action, best-effort (fail_ci_if_error: false so a Codecov outage or an absent token never reds the gate). CODECOV_TOKEN is stored in both the repo actions and dependabot secrets stores, the second so the upload does not skip on a Dependabot PR, and the caller maps it to the reusable validator by name. The validator prefixes each report to coverage-.cobertura.xml before uploading, since codecov-cli does not match the default name. Where the repo's test project is MTP-based (xunit.v3 4.0.0 or later), it also carries a root global.json declaring test.runner as Microsoft.Testing.Platform, references Microsoft.Testing.Extensions.CodeCoverage at 18.9.0 or later rather than coverlet.collector, and drops xunit.runner.visualstudio. A test project not yet MTP-based keeps the VSTest collector and its existing pin, which is a migration owed rather than drift. Required for every C# repo with tests.", "intentRef": "WORKFLOW.md", "minProfile": "build" } ] }, "nuget": { diff --git a/tests/test_release_guards.py b/tests/test_release_guards.py index 83c124d3b..e3ea804ee 100755 --- a/tests/test_release_guards.py +++ b/tests/test_release_guards.py @@ -2308,6 +2308,17 @@ def test_validator_runs_each_dotnet_line_and_python_line_as_its_own_leg(self) -> self.assertNotIn(needle, python_job) self.assertIn(" if: ${{ needs.test-matrix.outputs.python-any == 'true' }}\n", python_job) self.assertIn("python-any: ${{ steps.python-directories.outputs.any }}", builder) + self.assertIn("dotnet-matrix: ${{ steps.build.outputs.dotnet-matrix }}", builder) + self.assertIn("dotnet-tests: ${{ steps.build.outputs.dotnet-tests }}", builder) + build = yaml_step(builder, "Build unit-test matrix step") + self.assertEqual( + "${{ steps.dotnet-sdk.outputs.lines }}", yaml_value(build, "env", "DOTNET_LINES") + ) + self.assertEqual( + "${{ hashFiles('**/*Tests*.csproj') != '' }}", yaml_value(build, "env", "DOTNET_TESTS") + ) + sdk = yaml_step(builder, "Validate dotnet-versions input step") + self.assertEqual("dotnet-sdk", yaml_value(sdk, "id")) resolve = yaml_step(builder, "Resolve Python directories step") self.assertEqual("$/.github/actions/python-directories", yaml_value(resolve, "uses")) self.assertEqual( From e829600c950a0385ae346e1548f0f009af594dc2 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 3 Dec 2026 07:03:13 -0800 Subject: [PATCH 4/5] Fix Two Stale Single-Job References Co-Authored-By: Claude Sonnet 5.5 --- .github/actions/validate-default/action.yml | 2 +- docs/reusable-workflows.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/validate-default/action.yml b/.github/actions/validate-default/action.yml index 7727711c4..ff3b20bc9 100644 --- a/.github/actions/validate-default/action.yml +++ b/.github/actions/validate-default/action.yml @@ -1,7 +1,7 @@ # The hub default for the validate hook, used when a caller carries no .github/actions/validate/action.yml of its own. # A repo with no domain checks of its own has nothing for this hook to run. # These domain checks include an ESPHome compile, a Hugo build, a KiCad ERC, codegen drift, and PowerShell tests. -# The fleet doc-lint block plus the generic unit-test job already cover everything else validate-task.yml checks. +# The fleet doc-lint block plus the generic unit-test jobs already cover everything else validate-task.yml checks. name: Validate repository (default) description: No-op default for the validate hook. diff --git a/docs/reusable-workflows.md b/docs/reusable-workflows.md index 92e36e1fe..60187cafe 100644 --- a/docs/reusable-workflows.md +++ b/docs/reusable-workflows.md @@ -87,7 +87,7 @@ The target set. A row exists once its hub task ships, and until then the row is | Hub task | Hooks, at `.github/actions//action.yml` in the caller | Hub default | | --- | --- | --- | | `merge-bot-task.yml` | none, extra bot rules are a `with:` input | not applicable | -| `validate-task.yml` | `validate` (a repo's own domain checks, beyond the fleet doc-lint block and the generic unit-test job), `install-test-deps` (a `test-matrix` leg's dependency install and per-leg checks). Also `pre-test`, for system tools the .NET tests need | no-op for `validate`, none for `install-test-deps`, which is required where `test-matrix` or `test-matrix-file` is set. None for `pre-test` | +| `validate-task.yml` | `validate` (a repo's own domain checks, beyond the fleet doc-lint block and the generic unit-test jobs), `install-test-deps` (a `test-matrix` leg's dependency install and per-leg checks). Also `pre-test`, for system tools the .NET tests need | no-op for `validate`, none for `install-test-deps`, which is required where `test-matrix` or `test-matrix-file` is set. None for `pre-test` | | `get-version-task.yml`, `publish-plan-task.yml` | none | not applicable | | `build-release-task.yml` | `dotnet-publish`, `build-nuget`, `build-pypi`, `build-release-asset` | `dotnet-publish-default`, `nuget-build-default` followed by `package-consume-nuget`, `pypi-build-default` followed by `package-consume-pypi`, none for `build-release-asset`, which is required where `enable_release_asset` is set | | `build-docker-task.yml` | `docker-prepare` (extra tags, build-args, matrix), `docker-build-base` | vanilla single-target from `image`, base build required when `build-base` | @@ -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, a lower framework's tests run only where the runner image happens to carry its runtime. +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 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. From 182131d72d5d3c277831bae757946d5ede6ac3b0 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 3 Dec 2026 07:31:30 -0800 Subject: [PATCH 5/5] Reword the Python Version Comment for the Whole-Tree Checkout Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/validate-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index dd0550efe..4ffcfcb0d 100644 --- a/.github/workflows/validate-task.yml +++ b/.github/workflows/validate-task.yml @@ -81,7 +81,7 @@ jobs: with: persist-credentials: false - # This job cannot tell whether the caller holds Python, so the lint job, which can, warns of a fallback instead. + # The lint job warns of a fallback line, so this job selects it without repeating the warning. - name: Select Python version step id: python-version if: ${{ inputs.python-versions == '' }}