Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Remove Process.json #358

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ WEBHOOK_SECRET=hunter2
# The Github App ID according to the Github App's settings.
GITHUB_APP_ID=123

# The GitHub team which whose members will be used as team leads
# Must be in the same organization where this bot is installed
TEAM_LEADS_TEAM=team

# The GitHub team which whose members will be used as core developers
# Must be in the same organization where this bot is installed
CORE_DEVS_TEAM=team


# --- OPTIONAL VARIABLES ---
# If you set this variable, the application will receive events from Smee and a
# local server will not be started
WEBHOOK_PROXY_URL=https://smee.io/parity-processbot
# WEBHOOK_PROXY_URL=https://smee.io/parity-processbot

# Disable organization checks such as the substrateteamleads and core-devs checks.
DISABLE_ORG_CHECK=true
# DISABLE_ORG_CHECK=true
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ dockerize-processbot:
--set "app.PROCESSBOT_KEY=${PROCESSBOT_KEY}"
--set "app.GITHUB_APP_ID=${GITHUB_APP_ID}"
--set "app.WEBHOOK_SECRET=${WEBHOOK_SECRET}"
--set "app.TEAM_LEADS_TEAM=${TEAM_LEADS_TEAM}"
--set "app.CORE_DEVS_TEAM=${CORE_DEVS_TEAM}"

deploy-staging:
stage: deploy
Expand Down
15 changes: 0 additions & 15 deletions Process.json

This file was deleted.

80 changes: 19 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,10 @@ which will allow processbot to detect and disregard them.
A Pull Request needs either (meaning, only **one of** the following
requirements needs to be fulfilled)

- [core-dev](#core-devs) member approvals (2 for Substrate, 1 otherwise), or
- One [substrateteamleads](#substrateteamleads) member approval, or
- One approval from the project owner **for the PR**. Projects are managed
[through the Github UI](#github-project) and its [owners](#project-owners)
are defined in `Process.json`. If the PR does not belong to any project or if
it has been approved by a project owner which is not the PR's project owner,
then this rule will not take effect.

This criteria strictly matters only for the bot's internal logic irrespective
- [core-dev](https://github.com/orgs/paritytech/teams/core-devs) member approvals (2 for Substrate, 1 otherwise), or
- One [substrateteamleads](https://github.com/orgs/paritytech/teams/substrateteamleads) member approval

This criterion strictly matters only for the bot's internal logic irrespective
of Github Repository Settings and will not trump the latter in any case. For
instance, the rule:

Expand All @@ -69,51 +64,33 @@ instance, the rule:
does not imply that the pull request will be mergeable if the Github Settings
require more approvals than that. The bot's rules work *in addition* to the
repository's settings while still respecting them. Specifically when it comes
to the approvals' count, however, the bot might able to help if an "Allowed
Developer" is requesting the merge.

Consider "Allowed Developers" to be either

- [Project Owners](#project-owners)
- [substrateteamleads](#substrateteamleads)
to the approvals' count, however, the bot might able to help if a
[team lead](https://github.com/orgs/paritytech/teams/substrateteamleads)
is requesting the merge.

When the bot is commanded to merge, if the PR is short of 1 approval and the
command's requester might not be able to fulfill the approval count on their
own, then the bot will try to pitch in the missing approval if the requester is
an Allowed Developer. The reasoning for this feature is as follows:
a [team lead](https://github.com/orgs/paritytech/teams/substrateteamleads).
The reasoning for this feature is as follows:

1. PR authors cannot approve their own merge requests, although Allowed
Developers should have the means to bypass that requirement e.g. for trivial
or urgent changes.
1. PR authors cannot approve their own merge requests, although
[team leads](https://github.com/orgs/paritytech/teams/substrateteamleads)
should have the means to bypass that requirement e.g. for trivial or urgent
changes.

2. If the Allowed Developer has already approved and it's still short of one,
they cannot "approve twice" in order to meet the quota. In that case, the
bot should contribute one approval in order to help them meet that
requirement.
2. If the
[team lead](https://github.com/orgs/paritytech/teams/substrateteamleads)
has already approved and it's still
short of one, they cannot "approve twice" in order to meet the quota. In that
case, the bot should contribute one approval in order to help them meet that
requirement.

## Checks and statuses

All [Important and above](#relation-to-ci) checks should be green when using
`bot merge` (can be bypassed by using `bot merge force`).

# Project Owners <a name="project-owners"></a>

Project owners can be configured by placing a `Process.json` file in the root
of your repository. **The bot always considers only the `master` branch's
version of the file**. See [./Process.json](./Process.json) or
[Substrate's Process.json](https://github.com/paritytech/substrate/blob/master/Process.json)
for examples.

The file should have a valid JSON array of
`{ "project_name": string, "owner": string, "matrix_room_id": string }`
where:

- `project_name` is the [Github Project](#github-project)'s name
- `owner` is the Github Username of the project's lead
- `matrix_room_id` is the project's room address on Matrix, like
`"!yBKstWVBkwzUkPslsp:matrix.parity.io"`. It's not currently used, but needs to
be defined.

# Github App Configuration

Repository permissions
Expand Down Expand Up @@ -221,22 +198,3 @@ The deployment's status can be followed through
All of the relevant configuration for deployment lives in the [./helm](./helm)
folder. The values for each specific environment are in `values-*.yml`. If you
add a value, it needs to be used in `templates/processbot.yaml`.

# FAQ

- Who are "core-devs"? <a name="core-devs"></a>
- https://github.com/orgs/paritytech/teams/core-devs/members

- Who are "substrateteamleads"? <a name="substrateteamleads"></a>
- https://github.com/orgs/paritytech/teams/substrateteamleads/members

- What is a project column and how do I attach one? <a name="github-project"></a>
- A project column is necessary for Processbot to identify a
[Project Owner](#project-owners).
- A pull request can be attached to a project column using the Github UI:
- Having no project, it *will not be recognized*
![](https://github.com/paritytech/parity-processbot/blob/master/doc/no-project.png)
- Having a project, but no column, it *will not be recognized*
![](https://github.com/paritytech/parity-processbot/blob/master/doc/no-column.png)
- Having both project a column, it *will be recognized*
![](https://github.com/paritytech/parity-processbot/blob/master/doc/proj-column.png)
Binary file removed doc/no-column.png
Binary file not shown.
Binary file removed doc/no-project.png
Binary file not shown.
Binary file removed doc/proj-column.png
Binary file not shown.
4 changes: 4 additions & 0 deletions helm/templates/processbot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ spec:
value: {{ quote .Values.app.WEBHOOK_PORT }}
- name: GITHUB_APP_ID
value: {{ quote .Values.app.GITHUB_APP_ID }}
- name: CORE_DEVS_TEAM
value: {{ .Values.app.CORE_DEVS_TEAM }}
- name: TEAM_LEADS_TEAM
value: {{ .Values.app.TEAM_LEADS_TEAM }}
- name: DB_PATH
value: /usr/local/share/db
- name: WEBHOOK_SECRET
Expand Down
2 changes: 2 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ app:
PROCESSBOT_KEY: from-gitlab-vars
WEBHOOK_SECRET: from-gitlab-vars
KUBE_NAMESPACE: from-gitlab-vars
CORE_DEVS_TEAM: from-gitlab-vars
TEAM_LEADS_TEAM: from-gitlab-vars
9 changes: 9 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub struct MainConfig {
pub github_api_url: String,
pub companion_status_settle_delay: u64,
pub merge_command_delay: u64,
pub core_devs_team: String,
pub team_leads_team: String,
}

impl MainConfig {
Expand Down Expand Up @@ -52,6 +54,11 @@ impl MainConfig {

let companion_status_settle_delay = 4096;

let core_devs_team =
dotenv::var("CORE_DEVS_TEAM").expect("CORE_DEVS_TEAM");
let team_leads_team =
dotenv::var("TEAM_LEADS_TEAM").expect("TEAM_LEADS_TEAM");

Self {
installation_login,
webhook_secret,
Expand All @@ -64,6 +71,8 @@ impl MainConfig {
github_api_url,
merge_command_delay,
companion_status_settle_delay,
core_devs_team,
team_leads_team,
}
}
}
6 changes: 0 additions & 6 deletions src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
pub const SUBSTRATE_TEAM_LEADS_GROUP: &str = "substrateteamleads";

pub const CORE_DEVS_GROUP: &str = "core-devs";

pub const PROCESS_FILE: &str = "Process.json";

// Note: the old database will be *DELETED* when changing this constant, so do not change this
// without checking the implementation first
pub const DATABASE_VERSION: &str = "v1.0";
7 changes: 1 addition & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ pub enum Error {
actual: String,
},

#[snafu(display("Missing process info."))]
ProcessInfo {
errors: Option<Vec<String>>,
},

#[snafu(display("Missing approval."))]
Approval {
errors: Option<Vec<String>>,
errors: Vec<String>,
},

#[snafu(display("{}", msg))]
Expand Down
15 changes: 1 addition & 14 deletions src/github_bot/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{config::MainConfig, constants::*, github::*, Result};
use futures_util::TryFutureExt;
use crate::{config::MainConfig, github::*, Result};

pub mod issue;
pub mod project;
Expand Down Expand Up @@ -101,16 +100,4 @@ impl GithubBot {
});
self.client.put(url, body).await
}

pub async fn core_devs(&self, owner: &str) -> Result<Vec<User>> {
self.team(owner, CORE_DEVS_GROUP)
.and_then(|team| self.team_members(team.id))
.await
}

pub async fn substrate_team_leads(&self, owner: &str) -> Result<Vec<User>> {
self.team(owner, SUBSTRATE_TEAM_LEADS_GROUP)
.and_then(|team| self.team_members(team.id))
.await
}
}
11 changes: 11 additions & 0 deletions src/github_bot/team.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{github, Result};
use futures_util::TryFutureExt;

use super::GithubBot;

Expand All @@ -20,4 +21,14 @@ impl GithubBot {
))
.await
}

pub async fn team_members_by_team_name(
&self,
owner: &str,
team: &str,
) -> Result<Vec<github::User>> {
self.team(owner, team)
.and_then(|team| self.team_members(team.id))
.await
}
}
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub mod error;
pub mod github;
pub mod github_bot;
pub mod http;
pub mod process;
pub mod rebase;
pub mod server;
pub mod utils;
Expand Down
Loading