Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

hideHeadertrue
urlhttps://bitbucket.org/mibexsoftware/codeowners-documentation/src/main/bitbucket-dc/devsensei.md
syntaxHighlightingMarkdown

DevSensei: PR Workflow Automation

DevSensei-logo-colour.pngImage Removed

Workflow Automation for Dev Teams

What is DevSensei?

DevSensei is a new pull request workflow automation solution integrated into the Code Owners App.

...

Here's an example devsensei.yaml that assigns Code Owners for a pull request introducing a new feature where the pull request is opened from a branch including the prefix feature/ with the destination branch being main or release:

Code Block
languageyaml
workflows:
- name: Add Code Owners
  conditions:
    - source~=feature/*
    - or:
        - destination=main
        - destination~=release/*
  actions:
    - add-codeowners:
        rules: |
          *.js            @@frontendDevs
          devsensei.yaml  @@team

...

Code Owners Settings NOT supported in DevSensei add-codeowners action

Code Owners feature

Why not supported / Alternative?

CODEOWNERS.toplevel.create_pull_request_comment

May be added later

CODEOWNERS.toplevel.subdirectory_override

Obsolete with includes

...

Each workflow is meant to automate specific tasks for the pull requests of your team.

Attributes

Definition

name

The name of the workflow. Must be unique in a repository.

conditions

A set of conditions to be met for the actions of the workflow to be executed for a pull request

actions

A set of actions to be executed when the conditions are met for a pull request

overrides

A workflow with the same name can be overridden in the main devsensei.yaml file. If so, the workflow object must have overrides=true. If not, then you will get a validation error for the duplicate names.

main.yaml

Code Block
includes:
  - other.yaml
workflow:
  - name: Code Owners
  - name: I am overridden
    overrides: true

other.yaml

Code Block
workflow:
  - name: Checklist
  - name: I am overridden

Conditions

Conditions define the criteria that must be met so that the actions of a workflow are executed. They allow you to define which pull requests should be handled by DevSensei based on various criteria like the draft pull request status, source and destination branches, and more.

...

Code Block
languageyaml
conditions:
- or:
    - destination=main
    - destination~=release/*
    - source~!=hotfix/*

Condition Attributes

Meaning

source

Source branch of pull request

destination

Destination branch of pull request

draft

Is it a draft pull request

Conditions Combination Operator

Meaning

and

All conditions must be fulfilled

or

At least one of the conditions must be fulfilled

Conditions Attributes Operator

Meaning

~=

Glob match

~!=

Glob negative match

=

Equals

!=

Not equals

! or not

Negate a boolean attribute

Actions

add-codeowners

Adds Code Owners as reviewers to a pull request.

Attributes

Definition

assignment-routing

random: n

reduce the number of Code Owners that are automatically assigned to a pull request. (opt-in) Currently, the only available method of assignment is at random.

Code Block
languageyaml
- add-codeowners:
  assignment-routing:
  random: 2

rules

The Code Owners rules and merge checks. For existing CODEOWNERS users, copy your owner rules and the merge checks to the rules section. Note: for sub-directory overrides, check "Not supported settings" section.

Code Block
languageyaml
- add-codeowners:
  rules: |
    *          @jordan jordan@example.com
    /backend/  @@backendies
    /frontend/ @@frontendies

custom-groups

Define custom Code Owners groups.

Code Block
languageyaml
- add-codeowners:
  rules: |
    pipelines.yml           @@admins
    backend/                @@backendies
    src/components/**/*.js  @@frontendies
  custom-groups:
    admins:
      - @bobby
    backendies:
      - @jordan
      - john.doe@localhost.ch
    frontendies:
      - @charly
      - @@admins

auto-unapprove-on-change

Remove approval if owned code changes.

Code Block
languageyaml
- add-codeowners:
  auto-unapprove-on-change: true

Includes

With includes, common Devsensei workflows can be shared both across repositories as well within projects in a monorepo.

...

  • The files are read from the latest commit of the default branch

  • YAML Anchors will be resolved per file.

  • Only one level of includes are support (no recursion supported)

YAML Anchors

Use YAML Anchors to define reusable content in the same YAML file.

...