This document describes how to use actionlint as Go library.
actionlint can be used from Go programs by importing the module.
import "github.com/rhysd/actionlint"See the documentation to know the list of all APIs. It contains
a workflow file parser built on top of yaml/go-yaml library, expression ${{ }} lexer/parser/checker, etc.
Followings are unexhaustive list of interesting APIs.
Commandstruct represents entireactionlintcommand.Command.Maintakes command line arguments and runs command until the end and returns exit status.Lintermanages linter lifecycle and applies checks to given files. If you want to run actionlint checks in your program, please use this struct.ProjectandProjectsdetect a project (Git repository) in a given directory path and find configuration in it.Configrepresents structure ofactionlint.yamlconfig file. It can be decoded by yaml/go-yaml library.Workflow,Job,Step, ... are nodes of workflow syntax tree.Workflowis a root node.Parse()parses given contents into a workflow syntax tree. It tries to find syntax errors as much as possible and returns found errors as slice.Passis a visitor to traverse a workflow syntax tree. Multiple passes can be applied at single pass usingVisitor.Ruleis an interface for rule checkers andRuneBaseis a base struct to implement a rule checker.RuleExpressionis a rule checker to check expression syntax in${{ }}.RuleShellcheckis a rule checker to applyshellcheckcommand torun:sections and collect errors from it.RuleJobNeedsis a rule checker to check dependencies inneeds:section. It can detect cyclic dependencies.- ...
ExprLexerlexes expression syntax in${{ }}and returns slice ofToken.ExprParserparses given slice ofTokenand returns syntax tree for expression in${{ }}.ExprNodeis an interface for nodes in the expression syntax tree.ExprTypeis an interface of types in expression syntax${{ }}.ObjectType,ArrayType,StringType,NumberType, ... are structs to represent actual types of expression.ExprSemanticsCheckerchecks semantics of expression syntax${{ }}. It traverses given expression syntax tree and deduces its type, checking types and resolving variables (contexts).ValidateRefGlob()andValidatePathGlob()validate glob filter pattern and returns all errors found by the validator.ActionMetadatais a struct for action metadata file (action.yml). It is used to check inputs specified atwith:and typingsteps.{id}.outputsobject strictly.PopularActionsglobal variable is the data set of popular actions' metadata collected by the script.AllWebhookTypesglobal variable is the mapping from all webhook names to their types collected by the script.WorkflowKeyAvailability()returns available context names and special function names for the given workflow key likejobs.<job_id>.outputs.<output_id>. This function uses the data collected by the script.
The version of this repository is for command line tool actionlint. So it does not represent the version of the library.
It means that the library does not follow semantic versioning and any patch version bump may introduce some breaking changes.
Following the Go's official policy, last two major Go versions are supported. For example, when the latest Go version is
v1.22, v1.21 and v1.22 are supported. Minimum supported Go version is written in the go.mod file in this
repository.
Checks | Installation | Usage | Configuration | References