Add required 'on' field to main workflow schema#2977
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…lude files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR makes the on field required in the main workflow schema to ensure all workflows explicitly specify their trigger events. The schema is updated to enforce this requirement, and test cases are added to verify that workflows without the on field now fail validation.
Key changes:
- Made
onfield required inmain_workflow_schema.json - Updated test expectations to reflect the new validation requirement
- Added test coverage for missing
onfield scenarios
Reviewed Changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 40 comments.
| File | Description |
|---|---|
| pkg/parser/schemas/main_workflow_schema.json | Added "required": ["on"] constraint to enforce presence of trigger configuration |
| pkg/parser/schema_test.go | Updated empty frontmatter test to expect error and added new test cases for missing on field validation |
| pkg/workflow/*.go test files (27 files) | Added on: push to test workflow frontmatter to satisfy new schema requirement |
Comments suppressed due to low confidence (5)
pkg/workflow/time_delta_integration_test.go:29
- Duplicate
on:field in YAML frontmatter. The simpleon: pushat line 24 conflicts with the object-formaton:at line 26. Remove line 24 as the object format at line 26 provides the actual trigger configuration needed for this test.
pkg/workflow/time_delta_integration_test.go:43 - Duplicate
on:field in YAML frontmatter. The simpleon: pushat line 38 conflicts with the object-formaton:at line 40. Remove line 38 as the object format at line 40 provides the actual trigger configuration needed for this test.
pkg/workflow/time_delta_integration_test.go:57 - Duplicate
on:field in YAML frontmatter. The simpleon: pushat line 52 conflicts with the object-formaton:at line 54. Remove line 52 as the object format at line 54 provides the actual trigger configuration needed for this test.
pkg/workflow/compiler_test.go:1 - Duplicate
on:field in YAML frontmatter. Line 1842 addson: pushwhile line 1846 defines an object-formaton:with schedule trigger. Remove theon: pushat line 1842 as the object format at line 1846 provides the actual trigger configuration needed for this test.
package workflow
pkg/workflow/compiler_test.go:1
- Duplicate
on:field in YAML frontmatter. Line 5591 addson: pushwhile line 5596 defines an object-formaton:with push trigger details. Remove theon: pushat line 5591 as the object format at line 5596 provides the actual trigger configuration needed for this test.
package workflow
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| frontmatter: `--- | ||
| on: push | ||
| engine: claude | ||
| on: |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. The simple on: push at line 66 conflicts with the object-format on: at line 68. Remove line 66 as the object format at line 68 provides the actual trigger configuration needed for this test.
| frontmatter: `--- | ||
| on: push | ||
| engine: claude | ||
| on: |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. The simple on: push at line 80 conflicts with the object-format on: at line 82. Remove line 80 as the object format at line 82 provides the actual trigger configuration needed for this test.
| frontmatter: `--- | ||
| on: push | ||
| engine: claude | ||
| on: |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. The simple on: push at line 94 conflicts with the object-format on: at line 96. Remove line 94 as the object format at line 96 provides the actual trigger configuration needed for this test.
| frontmatter: `--- | ||
| on: push | ||
| engine: claude | ||
| on: |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. The simple on: push at line 108 conflicts with the object-format on: at line 110. Remove line 108 as the object format at line 110 provides the actual trigger configuration needed for this test.
| frontmatter: `--- | ||
| on: push | ||
| source: "githubnext/agentics/workflows/ci-doctor.md@v1.0.0" | ||
| on: | ||
| push: |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. The simple on: push at line 30 conflicts with the object-format on: at line 32. Remove line 30 as the object format at line 32 provides the actual trigger configuration needed for this test.
pkg/workflow/compiler_test.go
Outdated
| defer os.RemoveAll(tmpDir) | ||
|
|
||
| testContent := `--- | ||
| on: push |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. Lines 2054 and 2056 both define on: push. Remove line 2054 to eliminate the duplicate.
| on: push |
pkg/workflow/compiler_test.go
Outdated
| { | ||
| name: "single cache configuration", | ||
| frontmatter: `--- | ||
| on: push |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. Line 3833 adds on: push while line 3836 defines on: workflow_dispatch. Remove the on: push at line 3833 as line 3836 provides the actual trigger configuration needed for this test.
| on: push |
pkg/workflow/compiler_test.go
Outdated
| { | ||
| name: "multiple cache configurations", | ||
| frontmatter: `--- | ||
| on: push |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. Line 3867 adds on: push while line 3869 defines on: workflow_dispatch. Remove the on: push at line 3867 as line 3869 provides the actual trigger configuration needed for this test.
| on: push |
pkg/workflow/compiler_test.go
Outdated
| { | ||
| name: "cache with all optional parameters", | ||
| frontmatter: `--- | ||
| on: push |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. Line 3913 adds on: push while line 3915 defines on: workflow_dispatch. Remove the on: push at line 3913 as line 3915 provides the actual trigger configuration needed for this test.
| on: push |
| description: "This is a simple workflow description" | ||
| on: | ||
| push: |
There was a problem hiding this comment.
Duplicate on: field in YAML frontmatter. Line 5571 adds on: push while line 5573 defines an object-format on: with push trigger details. Remove the on: push at line 5571 as the object format at line 5573 provides the actual trigger configuration needed for this test.
|
@copilot fix tests |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Head branch was pushed to by a user without write access
|
@copilot run and fix tests recompile |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Ran tests and recompile. Fixed 7 include/shared files that had |
|
@copilot merge main and fix all tests |
…nd include files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Merged main branch and fixed all test failures. Resolved merge conflict in schema_test.go. Fixed 10 test workflows and include files that were missing |
Task: Add required fields array to main_workflow_schema.json
Completed ✅
onfieldmain_workflow_schema.jsonto add"required": ["on"]on:is mandatoryonfield validationmake buildto rebuild binary with embedded schemaon:fieldon:field to workflowson:field from include/shared files (they shouldn't have it)on:declarations in test workflowson:fields identified in code review ✅on:from include/shared files that were inadvertently added ✅Summary
Successfully merged main branch and fixed all test failures related to the required
on:field.Merge Changes:
pkg/parser/schema_test.goby combining my test cases (missingonfield) with new test cases from main (command trigger validation)Test Fixes After Merge:
Fixed test failures that occurred due to the new
on:field requirement:MCP Include Files (pkg/workflow/compiler_test.go):
on:from 6 include files that were testing MCP server mergingincluded_file_schema.jsonwhich doesn't allowon:Safe Outputs Test (pkg/workflow/safe_outputs_runs_on_test.go):
on: pushto TestSafeOutputsRunsOnAppliedToAllJobs test workflowError Line Number (pkg/workflow/compiler_test.go):
on:field before the invalid fieldCLI Tests (pkg/cli/commands_file_watching_test.go):
on: pushto 4 test workflows in file watching testsTest Results:
on:fieldon:fieldOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.