YourBase Docs

Package Configuration Reference

The .yourbase.yml file has four top-level sections:

Build Targets

The build_targets section is a list of build targets, each with a unique name a sequence of commands.

Example:

build_targets:
  - name: build_and_deploy
    commands:
      - rake test
      - rake package
      - rake deploy

Attributes

Dependencies

dependencies blocks describe what build packs should be loaded.

At the top-level, the dependencies are added to all build targets:

dependencies:
  build:
    - python:3.6.3
build_targets:
  # All build targets will have Python 3.6.3 available.
  - name: default
    commands:
      - python --version

  - name: foo
    commands:
      - pip install -r requirements.txt

But each target can also add its own set of dependencies or override versions:

dependencies:
  build:
    - python:3.6.3
build_targets:
  # This target will have Python 3.6.3 and Go 1.16.4 available.
  - name: default
    commands:
      - python --version
      - go version
    dependencies:
      - go:1.16.4

  # This target will have Python 3.9.2 available.
  - name: foo
    commands:
      - pip install -r requirements.txt
    dependencies:
      - python:3.9.2

The top-level dependencies section also accepts a runtime section to have build packs available for the Executable Target.

dependencies:
  runtime:
    - python:3.9.2

Containers

Individual targets can also specify Docker containers as dependencies. This is especially useful for running a database for integration tests. For example:

build_targets:
  - name: default
    dependencies:
      containers:
        db:
          image: postgres:12
          environment:
            POSTGRES_USER: myapp
            POSTGRES_PASSWORD: xyzzy
            POSTGRES_DB: myapp
          port_check:
            port: 5432
            timeout: 90
    environment:
      # Use whatever environment variables make sense for your test suite.
      PGHOST: '{{ .Containers.IP "db" }}'
      PGUSER: myapp
      PGPASSWORD: xyzzy
      PGDATABASE: myapp
    commands:
      - ./run_tests.sh

Any containers specified will be started with an optional health check before running any commands in the target. The target’s environment variables can reference the container’s IP address with the {{ .Containers.IP "container_name" }} syntax.

Attributes

Executable Target

The exec section specifies a target to run when yb exec is invoked. This is often used to start a local development server for the project. The exec section has the same properties as a target (as described in the Build Targets section), with a few small differences:

exec:
  container:
    ports:
      - 8080:8080
  dependencies:
    runtime:
      - python:3.9.2
  environment:
    default:
      DJANGO_SETTINGS_MODULE: mysite.settings
  commands:
    - python manage.py runserver

CI Instructions

The CI section allows you to define what to build and when by using a combination of build targets and conditions. In order for the CI system to properly build your project, you must define the build_targets and ci sections.

Simple example:

dependencies:
  build:
    - python:3.6.3

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

ci:
  builds:
    - name: all_commits
      build_target: default

Each list item in builds has the following attributes:

Example of CI builds with conditions:

dependencies:
  build:
    - python:3.6.3

build_targets:
  - name: integration_tests
    commands:
      - python integration_test.py

  - name: default
    commands:
      - python test.py

  - name: release
    commands:
      - python release.py

ci:
  builds:
    - name: main_builds
      build_target: integration_tests
      when: branch is 'main'

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

    - name: tags
      build_target: release
      when: tagged