Skip to content

Commit be4706c

Browse files
Copilotankitbko
andauthored
Remove redundant fork rejection from validation (#1018)
* Remove explicit fork rejection from validation Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com> * Correct fork handling in run setup workflow Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com> * Allow fork PRs in hosted agents pipeline Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com> * Align fork approval documentation Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com> Co-authored-by: Ankit Sinha <ankitbko@gmail.com>
1 parent 0546234 commit be4706c

3 files changed

Lines changed: 16 additions & 23 deletions

File tree

‎.azure-pipelines/README.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ A repository/pipeline administrator must complete these separately:
4949
2. Authorize the GitHub connection to read this repository and report build
5050
results. Authorize each variable group and Azure service connection only for
5151
the intended pipelines.
52-
3. Disable fork PR builds for these credentialed pipelines in Azure DevOps.
53-
Keep fork secrets and full-access tokens disabled. Use resource approvals and
54-
checks to enforce the intended trust boundary before granting cloud access.
52+
3. Require maintainer approval before fork PR builds run. Keep fork secrets and
53+
full-access tokens disabled. Use resource approvals and checks to enforce the
54+
intended trust boundary before granting cloud access.
5555
4. Supply the test-resource configuration below. Use separate disposable test
5656
resources with permissions for deployment, invocation, evidence retrieval and
5757
cleanup; never production resources.
5858

59-
The YAML also gates PR runs on `System.PullRequest.IsFork` being explicitly
60-
`False`. Missing or true values skip the cloud path. This is defense in depth,
61-
not a substitute for Azure DevOps authorization: a PR can change its YAML.
62-
Skipped cloud runs are not evidence of a successful live test.
59+
Repository settings gate fork PR builds on maintainer approval. The YAML does
60+
not independently reject fork PRs, so resource approvals and checks must
61+
protect credentials and cloud access: a PR can change its YAML. Fork PRs that
62+
are not approved do not produce evidence of a successful live test.
6363

6464
Service-connection, variable-group and required-status settings are external to
6565
this repository. These files do not alter GitHub merge rules or activate a

‎.azure-pipelines/hosted-agents-samples-ci.yml‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#
99
# Discovery, deploy, invoke and assertion behavior uses repository-local
1010
# helpers; authentication, matrices, artifacts and annotations are ADO-native.
11-
# Operators must disable fork builds and restrict/approve the service
12-
# connection outside YAML before enabling this credentialed pipeline.
11+
# Repository settings require maintainer approval before fork PR builds run.
12+
# Restrict/approve the service connection outside YAML before enabling this
13+
# credentialed pipeline.
1314
#
1415
# Infrastructure modes:
1516
# - SKIP_PROVISION=true (default): uses an existing Foundry project. Requires
@@ -98,18 +99,11 @@ stages:
9899
# Runs unless the kill-switch is explicitly set to 'false'. It is deliberately
99100
# not gated on `eq(..., 'true')`: an unset variable would then skip every
100101
# stage and report a false pass. Missing configuration fails in the guard
101-
# step below instead. PRs also require an explicitly non-fork source; missing
102-
# fork metadata fails closed. This guard is not a service-connection approval.
102+
# step below instead. Fork PR execution is controlled by the repository's
103+
# maintainer-approval setting, not by this stage condition.
103104
- stage: Discover
104105
displayName: Discover Samples
105-
condition: |
106-
and(
107-
ne(variables['CLOUD_E2E_ENABLED'], 'false'),
108-
or(
109-
ne(variables['Build.Reason'], 'PullRequest'),
110-
eq(variables['System.PullRequest.IsFork'], 'False')
111-
)
112-
)
106+
condition: ne(variables['CLOUD_E2E_ENABLED'], 'false')
113107
jobs:
114108
- job: DiscoverSamples
115109
displayName: Build sample matrix

‎.azure-pipelines/scripts/hosted-agents/tests/test_hosted_agent_pipeline.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,16 @@ def test_discovery_uses_shared_exact_skiplist_matching(self):
186186
self.assertNotIn('/.ci-skip', discovery)
187187
self.assertNotIn('/.code-ci-skip', discovery)
188188

189-
def test_discovery_requires_explicit_nonfork_pr(self):
189+
def test_discovery_allows_approved_fork_pr(self):
190190
discover = next(
191191
stage for stage in PIPELINE["stages"] if stage.get("stage") == "Discover"
192192
)
193193
condition = re.sub(r"\s+", "", discover["condition"])
194194
self.assertEqual(
195195
condition,
196-
"and(ne(variables['CLOUD_E2E_ENABLED'],'false'),"
197-
"or(ne(variables['Build.Reason'],'PullRequest'),"
198-
"eq(variables['System.PullRequest.IsFork'],'False')))",
196+
"ne(variables['CLOUD_E2E_ENABLED'],'false')",
199197
)
198+
self.assertNotIn("System.PullRequest.IsFork", condition)
200199
cloud_stage = next(iter(SHARDS.values()))[0]
201200
self.assertIn("Discover", cloud_stage["dependsOn"])
202201
self.assertIn("succeeded('Discover')", cloud_stage["condition"])

0 commit comments

Comments
 (0)