diff --git a/Adopt-Project.ps1 b/Adopt-Project.ps1 index 6a57f2cd..a750c016 100644 --- a/Adopt-Project.ps1 +++ b/Adopt-Project.ps1 @@ -29,7 +29,7 @@ When tag-release.yml calls a ci.yml the repository kept, it prints the notes .\.template\Update-Project.ps1 prints when that ci.yml has no workflow_call trigger, or when its top-level permissions or a job's ask for more than contents: read, which tag-release.yml grants it: until then, no release is tagged (ADR-0026). - When the repository has version.json, it prints the note .\.template\Update-Project.ps1 prints for each job of the repository's own workflows, other than publish.yml, that builds with an actions/checkout step without fetch-depth: 0 or a -p:Version argument, which Nerdbank.GitVersioning fails on or ignores (ADR-0138). + When the repository has version.json, it prints the note .\.template\Update-Project.ps1 prints for each job of the repository's own workflows, other than publish.yml, that builds in the folder of an actions/checkout step without fetch-depth: 0, or with a -p:Version argument, which Nerdbank.GitVersioning fails on or ignores (ADR-0138). When the SECURITY.md the adoption leaves says releases are immutable and a workflow in .github/workflows runs on a release event or uploads release assets, it prints the note .\.template\Update-Project.ps1 prints: delete that diff --git a/CHANGELOG.md b/CHANGELOG.md index 2febca5b..57803c00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +## [0.111.3] - 2026-11-21 + +### Fixed + +- The template's `code-review.yml` pins NCode Review v1.5.0, released on 2026-11-21, by ADR-0009's commented exception until its three-day cooldown ends on 2026-11-24, and the NCode Review note `.template/Update-Project.ps1` prints says a project adopts v1.5.0 from that day, or sooner only by such an exception ([#464](https://github.com/NCodeGroup/project-template/issues/464), [ADR-0009](template/docs/decisions/project-template/0009-new-dependency-versions-wait-a-cooldown.md)). +- `.template/Update-Project.ps1` and `Adopt-Project.ps1` name a shallow `actions/checkout` of a job that builds with Nerdbank.GitVersioning only when a build step runs in its folder, by the step's `working-directory:` or the job's or workflow's `defaults:`, and give a named checkout's `path:`, so a checkout such as `path: current` beside a build with `working-directory: rebuild` is no longer flagged ([#465](https://github.com/NCodeGroup/project-template/issues/465), [ADR-0138](template/docs/decisions/project-template/0138-package-versions-come-from-version-json-through-nerdbank-gitversioning.md)). + ## [0.111.2] - 2026-11-21 ### Added @@ -1817,7 +1824,8 @@ To run the v0.9.0 logic on the first update instead, run the wrapper from a clon - The .NET layer: `build/ProjectTemplate.props` (latest C#, nullable reference types, implicit usings, warnings as errors, `ContinuousIntegrationBuild` when `CI=true`, author metadata), central package management in `Directory.Packages.props`, the SDK in `global.json`, and C# conventions for Copilot and Claude Code. - CI on GitHub or GitLab that runs the build and test commands, with GitHub Actions pinned to commit SHAs, and on GitHub, Dependabot for the CI actions and, by stack, packages and the .NET SDK. -[unreleased]: https://github.com/NCodeGroup/project-template/compare/v0.111.2...HEAD +[unreleased]: https://github.com/NCodeGroup/project-template/compare/v0.111.3...HEAD +[0.111.3]: https://github.com/NCodeGroup/project-template/compare/v0.111.2...v0.111.3 [0.111.2]: https://github.com/NCodeGroup/project-template/compare/v0.111.1...v0.111.2 [0.111.1]: https://github.com/NCodeGroup/project-template/compare/v0.111.0...v0.111.1 [0.111.0]: https://github.com/NCodeGroup/project-template/compare/v0.110.0...v0.111.0 diff --git a/README.md b/README.md index cdd3533a..9147aed2 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,7 @@ Some judgment is left to you. The script prints it as a ready request: folding ` When the repository has version tags merged into the current branch that its changelog has no section for, the request also says to backfill them, such as `backfill CHANGELOG.md from the releases v0.1.0..v0.3.0`. The changelog is the file the `changelog` key of `AGENTS.md`'s Landing section names, `CHANGELOG.md` by default, and only tags shaped like `v1.2.3` or `1.2.3` count. With `pre-release: untracked` in that Landing section, the tags below 1.0.0 don't count. -For a .NET library, adoption sets the `version.json` it adds to the patch after the newest release tag, with the `assemblyVersion` a release of its current major shipped when it was built with a higher one than the template pins, such as `{ "version": "5.3", "precision": "minor" }`, and the request asks to add `-p:PublicRelease=true` to a `publish.yml` the repository keeps without it. A library whose own workflow already runs `nuget push` keeps it alone, without the template's `publish.yml`, `release-provenance.yml` or `raise-baseline.yml`, records it in the `nuget_publisher` answer, and the report says so. Adoption drops the repository's own Nerdbank.GitVersioning reference, which `build/ProjectTemplate.props` makes a second one once `version.json` exists, and reports it; the update warns about a `.gitlab-ci.yml` that packs without `PublicRelease=true` or `GIT_DEPTH: "0"`, as it does for a `publish.yml`, and both name each job of the repository's own workflows that checks out without `fetch-depth: 0` or passes `-p:Version`. Adoption and the update both name the stale NuGet logistics of an older library (an unimported `.props` file, `GeneratePackageOnBuild`, settings the template already makes, a `.sln`, a UTF-8 BOM, projects at the root) and fix none (ADR-0149). They also compare each packable project's Description and PackageTags with the newest published package and name any that differ. A repository that keeps its own `.github/workflows/publish.yml` without a `workflow_dispatch` trigger gets the warning `Update-Project.ps1` prints for it: the Release workflow, `tag-release.yml`, starts `publish.yml` through that trigger, so until it has one, a release ships no packages. +For a .NET library, adoption sets the `version.json` it adds to the patch after the newest release tag, with the `assemblyVersion` a release of its current major shipped when it was built with a higher one than the template pins, such as `{ "version": "5.3", "precision": "minor" }`, and the request asks to add `-p:PublicRelease=true` to a `publish.yml` the repository keeps without it. A library whose own workflow already runs `nuget push` keeps it alone, without the template's `publish.yml`, `release-provenance.yml` or `raise-baseline.yml`, records it in the `nuget_publisher` answer, and the report says so. Adoption drops the repository's own Nerdbank.GitVersioning reference, which `build/ProjectTemplate.props` makes a second one once `version.json` exists, and reports it; the update warns about a `.gitlab-ci.yml` that packs without `PublicRelease=true` or `GIT_DEPTH: "0"`, as it does for a `publish.yml`, and both name each job of the repository's own workflows that builds in a checkout without `fetch-depth: 0` or passes `-p:Version`, leaving out a checkout no build step's working directory lies in. Adoption and the update both name the stale NuGet logistics of an older library (an unimported `.props` file, `GeneratePackageOnBuild`, settings the template already makes, a `.sln`, a UTF-8 BOM, projects at the root) and fix none (ADR-0149). They also compare each packable project's Description and PackageTags with the newest published package and name any that differ. A repository that keeps its own `.github/workflows/publish.yml` without a `workflow_dispatch` trigger gets the warning `Update-Project.ps1` prints for it: the Release workflow, `tag-release.yml`, starts `publish.yml` through that trigger, so until it has one, a release ships no packages. ```text Still to do — in the repository, run: @@ -430,7 +430,7 @@ No license: the license answer is blank and the repository has no LICENSE or COP When the `best_practices_project` answer is set and `README.md` doesn't show the project's OpenSSF Best Practices badge, the update says so, also when the project is already up to date, and prints the line to add near the top of `README.md`, which `documentation_achievements` asks for within 48 hours of earning a level: `README.md` is project-owned, so the template never adds it there ([ADR-0025](template/docs/decisions/project-template/0025-every-best-practices-criterion-is-mapped-in-a-template-owned-page.md)). -With NCode Review, when `.github/workflows/code-review.yml` pins `NCodeGroup/code-review` before v1.5.0, passes no `approve: true` or passes it without `approver-private-key`, or `AGENTS.md`'s Landing section doesn't say `draft: yes`, the update says what to change, also when the project is already up to date, to store the approver's key with NCodeGroup/code-review's `tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath`, and to run `tools/Set-RepositoryBaseline.ps1` again, so the default branch requires one approval, of the last push, once NCode Review's approver is set up or a second person has write access, and none with one writer otherwise, since GitHub counts no approval from NCode Review's own app ([ADR-0022](template/docs/decisions/project-template/0022-ncode-reviews-approval-gates-the-merge.md.jinja), [ADR-0034](template/docs/decisions/project-template/0034-with-one-writer-the-baseline-requires-no-approval.md), [ADR-0036](template/docs/decisions/project-template/0036-a-required-approval-is-met-by-ncode-reviews-approver-app.md)). Both files are the project's, so the update changes neither. +With NCode Review, when `.github/workflows/code-review.yml` pins `NCodeGroup/code-review` before v1.5.0, passes no `approve: true` or passes it without `approver-private-key`, or `AGENTS.md`'s Landing section doesn't say `draft: yes`, the update says what to change, also when the project is already up to date, to store the approver's key with NCodeGroup/code-review's `tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath`, and to run `tools/Set-RepositoryBaseline.ps1` again, so the default branch requires one approval, of the last push, once NCode Review's approver is set up or a second person has write access, and none with one writer otherwise, since GitHub counts no approval from NCode Review's own app ([ADR-0022](template/docs/decisions/project-template/0022-ncode-reviews-approval-gates-the-merge.md.jinja), [ADR-0034](template/docs/decisions/project-template/0034-with-one-writer-the-baseline-requires-no-approval.md), [ADR-0036](template/docs/decisions/project-template/0036-a-required-approval-is-met-by-ncode-reviews-approver-app.md)). It also says that NCode Review v1.5.0, published on 2026-11-21, waits out the three-day cooldown of [ADR-0009](template/docs/decisions/project-template/0009-new-dependency-versions-wait-a-cooldown.md) until 2026-11-24, or is adopted sooner only by that record's commented exception. Both files are the project's, so the update changes neither. When the project has version tags merged into the current branch that its changelog has no section for, such as releases from before it had a changelog, the update ends with a request to backfill them: @@ -439,7 +439,7 @@ Version tags without a section in CHANGELOG.md: v0.1.0..v0.3.0. To give the chan /plan-migration Backfill CHANGELOG.md from the releases v0.1.0..v0.3.0 ``` -For a .NET library whose current major has a release built with a higher assembly version than `build/ProjectTemplate.props` pins, such as `5.3.0` built as `5.3.0.0` by a build that doesn't pin it, the update writes it into the `version.json` it adds, as the template's ADR-0136 and ADR-0138 say, or, for a library without `version.json`, names the `AssemblyVersion` to set in `Directory.Build.props` until the next major. It leaves `.github/workflows/publish.yml` out of a library whose own workflow already runs `nuget push`, so a published release runs one publisher, and warns when both exist; the `nuget_publisher` answer then names that workflow, so the update also leaves out `release-provenance.yml` and `raise-baseline.yml`, deleting them where an earlier update added them, and renders the documents it adds, and the template changes it shows, with that workflow in place of `publish.yml`. A `version.json` the update adds starts at the patch after the newest release tag, and while the library has one, the update warns about a `publish.yml` that packs without `-p:PublicRelease=true` and names the files that reference Nerdbank.GitVersioning themselves, and each job of the project's own workflows, other than `publish.yml`, that builds, packs, tests or pushes packages with an `actions/checkout` step without `fetch-depth: 0`, on which Nerdbank.GitVersioning fails the build, or with a `-p:Version` argument, which it ignores. A NuGet package needs a license: when a library's answers and `-Data` give none, the update stops before it changes anything and prints the `-Data @{ license = '' }` to run it with. +For a .NET library whose current major has a release built with a higher assembly version than `build/ProjectTemplate.props` pins, such as `5.3.0` built as `5.3.0.0` by a build that doesn't pin it, the update writes it into the `version.json` it adds, as the template's ADR-0136 and ADR-0138 say, or, for a library without `version.json`, names the `AssemblyVersion` to set in `Directory.Build.props` until the next major. It leaves `.github/workflows/publish.yml` out of a library whose own workflow already runs `nuget push`, so a published release runs one publisher, and warns when both exist; the `nuget_publisher` answer then names that workflow, so the update also leaves out `release-provenance.yml` and `raise-baseline.yml`, deleting them where an earlier update added them, and renders the documents it adds, and the template changes it shows, with that workflow in place of `publish.yml`. A `version.json` the update adds starts at the patch after the newest release tag, and while the library has one, the update warns about a `publish.yml` that packs without `-p:PublicRelease=true` and names the files that reference Nerdbank.GitVersioning themselves, and each job of the project's own workflows, other than `publish.yml`, that builds, packs, tests or pushes packages with an `actions/checkout` step without `fetch-depth: 0` whose folder holds such a step's working directory (its `working-directory:`, or the job's or workflow's `defaults:`), on which Nerdbank.GitVersioning fails the build, or with a `-p:Version` argument, which it ignores. A NuGet package needs a license: when a library's answers and `-Data` give none, the update stops before it changes anything and prints the `-Data @{ license = '' }` to run it with. To plan an update instead of running it, run `/plan-template-update` in the project, or name a version: `/plan-template-update v0.14.0`. It reads `.copier-answers.yml` and the release notes since the project's version, runs `Update-Project.ps1 -NoCommit` on a clone of the project in a temporary folder, and plans from what that trial changed. The plan's first step runs the update with `-Ref` pinned to the target and `-NoCommit`, so it is committed as a plan step, and a result that differs from the trial escalates. The next steps run the project's checks and fix the project's own files that still describe the old template, and the last runs the project's tests. Every check is judged by its exit code. The planning session files an issue here for each gap in the template that the trial shows. In Claude Code the plan gets its own worktree, unless the project's `plan-executor` subagent predates v0.11.0 and can't run PowerShell there; then it runs on a `build/project-template-` branch in the current checkout. A project on v0.13.0 or earlier doesn't have the command yet: compose it from this repository's clone with `.\workflow\New-PlanPrompt.ps1 plan-template-update`, or install the commands for your user with `.\workflow\Install-HybridWorkflow.ps1 -User`. @@ -603,7 +603,7 @@ A Dependabot pull request that only moves the NCode Review pin in `.github/workf | `tests/Test-InvokeAllTests.ps1`: `tests/Invoke-AllTests.ps1` runs only the `Test-*.ps1` scripts in a folder and then each `-SetupOnly` line of the `.github/workflows/test-template.yml` in its parent folder, in the workflow's order, each with a `-Work` folder of its own and a log, skipping a line without `-SetupOnly` and counting a failed setup as failed, prints `PASS` or `FAIL` per suite with a failed suite's `FAIL` lines, logs each suite's output, counts a suite that throws as failed, passes `-SkipDotnetBuild` only to suites that take it, points the suites' Copier cache at the run's own folder, exits 1 when a suite fails or none is found, prints the run's wall-clock time as `Time: ` and ends with `All tests: PASSED` or `All tests: FAILED ()`; runs two suites at once and prints their results in name order, not the order they finish, and one at a time with `-Serial` or `-ThrottleLimit 1`; two runs at once without `-Work` log to folders of their own, deleted when the run passes or finds no suites and kept when one fails; `tests/Remove-TestWork.ps1` deletes a folder or says it couldn't; and every suite with `-Work` keeps a folder of its own on a failure, or on an error, when it prints its path, and deletes it on a pass; every suite that builds a template snapshot keeps Copier's mirrors in its work folder, not the user's cache; `tests/Measure-Suites.ps1` prints a suite's median time over `-Repeat` runs and fails the run for a suite that fails, is missing or is slower than `-MaxSeconds`, passing `-SkipDotnetBuild` to a suite that takes it | Always | | `tests/Test-AgentRunner.ps1`: `tests/e2e/Agent.ps1`, against stand-ins for `claude` and `copilot`, runs a prompt and resumes its session with each tool's flags, Claude Code's `--permission-mode bypassPermissions` and `--strict-mcp-config`, Copilot's `--allow-all`, `--no-ask-user`, `--disable-builtin-mcps` and `--secret-env-vars=COPILOT_GITHUB_TOKEN` in a `COPILOT_HOME` of its own with `COPILOT_ALLOW_ALL=true` and the token it read before the run, and puts the environment back; reads the session, adds up the cost, a Copilot session's from its AI credits, prints the command that continues the session, fails a run that returns no session, and a Copilot run that ran no skill for its slash command or loaded an MCP server; takes `GH_TOKEN` when `COPILOT_GITHUB_TOKEN` is unset, with a warning that a general token is in use; caps a Copilot session at 30 AI credits at least and passes no cap for a budget of 0; warns with the path of a usage file it can't read and prints the cost as unknown or as at least what it read; stops a run past `-TimeoutMinutes` with its child processes and fails its session check; and names each tool's run checkout and installed command | Always | | `tests/Test-BrandKit.ps1`: `node brand/build.mjs --check` passes on the committed logo kit, a build into an empty folder writes every file the kit has and passes its own check, and the check fails, naming the file, once one is removed or holds something else | Always | -| `tests/Test-UpdateNotes.ps1`: `.template/Update-Project.ps1` passes `=false` for each opt-in answer the answers file lacks and `-Data` doesn't set; adoption answers `node_lint`, `coverage_gate` and `file_headers` off; the update says to add `workflow_call` to `ci.yml` when `tag-release.yml` calls it without one, and names each job of `ci.yml`, or its top-level `permissions:`, that asks for more than the `contents: read` `tag-release.yml` grants, in a block or a flow mapping, and nothing for `contents: read`, a `none` scope or a step's `with:` input; `tools/adopt/Adoption.psm1`'s copies print the same notes; and it prints the badge line to add when `best_practices_project` is set and `README.md` lacks the badge; and it says to delete or leave out `SECURITY.md`'s "Releases are immutable" paragraph when a workflow runs on a `release` event or uploads release assets, with copies of `Get-WorkflowEvents` and `Test-ReleaseAssetWorkflow` that match the baseline script's, and copies of those and `Get-ImmutableReleaseNote` in `Adopt-Project.ps1` that match the update's; the update names each job of a workflow other than `publish.yml` that builds without `fetch-depth: 0` or passes `-p:Version` once `version.json` exists, says what `code-review.yml` and `AGENTS.md` lack for NCode Review's approval, and works out the `nuget_publisher` and `release_policy` answers, and `tools/adopt/Adoption.psm1`'s copies print and answer the same | Always | +| `tests/Test-UpdateNotes.ps1`: `.template/Update-Project.ps1` passes `=false` for each opt-in answer the answers file lacks and `-Data` doesn't set; adoption answers `node_lint`, `coverage_gate` and `file_headers` off; the update says to add `workflow_call` to `ci.yml` when `tag-release.yml` calls it without one, and names each job of `ci.yml`, or its top-level `permissions:`, that asks for more than the `contents: read` `tag-release.yml` grants, in a block or a flow mapping, and nothing for `contents: read`, a `none` scope or a step's `with:` input; `tools/adopt/Adoption.psm1`'s copies print the same notes; and it prints the badge line to add when `best_practices_project` is set and `README.md` lacks the badge; and it says to delete or leave out `SECURITY.md`'s "Releases are immutable" paragraph when a workflow runs on a `release` event or uploads release assets, with copies of `Get-WorkflowEvents` and `Test-ReleaseAssetWorkflow` that match the baseline script's, and copies of those and `Get-ImmutableReleaseNote` in `Adopt-Project.ps1` that match the update's; the update names each job of a workflow other than `publish.yml` that builds in a checkout without `fetch-depth: 0`, by a step's own or default working directory, or passes `-p:Version` once `version.json` exists, says what `code-review.yml` and `AGENTS.md` lack for NCode Review's approval, and works out the `nuget_publisher` and `release_policy` answers, and `tools/adopt/Adoption.psm1`'s copies print and answer the same | Always | | `tests/Test-Coverage.ps1`: `.template/Test-Coverage.ps1` reads and merges Cobertura and LCOV reports, leaves out test code and the template's files, fails below 90% of the statements or 80% of the branches and names the least covered files, fails without a report, and passes a report that measures no code or no branches | Always | | `tests/Test-FileHeaders.ps1`: `.template/Test-FileHeaders.ps1` fails and names the source files without the copyright or the SPDX line, skips `.template/`, the five template-owned `build/` scripts, `vendor/`, git-ignored files and other kinds of files, checks a tracked `.d.ts` file, checks Astro components inside their frontmatter and stylesheets with `/* */` comments, `-Fix` adds the header at the top, after a `#!` line or inside an Astro frontmatter, a block of its own when there is none, and keeps CRLF and a byte order mark, and a blank license or no author narrows or skips the check | Always | | `tests/e2e/Test-RunIssues.ps1 -SetupOnly`: the fixture project, its local GitHub-shaped `origin` and the `gh` stand-in, where the state script sees `host: github` and `protected: hook`, `origin` has NCode Review's `code-review.yml`, and the stand-in gives a new pull request its seeded review threads and records thread replies; the stand-in gives NCode Review's review of a push on the first read after a `/review` comment that follows the push, footer or not, and with `-Scenario max-rounds` the Landing section has `max-review-rounds: 1`; with `-Scenario review-with-footer` the host folder has `footer.txt` and `footer-pr-only.txt`, which keeps the footer off issue comments, and NCode Review's review of the first push carries a request of the owner's; with `-Scenario push-branch` the Landing section has `max-review-rounds: 1`, `origin`'s `claude/fixture-push-a1b2` holds the head of a pull request #2 that `main` has as a squash commit, and the state script reads that push branch as `landed` from a plan's worktree; and the stand-in's `gh pr view ` picks a branch's open pull request over a merged one, and `gh pr list` without `--state` lists only open ones, as `gh` does | Always | diff --git a/template/.github/workflows/code-review.yml b/template/.github/workflows/code-review.yml index 908ad5c8..58f0e95f 100644 --- a/template/.github/workflows/code-review.yml +++ b/template/.github/workflows/code-review.yml @@ -24,6 +24,9 @@ name: Code review # docs/decisions/project-template/0022-ncode-reviews-approval-gates-the-merge.md, # 0034-with-one-writer-the-baseline-requires-no-approval.md and # 0036-a-required-approval-is-met-by-ncode-reviews-approver-app.md say why. +# v1.5.0 was released on 2026-11-21, under the three days ADR-0009 waits: approver-private-key needs it, so it is +# pinned by that record's commented exception, and this sentence goes once 2026-11-24 has passed +# (NCodeGroup/project-template#475). # # pull_request_target and issue_comment both run this file from the default branch, so a pull request can't change its # own review. The engine fetches its code only to read it: nothing from it is built, run or installed. diff --git a/template/.template/Update-Project.ps1 b/template/.template/Update-Project.ps1 index e0aeac3d..ab0e95bd 100644 --- a/template/.template/Update-Project.ps1 +++ b/template/.template/Update-Project.ps1 @@ -79,7 +79,7 @@ ADR-0151). When the project has version.json, it also warns about a publish.yml or a .gitlab-ci.yml that packs without -p:PublicRelease=true and names the files that reference Nerdbank.GitVersioning themselves (the template's ADR-0138). - It also names each job of the project's own workflows, other than publish.yml, that builds, packs, tests without --no-build or pushes packages with an actions/checkout step without fetch-depth: 0, on which Nerdbank.GitVersioning fails the build, or with a -p:Version argument, which it ignores. + It also names each job of the project's own workflows, other than publish.yml, that builds, packs, tests without --no-build or pushes packages with an actions/checkout step without fetch-depth: 0 whose folder holds such a step's working directory (its working-directory:, or the job's or the workflow's defaults:), on which Nerdbank.GitVersioning fails the build, or with a -p:Version argument, which it ignores; when it can't tell which checkout a step runs in, it names each shallow checkout of the job. Such a library's nuget_publisher answer names its own publishing workflows, so the update also leaves out or deletes release-provenance.yml and raise-baseline.yml, and its documents name those workflows instead of publish.yml. When -Data turns csharp_format on, it counts the C# files that don't start with the header .editorconfig sets and names the first five, because IDE0073 then fails the build for each (the template's ADR-0148); it rewrites none. An existing project keeps off the checks a new one starts with until -Data turns them on: csharp_format, node_lint, coverage_gate and file_headers are false when its answers lack them. @@ -95,7 +95,7 @@ in .github/workflows runs on a release event or uploads release assets, whose releases the template's tools/Set-RepositoryBaseline.ps1 leaves mutable, it says to delete or leave out that paragraph, also when the project is already up to date (the template's ADR-0028). - With NCode Review, when .github/workflows/code-review.yml pins NCodeGroup/code-review before v1.5.0, passes no approve: true or passes approve: true without approver-private-key, or AGENTS.md's Landing section doesn't say draft: yes, it says what to change, to store the approver's key with tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath from NCodeGroup/code-review and to run the template's tools/Set-RepositoryBaseline.ps1 again, also when the project is already up to date (the template's ADR-0022 and ADR-0036). + With NCode Review, when .github/workflows/code-review.yml pins NCodeGroup/code-review before v1.5.0, passes no approve: true or passes approve: true without approver-private-key, or AGENTS.md's Landing section doesn't say draft: yes, it says what to change, to store the approver's key with tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath from NCodeGroup/code-review and to run the template's tools/Set-RepositoryBaseline.ps1 again, also when the project is already up to date (the template's ADR-0022 and ADR-0036). It says that v1.5.0, published on 2026-11-21, waits out the three-day cooldown of the template's ADR-0009 until 2026-11-24, or is adopted sooner only by that record's commented exception. On Windows it stops before it changes anything when the project's template version has a path Git for Windows refuses to check out, such as the uses_node file names of v0.69.0 to v0.75.0, because the update starts with @@ -321,7 +321,8 @@ function Get-CiPermissionNote { # NCode Review approves a clean pull request only with approve: true, and from NCodeGroup/code-review v1.5.0 on submits the # approval as the NCode Review Approver, which meets a required approval, when approver-private-key is passed; code-review.yml -# and AGENTS.md are project-owned, so the update can only say what they still lack (the template's ADR-0022 and ADR-0036). +# and AGENTS.md are project-owned, so the update can only say what they still lack (the template's ADR-0022 and ADR-0036), +# and when ADR-0009's cooldown lets it adopt v1.5.0. function Get-CodeReviewNote { $workflow = '.github/workflows/code-review.yml' if (-not (Test-Path -LiteralPath $workflow -PathType Leaf)) { return } @@ -349,24 +350,39 @@ function Get-CodeReviewNote { } if (-not $findings.Count) { return } '' - "NCode Review approves a clean pull request only with approve: true, and from NCodeGroup/code-review v1.5.0 on, given approver-private-key, submits the approval as the NCode Review Approver, an app that can write, so the approval meets a required approval (the template's ADR-0022, ADR-0034 and ADR-0036, in docs/decisions/project-template/): $($findings -join '; '). Pin v1.5.0 or later and pass approve: true and approver-private-key: `${{ secrets.NCODE_REVIEW_APPROVER_PRIVATE_KEY }} in the review job of .github/workflows/code-review.yml, as the template's code-review.yml does, store the approver's key in the code-review environment with tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath from NCodeGroup/code-review, set - draft: yes in AGENTS.md's Landing section, so a pull request opens as a draft and marking it ready is the maintainer's review, then run the template's tools/Set-RepositoryBaseline.ps1 again, so the default branch dismisses stale approvals and requires one approval, of the last push, where the approver is set up or a second person has write access." + "NCode Review approves a clean pull request only with approve: true, and from NCodeGroup/code-review v1.5.0 on, given approver-private-key, submits the approval as the NCode Review Approver, an app that can write, so the approval meets a required approval (the template's ADR-0022, ADR-0034 and ADR-0036, in docs/decisions/project-template/): $($findings -join '; '). Pin v1.5.0 or later (published on 2026-11-21: the three-day cooldown of the template's ADR-0009 adopts it from 2026-11-24, and sooner only by that record's commented exception) and pass approve: true and approver-private-key: `${{ secrets.NCODE_REVIEW_APPROVER_PRIVATE_KEY }} in the review job of .github/workflows/code-review.yml, as the template's code-review.yml does, store the approver's key in the code-review environment with tools/Enable-CodeReview.ps1 -ApproverPrivateKeyPath from NCodeGroup/code-review, set - draft: yes in AGENTS.md's Landing section, so a pull request opens as a draft and marking it ready is the maintainer's review, then run the template's tools/Set-RepositoryBaseline.ps1 again, so the default branch dismisses stale approvals and requires one approval, of the last push, where the approver is set up or a second person has write access." } -# Nerdbank.GitVersioning, which version.json turns on (the template's ADR-0138), fails a build on a shallow clone and ignores -p:Version: name each job of the project's own workflows, other than publish.yml, which has its own check, that builds, packs, tests without --no-build or pushes packages with a shallow actions/checkout or a -p:Version argument. +# Nerdbank.GitVersioning, which version.json turns on (the template's ADR-0138), fails a build on a shallow clone and ignores -p:Version: name each job of the project's own workflows, other than publish.yml, which has its own check, that builds, packs, tests without --no-build or pushes packages in a shallow actions/checkout's folder, by the step's working-directory: or the job's or workflow's defaults:, or with a -p:Version argument. # tools/adopt/Adoption.psm1 has a deliberate copy of this function for the template's Adopt-Project.ps1. Change both together; tests/Test-UpdateNotes.ps1 runs both copies through the same cases. function Get-GitVersioningWorkflowNote { if (-not (Test-Path -LiteralPath version.json) -or -not (Test-Path -LiteralPath .github/workflows -PathType Container)) { return } $findings = [Collections.Generic.List[string]]::new() + # A folder as the workspace-relative path actions/checkout's path: or a working-directory: names it: '' for the workspace, $null for one this check can't place. + $folderOf = { + param([string]$Value) + $v = ($Value -replace '\s+#.*$', '').Trim().Trim('''', '"').Trim() + $v = $v -replace '^\$\{\{\s*github\.workspace\s*\}\}/?', '' -replace '^(?:\./)+', '' -replace '/+$', '' + if ($v -eq '.') { $v = '' } + if ($v -match '\$\{\{|^/|^[A-Za-z]:|(?:^|/)\.\.(?:/|$)') { return $null } + $v + } + # The first capture of Pattern in Lines, or $null when no line matches. + $valueIn = { param([string[]]$Lines, [string]$Pattern) foreach ($l in $Lines) { if ($l -match $Pattern) { return $Matches[1] } } } + $isBuild = { param([string]$Line) $Line -match '(?i)\bdotnet\s+(?:build|pack)\b' -or ($Line -match '(?i)\bdotnet\s+test\b' -and $Line -notmatch '--no-build') -or $Line -match '(?i)\bnuget(?:\.exe)?\s+push\b' } foreach ($file in @(Get-ChildItem -LiteralPath .github/workflows -File | Where-Object { $_.Name -match '\.ya?ml$' -and $_.Name -ne 'publish.yml' } | Sort-Object Name)) { - # The lines of each job under the top-level jobs: key, by job name. + # The lines of each job under the top-level jobs: key, by job name, and the lines of the top-level defaults: key. $jobs = [ordered]@{} + $defaults = [Collections.Generic.List[string]]::new() $inJobs = $false + $inDefaults = $false $jobIndent = -1 $current = $null foreach ($line in Get-Content -LiteralPath $file.FullName) { if ($line -match '^\s*(#.*)?$') { continue } $indent = $line.Length - $line.TrimStart().Length - if ($indent -eq 0) { $inJobs = $line -match '^jobs:\s*(#.*)?$'; $jobIndent = -1; $current = $null; continue } + if ($indent -eq 0) { $inJobs = $line -match '^jobs:\s*(#.*)?$'; $inDefaults = $line -match '^defaults:\s*(#.*)?$'; $jobIndent = -1; $current = $null; continue } + if ($inDefaults) { $defaults.Add($line); continue } if (-not $inJobs) { continue } if ($jobIndent -lt 0) { $jobIndent = $indent } if ($indent -eq $jobIndent -and $line -match '^\s*([\w-]+):') { @@ -376,24 +392,54 @@ function Get-GitVersioningWorkflowNote { } if ($current) { $jobs[$current].Add($line) } } + $workflowDefault = & $valueIn $defaults '^\s*working-directory:\s*(.*)$' foreach ($name in $jobs.Keys) { $lines = @($jobs[$name]) - $builds = @($lines | Where-Object { $_ -match '(?i)\bdotnet\s+(?:build|pack)\b' -or ($_ -match '(?i)\bdotnet\s+test\b' -and $_ -notmatch '--no-build') -or $_ -match '(?i)\bnuget(?:\.exe)?\s+push\b' }) - if (-not $builds.Count) { continue } - for ($i = 0; $i -lt $lines.Count; $i++) { - if ($lines[$i] -notmatch '\buses:\s*[''"]?actions/checkout@') { continue } + if (-not @($lines | Where-Object { & $isBuild $_ }).Count) { continue } + $stepAt = { + param([int]$At) # The step starts at the nearest line at or above that starts a list item, and ends before the next one no deeper. - $start = $i + $start = $At while ($start -ge 0 -and $lines[$start] -notmatch '^\s*-\s') { $start-- } - if ($start -lt 0) { $start = $i } + if ($start -lt 0) { $start = $At } $startIndent = $lines[$start].Length - $lines[$start].TrimStart().Length $end = $lines.Count for ($j = $start + 1; $j -lt $lines.Count; $j++) { if ($lines[$j] -match '^\s*-\s' -and ($lines[$j].Length - $lines[$j].TrimStart().Length) -le $startIndent) { $end = $j; break } } - $step = @($lines[$start..($end - 1)]) - if (-not @($step | Where-Object { $_ -match '(?