Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Addresses feedback on #6082 to improve campaign management code structure, reuse existing frontmatter parsing, and add JSON schema validation.

Changes

Package structure

  • Moved campaign code from pkg/cli/campaigns.go to pkg/campaign package
  • Split 857-line monolith into 5 focused modules:
    • spec.go: Type definitions
    • loader.go: Loading and filtering with parser.ExtractFrontmatterFromContent
    • validation.go: JSON schema validation
    • status.go: Runtime status and metrics
    • command.go: CLI integration

Validation improvements

  • Created campaign_spec_schema.json for structured validation
  • Implemented schema validation using gojsonschema (matches workflow validation pattern)
  • Separate validation spec type excludes runtime fields from schema checks

Before (manual frontmatter parsing):

lines := strings.Split(content, "\n")
if len(lines) == 0 || strings.TrimSpace(lines[0]) != "---" {
    return nil, fmt.Errorf("must start with YAML frontmatter")
}
// ... 30+ lines of parsing logic

After (reuse parser package):

result, err := parser.ExtractFrontmatterFromContent(string(data))
if err != nil {
    return nil, fmt.Errorf("failed to parse frontmatter: %w", err)
}

Test coverage

  • 45 tests across 5 test files (loader, validation, filtering, creation, integration)
  • All campaign package tests passing

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 11, 2025 14:04
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Created pkg/campaign package with modular structure:
  - spec.go: Campaign spec type definitions
  - loader.go: Loading specs from files using parser.ExtractFrontmatterFromContent
  - validation.go: JSON schema-based validation
  - status.go: Campaign status computation
  - command.go: Cobra command integration
- Replaced manual frontmatter parsing with parser package helper (addresses comment 2610682143)
- Created campaign_spec_schema.json for JSON schema validation (addresses comment 2610689719)
- Added extensive tests:
  - campaign_test.go: Integration tests
  - loader_test.go: 10 tests for loading specs
  - validation_test.go: 16 tests for validation logic
  - filter_test.go: 7 tests for filtering
  - create_test.go: 11 tests for spec creation
- Updated main.go to use new campaign package
- Removed old pkg/cli/campaigns.go
- All tests passing (45 tests total)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 11, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • go.googlesource.com
    • Triggering command: /update-job-proxy /update-job-proxy /usr/bin/gh /usr/local/sbin//etc/ssl/certs/feffd413.0 basename /usr�� ity_-_G4.pem test /bin/test 52c538d.0 git est basename /usr�� ntrust.net_Premium_2048_Secure_Server_CA.pem test /home/dependabot/bin/test 94d09e5.0 git /bin/test test (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy DROP /usr/bin/readlinextensions.objectformat test -e e=false readlink /usr/bin/test test %H %ct %D 3f456775b00c7065--objects test -e e=false f6ca3761:go.mod /bin/git ommScope_Public_/usr/sbin/ip6tables %H %ct %D 0 /usr/bin/git (dns block)
  • go.uber.org
    • Triggering command: /update-job-proxy /update-job-proxy /usr/bin/gh /usr/local/sbin//etc/ssl/certs/feffd413.0 basename /usr�� ity_-_G4.pem test /bin/test 52c538d.0 git est basename /usr�� ntrust.net_Premium_2048_Secure_Server_CA.pem test /home/dependabot/bin/test 94d09e5.0 git /bin/test test (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy DROP /usr/bin/readlinextensions.objectformat test -e e=false readlink /usr/bin/test test %H %ct %D 3f456775b00c7065--objects test -e e=false f6ca3761:go.mod /bin/git ommScope_Public_/usr/sbin/ip6tables %H %ct %D 0 /usr/bin/git (dns block)
  • go.yaml.in
    • Triggering command: /update-job-proxy /update-job-proxy /usr/bin/gh /usr/local/sbin//etc/ssl/certs/feffd413.0 basename /usr�� ity_-_G4.pem test /bin/test 52c538d.0 git est basename /usr�� ntrust.net_Premium_2048_Secure_Server_CA.pem test /home/dependabot/bin/test 94d09e5.0 git /bin/test test (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy DROP /usr/bin/readlinextensions.objectformat test -e e=false readlink /usr/bin/test test %H %ct %D 3f456775b00c7065--objects test -e e=false f6ca3761:go.mod /bin/git ommScope_Public_/usr/sbin/ip6tables %H %ct %D 0 /usr/bin/git (dns block)
  • gopkg.in
    • Triggering command: /update-job-proxy /update-job-proxy /usr/bin/gh /usr/local/sbin//etc/ssl/certs/feffd413.0 basename /usr�� ity_-_G4.pem test /bin/test 52c538d.0 git est basename /usr�� ntrust.net_Premium_2048_Secure_Server_CA.pem test /home/dependabot/bin/test 94d09e5.0 git /bin/test test (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy DROP /usr/bin/readlinextensions.objectformat test -e e=false readlink /usr/bin/test test %H %ct %D 3f456775b00c7065--objects test -e e=false f6ca3761:go.mod /bin/git ommScope_Public_/usr/sbin/ip6tables %H %ct %D 0 /usr/bin/git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Address feedback on campaign management commands Refactor campaign code to pkg/campaign with schema validation and comprehensive tests Dec 11, 2025
Copilot AI requested a review from pelikhan December 11, 2025 14:29
@mnkiefer
Copy link
Contributor

@pelikhan: LGTM! 🎉

@mnkiefer mnkiefer marked this pull request as ready for review December 11, 2025 14:34
@mnkiefer mnkiefer merged commit 4f638ab into campaign-design Dec 11, 2025
@mnkiefer mnkiefer deleted the copilot/sub-pr-6082 branch December 11, 2025 14:43
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.

3 participants