Skip to content

[DO NOT MERGE] probe: can the maui-pr-uitests job token queue builds - #40502

Closed
kubaflo wants to merge 2 commits into
mainfrom
kubaflo/azdo-token-probe
Closed

kubaflo wants to merge 2 commits into
mainfrom
kubaflo/azdo-token-probe

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Temporary probe for the /review run-tests fix; will be closed and the branch deleted shortly.

@kubaflo

This comment has been minimized.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 22, 2026 02:15 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40502

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40502"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
No pipelines were found matching this branch/path.

@azure-pipelines

This comment has been minimized.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 22, 2026 02:15 — with GitHub Actions Inactive
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

kubaflo commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Probe done: the job token (public Build Service) has no 'Queue builds' on maui-pr-uitests (403).

@kubaflo kubaflo closed this Nov 22, 2026
@kubaflo
kubaflo deleted the kubaflo/azdo-token-probe branch November 22, 2026 02:19
kubaflo added a commit that referenced this pull request Nov 22, 2026
…* branch, since Entra blocks the Azure DevOps sign-in (#40504)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Target Branch

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

CI workflow infrastructure follow-up to #40468 / #40485 / #40492, so it
targets `main`.

### Why `/review run-tests` still queues nothing

Since about 21:00 UTC on 2026-11-20, every `/review run-tests` dispatch
fails at the same step: Microsoft Entra refuses the GitHub OIDC → Azure
DevOps token exchange with `AADSTS53003: Access has been blocked by
Conditional Access policies`. Before that, the same code queued build
1692555. `review-trigger.yml` (`/review` → maui-copilot) fails the same
way whenever it gets as far as the token step; its other runs only look
green because they stop before it. #40492 added an `AZDO_TRIGGER_PAT`
fallback, but no such secret exists, and using a personal PAT to get
around a Conditional Access policy is not a fix we should ship.

The repo has no other way to queue a build. I checked each option:

| Option | Result |
| --- | --- |
| Federated identity (OIDC) | `AADSTS53003` on every attempt since
2026-11-20 |
| `/azp run` comment from `github-actions[bot]` | Azure Pipelines
answers "Commenter does not have sufficient privileges" (probe #40500) |
| Queue from inside Azure DevOps with `System.AccessToken` | The job
identity (public Build Service) has no *Queue builds* permission on
maui-pr-uitests: permission API `false`, queue request 403 (probe
#40502) |

### Description of Change

`/review run-tests` now starts maui-pr-uitests through its YAML **CI
trigger**, so no Azure DevOps credentials are involved:

1. `Invoke-RunTests.ps1` validates the selection as before, then uses
the Git Data API to push a **dispatch commit** to `run-tests/pr<N>-<run
id>`. Its tree is GitHub's test-merge tree of the PR, with
`eng/pipelines` and `.github` replaced by the copies at the **target
branch tip**, plus a generated
`eng/pipelines/common/run-tests-request.yml`. Its parent is that
target-branch commit, so the push changes no workflow. GITHUB_TOKEN is
not allowed to change workflows, and its pushes don't start Actions
runs.
2. `ci-uitests.yml` now builds `run-tests/*` branches. For those
branches it reads the request and passes the same `selectedPlatforms` /
`selectedCategories` to `common/ui-tests.yml` that the `uitest_*`
parameters produced before. If the mode isn't `full`, the run is
narrowed, so an unfilled request runs nothing rather than the full
suite. Dispatch builds get the pull-request lanes (iOS `latest` only).
3. **Secrets:** `variables.yml` doesn't link the `MAUI` variable group
(`maui-cert-password`) for `run-tests/*` builds. PR code then runs
without secrets, as it does in a PR build from a fork. The pipeline YAML
always comes from the target branch, never from the PR.
4. Azure Pipelines reports its checks on the dispatch commit, so a
**`maui-pr-uitests (selected run)`** check on the PR head follows the
build. The skipped and selection checks are unchanged.
`Update-RunTestsResults.ps1` matches comments by the dispatch commit
too, completes that check, and its 30-minute sweep deletes dispatch
branches older than 3 days.
5. Removed: the Entra token exchange, the PAT fallback, `id-token:
write`, and the template-parameter queue request. The dispatch workflow
now needs `contents: write`, and the results workflow needs `checks:
write` and `contents: write`.

### Validation

- Ran `Invoke-RunTests.ps1` locally with this branch as
`-PipelineSource`, on #40437 at `85ec75d5`, with the real GPT-6.1 Sol
and Claude Opus 5.5 proposals from run 44944036321. It pushed
`run-tests/pr40437-1795314808` (dispatch commit `81026002`), and
**maui-pr-uitests build 1693858** started from the CI trigger about 15 s
later. That build has 8 stages instead of 12, and only maui-pr-uitests
built the branch. The comment was posted, and
`Update-RunTestsResults.ps1` finds it by the dispatch commit.
- Azure DevOps pipeline preview of the dispatch YAML:
- `selected`: only the selected stages; each matrix holds only the
selected categories, and the zero-tests guard is on.
  - `full`: all 12 stages.
- the checked-in default (`none`): rejected with "no stages", never the
full suite.
  - None of the three links the `MAUI` group.
- `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 68 passed. The
new tests cover:
- the request encoding, and that it rejects any value that would inject
YAML;
  - the branch naming;
- the pipeline guards, including the `MAUI` group exclusion and that no
other pipeline builds `run-tests/*`;
  - that the dispatch path uses no Azure DevOps credentials.

### For reviewers

- For PRs from forks, the dispatch build runs the PR's code with the
branch-build job token (public Build Service, which also has *Manage
build queue*) instead of a fork PR build's read-only token. It still
gets no variable-group secrets and none of the PR's pipeline YAML. If
that's not acceptable, I can limit dispatch to same-repo PRs.
- Restoring the federated identity (a Conditional Access exclusion for
the workload identity) would also fix `/review`, which this PR does not
touch.
- After merge, `run-tests/*` branches appear in dotnet/maui. No ruleset,
Actions workflow or other pipeline reacts to them.

Co-authored-by: kubaflo <kubaflo@users.noreply.github.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…* branch, since Entra blocks the Azure DevOps sign-in (dotnet#40504)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Target Branch

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

CI workflow infrastructure follow-up to dotnet#40468 / dotnet#40485 / dotnet#40492, so it
targets `main`.

### Why `/review run-tests` still queues nothing

Since about 21:00 UTC on 2026-11-20, every `/review run-tests` dispatch
fails at the same step: Microsoft Entra refuses the GitHub OIDC → Azure
DevOps token exchange with `AADSTS53003: Access has been blocked by
Conditional Access policies`. Before that, the same code queued build
1692555. `review-trigger.yml` (`/review` → maui-copilot) fails the same
way whenever it gets as far as the token step; its other runs only look
green because they stop before it. dotnet#40492 added an `AZDO_TRIGGER_PAT`
fallback, but no such secret exists, and using a personal PAT to get
around a Conditional Access policy is not a fix we should ship.

The repo has no other way to queue a build. I checked each option:

| Option | Result |
| --- | --- |
| Federated identity (OIDC) | `AADSTS53003` on every attempt since
2026-11-20 |
| `/azp run` comment from `github-actions[bot]` | Azure Pipelines
answers "Commenter does not have sufficient privileges" (probe dotnet#40500) |
| Queue from inside Azure DevOps with `System.AccessToken` | The job
identity (public Build Service) has no *Queue builds* permission on
maui-pr-uitests: permission API `false`, queue request 403 (probe
dotnet#40502) |

### Description of Change

`/review run-tests` now starts maui-pr-uitests through its YAML **CI
trigger**, so no Azure DevOps credentials are involved:

1. `Invoke-RunTests.ps1` validates the selection as before, then uses
the Git Data API to push a **dispatch commit** to `run-tests/pr<N>-<run
id>`. Its tree is GitHub's test-merge tree of the PR, with
`eng/pipelines` and `.github` replaced by the copies at the **target
branch tip**, plus a generated
`eng/pipelines/common/run-tests-request.yml`. Its parent is that
target-branch commit, so the push changes no workflow. GITHUB_TOKEN is
not allowed to change workflows, and its pushes don't start Actions
runs.
2. `ci-uitests.yml` now builds `run-tests/*` branches. For those
branches it reads the request and passes the same `selectedPlatforms` /
`selectedCategories` to `common/ui-tests.yml` that the `uitest_*`
parameters produced before. If the mode isn't `full`, the run is
narrowed, so an unfilled request runs nothing rather than the full
suite. Dispatch builds get the pull-request lanes (iOS `latest` only).
3. **Secrets:** `variables.yml` doesn't link the `MAUI` variable group
(`maui-cert-password`) for `run-tests/*` builds. PR code then runs
without secrets, as it does in a PR build from a fork. The pipeline YAML
always comes from the target branch, never from the PR.
4. Azure Pipelines reports its checks on the dispatch commit, so a
**`maui-pr-uitests (selected run)`** check on the PR head follows the
build. The skipped and selection checks are unchanged.
`Update-RunTestsResults.ps1` matches comments by the dispatch commit
too, completes that check, and its 30-minute sweep deletes dispatch
branches older than 3 days.
5. Removed: the Entra token exchange, the PAT fallback, `id-token:
write`, and the template-parameter queue request. The dispatch workflow
now needs `contents: write`, and the results workflow needs `checks:
write` and `contents: write`.

### Validation

- Ran `Invoke-RunTests.ps1` locally with this branch as
`-PipelineSource`, on dotnet#40437 at `85ec75d5`, with the real GPT-6.1 Sol
and Claude Opus 5.5 proposals from run 44944036321. It pushed
`run-tests/pr40437-1795314808` (dispatch commit `81026002`), and
**maui-pr-uitests build 1693858** started from the CI trigger about 15 s
later. That build has 8 stages instead of 12, and only maui-pr-uitests
built the branch. The comment was posted, and
`Update-RunTestsResults.ps1` finds it by the dispatch commit.
- Azure DevOps pipeline preview of the dispatch YAML:
- `selected`: only the selected stages; each matrix holds only the
selected categories, and the zero-tests guard is on.
  - `full`: all 12 stages.
- the checked-in default (`none`): rejected with "no stages", never the
full suite.
  - None of the three links the `MAUI` group.
- `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 68 passed. The
new tests cover:
- the request encoding, and that it rejects any value that would inject
YAML;
  - the branch naming;
- the pipeline guards, including the `MAUI` group exclusion and that no
other pipeline builds `run-tests/*`;
  - that the dispatch path uses no Azure DevOps credentials.

### For reviewers

- For PRs from forks, the dispatch build runs the PR's code with the
branch-build job token (public Build Service, which also has *Manage
build queue*) instead of a fork PR build's read-only token. It still
gets no variable-group secrets and none of the PR's pipeline YAML. If
that's not acceptable, I can limit dispatch to same-repo PRs.
- Restoring the federated identity (a Conditional Access exclusion for
the workload identity) would also fix `/review`, which this PR does not
touch.
- After merge, `run-tests/*` branches appear in dotnet/maui. No ruleset,
Actions workflow or other pipeline reacts to them.

Co-authored-by: kubaflo <kubaflo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant