Build Pipeline

Introduction

Build pipeline is the core of Torch, as well as any other Continuous Integration. Torch makes defining as well as running all your build steps very easy. All build steps for a build are run in sequence and if any fail, Torch will not run the rest of the steps.

Build steps are a series of Bash scripts that run after the container is configured.

Defining build steps

To define which build steps Torch should run, define the build key in the project's torchci.yml file with a list of build steps, or manually from the "Build Pipeline" tab in the project's settings in Torch UI.

php: 7.4
build:
    - 'composer install'
    - 'npm install'
    - 'npm run production'
    - 'phpunit'

Advanced Configuration

Alternatively, you may provide an object of options for each build step definition to do more customization and configuration, like giving a build step a pretty name and configuring build step restrictions.

When using the key-value format, be sure to add the commands key to define a list of commands. See an example below:

php: 7.4
build:
    - name: Install Composer deps
      commands: 'composer install'
    - name: Compile Assets
      commands:
        - 'npm install'
        - 'npm run production'
    - name: Run tests
      commands: 'phpunit'

Restrictions

Just like in project and hook restrictions, you can restrict build steps to run only for certain branches. To restrict a build step, add a only key with a list of branches to the build step definition in your project's torchci.yml file.

build:
    - name: Install Composer deps
      commands: 'composer install'
    - name: Deploy production to Vapor
      commands: 'vapor deploy production'
      only: master
    - name: Deploy staging to Vapor
      commands: 'vapor deploy staging'
      only:
        - staging
        - features/*

Alternatively, you may use except key to instruct Torch to ignore build steps for a list of branches.

build:
    - name: Install Composer deps
      commands: 'composer install'
    - name: Deploy to Vapor
      commands: 'vapor deploy staging'
      except:
        - master

Paralellism

If Parallel Builds are enabled for a project, Torch will not wait to for all previous builds to finish to start the pending builds, but rather start immediately. This may result in overlaps in build steps and therefore it may result in an unwanted failure or a bug.

For example, when deploying your application with a service like Laravel Vapor (opens new window), you may want to run all deployments in sequence instead of in parallel to always have the latest deployment active.

To avoid overlaps, Torch allows you to define the wait: true directive in a build step definition in your project's torchci.yml file, or by toggling "Wait" checkbox from the Torch UI. This will put the build step in a Waiting state, which will instruct Torch to wait for previous builds to end before running. This ensures there are no overlaps in build steps.

parallel: true
build:
    - name: Install Composer deps
      commands: 'composer install'
    - name: Deploy to Vapor
      commands: 'vapor deploy production'
      wait: true