Built-in actions

Gilbert contains a few core built-in actions. External actions are available through third-party plugins.

Build action

Build action is abstraction over go build compile tool and simplifies build params pass.
This action can operate without configuration.

Configuration sample

version: 1.0
tasks:
    build:
    - action: build
      params:
        source: 'github.com/foo/bar'        # default: current package
        buildMode: 'c-archive'              # default: "default"
        outputPath: './build/foo.exe'       # default: project directory
        tags: 'foo bar baz'                 # set of build tags, separated by space
        params:
            stripDebugInfo: true            # removes debug info, default: false
            linkerFlags:                    # custom linker flags, default: empty
            - '-X main.foo=bar'
        target:
            os: windows     # default: current OS
            arch: '386'     # default: current arch
        variables:          # default: empty
            'main.commit': '{% git log --format=%H -n 1 %}' 

Configuration params

Param name Type Description
source string Package name to be built
buildMode string Build mode, see go help buildmode for possible values
outputPath string Artifact output path
tags string List of Go build tags separated by space (e.g: foo bar)
params object Additional params related to linker:
  • stripDebugInfo - Remove all debug symbols
  • linkerFlags - Array of flags passed to linker
target object Defines build target:
  • os - Target operating system (default: current OS)
  • arch - Target architecture (default: current architecture)
variables dict Key-value pair of variables to replace in executable by linker (main.version for example).
Can be useful to set application version or build commit.

Shell action

Shell action allows to execute shell commands. If command returns non-zero exit code, task will fail.

Configuration sample

version: 1.0
tasks:
  run_something:
  - action: shell
    params:
      command: 'scp root@localhost:/foo/bar ./bar'
      silent: false           # optional, default: false
      rawOutput: false        # optional, default: false
      shell: '/bin/bash'      # optional, default: /bin/sh or cmd.exe
      shellExecParam: '-c'    # optional, default: -c (or /c on windows for cmd.exe)
      workDir: '/tmp'         # optional, default: project directory
      env:                    # optional, default: use user's env vars
        LC_LANG: 'en_UTF-8'

Configuration params

Param name Type Description
command string Command to run
silent boolean Hide command output
rawOutput boolean Do not decorate command output, can be useful if command output seems ugly
shell string Shell executable, not recommended to change on Windows
shellExecParam string Shell command argument, not recommended to change
workDir string Working directory
env dict Custom environment variables

Watch action

Tracks file changes in specified path and restarts specified job on file/folder change.

Configuration sample

version: 1.0
tasks:
  watch:
  - action: watch
    params:
      path: './src/...'   # path to watch, required
      debounceTime: 300   # debounce time, optional
      ignore:
      - *.log             # list of entries to ignore, optional
      run:
        mixin: build-and-run-server # job or mixin to execute, similar to manifest job syntax. required.

Configuration params

Param name Type Description
path string Path to track for changes. Use /... to track changes in all sub-directories.
run object Job or mixin to run on change. See Job definition for more info
debounceTime int period to postpone job execution until after wait milliseconds have elapsed since the last time it was invoked
ignore []string List of entries to ignore. All dotfiles are already included

- Required parameter

Cover action

Runs package tests and checks package code coverage. Task fails if code coverage is below specified threshold.

Full configuration sample

version: 1.0
tasks:
  coverage:
  - action: cover
    params:
      threshold: 60.5       # minimal coverage percent
      reportCoverage: true  # show coverage report in output
      fullReport: false     # display coverage for each function
      showUncovered: false  # show list of packages without tests
      sort:
        by: 'coverage'      # sort report by package name or coverage
        desc: true          # sort ascending or descending
      packages:
      - ./controllers       # list of packages to cover
      - ./src/...

Configuration params

Param name Type Description
packages []string List of packages to check
threshold double Minimal coverage percent
reportCoverage boolean Display coverage summary
fullReport boolean Display coverage for each function in package
showUncovered boolean Display list of packages without tests
sort object Coverage report sort

- Required parameter

HTML coverage report action

Shows coverage report in web-browser.

Configuration sample

tasks:
  cover-html:
    - action: cover:html
      params:
        packages:
        - './foo'
        - './bar'

Param name Type Description
packages []string List of packages process
timeout int Time in milliseconds to wait for web-browser before coverge report file removal

- Required parameter

Get-Package action

Installs libraries using go get tool

Configuration sample

version: 1.0
tasks:
  watch:
  - action: get-package
    params:
      update: false       # force update, optional
      verbose: false      # debug output, optional
      downloadOnly: false # download without build, optional
      packages:
      - github.com/stretchr/testify
      - github.com/alecthomas/gometalinter

Configuration params

Param name Type Description
packages []string List of packages to install
update boolean Force package update
downloadOnly boolean Download libraries without compilation
verbose boolean Debug output

- Required parameter

Third-party actions

Third party actions could be added with custom plugins. See plugins docs for more info.