job

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

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

This package owns:

  • parsed job modeling from provider parse flows,
  • job-specific validation rules (uses/runs-on/steps/needs),
  • strategy matrix normalization helpers.

Emission and orchestration remain in provider/github root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NeedsFromYAML

func NeedsFromYAML(raw any) ([]string, error)

NeedsFromYAML extracts the needs list from a raw YAML value (string or list).

func NormalizeStrategyMatrix

func NormalizeStrategyMatrix(matrix map[string]any) (map[string]any, error)

NormalizeStrategyMatrix flattens HCL "variable" blocks into top-level matrix keys.

func ValidateModel

func ValidateModel(job ValidationModel, runsOnName string) error

ValidateModel checks that a job's fields are consistent (e.g. uses vs runs-on).

func ValidateNeedsCycles

func ValidateNeedsCycles(jobs map[string]ValidationModel) error

ValidateNeedsCycles detects circular dependencies in the job needs graph.

func ValidateNeedsReferences

func ValidateNeedsReferences(needs []string, jobs map[string]ValidationModel) error

ValidateNeedsReferences ensures all needs entries reference existing, non-duplicate jobs.

Types

type MatrixAxis

type MatrixAxis struct {
	Name  string
	Value any
}

MatrixAxis represents a single axis (name-value pair) in a strategy matrix.

func AxesFromMap

func AxesFromMap(mapping map[string]any) []MatrixAxis

AxesFromMap converts a map into a sorted slice of MatrixAxis values.

type MatrixVariable

type MatrixVariable struct {
	Name  string
	Value any
}

MatrixVariable represents a single named variable in a strategy matrix.

type Parsed

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

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

func NewParsed

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

NewParsed creates a Parsed job, extracting step references from the body.

type ValidationModel

type ValidationModel struct {
	ID         string
	Uses       string
	HasRunsOn  bool
	StepCount  int
	HasWith    bool
	HasSecrets bool
	Needs      []string
}

ValidationModel contains the fields needed to validate a job definition.

func ModelFromParsed

func ModelFromParsed(p Parsed) (ValidationModel, error)

ModelFromParsed builds a ValidationModel from a Parsed job.

func ModelFromYAML

func ModelFromYAML(id string, raw map[string]any) (ValidationModel, error)

ModelFromYAML builds a ValidationModel from raw YAML job data.

Jump to

Keyboard shortcuts

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