0.2.26-renovate-non-major-da3053768f16377e60509c5fd1e733785725328c • Published 5 years ago

@balena/ci-task-runner v0.2.26-renovate-non-major-da3053768f16377e60509c5fd1e733785725328c

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
5 years ago

CI Task Runner

Tool for running tasks inside of the balenaCI Docker Compose sut container.

Usage

This tool can either be used as a command-line tool or programatically.

Command line tool example:

$ ci-task-runner help
$ ci-task-runner validate --config /tmp/config.yml
$ ci-task-runner run --config /tmp/config.yml

Programatically:

const TaskRunner = require('@balena/ci-task-runner')

const taskRunner = new TaskRunner('/tmp/config.yml')
taskRunner.start()

Setup

To begin using this tool with your project, a YAML configuration file defining tasks is necessary must first be prepared. Once this has been created and added to your project's repository, install @balena/ci-task-runner in your sut container as a globally available command with npm i -g @balena/ci-task-runner and set your container's CMD to execute something like ci-task-runner run --config /path/to/my/config.yml.

Example Config

tickTimeout: 5
retryTimeout: 120
attemptsDefault: 3
tasks:
  - name: 'my-first-task'
    description: 'My first task'
    command: 'ls'
    cwd: '/usr/src/jellyfish'
    required: true
  - name: 'my-second-task'
    description: 'My second task'
    command: 'echo $MY_TASK_VAR'
    cwd: '/usr/src/jellyfish'
    required: false
    attempts: 1
    environment:
      - name: 'MY_TASK_VAR'
        value: 'foobar'
    dependencies:
      - 'my-first-task'

Documentation

A module for running a set of CI tasks.

module.exports ⏏

Kind: Exported class
Summary: CI task
Access: public

new module.exports(attemptsDefault, environment, options)

ParamTypeDescription
attemptsDefaultNumberdefault task attempt limit
environmentObjectsystem environment variables
optionsObjecttask options

Example

const task = new Task(3, {
  FIRST_VAR: 'first_value',
  SECOND_VAR: 'second_value'
}, {
  name: 'example-task',
  attempts: 10,
  description: 'Example task',
  command: 'ls -al',
  cwd: '/tmp',
  required: true,
  dependencies: [
    'other-task'
  ]
})
task.start()

module.exports.TaskRunner

Kind: static class of module.exports
Summary: CI task runner
Access: public

new exports.TaskRunner(configPath)
ParamTypeDescription
configPathStringpath to task configuration file

Example

const runner = new Runner('/usr/src/jellyfish/ci/tasks/config.yml')
runner.start()

taskRunner.start()

Kind: instance method of TaskRunner
Summary: Start tasks as background processes

taskRunner.monitor()

Kind: instance method of TaskRunner
Summary: Monitor running tasks for completion and/or inactivity

taskRunner.onSuccess()

Kind: instance method of TaskRunner
Summary: Execute onSuccess event handler

taskRunner.onFailure()

Kind: instance method of TaskRunner
Summary: Execute onFailure event handler

module.exports.isDirectory(location) ⇒ Boolean

Kind: static method of module.exports
Summary: Check if a given path is a directory that exists or not
Returns: Boolean - check result

ParamTypeDescription
locationStringpath to check

Example

const location = '/tmp'
if (exports.isDirectory(location)) {
  console.log(`${location} is a directory`)
}

module.exports.isWritable(location) ⇒ Boolean

Kind: static method of module.exports
Summary: Check if a given path is writable
Returns: Boolean - check result

ParamTypeDescription
locationStringpath to check

Example

const isWritable = exports.isWritable('/tmp')
console.log(isWritable)

module.exports.isWritableFile(location) ⇒ Boolean

Kind: static method of module.exports
Summary: Check if a given file path is writable
Returns: Boolean - check result

ParamTypeDescription
locationStringpath to check

Example

const isWritable = exports.isWritableFile('/tmp/test.json')
console.log(isWritable)

module.exports.validate(config)

Kind: static method of module.exports
Summary: Validate a config object against the schema definition

ParamTypeDescription
configObjectobject created from configuration file

Example

const config = yaml.safeLoad(fs.readFileSync(configPath, 'utf8'))
utils.validate(config)

module.exports.cleanString(original) ⇒ String

Kind: static method of module.exports
Summary: Clean up an environment variable string, remove whitespace and quotes
Returns: String - cleaned up string

ParamTypeDescription
originalStringoriginal string

Example

const result = exports.cleanString(process.env.MY_STRING_VAR)

module.exports.getTimestamp() ⇒ Number

Kind: static method of module.exports
Summary: Generates and returns the current unix timestamp
Returns: Number - current unix timestamp

0.2.94

5 years ago

0.2.93

5 years ago

0.2.92

5 years ago

0.2.91

5 years ago

0.2.90

5 years ago

0.2.89

5 years ago

0.2.88

5 years ago

0.2.87

5 years ago

0.2.86

5 years ago

0.2.85

5 years ago

0.2.84

5 years ago

0.2.83

5 years ago

0.2.82

5 years ago

0.2.81

5 years ago

0.2.80

5 years ago

0.2.79

5 years ago

0.2.78

5 years ago

0.2.77

5 years ago

0.2.76

5 years ago

0.2.75

5 years ago

0.2.74

5 years ago

0.2.73

5 years ago

0.2.72

5 years ago

0.2.71

5 years ago

0.2.70

5 years ago

0.2.69

5 years ago

0.2.68

5 years ago

0.2.67

5 years ago

0.2.66

5 years ago

0.2.65

5 years ago

0.2.64

5 years ago

0.2.63

5 years ago

0.2.62

5 years ago

0.2.61

5 years ago

0.2.60

5 years ago

0.2.59

5 years ago

0.2.58

5 years ago

0.2.57

5 years ago

0.2.56

5 years ago

0.2.55

5 years ago

0.2.54

5 years ago

0.2.53

5 years ago

0.2.52

5 years ago

0.2.51

5 years ago

0.2.50

5 years ago

0.2.49

5 years ago

0.2.48

5 years ago

0.2.47

5 years ago

0.2.46

5 years ago

0.2.45

5 years ago

0.2.44

5 years ago

0.2.43

5 years ago

0.2.42

5 years ago

0.2.41

5 years ago

0.2.40

5 years ago

0.2.39

5 years ago

0.2.38

5 years ago

0.2.37

5 years ago

0.2.36

5 years ago

0.2.35

5 years ago

0.2.34

5 years ago

0.2.33

5 years ago

0.2.32

5 years ago

0.2.31

5 years ago

0.2.30

5 years ago

0.2.29

5 years ago

0.2.28

5 years ago

0.2.27

5 years ago

0.2.26

5 years ago

0.2.25

5 years ago

0.2.24

5 years ago

0.2.23

5 years ago

0.2.22

5 years ago

0.2.21

5 years ago

0.2.20

5 years ago

0.2.19

5 years ago

0.2.18

5 years ago

0.2.17

5 years ago

0.2.16

5 years ago

0.2.15

5 years ago

0.2.14

5 years ago

0.2.13

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago