Yourbase YAML Config

Examples

Python

+ show/hide code

Python (Large)

+ show/hide code

Go

+ show/hide code

Ruby

+ show/hide code

NodeJS

+ show/hide code

YAML Syntax Reference

The YourBase YAML file is broken into four primary sections:

  • Dependencies

  • Build Targets

  • Runtime Target

  • CI Instructions

Dependencies

dependencies

The dependencies section describes what build packs need to be loaded for the build

Example:

1
2
3
4
5
dependencies:
  build:
    - python:3.6.3
  runtime:
    - heroku:latest

build

Dependencies used by all build_targets (see below).

runtime

Dependencies used by all exec targets (see below).

Build Targets

build_targets

A list of build targets (see below) - each target has a unique name and some commands as a minimum to be useful; there are other options including environment, container definition and target chaining that are explained further down.

name

The name of the build target, this is referenced on the command-line yb build targetname, in CI configuration sections or as things to build first.

Naming a build target
1
2
build_targets:
  - name: rspec_tests

commands

The commands to be executed; these can be anything you would run on the command-line. Note YourBase does not expand environment variables using the normal ${VALUE} syntax, though there are ways to do this. We do not run sh or bash as this is not portable; if you need to do that, create a shell script and run it as a command explicitly.

List of commands to run
1
2
3
4
5
6
build_targets:
  - name: build_and_deploy
    commands:
      - rake test
      - rake package
      - rake deploy

tags

Tags are used to select which build server can handle each build.

os

Specifies which operating system this build target is applicable to. Current valid options:

  • linux (default)

  • osx

Builds for different operating systems
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
- name: android
  tags:
    os: linux
  commands:
    - apt-get update
    - apt-get install -y software-properties-common
    - add-apt-repository -y ppa:ubuntu-toolchain-r/test
    - apt-get update
    - apt-get install -y lib32stdc++6
    - sh build.sh
- name: ios
  tags:
    os: darwin
  commands:
      - brew update
      - brew install --HEAD usbmuxd
      - brew link usbmuxd
      - brew install --HEAD libimobiledevice
      - brew install ideviceinstaller
      - brew install ios-deploy
      - sh build.sh

environment

A list of KEY=VALUE items that are used as environment variables.

Setting environment variables
1
2
3
4
5
build_targets:
  - name: default
    environment:
      - ENVIRONMENT=development
      - DATABASE_URL=db://localhost:1234/foo

root

The name of a path where it should run commands from, relative to the root of the project. TODO: consider renaming to workdir?

Setting a command working dir
1
2
3
4
5
6
build_targets:
  - name: default
    root: sdk
    commdands:
      - yarn install --focus
      - yarn test --no-watch

build_after

A list of build targets whose commands will be executed before this target. Note This is not transitive by design; if you want a target to depend on multiple others, you need to list them. This allows the target to be clear in what’s happening and permit some additional flexibility.

Example with build order.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
build_targets:
  - name: test
    commands:
      - echo "Hi"
      - python tests.py

  - name: validate
    commands:
      - python validate.py

  - name: release
    build_after:
      - test
      - validate
    commands:
      - python kraken.py

container

If this build is to be built in a container, this directive allows you to describe the container. All the commands in the commands directive will be executed inside a container using the provided configuration.

Perform a build inside a golang 1.12 container
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
build_targets:
  - name: container_build
    container:
      image: golang:1.12
      mounts:
         - data:/data
      ports:
         - 123:456
      environment:
         - FOO=bar
         - PASSWORD=sekret
      workdir:
         - /source
    commands:
      - go get
      - go build
      - go test ./...

CI Build Directives

The CI section allows you to define what to build and when by using a combination of build targets and conditions.

ci

The CI section contains information about which build targets to run and when to run them. In order for the CI system to properly build your project you must define the dependencies, build_targets and ci sections.

Simple CI example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
dependencies:
  build:
    - python:3.6.3

build_targets:
   - name: default
     commands:
      - python test.py

ci:
   builds:
      - name: all_commits
        build_target: default

builds:

A list of CI targets, each has a name, a build target to execute and an optional conditional clause telling the CI system when to build it. (Omitting the conditional clause means that the target will be built on every commit)

name

The name of the CI build itself (arbitrary string)

build_target

The name of the build target to run (must match one of the names in the build_targets section)

when

CI build conditions for this target. You can use the following conditions and combine them using simple boolean logic.

branch

Any arbitrary string that matches a branch in your repository

Ex: “branch is ‘master’”, “branch is not ‘test’”

action

Possible values: “commit”, “pull_request”

Ex: “action is ‘pull_request’”

tagged

Boolean value, either true or false

Ex: “tagged”

CI builds with conditions
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
dependencies:
  build:
    - python:3.6.3

build_targets:
   - name: default
     commands:
      - python test.py

   - name: integration
     commands:
      - python integration_tests.py

   - name: release
     commands:
      - python kraken.py

ci:
   builds:
      - name: master_builds
        build_target: default
        when: branch is 'master'

      - name: pr_builds
        build_target: integration
        when: action is 'pull_request'

      - name: release
        build_target: release
        when: tagged