Skip to content

Make timeout-minutes a templatable integer in schema + custom job compilation#36314

Merged
pelikhan merged 6 commits into
mainfrom
copilot/validate-timeout-minutes
Jun 1, 2026
Merged

Make timeout-minutes a templatable integer in schema + custom job compilation#36314
pelikhan merged 6 commits into
mainfrom
copilot/validate-timeout-minutes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 1, 2026

timeout-minutes needed to validate as a templatable_integer and behave consistently when provided as either a literal integer or a GitHub Actions expression. This change aligns schema validation and Go-side job rendering with that contract.

  • Schema updates

    • Switched workflow-level and job-level timeout-minutes definitions to the shared templatable-integer shape in main_workflow_schema.json.
    • Ensures ${{ ... }} timeout expressions validate in the same path as integer literals.
  • Go compiler behavior

    • Extended custom job parsing to preserve expression-form timeouts instead of only numeric values.
    • Job YAML generation now emits expression-form timeout-minutes when present.
  • Guardrails

    • Rejects non-expression string values for timeout-minutes in custom jobs.
    • Rejects ambiguous job configs that set both integer and expression timeout forms.
  • Targeted coverage additions

    • Added parser schema test for templated workflow/job timeout acceptance.
    • Added workflow tests for expression rendering, invalid string rejection, and conflict validation.
jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: ${{ inputs.job_timeout }}
    steps:
      - run: echo "hello"

Copilot AI and others added 3 commits June 1, 2026 19:26
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Validate templated timeout-minutes in schema and compiler Make timeout-minutes a templatable integer in schema + custom job compilation Jun 1, 2026
Copilot AI requested a review from pelikhan June 1, 2026 19:40
@github-actions github-actions Bot mentioned this pull request Jun 1, 2026
@pelikhan pelikhan marked this pull request as ready for review June 1, 2026 20:07
Copilot AI review requested due to automatic review settings June 1, 2026 20:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns timeout-minutes handling across the JSON schema and the Go workflow compiler so that it accepts either a literal integer or a GitHub Actions expression (${{ ... }}), and renders expression-form timeouts correctly for custom jobs.

Changes:

  • Update workflow-level and job-level schema for timeout-minutes to use a shared “templatable integer” shape.
  • Extend custom job compilation to preserve expression-form timeout-minutes and emit it during job YAML rendering.
  • Add targeted tests covering schema acceptance, rendering of expression timeouts, and rejection of invalid string values / conflicting configs.
Show a summary per file
File Description
pkg/workflow/jobs.go Add TimeoutMinutesExpression and render expression-form timeout-minutes when present.
pkg/workflow/jobs_validation.go Extend validation to forbid timeout-minutes (int or expression) on reusable-workflow caller jobs and reject int+expression conflicts.
pkg/workflow/jobs_test.go Add unit tests for reusable-workflow restriction with expression timeouts and conflict validation.
pkg/workflow/compiler_jobs.go Parse custom job timeout-minutes strings as expressions (reject non-expression strings).
pkg/workflow/compiler_jobs_test.go Add tests for expression parsing/rendering and invalid string rejection.
pkg/parser/schemas/main_workflow_schema.json Switch workflow/job timeout-minutes to reference templatable_integer.
pkg/parser/schema_test.go Add schema test ensuring templated workflow/job timeout-minutes values validate.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 7/7 changed files
  • Comments generated: 3

Comment on lines 2483 to 2486
"timeout-minutes": {
"type": "integer",
"minimum": 1,
"$ref": "#/$defs/templatable_integer",
"description": "Job timeout in minutes"
},
Comment on lines 2633 to 2637
"timeout-minutes": {
"$ref": "#/$defs/templatable_integer",
"description": "Workflow timeout in minutes (GitHub Actions standard field). Defaults to 20 minutes for agentic workflows. Has sensible defaults and can typically be omitted. Custom runners support longer timeouts beyond the GitHub-hosted runner limit. Supports GitHub Actions expressions (e.g. '${{ inputs.timeout }}') for reusable workflow_call workflows.",
"oneOf": [
{
"type": "integer",
"minimum": 1,
"examples": [5, 10, 30]
},
{
"type": "string",
"pattern": "^\\$\\{\\{.*\\}\\}$",
"description": "GitHub Actions expression that resolves to an integer (e.g. '${{ inputs.timeout }}')"
}
]
"examples": [5, 10, 30]
},
Comment on lines +664 to +666
// isExpression validates full GitHub Actions expression syntax (${{
// ... }}) and is defined in expression_patterns.go.
if isExpression(v) {
@pelikhan pelikhan merged commit 675335f into main Jun 1, 2026
26 checks passed
@pelikhan pelikhan deleted the copilot/validate-timeout-minutes branch June 1, 2026 20:17
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