step

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright 2026 YLD Limited SPDX-License-Identifier: Apache-2.0 Package step contains the Step domain model and bidirectional serialization logic. StepConfig represents the HCL-side structure decoded via gohcl, while Step holds the normalized intermediate representation used for both HCL-to-YAML parsing and YAML-to-HCL unparsing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment added in v0.7.0

type Comment struct {
	Head string
	Line string
}

Comment holds the two comments one step attribute can carry: the run written on its own lines above it, and the one sharing its line.

func (Comment) Empty added in v0.7.0

func (c Comment) Empty() bool

Empty reports whether the attribute carried no comment at all.

type Comments added in v0.7.0

type Comments struct {
	Head string
	// Foot is the comment written at the end of the step block with nothing
	// after it. It belongs to the block rather than to any one attribute.
	Foot  string
	Attrs map[string]Comment
	// Nested holds the comments on the entries of a step's "env" and "with"
	// maps, keyed by the map's own key and then by the entry's.
	Nested map[string]map[string]Comment
}

Comments holds the comments written on a step, keyed by the YAML key each attribute becomes, plus the one written above the step block itself.

Keyed by YAML key rather than HCL name because both directions already speak in YAML keys at the point they read this: parse is about to build the YAML mapping, and unparse has just decoded one.

func (Comments) At added in v0.7.0

func (c Comments) At(key string) Comment

At returns the comments written on the attribute emitted as key.

func (Comments) Nest added in v0.7.0

func (c Comments) Nest(key string) map[string]Comment

Nest returns the comments on the entries of the map emitted as key.

type Step

type Step struct {
	Identifier string    `yaml:"-"`
	Id         cty.Value `yaml:"id,omitempty" hcl:"id"`
	// IgnoreId marks a step that must not be given an id on the way out.
	// Unparse sets it for a step whose source YAML carried no "id", so
	// converting back writes the step exactly as it was read.
	IgnoreId         bool      `yaml:"-"`
	If               cty.Value `yaml:"if,omitempty" hcl:"if"`
	Name             cty.Value `yaml:"name,omitempty" hcl:"name"`
	Uses             cty.Value `yaml:"uses,omitempty" hcl:"uses"`
	Run              cty.Value `yaml:"run,omitempty" hcl:"run"`
	WorkingDirectory cty.Value `yaml:"working-directory,omitempty" hcl:"working_directory"`
	Shell            cty.Value `yaml:"shell,omitempty" hcl:"shell"`
	With             cty.Value `yaml:"with,omitempty" hcl:"with"`
	Env              cty.Value `yaml:"env,omitempty" hcl:"env"`
	ContinueOnError  cty.Value `yaml:"continue-on-error,omitempty" hcl:"continue_on_error"`
	TimeoutMinutes   cty.Value `yaml:"timeout-minutes,omitempty" hcl:"timeout_minutes"`
	// Comments holds what was written above and beside the step and its
	// attributes. Not a field of the step as GitHub reads it, so it stays out
	// of the marshalled YAML and is applied to the document separately.
	Comments Comments `yaml:"-"`
}

Step holds the parsed fields of a single GitHub Actions workflow step.

func (*Step) Decode

func (s *Step) Decode(body *hclwrite.Body, attr string) error

Decode writes the step as an HCL block into the given body.

func (*Step) PreDecode

func (s *Step) PreDecode(val cty.Value) error

PreDecode populates the step fields from a cty object value (YAML-to-HCL path).

func (*Step) Update

func (s *Step) Update(filename string)

Update sets the step's identifier to the given filename.

type StepConfig

type StepConfig struct {
	Identifier       string                `hcl:"id,label"`
	Id               hcl.Expression        `hcl:"id,attr"`
	IgnoreId         hcl.Expression        `hcl:"ignore_id,attr"`
	If               hcl.Expression        `hcl:"if,attr"`
	Name             hcl.Expression        `hcl:"name,attr"`
	Uses             action.UsesListConfig `hcl:"uses,block"`
	Run              hcl.Expression        `hcl:"run,attr"`
	WorkingDirectory hcl.Expression        `hcl:"working_directory,attr"`
	Shell            hcl.Expression        `hcl:"shell,attr"`
	With             action.WithListConfig `hcl:"with,block"`
	Env              action.EnvListConfig  `hcl:"env,block"`
	ContinueOnError  hcl.Expression        `hcl:"continue_on_error,attr"`
	TimeoutMinutes   hcl.Expression        `hcl:"timeout_minutes,attr"`

	// Carried only for its source range, which is where the comment written
	// above the step block is found. The decode fills it with what the
	// attributes above did not take, which for a step is nothing.
	Body hcl.Body `hcl:",remain"`
}

StepConfig represents the HCL configuration for a single step block.

func (*StepConfig) Parse

func (config *StepConfig) Parse(hv *hclparser.HCLVars) (Step, error)

Parse resolves the HCL step configuration into a Step using the provided variables.

type StepListConfig

type StepListConfig []StepConfig

StepListConfig is a slice of StepConfig decoded from HCL step blocks.

func (*StepListConfig) Parse

func (config *StepListConfig) Parse(hv *hclparser.HCLVars) (Steps, error)

Parse resolves all step configurations in the list into a Steps map.

type Steps

type Steps map[string]Step

Steps maps step identifiers to their parsed Step representations.

Jump to

Keyboard shortcuts

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