Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/trolit/Patchron
Browse files Browse the repository at this point in the history
  • Loading branch information
trolit committed Sep 2, 2022
2 parents a1c1aaa + a5c329d commit 1851944
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@ There might be a case where single repository is used to store more app parts (e
## 2. Configuration
| Property | Type (default) | Description |
| :------------------------------------------ | :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `NODE_ENV` | String (` `) | specifies environment in which app is running. For GitHub actions use `github`, for testing purposes `test` and for self hosted app `production`. GitHub POST comments, summary, approve actions are limited to `github` and `production` environments. |
| `RULES_CONFIGURATION_PATH` | String (`src/config/rules`) | Path to rules configuration file stored in project. Used when `RULES_CONFIGURATION_URL` is not provided. |
| `RULES_CONFIGURATION_URL` | String (` `) | When provided, attempts to fetch rules configuration from given URL. URL should point to `.json` file ([example structure](./src/config/rules.json)). |
| `IS_GET_FILES_REQUEST_PAGINATED` | boolean (`false`) | Controls files fetching strategy. Unpaginated response includes a maximum of 3000 files which is sufficient in 99.9999999999% of cases. |
| `DELAY_BETWEEN_COMMENT_REQUESTS_IN_SECONDS` | Number (`3`) | After pull request review is done, delays time between each comment POST request to not overload GitHub API. Creating content too quickly may result in secondary rate limiting. |
| `IS_OWNER_ASSIGNING_ENABLED` | boolean (`true`) | When true, PR owner will be automatically assigned on issueing pull request. |
| `IS_REVIEW_SUMMARY_ENABLED` | boolean (`false`) | When true, at the end of the PR review, app will post summary that contains various information e.g. total comments that were successfully posted. |
| `IS_STORING_LOGS_ENABLED` | boolean (`false`) | When true, logs are also stored physically in `.logs` directory. Log files are named in following format: `YYYY-MM-DD`. |
| `MAX_COMMENTS_PER_REVIEW` | Number (`25`) | Limits number of comments that can be posted in single review under single pull request. |
| `SENDERS` | Array<`string`> (`[]`) | Allows to limit pull requests reviews to certain users. Pass GitHub usernames as array e.g. `['trolit'].`. |
| `APPROVE_PULL_ON_EMPTY_REVIEW_COMMENTS` | boolean (`true`) | When true, approves pull request on empty review comments. |
| Property | Type (default) | Description |
| :------------------------------------------ | :-------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `NODE_ENV` | String (` `) | specifies environment in which app is running. For GitHub actions use `github`, for testing purposes `test` and for self hosted app `production`. GitHub POST comments, summary, approve actions are limited to `github` and `production` environments. |
| `RULES_CONFIGURATION_PATH` | String (`src/config/rules`) | Path to rules configuration file stored in project. Used when `RULES_CONFIGURATION_URL` is not provided. |
| `RULES_CONFIGURATION_URL` | String (` `) | When provided, attempts to fetch rules configuration from given URL. URL should point to `.json` file ([example structure](./src/config/rules.json)). |
| `IS_GET_FILES_REQUEST_PAGINATED` | boolean (`false`) | Controls files fetching strategy. Unpaginated response includes a maximum of 3000 files which is sufficient in 99.9999999999% of cases. |
| `DELAY_BETWEEN_COMMENT_REQUESTS_IN_SECONDS` | Number (`3`) | After pull request review is done, delays time between each comment POST request to not overload GitHub API. Creating content too quickly may result in secondary rate limiting. |
| `IS_OWNER_ASSIGNING_ENABLED` | boolean (`true`) | When true, PR owner will be automatically assigned on issueing pull request. |
| `IS_REVIEW_SUMMARY_ENABLED` | boolean (`false`) | When true, at the end of the PR review, app will post summary that contains various information e.g. total comments that were successfully posted. |
| `IS_STORING_LOGS_ENABLED` | boolean (`false`) | When true, logs are also stored physically in `.logs` directory. Log files are named in following format: `YYYY-MM-DD`. |
| `MAX_COMMENTS_PER_REVIEW` | Number (`25`) | Limits number of comments that can be posted in single review under single pull request. |
| `SENDERS` | String (` `) | Allows to limit pull requests reviews to certain users. Pass string with usernames separated by comma e.g. `'test1, test2, test3'` |
| `APPROVE_PULL_ON_EMPTY_REVIEW_COMMENTS` | boolean (`true`) | When true, approves pull request on empty review comments. |
## 3. Useful links
Expand Down
4 changes: 3 additions & 1 deletion src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ function _setupEnv() {

if (nodeEnvironment === GITHUB_ACTION_ENVIRONMENT) {
const githubEnv = {
SENDERS: process.env.SENDERS,
SENDERS: process.env.SENDERS
? process.env.SENDERS.split(',')
: undefined,
IS_GET_FILES_REQUEST_PAGINATED:
process.env.IS_GET_FILES_REQUEST_PAGINATED,
APPROVE_PULL_ON_EMPTY_REVIEW_COMMENTS:
Expand Down
13 changes: 7 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ module.exports = (app) => {
app.on(['pull_request.opened'], async (context) => {
patchronContext.initializePullRequestData(context);

const { owner } = context.pullRequest();

if (senders?.length && !senders.includes(owner)) {
return;
}

if (nodeEnvironment !== TEST_ENVIRONMENT && rulesConfigurationUrl) {
try {
const response = await fetch(rulesConfigurationUrl);
Expand All @@ -61,17 +67,12 @@ module.exports = (app) => {
}
}

const { owner } = context.pullRequest();

if (senders?.length && !senders.includes(owner)) {
return;
}

if (isOwnerAssigningEnabled) {
await addAssignees(patchronContext, [owner]);
}

const reviewComments = review(patchronContext, config.rules?.pull);

const isReviewAborted = _isReviewAborted(reviewComments);

if (!isReviewAborted) {
Expand Down

0 comments on commit 1851944

Please sign in to comment.