Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/copilot-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Copilot code review environment action

# Temporary measurement for #1321.
# It asks whether a setup step can place content where the Copilot reviewer reads it.
# GitHub matches this workflow by its file path and its job by the job id, so neither is free.
# The workflow, job and step names follow the ordinary fleet convention and are not part of that.
# GitHub documents that it checks the repository out after these steps, where they did not.
# Whether that checkout removes an untracked file here is one of the things being measured.
# The token is written to three places for that reason, and each write reports its own outcome.

on:
workflow_dispatch:
push:
branches: [main, develop]
paths:
- .github/workflows/copilot-code-review.yml
pull_request:
branches: [main, develop]
paths:
- .github/workflows/copilot-code-review.yml

concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true

permissions: {}

jobs:
copilot-setup-steps:
name: Copilot setup steps job
runs-on: ubuntu-latest
# Declared on the job as well as the workflow.
# GitHub documents the job's own keys as the surface a setup step is read from.
permissions: {}
steps:
# No checkout, so the job needs no token scope.
# A checkout would also persist a credential in the workspace a reviewer then reads.
- name: Write probe token step
shell: bash
# The token is never printed, since a log on this public repository would publish it.
# A review could then quote it without having read any file.
run: |
set -Eeuo pipefail
: "${RUN_ID:?run id is empty, which would write a forgeable token}"
token="PROBE-SETUP-${RUN_ID}"
write_probe() {
local label="$1" base="$2" rel="$3" path
if [[ -z "$base" ]]; then
printf 'probe: %s has no base directory in this environment\n' "$label"
return 0
fi
path="$base/$rel"
if mkdir -p "$(dirname "$path")" && rm -f "$path" && printf '%s\n' "$token" > "$path"; then
printf 'probe: %s written\n' "$label"
else
printf 'probe: %s could not be written\n' "$label"
fi
return 0
}
write_probe workspace "${GITHUB_WORKSPACE:-}" '.copilot-probe/setup-token.txt'
write_probe temp "${RUNNER_TEMP:-}" 'copilot-probe-setup-token.txt'
write_probe home "${HOME:-}" '.copilot-probe-setup-token.txt'
env:
RUN_ID: ${{ github.run_id }}
13 changes: 7 additions & 6 deletions docs/homelab-runner-selection-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ Ordinary fleet CI and Copilot code review therefore have separate runner policie

The fleet runner variable never reaches Copilot configuration. Homelab labels never appear in the Copilot workflow.

The organization-level Copilot runner type applies to both code review and the cloud agent. It selects a standard GitHub-hosted runner for both workloads. Repository customization of the Copilot runner type is disabled. Before rollout, verify these effective organization settings rather than relying on the planned values.
The organization-level Copilot runner type applies to both code review and the cloud agent. It selects a standard GitHub-hosted runner for both workloads. Repository customization of the Copilot runner type is disabled, which a setup step's own `runs-on` appears to contradict. Which of the two wins is unresolved and tracked in [issue #1448][issue-1448]. Before rollout, verify these effective organization settings rather than relying on the planned values.

The proposed implementation adds a dedicated `.github/workflows/copilot-code-review.yml`. It pins `copilot-setup-steps` to `ubuntu-24.04` and begins with a step that fails unless `runner.environment` is `github-hosted`.
The proposed implementation adds a dedicated `.github/workflows/copilot-code-review.yml`. Its `copilot-setup-steps` job runs on `ubuntu-latest`. That path is occupied by a temporary measurement for [issue #1321][issue-1321] until that issue is answered.

The organization policy is the authorization boundary. The workflow pin and runtime assertion detect configuration drift. The assertion does not make a job safe after GitHub has assigned it to the wrong runner.
The organization policy is the authorization boundary. An earlier draft of this plan pinned the image and asserted `runner.environment` at runtime, and neither is kept, since an assertion does not make a job safe after GitHub has assigned it to the wrong runner.

## Configuration Contract

Expand All @@ -110,14 +110,14 @@ The explicit target leaves room for future values such as `arc`. A boolean would

## Selection Architecture

A small selector job runs on `ubuntu-24.04` before any selectable validation job.
A small selector job runs on `ubuntu-latest` before any selectable validation job.

The selector validates the requested target, event, actor, and ref. It emits one JSON `runs-on` value.

GitHub-hosted output:

```json
["ubuntu-24.04"]
["ubuntu-latest"]
```

Homelab output:
Expand Down Expand Up @@ -240,7 +240,6 @@ Automated tests cover:
- A direct-label workflow cannot use the homelab runner group.
- An unapproved workflow ref cannot use the homelab runner group.
- Public-repository access follows the explicit opt-in exactly.
- A fixed GitHub-hosted Copilot runner.
- Absence of the fleet variable from Copilot configuration.
- Absence of homelab labels from Copilot configuration.

Expand Down Expand Up @@ -334,6 +333,8 @@ Implementation waits for an explicit decision on each item.

<!-- GitHub -->

[issue-1321]: https://github.com/ptr727/ProjectTemplate/issues/1321
[issue-1448]: https://github.com/ptr727/ProjectTemplate/issues/1448
[issue-889]: https://github.com/ptr727/ProjectTemplate/issues/889

<!-- External -->
Expand Down