diff --git a/.agents/skills/testing/SKILL.md b/.agents/skills/testing/SKILL.md index 5ab8a2c7..0ae44953 100644 --- a/.agents/skills/testing/SKILL.md +++ b/.agents/skills/testing/SKILL.md @@ -49,12 +49,12 @@ dotnet test --no-build -c Release -- --treenode-filter "/*/*/*/*[PropertyName=va **Run tests for a specific framework only**: ```bash -dotnet test --no-build -c Release --framework net8.0 +dotnet test --no-build -c Release --framework net10.0 ``` **List all available tests without running them**: ```bash -dotnet run --no-build -c Release --framework net8.0 -- --list-tests +dotnet run --no-build -c Release --framework net10.0 -- --list-tests ``` **Key points about test filtering with TUnit / MTP v2**: diff --git a/.github/workflows/docs_validate.yml b/.github/workflows/docs_validate.yml index 4fc53e34..432f315e 100644 --- a/.github/workflows/docs_validate.yml +++ b/.github/workflows/docs_validate.yml @@ -20,7 +20,7 @@ jobs: with: fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - name: 🔗 Markup Link Checker (mlc) - uses: becheran/mlc@b0d0d353e04fcbcfd1d86716103d78a61e5b25dd # v1.2.2 + uses: becheran/mlc@d791bd6ae91ea883f02172e21f453ba8da45dfcd # v1.3.0 - name: Authenticate to Azure with GitHub OIDC id: azure-login # This tenant requires enterprise-issued assertions. Other owners restore anonymously. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ebf4b08b..0864bcda 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,7 +49,9 @@ Run `dotnet publish tools/dirs.proj -c Release` to publish the shipping-library Then run `./tools/dotnet-test-cloud.ps1 -Configuration Release -IncludeNativeAOT` to run managed TUnit tests and the published NativeAOT tests. The traversal projects discover projects under `src` and `test`; `test/AotCompatibilityTest` compiles the shipping assembly with NativeAOT, while `-IncludeNativeAOT` runs eligible test executables. These are separate validations. Keep test projects in the solution as well: managed test runs still use the solution, while the traversal handles NativeAOT publishing. -The test projects remain managed because the Moq-based tests and Roslyn analyzer tests rely on runtime code generation or dynamic composition.`nTest projects can opt out of NativeAOT publishing with `false`. +The test projects remain managed because the Moq-based tests and Roslyn analyzer tests rely on runtime code generation or dynamic composition. + +Test projects can opt out of NativeAOT publishing with `false`. Shipping libraries targeting .NET 8 or later opt into NativeAOT compatibility analysis with `IsAotCompatible`. Add each NativeAOT-compatible shipping assembly as a `TrimmerRootAssembly` in `test/AotCompatibilityTest`, and keep this project publishable in `test/dirs.proj`. Root `Directory.Build.props` supplies project-reference defaults for both traversal and SDK projects that remove the `_IsPublishing` global property for managed dependencies, avoiding duplicate project instances that write to the same outputs during parallel publishing. @@ -76,15 +78,16 @@ API and hand-written docs are found under the `docfx/` directory and are built b You can make changes and host the site locally to preview them by switching to that directory and running the `dotnet docfx --serve` command. After making a change, you can rebuild the docs site while the localhost server is running by running `dotnet docfx` again from a separate terminal. -DocFX metadata extraction suppresses `NU1901` through `NU1904` in `docfx/docfx.json` to match the nonfatal NuGet audit warning policy in `.github/workflows/build.yml`. +DocFX metadata extraction suppresses `NU1901` through `NU1904` in `docfx/docfx.json` to match the nonfatal NuGet audit warning policy in `azure-pipelines/dotnet.yml`. DocFX otherwise turns MSBuild workspace warnings into fatal documentation warnings under `--warningsAsErrors`. Normal builds still report these audit warnings, and other documentation warnings remain fatal in CI. The `.github/workflows/docs.yml` GitHub Actions workflow publishes the content of these docs to github.io if the workflow itself and [GitHub Pages is enabled for your repository](https://docs.github.com/en/pages/quickstart). -### Documentation validation feed authentication +### Documentation validation and Copilot feed authentication -The `.github/workflows/docs_validate.yml` workflow uses GitHub OIDC to authenticate +The `.github/workflows/docs_validate.yml` and `.github/workflows/copilot-setup-steps.yml` +workflows use GitHub OIDC to authenticate as the **azure-public/vside package pull** Entra application before `init.ps1` restores packages. It requests an Azure DevOps access token and supplies it through `NuGetPackageSourceCredentials_` for each Azure Artifacts source in @@ -98,12 +101,15 @@ Sign in with `gh auth login` and `az login --tenant 72f988bf-86f1-41af-91ab-2d7cd011db47 --allow-no-subscriptions` first. The signed-in identities need repository administration and permission to manage the app's federated credentials. Use `-WhatIf` to preview without making changes. -The script discovers the calling repository, trusts pull requests plus its default branch, -and can be rerun without duplicating credentials. +The script discovers the calling repository, trusts pull requests, its default branch, +and the `copilot` environment used by Copilot code review and cloud agent setup. +It can be rerun without duplicating credentials. Use `-Branches microbuild,release` to add other trusted branches; the default branch -and PR context are always included. The script reports each created or reused credential. -Credential names identify the owner, repository, and PR or branch context, for example -`github-AArnott-Library.Template-pull-request` and +and the PR and Copilot environment contexts are always included. +The script reports each created or reused credential. +Credential names identify the owner, repository, and PR, environment, or branch context, for example +`github-AArnott-Library.Template-pull-request`, +`github-AArnott-Library.Template-environment-copilot`, and `github-AArnott-Library.Template-branch-main`. Names requiring punctuation replacement or truncation include a short hash suffix to preserve uniqueness within Entra's name limits. @@ -111,6 +117,12 @@ This changes OIDC subjects for **all workflows** in the repository. Update any o trust policies (including environment subjects) before running it; existing Entra credentials are preserved. The script does not configure Azure DevOps feed permissions. +For repositories configured before Copilot environment trust was included, rerun the script +with any additional trusted branches retained, then re-request the Copilot review. +Copilot setup runs use an OIDC subject ending in `:environment:copilot`, rather than the +PR or branch subject, so those existing credentials alone do not authenticate Copilot. +Without the environment credential, Azure login fails with `AADSTS700213` before package restore. + Authentication is enabled only for repositories owned by the `microsoft` organization, because this Entra tenant requires enterprise-issued GitHub assertions. Same-repository dependency update PRs, including Renovate and Dependabot, authenticate diff --git a/Directory.Build.props b/Directory.Build.props index 5d12bb9d..47207fce 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -41,7 +41,7 @@ - 14 + 15 16.9 diff --git a/global.json b/global.json index fc64c1f0..fbb86c21 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.403", + "version": "11.0.100", "rollForward": "patch", "allowPrerelease": false }, diff --git a/test/dirs.proj b/test/dirs.proj index 3b7855fd..bdb2aa14 100644 --- a/test/dirs.proj +++ b/test/dirs.proj @@ -11,7 +11,7 @@ - <_NativeAOTTest Update="@(_NativeAOTTest)" UndefineProperties="" + <_NativeAOTTest UndefineProperties="" AdditionalProperties="TargetFramework=%(_NativeAOTTest.TargetFramework)" /> diff --git a/tools/Configure-GitHubOidc.ps1 b/tools/Configure-GitHubOidc.ps1 index a48e739c..d4f80490 100644 --- a/tools/Configure-GitHubOidc.ps1 +++ b/tools/Configure-GitHubOidc.ps1 @@ -17,7 +17,8 @@ belong to this tenant. .PARAMETER Branches Additional branches to trust. Pull requests and the repository's default - branch are always included. + branch are always included, along with the copilot environment used by + Copilot code review and cloud agent setup. .EXAMPLE ./tools/Configure-GitHubOidc.ps1 -WhatIf .EXAMPLE @@ -91,7 +92,7 @@ if ($PSBoundParameters.ContainsKey('Branches')) { $trustedBranches += $Branches } -$contexts = @('pull_request') +$contexts = @('pull_request', 'environment:copilot') foreach ($branch in $trustedBranches) { if ([string]::IsNullOrWhiteSpace($branch)) { throw 'Branch names must not be empty or whitespace.' @@ -116,6 +117,8 @@ foreach ($context in ($contexts | Select-Object -Unique)) { $contextName = if ($context -eq 'pull_request') { 'pull-request' + } elseif ($context -eq 'environment:copilot') { + 'environment-copilot' } else { "branch-$($context.Substring('ref:refs/heads/'.Length).Replace('%3A', ':'))" } diff --git a/tools/tests/Configure-GitHubOidc.Tests.ps1 b/tools/tests/Configure-GitHubOidc.Tests.ps1 index e24a0256..93a7c9c5 100644 --- a/tools/tests/Configure-GitHubOidc.Tests.ps1 +++ b/tools/tests/Configure-GitHubOidc.Tests.ps1 @@ -102,14 +102,15 @@ function Assert-Fails([string]$Pattern, [hashtable]$Parameters = @{}) { Reset-State & $target -WarningAction SilentlyContinue $subjects = @($script:state.Credentials.subject) -Assert-True ($subjects.Count -eq 2) 'Expected two federated credentials.' +Assert-True ($subjects.Count -eq 3) 'Expected PR, Copilot environment, and default branch federated credentials.' Assert-True ($subjects -cnotcontains "${prefix}:ref:refs/heads/microbuild") 'microbuild must not be trusted by default.' -foreach ($context in @('pull_request', 'ref:refs/heads/trunk')) { +foreach ($context in @('pull_request', 'environment:copilot', 'ref:refs/heads/trunk')) { Assert-True ($subjects -ccontains "${prefix}:$context") "Missing subject: $context" } -Assert-True (($script:state.Writes -join ',') -eq 'az-create,az-create,gh-put') 'Azure trust must be created before GitHub settings change.' -Assert-True (@($script:state.Credentials.name | Select-Object -Unique).Count -eq 2) 'Credential names must be unique.' +Assert-True (($script:state.Writes -join ',') -eq 'az-create,az-create,az-create,gh-put') 'Azure trust must be created before GitHub settings change.' +Assert-True (@($script:state.Credentials.name | Select-Object -Unique).Count -eq 3) 'Credential names must be unique.' Assert-True ($script:state.Credentials.name -ccontains 'github-ExampleOrg-ExampleRepo-pull-request') 'PR credential name must be human-readable.' +Assert-True ($script:state.Credentials.name -ccontains 'github-ExampleOrg-ExampleRepo-environment-copilot') 'Copilot credential name must be human-readable.' Assert-True ($script:state.Credentials.name -ccontains 'github-ExampleOrg-ExampleRepo-branch-trunk') 'Branch credential name must be human-readable.' $firstCredentialName = $script:state.Credentials[0].name @@ -117,30 +118,44 @@ $script:state.Writes = @() & $target -WarningAction SilentlyContinue Assert-True ($script:state.Writes.Count -eq 0) 'Rerun must not duplicate credentials or rewrite settings.' +Reset-State +$script:state.Settings = @{ use_default = $true; use_immutable_subject = $true; sub_claim_prefix = $prefix } +$script:state.Credentials = @( + @{ name = 'existing-pr'; issuer = 'https://token.actions.githubusercontent.com'; subject = "${prefix}:pull_request"; audiences = @('api://AzureADTokenExchange') } + @{ name = 'existing-branch'; issuer = 'https://token.actions.githubusercontent.com'; subject = "${prefix}:ref:refs/heads/trunk"; audiences = @('api://AzureADTokenExchange') } +) +& $target -WarningAction SilentlyContinue +Assert-True (($script:state.Writes -join ',') -eq 'az-create') 'Existing configurations must add only the missing Copilot trust without rewriting GitHub settings.' +Assert-True ($script:state.Credentials.subject -ccontains "${prefix}:environment:copilot") 'Existing configurations must gain Copilot environment trust.' +Assert-True ($script:state.Credentials.name -ccontains 'existing-pr' -and $script:state.Credentials.name -ccontains 'existing-branch') 'Existing credential names must be preserved.' +$script:state.Writes = @() +& $target -WarningAction SilentlyContinue +Assert-True ($script:state.Writes.Count -eq 0) 'Rerunning the migration must not duplicate Copilot trust.' + Reset-State & $target -WhatIf -WarningAction SilentlyContinue Assert-True ($script:state.Writes.Count -eq 0) 'WhatIf must not mutate either service.' Reset-State & $target -Branches @('release', 'release') -WarningAction SilentlyContinue -Assert-True ($script:state.Credentials.Count -eq 3) 'Duplicate branches must be deduplicated while retaining the default branch.' +Assert-True ($script:state.Credentials.Count -eq 4) 'Duplicate branches must be deduplicated while retaining the default branch and Copilot environment.' Assert-True ($script:state.Credentials.subject -ccontains "${prefix}:ref:refs/heads/release") 'Custom branch subject missing.' Assert-True ($script:state.Credentials.subject -ccontains "${prefix}:ref:refs/heads/trunk") 'Explicit branches must not replace the default branch.' Reset-State & $target -Branches microbuild -WarningAction SilentlyContinue -Assert-True ($script:state.Credentials.Count -eq 3) 'A single additional branch must produce PR, default branch, and additional branch credentials.' +Assert-True ($script:state.Credentials.Count -eq 4) 'A single additional branch must produce PR, Copilot environment, default branch, and additional branch credentials.' Assert-True ($script:state.Credentials.subject -ccontains "${prefix}:ref:refs/heads/microbuild") 'Single-string branch argument must be trusted.' Assert-True ($script:state.Credentials.subject -ccontains "${prefix}:ref:refs/heads/trunk") 'Default branch must be retained with a single-string argument.' Reset-State & $target -Branches trunk -WarningAction SilentlyContinue -Assert-True ($script:state.Credentials.Count -eq 2) 'Explicit default branch must not duplicate default trust.' +Assert-True ($script:state.Credentials.Count -eq 3) 'Explicit default branch must not duplicate default trust.' Reset-State & $target -Branches @('feature/widget', 'feature-widget', ('long-' + ('x' * 150))) -WarningAction SilentlyContinue $names = @($script:state.Credentials.name) -Assert-True (($names | Select-Object -Unique).Count -eq 5) 'Sanitized branch names must remain unique.' +Assert-True (($names | Select-Object -Unique).Count -eq 6) 'Sanitized branch names must remain unique.' foreach ($name in $names) { Assert-True ($name.Length -le 120 -and $name -cmatch '^[A-Za-z0-9._-]+$') 'Credential names must satisfy Entra limits.' Assert-True ($name.StartsWith('github-ExampleOrg-ExampleRepo-')) 'Sanitized names must retain repository names.' @@ -153,7 +168,7 @@ Assert-True ($script:state.Writes.Count -eq 0) 'Sanitized names must remain idem Reset-State $script:state.Credentials = @(@{ name = 'unrelated'; issuer = 'other'; subject = 'other'; audiences = @('other') }) & $target -WarningAction SilentlyContinue -Assert-True ($script:state.Credentials[0].name -eq 'unrelated' -and $script:state.Credentials.Count -eq 3) 'Unrelated trust must be preserved.' +Assert-True ($script:state.Credentials[0].name -eq 'unrelated' -and $script:state.Credentials.Count -eq 4) 'Unrelated trust must be preserved.' Reset-State $script:state.Tenant = 'wrong-tenant'