Skip to content

Working with Workflows and Tasks (Jobs)

Workflows and Tasks are the heart of how Razorops works. A workflow is simply a series of tasks, executed in a runner (container or VM) environment such that it's completed in the quickest manner possible. Tasks are defined under tasks key and workflows under workflows key in the Pipeline YAML file.

There are mainly two ways to model a CI/CD process in Razorops depending on how task dependencies are defined. By default, all tasks run in parallel unless defined explicitly. It's essentially a directed acyclic graph to build the relationships where graph nodes represent CI tasks. With DAG, you can model any kind of complex workflow.

Defining dependencies under tasks

In the first approach, you will define your pipeline using tasks property and dependencies with depends property. Using task dependencies, you can model any simple to moderately complex CI process.

In the following example (in DAG tab) task t3 starts once tasks t1 and task t2 finish. Task t1 and Task t2 will start in parallel.

 |---------|
 |    t1   |------
 |---------|       \        |---------|
                    \ ----> |    t3   |
 |---------|        /       |---------|
 |    t2   |-------/
 |---------|
tasks:
  t1:
    depends: []
    ...

  t2:
    depends: []
    ...

  t3:
    depends: [t1, t2]
tasks:
  t1:
    depends: []
    ...

  t2:
    depends: [t1]
    ...

  t3:
    depends: [t2]

Defining dependencies under workflows

In the second approach, we define an additional property in Pipeline YAML - workflows. You can models more complex CI process where tasks are organizaed into multiple DAG(s). A trigger can create multiple new workflows that provides more flexibility. Here is an example -

## workflow [w1]
|---------|
|    t1   |------
|---------|       \        |---------|
                   \ ----> |    t3   |
|---------|        /       |---------|
|    t2   |-------/
|---------|


## workflow [w2]
|---------|      |--------|       |----------|
|    t1   |------|   t4   |-------|    t5    |
|---------|      |--------|       |----------|

|---------|
|   t7    |
|---------|
tasks:
  ## defines t1, t2, t3, t4, t5, t6, t7
  ...

workflows:
- name: w1
  tasks:
  - t1
  - t2
  - t3:
      depends: [t1, t2]

- name: w2
  tasks:
  - t1
  - t4:
      depends: [t1]
  - t5:
      depends: [t4]
  - t7

  ## Note: Since task `t6` is not included, it won't get executed.