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

feat: github comment generation and posting #12

Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e7b555d
chore: comment html generation (WIP)
gentlementlegen Apr 12, 2024
7e71e30
chore: added missing types for comments
gentlementlegen Apr 15, 2024
8dea21d
chore: debug mode and review comments for github comment module
gentlementlegen Apr 15, 2024
df2c34f
chore: comment incentive rows (WIP)
gentlementlegen Apr 15, 2024
c9897e2
chore: incentive rows generation
gentlementlegen Apr 15, 2024
29ce3c3
chore: comment posting to github
gentlementlegen Apr 15, 2024
d29427a
chore: fix pre div formatting
gentlementlegen Apr 15, 2024
ad141fd
Merge branch 'feat/permit-generation' into feat/github-comment
gentlementlegen Apr 16, 2024
96f4104
chore: update package version
gentlementlegen Apr 16, 2024
43b1912
chore: updated .gitignore
gentlementlegen Apr 16, 2024
1f9b050
chore: updated permit generation package
gentlementlegen Apr 17, 2024
3bab31a
chore: env check for permit generation module
gentlementlegen Apr 17, 2024
03fac6c
chore: added ignore words to cspell
gentlementlegen Apr 17, 2024
efe17cb
Merge branch 'refs/heads/development' into feat/github-comment
gentlementlegen Apr 17, 2024
119c633
chore: simplified code github comment module
gentlementlegen Apr 17, 2024
24c748d
chore: always return content on empty string
gentlementlegen Apr 18, 2024
5eaa303
chore: changed rpc for DAI
gentlementlegen Apr 18, 2024
6567feb
chore: testing suite for modules (WIP)
gentlementlegen Apr 18, 2024
559c13c
chore: fix knip and change COMMENT to COMMENTED, added jsdocs on enum
gentlementlegen Apr 18, 2024
abbcf33
chore: changed content to be an array of strings instead of a single …
gentlementlegen Apr 18, 2024
02bf994
chore: tests for data purge module
gentlementlegen Apr 18, 2024
5bf432f
chore: removed invalid type check
gentlementlegen Apr 19, 2024
3bab2b8
chore: set comment type to contributor if author_association is none
gentlementlegen Apr 20, 2024
e61436b
chore: changed body type to an array of string
gentlementlegen Apr 21, 2024
73c650f
chore: changed RPC for mainnet
gentlementlegen Apr 22, 2024
a22cec2
chore: removed spurious Promise resolves
gentlementlegen Apr 22, 2024
a12318e
chore: un-nested GitHub comment module functions to reduce reading co…
gentlementlegen Apr 22, 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
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir", "ubiquibot", "tiktoken", "typebox"],
"words": ["dataurl", "devpool", "outdir", "servedir", "ubiquibot", "tiktoken", "typebox", "supabase", "wxdai", "noopener"],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Spell Check

on:
push:
pull_request:

jobs:
spellcheck:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules
static/dist
.env
junit.xml
coverage
2 changes: 1 addition & 1 deletion knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const config: KnipConfig = {
project: ["src/**/*.ts"],
ignore: ["src/data-collection/examples/*.ts", "src/configuration/common-config-type.ts"],
ignoreExportsUsedInFile: true,
ignoreDependencies: ["ts-node"],
ignoreDependencies: ["ts-node", "msw"],
jest: {
config: ["jest.config.ts"],
entry: ["src/**/*.test.ts"],
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@octokit/rest": "20.1.0",
"@sinclair/typebox": "0.32.20",
"@supabase/supabase-js": "2.42.0",
"@ubiquibot/permit-generation": "1.0.3",
"@ubiquibot/permit-generation": "1.2.1",
"commander": "12.0.0",
"decimal.js": "10.4.3",
"dotenv": "16.4.5",
Expand All @@ -56,7 +56,7 @@
"@types/node": "20.11.28",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"babel-jest": "^29.7.0",
"babel-jest": "29.7.0",
"cspell": "8.3.2",
"eslint": "8.56.0",
"eslint-plugin-sonarjs": "0.23.0",
Expand All @@ -65,6 +65,7 @@
"jest-junit": "16.0.0",
"knip": "5.7.0",
"lint-staged": "15.2.2",
"msw": "2.2.14",
"npm-run-all": "4.1.5",
"prettier": "3.2.5",
"ts-node": "10.9.2",
Expand Down
28 changes: 19 additions & 9 deletions rewards-configuration.default.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#disabled: true
enabled: true
contentEvaluator:
enabled: true
userExtractor:
Expand Down Expand Up @@ -27,29 +27,39 @@ formattingEvaluator:
td: 1
hr: 0
multipliers:
- type: [ISSUE, ISSUER]:
- type: [ISSUE, ISSUER, TASK]:
formattingMultiplier: 1
wordValue: 0.1
- type: [ISSUE, ISSUER, COMMENTED]:
formattingMultiplier: 1
wordValue: 0.2
- type: [ISSUE, ASSIGNEE]:
- type: [ISSUE, ASSIGNEE, COMMENTED]:
formattingMultiplier: 0
wordValue: 0
- type: [ISSUE, COLLABORATOR]:
- type: [ISSUE, COLLABORATOR, COMMENTED]:
formattingMultiplier: 1
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved
wordValue: 0.1
- type: [ISSUE, CONTRIBUTOR]:
- type: [ISSUE, CONTRIBUTOR, COMMENTED]:
formattingMultiplier: 0.25
wordValue: 0.1
- type: [REVIEW, ISSUER]:
- type: [REVIEW, ISSUER, SPECIFICATION]:
formattingMultiplier: 0
wordValue: 0
- type: [REVIEW, ISSUER, COMMENTED]:
formattingMultiplier: 2
wordValue: 0.2
- type: [REVIEW, ASSIGNEE]:
- type: [REVIEW, ASSIGNEE, COMMENTED]:
formattingMultiplier: 1
wordValue: 0.1
- type: [REVIEW, COLLABORATOR]:
- type: [REVIEW, COLLABORATOR, COMMENTED]:
formattingMultiplier: 1
wordValue: 0.1
- type: [REVIEW, CONTRIBUTOR]:
- type: [REVIEW, CONTRIBUTOR, COMMENTED]:
formattingMultiplier: 0.25
wordValue: 0.1
permitGeneration:
enabled: true
githubComment:
enabled: true
post: false
debug: true
11 changes: 11 additions & 0 deletions src/configuration/github-comment-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Static, Type } from "@sinclair/typebox";

const githubCommentConfigurationType = Type.Object({
enabled: Type.Boolean({ default: true }),
post: Type.Boolean({ default: true }),
debug: Type.Boolean({ default: false }),
});

export type GithubCommentConfiguration = Static<typeof githubCommentConfigurationType>;

export default githubCommentConfigurationType;
41 changes: 38 additions & 3 deletions src/issue-activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,42 @@ import {
} from "./start";

export enum CommentType {
/**
* Review related item
*/
REVIEW = 0b1,
/**
* Issue related item
*/
ISSUE = 0b10,
/**
* User assigned to the {@link CommentType.ISSUE} or {@link CommentType.REVIEW}
*/
ASSIGNEE = 0b100,
/**
* The author of the {@link CommentType.ISSUE} or {@link CommentType.REVIEW}
*/
ISSUER = 0b1000,
/**
* A user that is part of the organization or owner of the repo
*/
COLLABORATOR = 0b10000,
/**
* A user that is NOT part of the organization nor owner of the repo
*/
CONTRIBUTOR = 0b100000,
/**
* A user comment action on a {@link CommentType.ISSUE} or {@link CommentType.REVIEW}
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved
*/
COMMENTED = 0b1000000,
/**
* Pull request opening item
*/
TASK = 0b10000000,
whilefoo marked this conversation as resolved.
Show resolved Hide resolved
/**
* Issue opening item
*/
SPECIFICATION = 0b100000000,
}

export class IssueActivity {
Expand Down Expand Up @@ -73,14 +103,19 @@ export class IssueActivity {
self: GitHubPullRequest | GitHubIssue | null
) {
let ret = 0;
ret |= "pull_request_review_id" in comment ? CommentType.REVIEW : CommentType.ISSUE;
ret |= "pull_request_review_id" in comment || "draft" in comment ? CommentType.REVIEW : CommentType.ISSUE;
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved
if (comment.id === self?.id) {
ret |= ret & CommentType.ISSUE ? CommentType.TASK : CommentType.SPECIFICATION;
} else {
ret |= CommentType.COMMENTED;
}
if (comment.user?.id === self?.user?.id) {
ret |= CommentType.ISSUER;
} else if (comment.user?.id === self?.assignee?.id) {
ret |= CommentType.ASSIGNEE;
} else if (comment.author_association === "MEMBER") {
} else if (comment.author_association === "MEMBER" || comment.author_association === "COLLABORATOR") {
ret |= CommentType.COLLABORATOR;
} else if (comment.author_association === "CONTRIBUTOR") {
} else {
ret |= CommentType.CONTRIBUTOR;
}
return ret;
Expand Down
Loading
Loading