Skip to content

Commit

Permalink
Merge pull request #234 from ubiquity-os-marketplace/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
gentlementlegen authored Jan 6, 2025
2 parents f423487 + 5bffc14 commit 263c03f
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 303 deletions.
211 changes: 102 additions & 109 deletions CHANGELOG.md

Large diffs are not rendered by default.

Binary file modified bun.lockb
Binary file not shown.
150 changes: 0 additions & 150 deletions dist/199.index.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/199.index.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/index.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/sourcemap-register.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@supabase/supabase-js": "2.42.0",
"@ubiquity-dao/rpc-handler": "1.3.0",
"@ubiquity-os/permit-generation": "^2.0.6",
"@ubiquity-os/plugin-sdk": "^1.1.1",
"@ubiquity-os/plugin-sdk": "^2.0.0",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"decimal.js": "10.4.3",
"ethers": "^5.7.2",
Expand Down
32 changes: 1 addition & 31 deletions src/parser/github-comment-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ interface SortedTasks {
export class GithubCommentModule extends BaseModule {
private readonly _configuration: GithubCommentConfiguration | null = this.context.config.incentives.githubComment;
private readonly _debugFilePath = "./output.html";
/**
* COMMENT_ID can be set in the environment to reference the id of the last comment created during this workflow.
* See also compute.yml to understand how it is set.
*/
private _lastCommentId: number | null = process.env.COMMENT_ID ? Number(process.env.COMMENT_ID) : null;

/**
* Ensures that a string containing special characters get HTML encoded.
Expand Down Expand Up @@ -117,7 +112,7 @@ export class GithubCommentModule extends BaseModule {
if (this._configuration?.post) {
try {
if (Object.values(result).some((v) => v.permitUrl) || isIssueCollaborative || isUserAdmin) {
await this.postComment(body);
await postComment(this.context, this.context.logger.info(body), { raw: true, updateComment: true });
} else {
const errorLog = this.context.logger.error("Issue is non-collaborative. Skipping permit generation.");
await postComment(this.context, errorLog);
Expand All @@ -137,31 +132,6 @@ export class GithubCommentModule extends BaseModule {
return true;
}

async postComment(body: string, updateLastComment = true) {
const { payload, logger } = this.context;
if (!this._configuration?.post) {
logger.debug("Won't post a comment since posting is disabled.", { body });
return;
}
if (updateLastComment && this._lastCommentId !== null) {
await this.context.octokit.rest.issues.updateComment({
body,
repo: payload.repository.name,
owner: payload.repository.owner.login,
issue_number: payload.issue.number,
comment_id: this._lastCommentId,
});
} else {
const comment = await this.context.octokit.rest.issues.createComment({
body,
repo: payload.repository.name,
owner: payload.repository.owner.login,
issue_number: payload.issue.number,
});
this._lastCommentId = comment.data.id;
}
}

_createContributionRows(result: Result[0], sortedTasks: SortedTasks | undefined) {
const content: string[] = [];

Expand Down
1 change: 0 additions & 1 deletion src/types/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ declare global {
PERMIT_FEE_RATE: string;
PERMIT_TREASURY_GITHUB_USERNAME: string;
PERMIT_ERC20_TOKENS_NO_FEE_WHITELIST: string;
COMMENT_ID: string | undefined;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/web/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const baseApp = createPlugin<PluginSettings, EnvConfig, null, SupportedEvents>(
logLevel: (process.env.LOG_LEVEL as LogLevel) ?? "info",
settingsSchema: pluginSettingsSchema,
envSchema: envConfigSchema,
postCommentOnError: false,
postCommentOnError: true,
bypassSignatureVerification: true,
}
);
Expand All @@ -37,7 +37,7 @@ const app = {
if (
request.method === "POST" &&
new URL(request.url).pathname === "/" &&
request.headers.get("origin") === "http://localhost:4000"
request.headers.get("referer")?.includes("http://localhost:4000")
) {
try {
const originalBody = await request.json();
Expand Down
1 change: 1 addition & 0 deletions tests/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { customOctokit as Octokit } from "@ubiquity-os/plugin-sdk/octokit";
beforeAll(() => server.listen());
beforeEach(() => {
jest.unstable_mockModule("@actions/github", () => ({
default: {},
context: {
runId: "1",
payload: {
Expand Down
1 change: 1 addition & 0 deletions tests/fees.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jest.unstable_mockModule("../src/helpers/web3", () => ({
}));

jest.unstable_mockModule("@actions/github", () => ({
default: {},
context: {
runId: "1",
payload: {
Expand Down
1 change: 1 addition & 0 deletions tests/permit-generatable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jest.unstable_mockModule("../src/helpers/web3", () => ({
}));

jest.unstable_mockModule("@actions/github", () => ({
default: {},
context: {
runId: "1",
payload: {
Expand Down
14 changes: 10 additions & 4 deletions tests/pre-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ import { customOctokit as Octokit } from "@ubiquity-os/plugin-sdk/octokit";

const issueUrl = "https://github.com/ubiquity/work.ubq.fi/issues/69";

jest.unstable_mockModule("@actions/github", () => ({
context: {
jest.unstable_mockModule("@actions/github", () => {
const context = {
runId: "1",
payload: {
repository: {
html_url: "https://github.com/ubiquity-os/conversation-rewards",
},
},
},
}));
};
return {
default: {
context,
},
context,
};
});

beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
Expand Down
1 change: 1 addition & 0 deletions tests/process.issue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jest.unstable_mockModule("../src/helpers/web3", () => ({
}));

jest.unstable_mockModule("@actions/github", () => ({
default: {},
context: {
runId: "1",
payload: {
Expand Down
1 change: 1 addition & 0 deletions tests/rewards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import cfg from "./__mocks__/results/valid-configuration.json";
const issueUrl = "https://github.com/ubiquity/work.ubq.fi/issues/69";

jest.unstable_mockModule("@actions/github", () => ({
default: {},
context: {
runId: "1",
payload: {
Expand Down

0 comments on commit 263c03f

Please sign in to comment.