Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

feat: follow up with reviewer #783

Closed
wants to merge 14 commits into from
Closed
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
60 changes: 54 additions & 6 deletions .github/ubiquibot-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
price-multiplier: 1.5
# newContributorGreeting:
# enabled: true
# header: "Thank you for contributing to UbiquiBot! Please be sure to set your wallet address before completing your first bounty so that the automatic payout upon task completion will work for you."
# helpMenu: true
# footer: "###### Also please star this repository and [@ubiquity/devpool-directory](https://github.com/ubiquity/devpool-directory/) to show your support. It helps a lot!"
evmNetworkId: 100
priceMultiplier: 1
assistivePricing: true
timeLabels:
- name: "Time: <1 Hour"
- name: "Time: <1 Day"
- name: "Time: <1 Week"
- name: "Time: <2 Weeks"
- name: "Time: <1 Month"
priorityLabels:
- name: "Priority: 0 (Normal)"
- name: "Priority: 1 (Medium)"
- name: "Priority: 2 (High)"
- name: "Priority: 3 (Urgent)"
- name: "Priority: 4 (Emergency)"
defaultLabels:
- "Time: <1 Hour"
- "Priority: 1 (Normal)"
paymentPermitMaxPrice: 1000
commentIncentives: true
promotionComment: "<h6>If you've enjoyed your experience in the DevPool, we'd appreciate your support. Follow <a href='https://github.com/ubiquity'>Ubiquity on GitHub</a> and star <a href='https://github.com/ubiquity/devpool-directory'>this repo</a>. Your endorsement means the world to us and helps us grow!</h6><h6>We are excited to announce that the DevPool and UbiquiBot are now available to partners! Our ideal collaborators are globally distributed crypto-native organizations, who actively work on open source on GitHub, and excel in research & development. If you can introduce us to the repository maintainers in these types of companies, we have a special bonus in store for you!</h6>"
registerWalletWithVerification: false
commandSettings:
- name: start
enabled: true
- name: stop
enabled: true
- name: wallet
enabled: true
- name: payout
enabled: true
- name: multiplier
enabled: true
- name: query
enabled: true
- name: allow
enabled: true
- name: autopay
enabled: true
- name: incentivize
enabled: true
- name: "comment-incentive"
enabled: true
privateKeyEncrypted: "GoBhfETSpBWPPFj_s2em46A-RkGT6piXGr_y_k3_YD-y1mE3zo1L66T7hfCx7Tg19B-9_41udoK1XeHtSxXVqn4ADamxxpInImnJgvpYtrYmNwZODmV53Sgb2X0WeWidtBOOOfkrNU0Gl-wnWRN7nA"
incentives:
comment:
elements:
code: 10
img: 1
li: 1
a: 1
blockquote: 1
totals:
word: 1
8 changes: 2 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Build and Test
name: Build
on:
push:
pull_request:

jobs:
build-and-test:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -21,10 +21,6 @@ jobs:
- name: Local Build
run: yarn build

# Enable `test` step once writing unit test done.
# - name: Test
# run: yarn test

- name: Lint
run: yarn lint

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/kebab-case.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
"^\.\/dist"
"^\.\/build"
"^\.\/vendor"
"^\.\/test"
"^\.\/\.next"
"\.sql$"
"\.md$"
"\.d.ts$"
"^\.\/\log-app"
)
while read -r file; do
basefile=$(basename "$file")
Expand All @@ -48,4 +48,4 @@ jobs:
echo " - $file"
done
exit 1
fi
fi
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ supabase/temp
# Local Netlify folder
.netlify
bin
.yarn
.nyc_output
.yarn
11 changes: 0 additions & 11 deletions .nycrc.json

This file was deleted.

23 changes: 4 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
"lint": "eslint --ext .ts ./src",
"start:serverless": "tsx src/adapters/github/github-actions.ts",
"start:watch": "nodemon --exec 'yarn start'",
"start": "probot run ./lib/src/index.js",
"prepare": "husky install",
"test": "nyc ts-mocha --check-leaks --exit --timeout 120000 './test/**/*.spec.ts'",
"utils:cspell": "cspell --config .cspell.json 'src/**/*.{js,ts,json,md,yml}'"
"utils:cspell": "cspell --config .cspell.json 'src/**/*.{js,ts,json,md,yml}'",
"start": "probot run ./lib/index.js",
"prepare": "husky install"
},
"dependencies": {
"@actions/core": "^1.10.0",
Expand Down Expand Up @@ -66,14 +65,7 @@
"probot": "^12.2.4",
"telegraf": "^4.11.2",
"tsx": "^3.12.7",
"yaml": "^2.2.2",
"mocha": "10.2.0",
"nyc": "15.1.0",
"ts-mocha": "10.0.0",
"chai": "4.3.7",
"chai-as-promised": "7.1.1",
"chai-subset": "1.6.0",
"sinon-chai": "3.7.0"
"yaml": "^2.2.2"
},
"devDependencies": {
"@types/eslint": "^8.40.2",
Expand All @@ -82,13 +74,6 @@
"@types/lodash": "^4.14.197",
"@types/node": "^14.18.37",
"@types/source-map-support": "^0.5.6",
"@types/mocha": "10.0.1",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@types/chai": "4.3.4",
"@types/chai-as-promised": "7.1.5",
"@types/chai-subset": "1.3.3",
"@types/sinon": "10.0.13",
"@types/sinon-chai": "3.2.9",
"eslint": "^8.43.0",
"jest": "^26.6.3",
"nock": "^13.0.5",
Expand Down
6 changes: 5 additions & 1 deletion src/bindings/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => {
botDelay,
followUpTime,
disqualifyTime,
followUpReviewerTime,
} = await getWideConfig(context);

const publicKey = await getScalarKey(process.env.X25519_PRIVATE_KEY);
Expand Down Expand Up @@ -65,12 +66,15 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => {
permitBaseUrl: process.env.PERMIT_BASE_URL || permitBaseUrl,
},
unassign: {
timeRangeForMaxIssue: process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE ? Number(process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE) : timeRangeForMaxIssue,
timeRangeForMaxIssue: process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE
? Number(process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE)
: timeRangeForMaxIssue,
timeRangeForMaxIssueEnabled: process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE_ENABLED
? process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE_ENABLED == "true"
: timeRangeForMaxIssueEnabled,
followUpTime: ms(process.env.FOLLOW_UP_TIME || followUpTime),
disqualifyTime: ms(process.env.DISQUALIFY_TIME || disqualifyTime),
followUpReviewerTime: ms(process.env.FOLLOW_UP_REVIEWER_TIME || followUpReviewerTime),
},
supabase: {
url: process.env.SUPABASE_URL ?? "",
Expand Down
1 change: 1 addition & 0 deletions src/configs/ubiquibot-config-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const DefaultConfig: MergedConfig = {
permitBaseUrl: "https://pay.ubq.fi",
botDelay: 100, // 100ms
followUpTime: "4 days",
followUpReviewerTime: "3 days",
disqualifyTime: "7 days",
newContributorGreeting: {
enabled: true,
Expand Down
24 changes: 22 additions & 2 deletions src/handlers/wildcard/unassign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
getAllIssueComments,
getCommitsOnPullRequest,
getOpenedPullRequestsForAnIssue,
getRequestedReviewerStart,
getReviewRequests,
listAllIssuesForRepo,
removeAssignees,
Expand Down Expand Up @@ -36,7 +37,7 @@
const payload = context.payload as Payload;
const logger = getLogger();
const {
unassign: { followUpTime, disqualifyTime },
unassign: { followUpTime, disqualifyTime, followUpReviewerTime },
} = getBotConfig();
logger.info(`Checking the bounty to unassign, issue_number: ${issue.number}`);
const { unassignComment, askUpdate } = GLOBAL_STRINGS;
Expand All @@ -56,7 +57,26 @@

if (pullRequest.length > 0) {
const reviewRequests = await getReviewRequests(context, pullRequest[0].number, payload.repository.owner.login, payload.repository.name);
if (!reviewRequests || reviewRequests.users?.length > 0) {
if (!reviewRequests) return false;
if (reviewRequests.users?.length > 0) {
let msg = "";
for (const reviewer of reviewRequests.users) {
//check if reviewer has to be followed up with
let reviewRequestedAt = await getRequestedReviewerStart(reviewer.login);

Check failure on line 65 in src/handlers/wildcard/unassign.ts

View workflow job for this annotation

GitHub Actions / build

'reviewRequestedAt' is never reassigned. Use 'const' instead
if (!reviewRequestedAt) continue;

let currDate = new Date();

Check failure on line 68 in src/handlers/wildcard/unassign.ts

View workflow job for this annotation

GitHub Actions / build

'currDate' is never reassigned. Use 'const' instead
let expectedDate = new Date(reviewRequestedAt);

Check failure on line 69 in src/handlers/wildcard/unassign.ts

View workflow job for this annotation

GitHub Actions / build

'expectedDate' is never reassigned. Use 'const' instead
expectedDate.setTime(expectedDate.getTime() + followUpReviewerTime);

if (currDate >= expectedDate) {
msg += "@" + reviewer.login + " ";
}
}
if (!msg.includes("@")) return false;
msg += "Can you please review this pull request";
// the below function can also add comment to prs
await addCommentToIssue(msg, pullRequest[0].number);
return false;
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/helpers/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Fetch issue events
const response = await context.octokit.issues.listEvents({
owner: payload.repository.owner.login,
repo: payload.repository.full_name,
repo: payload.repository.name,
issue_number: payload.issue.number,
per_page: 100,
page: page_number,
Expand Down Expand Up @@ -658,6 +658,16 @@
}
};

export async function getRequestedReviewerStart(user: string) {
let events = await getAllIssueEvents();

Check failure on line 662 in src/helpers/issue.ts

View workflow job for this annotation

GitHub Actions / build

'events' is never reassigned. Use 'const' instead
if (!events) return null;
const filteredEvents = events.filter((e) => e.event === "review_requested" && e.requested_reviewer?.login === user);
if (!filteredEvents) {
return null;
} else {
return events[events.length - 1].created_at;
}
}
// Get issues assigned to a username
export const getAssignedIssues = async (username: string) => {
const issuesArr = [];
Expand Down
10 changes: 0 additions & 10 deletions src/mocks/expect.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/mocks/index.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const PayoutConfigSchema = Type.Object({

export const UnassignConfigSchema = Type.Object({
followUpTime: Type.Number(),
followUpReviewerTime: Type.Number(),
disqualifyTime: Type.Number(),
timeRangeForMaxIssue: Type.Number(),
timeRangeForMaxIssueEnabled: Type.Boolean(),
Expand Down Expand Up @@ -241,6 +242,7 @@ export const MergedConfigSchema = Type.Object({
permitBaseUrl: Type.String(),
botDelay: Type.Number(),
followUpTime: Type.String(),
followUpReviewerTime: Type.String(),
disqualifyTime: Type.String(),
});

Expand Down
1 change: 1 addition & 0 deletions src/utils/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export const getWideConfig = async (context: Context) => {
botDelay: mergedConfigData.botDelay,
followUpTime: mergedConfigData.followUpTime,
disqualifyTime: mergedConfigData.disqualifyTime,
followUpReviewerTime: mergedConfigData.followUpReviewerTime,
};

return configData;
Expand Down
23 changes: 0 additions & 23 deletions test/utils/address.spec.ts

This file was deleted.

Loading
Loading