Skip to content

Enable-CodeReview: -SkipBedrock still grants the Bedrock key, and -Repo splits on commas - #60

Merged
polewskm merged 3 commits into
mainfrom
issue-34
Oct 31, 2026
Merged

polewskm merged 3 commits into
mainfrom
issue-34

Conversation

@polewskm

Copy link
Copy Markdown
Contributor

tools/Enable-CodeReview.ps1 -SkipBedrock now skips only prompting for and setting the Bedrock key: the repositories in -Repo still get access to the existing AWS_BEARER_TOKEN_BEDROCK org secret. When the organization has no such secret yet, the script says it skipped it. -Repo splits on commas, as Set-RepositoryBaseline.ps1 -RequireChecks does, so pwsh -File ... -Repo a,b works. The help and README now say that changing who can read an org secret needs admin:org (gh auth refresh -h github.com -s admin:org). Both failure messages for setting a secret and granting access to one give that hint too.

New test/enable-code-review.test.ts runs the script with pwsh -File. The only gh on its PATH is a stand-in that records each call. These tests failed on the old script and pass on this one, on Windows and on Linux. I ran the Linux check in a container.

Decisions

  • I kept the -SkipBedrock name and changed what it does, rather than renaming it.
  • I turned off positional binding (PositionalBinding = $false). Before, pwsh -File ... -Repo a, b bound b to -AppPrivateKeyPath, and the script only failed after it had already changed the repositories. Now the call fails before any change.
  • -UpdateBedrockKey together with -SkipBedrock is refused.
  • The test is a node:test file that runs a real pwsh process, because the repository has no PowerShell test pattern. Existing tests already run real processes. CI's npm test on ubuntu-latest, which has pwsh, runs it, so CI needed no change. If pwsh is missing, the test is skipped.
  • PSScriptAnalyzer reports two warnings, both already there before this change and left as they are: PSUseShouldProcessForStateChangingFunctions and PSShouldProcess, both on Set-OrgSecret.

Closes #34

…split -Repo on commas

-SkipBedrock now skips only prompting for and setting the key; the opted-in repositories still get access to the existing AWS_BEARER_TOKEN_BEDROCK secret. -Repo takes a comma-separated value, as pwsh -File passes one, and positional binding is off so -Repo a, b fails before any change. The help names the admin:org scope for changing who can read an organization secret. Tests run the script in pwsh against a stand-in gh.
@polewskm
polewskm deployed to code-review October 31, 2026 04:11 — with GitHub Actions Active

@ncode-review ncode-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 NCode Review at 6d1175a: 8 new findings on the changed lines.

Comment thread test/enable-code-review.test.ts Resolved
Comment thread tools/Enable-CodeReview.ps1 Resolved
Comment thread test/enable-code-review.test.ts Resolved
Comment thread test/enable-code-review.test.ts Resolved
Comment thread tools/Enable-CodeReview.ps1 Resolved
Comment thread tools/Enable-CodeReview.ps1 Resolved
Comment thread test/enable-code-review.test.ts Resolved
Comment thread tools/Enable-CodeReview.ps1 Resolved
@ncode-review

ncode-review Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

🤖 Review complete

Verdict: 💬 Comment — This PR adds test/enable-code-review.test.ts, which runs tools/Enable-CodeReview.ps1 in a real pwsh process with a fake gh that logs each call. The tests cover how -SkipBedrock handles the Bedrock key, how -Repo binds comma-separated values under pwsh -File, refusing conflicting flags, and stopping on errors. The harness is well isolated: it strips PATH and tokens, forces skips to fail in CI, and checks for an empty call log when the script should exit before changing anything. The one finding is a formatting nit.

5 reviewers run — 1 finding (run details)

Reviewer Model Findings Top
synthesis opus-5-5 1 🟡
conventions sonnet-5-5 0 🟢
correctness sonnet-5-5 0 🟢
hygiene haiku-5-5 1 🟡
rule-check sonnet-5-5 0 🟢
security sonnet-5-5 0 🟢

Skipped: api-compat, architecture, completeness, data-model, infrastructure, intent, performance, tests

Findings
  • 🟡 F1 test/enable-code-review.test.ts:208: Test file has no trailing newline

Trial: findings are posted as review threads and in the check run. $0.36 on Amazon Bedrock, 40s, at c21b557. (how to interact)

… in failures, and test the failure paths

Get-OrgSecret treats only a 404 as a missing secret and throws on any other gh failure, so -SkipBedrock can't skip granting an existing Bedrock key it failed to read. The grant goes through Invoke-Gh again, and the grant and secret set failures keep the command and exit code, with the admin:org hint written once. Tests cover failed grants and secret sets, a failed secret read, a Bedrock key visible to all repositories, <org>/<name> and empty -Repo entries, and run rather than skip in CI when pwsh is missing.
@polewskm

Copy link
Copy Markdown
Contributor Author

/review

@ncode-review ncode-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 NCode Review at c21b557: 1 new finding on the changed lines.

Comment thread test/enable-code-review.test.ts Resolved
@polewskm
polewskm marked this pull request as ready for review October 31, 2026 05:04
@polewskm
polewskm deployed to code-review October 31, 2026 05:04 — with GitHub Actions Active
@polewskm
polewskm merged commit 99395ab into main Oct 31, 2026
7 checks passed
@polewskm
polewskm deleted the issue-34 branch October 31, 2026 05:04

This branch was successfully deployed

1 active deployment
code-review — c21b5574 Deployed Oct 31, 2026 by polewskm via review #115
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.

Enable-CodeReview.ps1: -SkipBedrock also skips granting the Bedrock secret, and -Repo takes one value through pwsh -File

1 participant