Skip to content

[test] Add tests for main.main - #16783

Merged
lpcox merged 3 commits into
mainfrom
test-coverage-main-entrypoint-4079a8443973af14
Nov 18, 2026
Merged

lpcox merged 3 commits into
mainfrom
test-coverage-main-entrypoint-4079a8443973af14

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Function Analyzed

  • Package: main
  • Function: main
  • Previous coverage: 0.0%
  • New coverage: 100.0%
  • Complexity: Low, but it was the only actionable zero-coverage entrypoint after excluding the empty noopControlLogger helper.

Why This Function?

The complete baseline report showed only two functions below 50% coverage: the trivial empty fallback logger and the executable main entrypoint. The new test exercises the real startup wiring through Cobra's --version path without starting the gateway server, verifying that build metadata is assembled and installed before command execution.

Tests Added

  • ✅ Executes main through the real --version command path
  • ✅ Verifies version, commit, and build-date metadata reaches the shared version package
  • ✅ Restores process arguments and package-level version state after the test

Coverage Report

Before: main.main 0.0%, overall 97.6%
After:  main.main 100.0%, overall 97.6%
Improvement: +100 percentage points for the selected function

Test Execution

  • go test . -run '^TestMain_ExecutesVersionCommand$' -count=1 — passed
  • go test -coverprofile=/tmp/gh-aw/agent/coverage-after.out ./... — passed; selected function at 100.0%
  • make agent-finished — all Go unit and integration tests passed; golangci-lint was unavailable and skipped by the repository target, and Rust guard tests were blocked because Cargo could not validate the configured crates.io certificate. Offline Rust execution also confirmed the serde dependency is not cached.

No production code was changed.

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Coverage Improver · copilot · routed: gpt56 xhigh · ~7 AIC · ⊞ 5K · ◷

@lpcox
lpcox marked this pull request as ready for review November 18, 2026 16:42
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 16:42

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.

🟡 Changes recommended

The test leaves the CLI and shared version state altered because it restores both from the wrong value, potentially affecting subsequent tests.

1 open issue
What changed in this PR

Adds focused test coverage for the main.main entrypoint by exercising Cobra’s --version path and verifying build metadata propagation without changing production code.

Changes:

  • Adds a test invoking main() with --version.
  • Verifies version, commit, and build-date metadata.
  • Preserves and restores process and package state during cleanup.
File Description
main_coverage_test.go Adds coverage for main() through the CLI version path and validates build metadata propagation.

Review effort: Lite (adaptive)

Comment thread main_coverage_test.go Resolved
@github-actions

This comment has been minimized.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@lpcox

lpcox commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@github-actions

This comment has been minimized.

Copilot AI commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the failing lint checks https://github.com/github/gh-aw-mcpg/actions/runs/44351531883/job/134968185968?pr=16783

Fixed the formatting issue flagged by CI; make lint now passes locally. Commit: 3cf5c6f.

Copilot AI requested a review from lpcox November 18, 2026 16:54
@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 write tools absent from the 23-tool catalog; nothing to call BLOCKED ⚠️
C CLI reads (same ops via github CLI proxy) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh not authenticated ("not logged into any GitHub hosts") BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh not authenticated, not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: the exposed GitHub MCP tool catalog contains only 23 read-only tools (get_commit, get_file_contents, get_label, get_latest_release, get_release_by_tag, get_tag, issue_read, list_branches, list_commits, list_issue_fields, list_issue_types, list_issues, list_pull_requests, list_releases, list_repository_collaborators, list_starred_repositories, list_tags, pull_request_read, search_code, search_commits, search_issues, search_pull_requests, search_repositories) — none of the 6 targeted write tools were present, so gateway-level write-blocking could not be independently exercised on this surface; this only confirms backend/toolset config (gh-aw's GITHUB_READ_ONLY=1 default), not mcpg's own DIFC/guard layer.

⚠️ Part D/E: gh CLI has no authenticated host in this environment (gh auth status reports not logged in), so REST/GraphQL write attempts could not be made.

No write leaked in any part of this run; label/issue-filing skipped since the result is INCONCLUSIVE, not a confirmed PASS or FAIL.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit eb5982c into main Nov 18, 2026
28 checks passed
@lpcox
lpcox deleted the test-coverage-main-entrypoint-4079a8443973af14 branch November 18, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants