Skip to content

Add regression test diffing permissions.go constants against permissions schema enum - #54928

Merged
pelikhan merged 3 commits into
mainfrom
copilot/deep-report-add-regression-check
Aug 23, 2026
Merged

Add regression test diffing permissions.go constants against permissions schema enum#54928
pelikhan merged 3 commits into
mainfrom
copilot/deep-report-add-regression-check

Conversation

Copilot AI commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

pkg/workflow/permissions.go's PermissionScope constants and pkg/parser/schemas/main_workflow_schema.json's $defs.github_actions_permissions/$defs.github_app_permissions enums have drifted apart before (e.g. the missing secret-scanning-alerts entry). Nothing previously caught this class of drift automatically.

Changes

  • Added pkg/workflow/permissions_schema_consistency_test.go with two tests that parse the schema JSON directly and cross-check it against the Go constants:
    • TestPermissionConstantsMatchSchemaEnum — every scope from GetAllPermissionScopes(), PermissionCopilotRequests, and GetAllGitHubAppOnlyScopes() must have a matching property in $defs.github_actions_permissions or $defs.github_app_permissions.
    • TestPermissionsSchemaEnumMatchesConstants — the inverse check, so the schema can't declare a scope with no corresponding Go constant either.

Verified the test fails with a clear message when a scope (e.g. secret-scanning-alerts) is removed from the schema, confirming it reproduces and guards against the original drift.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add regression check for permissions constants against schema enum Add regression test diffing permissions.go constants against permissions schema enum Aug 22, 2026
Copilot AI requested a review from pelikhan August 22, 2026 23:54
@pelikhan
pelikhan marked this pull request as ready for review August 23, 2026 00:13
Copilot AI balanced review requested due to automatic review settings August 23, 2026 00:13
@pelikhan
pelikhan merged commit ff42988 into main Aug 23, 2026
31 checks passed
@pelikhan
pelikhan deleted the copilot/deep-report-add-regression-check branch August 23, 2026 00:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a regression test intended to prevent permission scope drift between Go definitions and JSON schema properties.

Changes:

  • Parses both permission schema definitions.
  • Adds bidirectional consistency checks.
Show a summary per file
File Description
pkg/workflow/permissions_schema_consistency_test.go Adds permission/schema consistency tests.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

// GITHUB_TOKEN-supported scopes (plus the special-cased copilot-requests scope,
// which is intentionally excluded from GetAllPermissionScopes() but must still be
// recognized) must appear under github_actions_permissions.
tokenScopes := append([]PermissionScope{}, GetAllPermissionScopes()...)
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.5

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.

[deep-report] Add regression check diffing permissions.go constants against permissions schema enum

3 participants