Earthly Simulator¶
Overview¶
The following document provides an overview and usage guide for simulating Earthly locally.
The simulation can be done in 2 ways
- Running a command line
simulate
: This will run Earthly command on every targets that match the given input targets. The targets will run sequentially, then preview the outcomes. - Running a command line
generate
: This will create an Earthfile, which is set to be created at thegenerate/
folder inside the current directory. Inside the Earthfile, it contains a main target calledsimulate
. This mainsimulate
target will contains all the targets that match the given input targets. In order to test it,earthly +simulate
can be run directly.
Setup¶
Both of the commands are written in Go, which located in catalyst-ci .
Note
Make sure that your GOPATH
is set correctly.
To begin, clone the Catalyst CI repository:
Navigate to cli
directory.
The command can be found in cli/cmd/main.go
Running the command¶
In the cli
directory, the following command can be run
Build a binary file¶
Instead of running the command directly from main.go
,
building binary file can be done instead.
Now the ci
command can be run directly without Go command
Simulate Command Usage¶
SimulateCmd Struct¶
The simulateCmd struct is designed to be used with a command-line interface (CLI) and has the following fields:
Path
: Specifies the directory path to be iterated to search for targets within the Earthfile.Target
: A list of Earthly target patterns that the simulation will run. If the flag is not set, the default pipeline will be runcheck check-* build test test-*
Default targets workflow¶
If the target flag is not set, the default target patterns will be used.
The defaults value include check check-* build test test-*
.
Customize targets workflow¶
Specific stages can be simulated by adding target flag.
The argument is a list of target pattern, for example, -t "<target> <target2>"
Generate Command Usage¶
GenerateCmd Struct¶
The generateCmd struct is designed to be used with a command-line interface (CLI) and has the following fields:
Path
: Specifies the directory path to be iterated to search for targets within the Earthfile.Target
: A list of Earthly target patterns that the simulation will run. If the flag is not set, the default pipeline will be runcheck check-* build test test-*
Version
: An Earthly version that need to be specify at the top of Earthfile. The default version is 0.8
Default value¶
If the target flag is not set, the default target patterns will be used.
The defaults value include check check-* build test test-*
.
The ci will create an Earthfile in generate/
folder of the current directory.
The version of the Earthly will be set to 0.8
The targets will be listed under the simulate
target.
eg. BUILD ../test/+target
Customize targets workflow¶
Customization can be done by specifying flags.
- Adding target flag
-t "<target>" -t "<target2>"
- Adding version flag
-v <version>
The ci will create an Earthfile in generate/
folder of the current directory.
The command above will iterate through the current directory.
Find the target that match test-*
and check-*
.
Set the version of Earthly to 0.6.
Warning
Make sure that the directory of the Earthfile is not conflict with the existing Earthfile.
The Earthfile should be ignore in the .gitignore