From a05e4325e08747bfc3be405f114e8bdd7fc09e7d Mon Sep 17 00:00:00 2001 From: "reviewpad[bot]" <104832597+reviewpad[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 10:09:58 +0000 Subject: [PATCH 01/10] feat: add reviewpad.yml file --- reviewpad.yml | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 reviewpad.yml diff --git a/reviewpad.yml b/reviewpad.yml new file mode 100644 index 000000000..119b18772 --- /dev/null +++ b/reviewpad.yml @@ -0,0 +1,127 @@ +# This file is used to configure Reviewpad. +# The configuration is a proposal to help you get started. +# You can use it as a starting point and customize it to your needs. +# For more details see https://docs.reviewpad.com/guides/syntax. + +# Define the list of labels to be used by Reviewpad. +# For more details see https://docs.reviewpad.com/guides/syntax#label. +labels: + small: + description: Pull request is small + color: "#76dbbe" + medium: + description: Pull request is medium + color: "#2986cc" + large: + description: Pull request is large + color: "#c90076" + +# Define the list of workflows to be run by Reviewpad. +# A workflow is a list of actions that will be executed based on the defined rules. +# For more details see https://docs.reviewpad.com/guides/syntax#workflow. +workflows: + # This workflow calls Reviewpad AI agent to summarize the pull request. + - name: summarize + description: Summarize the pull request + run: + # Summarize the pull request on pull request synchronization. + - if: ($eventType() == "synchronize" || $eventType() == "opened") && $state() == "open" + then: $summarize() + + # This workflow assigns the most relevant reviewer to pull requests. + # This helps guarantee that most pull requests are reviewed by at least one person. + - name: reviewer-assignment + description: Assign the most relevant reviewer to pull requests + run: + # Automatically assign reviewer when the pull request is ready for review; + - if: $isDraft() == false + then: $assignCodeAuthorReviewers() + + # This workflow praises contributors on their pull request contributions. + # This helps contributors feel appreciated. + - name: praise-contributors-on-milestones + description: Praise contributors based on their contributions + run: + # Praise contributors on their first pull request. + - if: $pullRequestCountBy($author()) == 1 + then: $commentOnce($sprintf("Thank you @%s for this first contribution!", [$author()])) + + # This workflow validates that pull requests follow the conventional commits specification. + # This helps developers automatically generate changelogs. + # For more details, see https://www.conventionalcommits.org/en/v1.0.0/. + - name: check-conventional-commits + description: Validate that pull requests follow the conventional commits + run: + - if: $isDraft() == false + then: + # Check commits messages against the conventional commits specification + - $commitLint() + # Check pull request title against the conventional commits specification. + - $titleLint() + + # This workflow validates best practices for pull request management. + # This helps developers follow best practices. + - name: best-practices + description: Validate best practices for pull request management + run: + # Warn pull requests that do not have an associated GitHub issue. + - if: $hasLinkedIssues() == false + then: $warn("Please link an issue to the pull request") + # Warn pull requests if their description is empty. + - if: $description() == "" + then: $warn("Please provide a description for the pull request") + # Warn pull request do not have a clean linear history. + - if: $hasLinearHistory() == false + then: $warn("Please rebase your pull request on the latest changes") + + # This workflow labels pull requests based on the total number of lines changed. + # This helps pick pull requests based on their size and to incentivize small pull requests. + - name: size-labeling + description: Label pull request based on the number of lines changed + run: + - if: $size() < 100 + then: $addLabel("small") + else: $removeLabel("small") + - if: $size() >= 100 && $size() < 300 + then: $addLabel("medium") + else: $removeLabel("medium") + - if: $size() >= 300 + then: $addLabel("large") + else: $removeLabel("large") + + # This workflow signals pull requests waiting for reviews. + # This helps guarantee that pull requests are reviewed and approved by at least one person. + - name: check-approvals + description: Check that pull requests have the required number of approvals + run: + # Label pull requests with `waiting-for-review` if there are no approvals; + - if: $isDraft() == false && $approvalsCount() < 1 + then: $addLabel("waiting-for-review") + + # This workflow labels pull requests based on the pull request change type. + # This helps pick pull requests based on their change type. + - name: change-type-labelling + description: Label pull requests based on the type of changes + run: + # Label pull requests with `docs` if they only modify Markdown or txt files. + - if: $hasFileExtensions([".md", ".txt"]) + then: $addLabel("docs") + else: $removeLabel("docs") + # Label pull requests with `infra` if they modify Terraform files. + - if: $hasFileExtensions([".tf"]) + then: $addLabel("infra") + else: $removeLabel("infra") + # Label pull requests with `dependencies` if they only modify `package.json` and `package.lock` files. + - if: $hasFileExtensions(["package.json", "package-lock.json"]) + then: $addLabel("dependencies") + else: $removeLabel("dependencies") + + # This workflow validates that pull requests do not contain changes to the license. + # This helps avoid unwanted license modifications. + - name: license-validation + description: Validate that licenses are not modified + run: + # Fail Reviewpad check on pull requests that modify any LICENSE; + - if: $hasFilePattern("**/LICENSE*") + then: $fail("License files cannot be modified") + From 30b3f48bee40a9d64340d2cd8fda9151af1b22d1 Mon Sep 17 00:00:00 2001 From: "reviewpad[bot]" <104832597+reviewpad[bot]@users.noreply.github.com> Date: Sun, 21 May 2023 03:57:07 +0000 Subject: [PATCH 02/10] chore: update reviewpad.yml configuration file --- reviewpad.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/reviewpad.yml b/reviewpad.yml index 119b18772..6c682b03c 100644 --- a/reviewpad.yml +++ b/reviewpad.yml @@ -46,19 +46,6 @@ workflows: - if: $pullRequestCountBy($author()) == 1 then: $commentOnce($sprintf("Thank you @%s for this first contribution!", [$author()])) - # This workflow validates that pull requests follow the conventional commits specification. - # This helps developers automatically generate changelogs. - # For more details, see https://www.conventionalcommits.org/en/v1.0.0/. - - name: check-conventional-commits - description: Validate that pull requests follow the conventional commits - run: - - if: $isDraft() == false - then: - # Check commits messages against the conventional commits specification - - $commitLint() - # Check pull request title against the conventional commits specification. - - $titleLint() - # This workflow validates best practices for pull request management. # This helps developers follow best practices. - name: best-practices From ae26bd57fd16afd92e30c0009ec07a3919d5d15c Mon Sep 17 00:00:00 2001 From: "reviewpad[bot]" <104832597+reviewpad[bot]@users.noreply.github.com> Date: Sun, 21 May 2023 03:58:20 +0000 Subject: [PATCH 03/10] chore: update reviewpad.yml configuration file --- reviewpad.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/reviewpad.yml b/reviewpad.yml index 6c682b03c..3158d5619 100644 --- a/reviewpad.yml +++ b/reviewpad.yml @@ -46,21 +46,6 @@ workflows: - if: $pullRequestCountBy($author()) == 1 then: $commentOnce($sprintf("Thank you @%s for this first contribution!", [$author()])) - # This workflow validates best practices for pull request management. - # This helps developers follow best practices. - - name: best-practices - description: Validate best practices for pull request management - run: - # Warn pull requests that do not have an associated GitHub issue. - - if: $hasLinkedIssues() == false - then: $warn("Please link an issue to the pull request") - # Warn pull requests if their description is empty. - - if: $description() == "" - then: $warn("Please provide a description for the pull request") - # Warn pull request do not have a clean linear history. - - if: $hasLinearHistory() == false - then: $warn("Please rebase your pull request on the latest changes") - # This workflow labels pull requests based on the total number of lines changed. # This helps pick pull requests based on their size and to incentivize small pull requests. - name: size-labeling From e6421b0d613ffa21289390e3a30e992389f72b52 Mon Sep 17 00:00:00 2001 From: "reviewpad[bot]" <104832597+reviewpad[bot]@users.noreply.github.com> Date: Sun, 21 May 2023 03:59:10 +0000 Subject: [PATCH 04/10] chore: update reviewpad.yml configuration file --- reviewpad.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/reviewpad.yml b/reviewpad.yml index 3158d5619..27fa1f865 100644 --- a/reviewpad.yml +++ b/reviewpad.yml @@ -37,15 +37,6 @@ workflows: - if: $isDraft() == false then: $assignCodeAuthorReviewers() - # This workflow praises contributors on their pull request contributions. - # This helps contributors feel appreciated. - - name: praise-contributors-on-milestones - description: Praise contributors based on their contributions - run: - # Praise contributors on their first pull request. - - if: $pullRequestCountBy($author()) == 1 - then: $commentOnce($sprintf("Thank you @%s for this first contribution!", [$author()])) - # This workflow labels pull requests based on the total number of lines changed. # This helps pick pull requests based on their size and to incentivize small pull requests. - name: size-labeling From 41e1fa98d0805d7bce81427a32ba6b5b2d8bae25 Mon Sep 17 00:00:00 2001 From: "reviewpad[bot]" <104832597+reviewpad[bot]@users.noreply.github.com> Date: Sun, 21 May 2023 04:11:29 +0000 Subject: [PATCH 05/10] chore: update reviewpad.yml configuration file --- reviewpad.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/reviewpad.yml b/reviewpad.yml index 27fa1f865..2cdb7cd25 100644 --- a/reviewpad.yml +++ b/reviewpad.yml @@ -61,24 +61,6 @@ workflows: - if: $isDraft() == false && $approvalsCount() < 1 then: $addLabel("waiting-for-review") - # This workflow labels pull requests based on the pull request change type. - # This helps pick pull requests based on their change type. - - name: change-type-labelling - description: Label pull requests based on the type of changes - run: - # Label pull requests with `docs` if they only modify Markdown or txt files. - - if: $hasFileExtensions([".md", ".txt"]) - then: $addLabel("docs") - else: $removeLabel("docs") - # Label pull requests with `infra` if they modify Terraform files. - - if: $hasFileExtensions([".tf"]) - then: $addLabel("infra") - else: $removeLabel("infra") - # Label pull requests with `dependencies` if they only modify `package.json` and `package.lock` files. - - if: $hasFileExtensions(["package.json", "package-lock.json"]) - then: $addLabel("dependencies") - else: $removeLabel("dependencies") - # This workflow validates that pull requests do not contain changes to the license. # This helps avoid unwanted license modifications. - name: license-validation From eec586069048628b41f5818d611db7c25a794038 Mon Sep 17 00:00:00 2001 From: "reviewpad[bot]" <104832597+reviewpad[bot]@users.noreply.github.com> Date: Sun, 21 May 2023 04:16:02 +0000 Subject: [PATCH 06/10] chore: update reviewpad.yml configuration file --- reviewpad.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/reviewpad.yml b/reviewpad.yml index 2cdb7cd25..c258d9b25 100644 --- a/reviewpad.yml +++ b/reviewpad.yml @@ -61,12 +61,3 @@ workflows: - if: $isDraft() == false && $approvalsCount() < 1 then: $addLabel("waiting-for-review") - # This workflow validates that pull requests do not contain changes to the license. - # This helps avoid unwanted license modifications. - - name: license-validation - description: Validate that licenses are not modified - run: - # Fail Reviewpad check on pull requests that modify any LICENSE; - - if: $hasFilePattern("**/LICENSE*") - then: $fail("License files cannot be modified") - From c44c088582305f579876dd639c35db2cc43f4c00 Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Sun, 21 May 2023 12:16:47 +0800 Subject: [PATCH 07/10] Delete gitstream.cm --- .cm/gitstream.cm | 74 ------------------------------------------------ 1 file changed, 74 deletions(-) delete mode 100644 .cm/gitstream.cm diff --git a/.cm/gitstream.cm b/.cm/gitstream.cm deleted file mode 100644 index 29a6ddba2..000000000 --- a/.cm/gitstream.cm +++ /dev/null @@ -1,74 +0,0 @@ -# -*- mode: yaml -*- - -manifest: - version: 1.0 - -# The `automations` section includes a list of automation that applies -# to the repository in which gitStream is installed. Each automation has an -# `if` key with a list of the necessary assertions, as well as a `run` key with a -# list of all actions. All the listed assertions need to pass in order -# for the following actions to be executed (there is AND relation between conditions). - -# Each automation under the `automations` section is independent of the others. -# Every time a PR is opened or changed, the automation's conditions are evaluated (the `if`). -# The actions under `run` are executed one by one if all the conditions pass. - -# Conditions consists of an expression, which are wrapped with double curly braces, and -# includes a context variable like `files` and filter functions like `length`. Filters -# functions are essentially functions that can be applied to context variables. They are -# called with a pipe operator (|) and can take arguments. Read more on https://docs.gitstream.cm - -automations: - # This is the name of the review automation. You can use whatever name, a meaningful name - # will help to identify it in the future. Each automation name in this file should be unique. - 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') }} - - safe_changes: - # The `if` key has a list of conditions, each condition is specified as a Jinja expression - # in a double curly braces. Expressions are evaluated by gitStream on a PR when triggered. - if: - # Given the PR code changes, check that only formatting changes were made - - {{ is.formatting or is.docs or is.tests }} - # `run` key has a list of actions, which are executed one by one whenever the automation - # conditions are met. - run: - # When the changes are validated as formatting only, you can help to speed up the review - # by adding a label that marks it accordingly. - - action: add-label@v1 - args: - label: 'safe-changes' - # You can uncomment the following action to get gitStream can even automatically approve - # such PRs to save reviewers time for such changes. - # - action: approve@v1 - - add_reviewers_gt_25: - if: - - true - run: - - action: add-reviewers@v1 - args: - reviewers: {{ repo | rankByGitBlame(gt=25) | filter(list=['20wildmanj', 'najclark', 'damianhxy', 'michellexliu', 'victorhuangwq', 'lykimchee', 'jlge', 'evanyeyeye', 'KesterTan']) | reject(pr.author) | random }} - unless_reviewers_set: true - - add_reviewers_lt_25: - if: - - true - run: - - action: add-reviewers@v1 - args: - reviewers: {{ repo | rankByGitBlame(lt=25) | filter(list=['20wildmanj', 'najclark', 'damianhxy', 'michellexliu', 'victorhuangwq', 'lykimchee', 'jlge', 'evanyeyeye', 'KesterTan']) | reject(pr.author) | random }} - unless_reviewers_set: true - -calc: - etr: {{ branch | estimatedReviewTime }} -is: - formatting: {{ source.diff.files | isFormattingChange }} - docs: {{ files | allDocs }} - tests: {{ files | allTests }} From 3c92d8b231b2cf83338ce6d4660e90db2bd04e60 Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Sun, 21 May 2023 12:16:55 +0800 Subject: [PATCH 08/10] Assign team-reviewer --- reviewpad.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reviewpad.yml b/reviewpad.yml index c258d9b25..49a27a8df 100644 --- a/reviewpad.yml +++ b/reviewpad.yml @@ -28,14 +28,14 @@ workflows: - if: ($eventType() == "synchronize" || $eventType() == "opened") && $state() == "open" then: $summarize() - # This workflow assigns the most relevant reviewer to pull requests. - # This helps guarantee that most pull requests are reviewed by at least one person. + # This workflow assigns the team developers-current as a reviewer + # This will trigger a review to a random team member (due to the team's code review settings) - name: reviewer-assignment description: Assign the most relevant reviewer to pull requests run: # Automatically assign reviewer when the pull request is ready for review; - if: $isDraft() == false - then: $assignCodeAuthorReviewers() + then: $assignTeamReviewer(["developers-current"]) # This workflow labels pull requests based on the total number of lines changed. # This helps pick pull requests based on their size and to incentivize small pull requests. From a45f6f234b090a3cc8603791426a275f99bf95e1 Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Sun, 21 May 2023 16:37:40 +0800 Subject: [PATCH 09/10] Delete gitstream.yml --- .github/workflows/gitstream.yml | 49 --------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 .github/workflows/gitstream.yml diff --git a/.github/workflows/gitstream.yml b/.github/workflows/gitstream.yml deleted file mode 100644 index f793c41f1..000000000 --- a/.github/workflows/gitstream.yml +++ /dev/null @@ -1,49 +0,0 @@ -# Code generated by gitStream GitHub app - DO NOT EDIT - -name: gitStream workflow automation - -on: - workflow_dispatch: - inputs: - client_payload: - description: The Client payload - required: true - full_repository: - description: the repository name include the owner in `owner/repo_name` format - required: true - head_ref: - description: the head sha - required: true - base_ref: - description: the base ref - required: true - installation_id: - description: the installation id - required: false - resolver_url: - description: the resolver url to pass results to - required: true - resolver_token: - description: Optional resolver token for resolver service - required: false - default: '' - -jobs: - gitStream: - timeout-minutes: 5 - # uncomment this condition, if you dont want any automation on dependabot PRs - # if: github.actor != 'dependabot[bot]' - runs-on: ubuntu-latest - name: gitStream workflow automation - steps: - - name: Evaluate Rules - uses: linear-b/gitstream-github-action@v1 - id: rules-engine - 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 }} From f692434d0baccb87803424d0c707e210d22faae9 Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Sun, 21 May 2023 16:46:05 +0800 Subject: [PATCH 10/10] Simplify reviewer-assignment logic --- reviewpad.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/reviewpad.yml b/reviewpad.yml index 49a27a8df..2605ff866 100644 --- a/reviewpad.yml +++ b/reviewpad.yml @@ -28,14 +28,13 @@ workflows: - if: ($eventType() == "synchronize" || $eventType() == "opened") && $state() == "open" then: $summarize() - # This workflow assigns the team developers-current as a reviewer - # This will trigger a review to a random team member (due to the team's code review settings) + # This workflow assigns a random current developer as a reviewer - name: reviewer-assignment - description: Assign the most relevant reviewer to pull requests + description: Assign a random reviewer to pull requests run: # Automatically assign reviewer when the pull request is ready for review; - if: $isDraft() == false - then: $assignTeamReviewer(["developers-current"]) + then: $assignReviewer($team("developers-current"), 1, "reviewpad") # This workflow labels pull requests based on the total number of lines changed. # This helps pick pull requests based on their size and to incentivize small pull requests.