Skip to content

Commit

Permalink
Merge pull request #5 from FiniteMonkeys/kc/2
Browse files Browse the repository at this point in the history
feat: add config and workflow for gitStream
  • Loading branch information
krisalyssa authored Jun 29, 2024
2 parents f12af8c + 0b4af40 commit 340709e
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .cm/gitstream.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# code: language=jinja-yaml insertSpaces=true tabSize=2

manifest:
version: 1.0

automations:
estimated_time_to_review:
if:
- true
run:
- action: add-label@v1
args:
label: "{{ calc.etr }} min review"
color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}

percent_new_code:
if:
- true
run:
- action: add-comment@v1
args:
comment: |
This PR is {{ changes.ratio }}% new code.

# custom expressions

# https://docs.gitstream.cm/filter-functions/#estimatedreviewtime
calc:
etr: {{ branch | estimatedReviewTime }}

changes:
additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}

# These are all of the colors in GitHub's default label color palette.
colors:
red: 'b60205'
orange: 'd93f0b'
yellow: 'fbca04'
green: '0e8a16'
blue: '1d76db'
purple: '5319e7'
47 changes: 47 additions & 0 deletions .github/workflows/gitstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# code: language=yaml insertSpaces=true tabSize=2
name: gitStream
run-name: |
/:\ gitStream: PR #${{ fromJSON(fromJSON(github.event.inputs.client_payload)).pullRequestNumber }} from ${{ github.event.inputs.full_repository }}
on:
workflow_dispatch:
inputs:
client_payload:
description: The client payload.
required: true
full_repository:
description: The repository name, including the owner name.
required: true
head_ref:
description: A ref to the head commit.
required: true
base_ref:
description: A ref to the base commit.
required: true
installation_id:
description: The GitHub App installation ID.
required: false
resolver_url:
description: The resolver URL to pass results to.
required: true
resolver_token:
description: Optional resolver token for the resolver service.
required: false
default: ""

jobs:
gitStream:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Evaluate Rules
id: rules-engine
uses: linear-b/gitstream-github-action@v2
with:
full_repository: ${{ github.event.inputs.full_repository }}
head_ref: ${{ github.event.inputs.head_ref }}
base_ref: ${{ github.event.inputs.base_ref }}
client_payload: ${{ github.event.inputs.client_payload }}
installation_id: ${{ github.event.inputs.installation_id }}
resolver_url: ${{ github.event.inputs.resolver_url }}
resolver_token: ${{ github.event.inputs.resolver_token }}

0 comments on commit 340709e

Please sign in to comment.