Skip to content

Commit

Permalink
ci(.cm): add .cm files for gitstream
Browse files Browse the repository at this point in the history
  • Loading branch information
benjivesterby committed Mar 27, 2023
1 parent 2c0851f commit 55e95a5
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .cm/approve-safe-changes.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- mode: yaml -*-

manifest:
version: 1.0

automations:
safe_changes:
if:
- {{ is.formatting or is.docs or is.tests or is.asset }}
run:
- action: add-label@v1
args:
label: 'safe-changes'
- action: approve@v1

# To simplify the automation, this calculation is placed under a unique YAML key.
# The result is is assigned to `is.formatting`, `is.docs` and `is.tests` which is
# used in the automation above. You can add as many keys as you like.
is:
formatting: {{ source.diff.files | isFormattingChange }}
docs: {{ files | allDocs }}
tests: {{ files | allTests }}
asset: {{ files | match(regex=r/\.(png|svg|gif|css)$/) | every }}
17 changes: 17 additions & 0 deletions .cm/assign-the-relevant-reviewers-to-prs.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- mode: yaml -*-

manifest:
version: 1.0

automations:
the_right_reviewer:
if:
- true
run:
- action: add-comment@v1
args:
comment: |
{{ repo | explainRankByGitBlame(gt=25) }}
- action: add-reviewers@v1
args:
reviewers: {{ repo | rankByGitBlame(gt=25) | random }}
20 changes: 20 additions & 0 deletions .cm/label-prs-by-complexity.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- mode: yaml -*-

manifest:
version: 1.0

automations:
estimated_time_to_review:
if:
- true
run:
- action: add-label@v1
args:
label: "{{ calc.etr }} min review"
color: {{ 'E94637' if (calc.etr >= 20) else ('FBBD10' if (calc.etr >= 5) else '36A853') }}

# To simplify the automation, this calculation is placed under a unique YAML key.
# The result is assigned to `calc.etr` which is used in the automation above.
# You can add as many keys as you like.
calc:
etr: {{ branch | estimatedReviewTime }}
17 changes: 17 additions & 0 deletions .cm/mark-prs-with-deleted-files.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- mode: yaml -*-

manifest:
version: 1.0

automations:
deleted:
if:
- {{ has.deleted_files }}
run:
- action: add-label@v1
args:
label: 'deleted-files'
color: '#DF9C04'

has:
deleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }}
14 changes: 14 additions & 0 deletions .cm/mark-prs-without-tests.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- mode: yaml -*-

manifest:
version: 1.0

automations:
no_tests:
if:
- {{ files | match(regex=r/(test|spec)/) | nope }}
run:
- action: add-label@v1
args:
label: 'missing-tests'
color: '#E94637'
15 changes: 15 additions & 0 deletions .cm/more-approvals-for-complex-changes.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- mode: yaml -*-

manifest:
version: 1.0

automations:
double_review:
if:
- {{ branch | estimatedReviewTime >= 30 }}
- {{ files | length >= 10 }}
- {{ files | match(regex=r/src\//) | some }}
run:
- action: set-required-approvals@v1
args:
approvals: 2

0 comments on commit 55e95a5

Please sign in to comment.