Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement handling RFCs #1212

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3cae67f
Update github.ts
xno-miner Jun 17, 2024
60498ef
Update index.ts
xno-miner Jun 17, 2024
c22b1c8
Minor fix
xno-miner Jun 17, 2024
f0e9c3d
Update helpers/github.ts
xno-miner Jun 17, 2024
9258750
Update devpool-issue-handler.test.ts
xno-miner Jun 17, 2024
a6c3c1e
Update devpool-issue-handler.test.ts
xno-miner Jun 17, 2024
d96e69e
Update index.ts
xno-miner Jun 17, 2024
22ebb9c
Update github.ts
xno-miner Jun 17, 2024
fe8c4c6
Minor fix
xno-miner Jun 17, 2024
80ce59b
Minor clean
xno-miner Jun 17, 2024
20d74be
Fix getting repo name
xno-miner Jun 17, 2024
b77c0c0
Moved DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME, DEVPOOL_RFC_OWNER_NAME a…
xno-miner Jun 28, 2024
4f3c962
Moved the DEVPOOL_ variables to .env (copy the values from .env.example)
xno-miner Jun 28, 2024
128c5d8
don't tweet rfcs
xno-miner Jun 28, 2024
212502f
don't tweet rfcs
xno-miner Jun 28, 2024
ea31d8a
Moved the DEVPOOL_ variables back from env
xno-miner Jun 29, 2024
a08862c
Improved code readability
xno-miner Jun 29, 2024
4cafbe3
Minor fix
xno-miner Jun 29, 2024
179586e
Further improved readability
xno-miner Jun 29, 2024
5263f17
Minor fix
xno-miner Jun 29, 2024
1a65d43
Create env variables for devpool/RFC
xno-miner Jul 2, 2024
133d263
Merge branch 'development' into development
xno-miner Jul 25, 2024
66f7d63
Create tests for RFCs
xno-miner Jul 26, 2024
7a583ab
Add missing files
xno-miner Jul 26, 2024
ed3bbf0
JSON.parse RFC env
xno-miner Jul 29, 2024
ea374eb
quotes in ymls
xno-miner Aug 1, 2024
5a7f812
Fix env and enable rfc test
xno-miner Aug 1, 2024
6318d84
minor cleanup
xno-miner Aug 1, 2024
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
29 changes: 20 additions & 9 deletions helpers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const projects = _projects as {

export const DEVPOOL_OWNER_NAME = "ubiquity";
export const DEVPOOL_REPO_NAME = "devpool-directory";
export const DEVPOOL_RFC_OWNER_NAME = "ubiquity";
export const DEVPOOL_RFC_REPO_NAME = "devpool-rfc";
rndquu marked this conversation as resolved.
Show resolved Hide resolved
export enum LABELS {
PRICE = "Price",
UNAVAILABLE = "Unavailable",
Expand Down Expand Up @@ -389,14 +391,14 @@ export async function createDevPoolIssue(projectIssue: GitHubIssue, projectUrl:
// if the project issue is assigned to someone, then skip it
if (projectIssue.assignee) return;

// if issue doesn't have the "Price" label then skip it, no need to pollute repo with draft issues
if (!(projectIssue.labels as GitHubLabel[]).some((label) => label.name.includes(LABELS.PRICE))) return;
// if the issue has no price labels, it will be added to RFC repo
const hasNoPriceLabels = !(projectIssue.labels as GitHubLabel[]).some((label) => label.name.includes(LABELS.PRICE));
rndquu marked this conversation as resolved.
Show resolved Hide resolved

// create a new issue
try {
const createdIssue = await octokit.rest.issues.create({
owner: DEVPOOL_OWNER_NAME,
repo: DEVPOOL_REPO_NAME,
owner: hasNoPriceLabels ? DEVPOOL_RFC_OWNER_NAME : DEVPOOL_OWNER_NAME,
repo: hasNoPriceLabels ? DEVPOOL_RFC_REPO_NAME : DEVPOOL_REPO_NAME,
title: projectIssue.title,
body,
labels: getDevpoolIssueLabels(projectIssue, projectUrl),
Expand Down Expand Up @@ -491,6 +493,9 @@ async function applyMetaChanges(
}

async function applyStateChanges(projectIssues: GitHubIssue[], projectIssue: GitHubIssue, devpoolIssue: GitHubIssue, hasNoPriceLabels: boolean) {
const isRFC = devpoolIssue.repository_url.includes(DEVPOOL_RFC_REPO_NAME)
const hasCorrectPriceLabels = isRFC ? hasNoPriceLabels : (!hasNoPriceLabels)

const stateChanges: StateChanges = {
// missing in the partners
forceMissing_Close: {
Expand All @@ -500,10 +505,16 @@ async function applyStateChanges(projectIssues: GitHubIssue[], projectIssue: Git
},
// no price labels set and open in the devpool
noPriceLabels_Close: {
cause: hasNoPriceLabels && devpoolIssue.state === "open",
cause: (!isRFC) && (!hasCorrectPriceLabels) && devpoolIssue.state === "open",
effect: "closed",
comment: "Closed (no price labels)",
},
// HAS price labels set and open in the RFC devpool
RFCPriceLabels_Close: {
xno-miner marked this conversation as resolved.
Show resolved Hide resolved
cause: isRFC && (!hasCorrectPriceLabels) && devpoolIssue.state === "open",
effect: "closed",
comment: "Closed (has price labels)",
},
// it's closed, been merged and still open in the devpool
issueComplete_Close: {
cause: projectIssue.state === "closed" && devpoolIssue.state === "open" && !!projectIssue.pull_request?.merged_at,
Expand All @@ -528,20 +539,20 @@ async function applyStateChanges(projectIssues: GitHubIssue[], projectIssue: Git
effect: "closed",
comment: "Closed (assigned-open)",
},
// it's open, merged, unassigned, has price labels and is closed in the devpool
// it's open, merged, unassigned, has CORRECT price labels and is closed in the devpool
issueReopenedMerged_Open: {
cause:
projectIssue.state === "open" &&
devpoolIssue.state === "closed" &&
!!projectIssue.pull_request?.merged_at &&
!hasNoPriceLabels &&
hasCorrectPriceLabels &&
!projectIssue.assignee?.login,
effect: "open",
comment: "Reopened (merged)",
},
// it's open, unassigned, has price labels and is closed in the devpool
// it's open, unassigned, has CORRECT price labels and is closed in the devpool
issueUnassigned_Open: {
cause: projectIssue.state === "open" && devpoolIssue.state === "closed" && !projectIssue.assignee?.login && !hasNoPriceLabels,
cause: projectIssue.state === "open" && devpoolIssue.state === "closed" && !projectIssue.assignee?.login && hasCorrectPriceLabels,
effect: "open",
comment: "Reopened (unassigned)",
},
Expand Down
7 changes: 6 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import dotenv from "dotenv";
import {
DEVPOOL_OWNER_NAME,
DEVPOOL_REPO_NAME,
DEVPOOL_RFC_OWNER_NAME,
DEVPOOL_RFC_REPO_NAME,
getAllIssues,
getIssueByLabel,
getProjectUrls,
Expand Down Expand Up @@ -36,6 +38,7 @@ async function main() {

// get devpool issues
const devpoolIssues: GitHubIssue[] = await getAllIssues(DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME);
const devpoolRFCs: GitHubIssue[] = await getAllIssues(DEVPOOL_RFC_OWNER_NAME, DEVPOOL_RFC_REPO_NAME);

// Calculate total rewards from open issues
const { rewards, tasks } = await calculateStatistics(devpoolIssues);
Expand Down Expand Up @@ -63,13 +66,15 @@ async function main() {
for (const projectIssue of projectIssues) {
// if issue exists in devpool
const devpoolIssue = getIssueByLabel(devpoolIssues, `id: ${projectIssue.node_id}`);
rndquu marked this conversation as resolved.
Show resolved Hide resolved
// if issue exists in RFC devpool
const devpoolRFC = getIssueByLabel(devpoolRFCs, `id: ${projectIssue.node_id}`);

// adding www creates a link to an issue that does not count as a mention
// helps with preventing a mention in partner's repo especially during testing
const body = isFork ? projectIssue.html_url.replace("https://github.com", "https://www.github.com") : projectIssue.html_url;

// for all issues
if (devpoolIssue) {
if (devpoolIssue || devpoolRFC) {
// if it exists in the devpool, then update it
await handleDevPoolIssue(projectIssues, projectIssue, projectUrl, devpoolIssue, isFork);
} else {
Expand Down
Loading