workflow

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2026 YLD Limited SPDX-License-Identifier: Apache-2.0 Package workflow contains GitHub workflow domain models and validation logic.

This package owns:

  • parsed workflow modeling from provider parse flows,
  • workflow YAML document modeling,
  • workflow-level validation rules,
  • trigger normalization/mapping helpers.

Emission and orchestration remain in provider/github root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DenormalizeScheduleEvent

func DenormalizeScheduleEvent(normalized map[string]any) []any

DenormalizeScheduleEvent is the inverse of normalizeScheduleEvent. It converts {cron: ["A", "B"]} back to [{cron: "A"}, {cron: "B"}] as required by GitHub Actions.

func NormalizeOn

func NormalizeOn(raw any, mapper func(any) (map[string]any, bool)) (map[string]any, error)

NormalizeOn converts the various YAML representations of 'on' into a uniform map.

func NormalizeOnEvent

func NormalizeOnEvent(event string, value map[string]any) map[string]any

NormalizeOnEvent applies rename rules to an event's configuration map (e.g. input to inputs).

func TriggerBlockTypeForEventKey

func TriggerBlockTypeForEventKey(event string, key string) (string, bool)

TriggerBlockTypeForEventKey returns the HCL block type for a given event and YAML key.

func ValidateCron

func ValidateCron(expr string) error

ValidateCron checks that a cron expression has 5 fields with valid ranges.

func ValidateModel

func ValidateModel(workflow ValidationModel) error

ValidateModel checks that a workflow has triggers and non-duplicate job references.

func ValidatePermissions

func ValidatePermissions(raw any) error

ValidatePermissions checks that a permissions value uses known scopes and valid levels. Accepts a string shorthand ("read-all"/"write-all"), an empty map (all none), or a map of scope→level.

func ValidateSchedule

func ValidateSchedule(value map[string]any) error

ValidateSchedule validates all cron entries in a normalized schedule event value.

Types

type Parsed

type Parsed struct {
	ID       string
	Filename string
	Body     map[string]any
	JobRefs  []string
}

Parsed holds the intermediate representation of a workflow after HCL parsing.

func NewParsed

func NewParsed(id string, body map[string]any) Parsed

NewParsed creates a Parsed workflow, extracting filename and job references from the body.

type ValidationModel

type ValidationModel struct {
	ID      string
	HasOn   bool
	OnCount int
	JobRefs []string
}

ValidationModel contains the fields needed to validate a workflow definition.

type YAMLDocument

type YAMLDocument struct {
	Raw   map[string]any
	HasOn bool
	On    map[string]any
	Jobs  map[string]any
}

YAMLDocument represents a parsed GitHub Actions workflow YAML document.

func NewYAMLDocument

func NewYAMLDocument(raw map[string]any, mapper func(any) (map[string]any, bool)) (YAMLDocument, bool, error)

NewYAMLDocument constructs a YAMLDocument from raw YAML data, returning false if neither on nor jobs are present.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL