Skip to content

Commit

Permalink
refactor: update payload limit constants in codebase
Browse files Browse the repository at this point in the history
Renamed and added constants for better payload limit definition.
  • Loading branch information
gentlementlegen committed Oct 11, 2024
1 parent cecf116 commit 84124a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const GITHUB_PAYLOAD_LIMIT = 65536;
export const GITHUB_COMMENT_PAYLOAD_LIMIT = 65536;
export const GITHUB_DISPATCH_PAYLOAD_LIMIT = 10240;
6 changes: 3 additions & 3 deletions src/parser/github-comment-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IssueActivity } from "../issue-activity";
import { getOctokitInstance } from "../octokit";
import program from "./command-line";
import { GithubCommentScore, Module, Result } from "./processor";
import { GITHUB_PAYLOAD_LIMIT } from "../helpers/constants";
import { GITHUB_COMMENT_PAYLOAD_LIMIT } from "../helpers/constants";

interface SortedTasks {
issues: { specification: GithubCommentScore | null; comments: GithubCommentScore[] };
Expand Down Expand Up @@ -79,11 +79,11 @@ export class GithubCommentModule implements Module {

const body = bodyArray.join("");
// We check this length because GitHub has a comment length limit
if (body.length > GITHUB_PAYLOAD_LIMIT) {
if (body.length > GITHUB_COMMENT_PAYLOAD_LIMIT) {
// First, we try to diminish the metadata content to only contain the URL
bodyArray[bodyArray.length - 2] = `\n${getGithubWorkflowRunUrl()}`;
const newBody = bodyArray.join("");
if (newBody.length <= GITHUB_PAYLOAD_LIMIT) {
if (newBody.length <= GITHUB_COMMENT_PAYLOAD_LIMIT) {
return newBody;
} else {
return this.getBodyContent(result, true);
Expand Down
4 changes: 2 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import configuration from "./configuration/config-reader";
import { collectLinkedMergedPulls } from "./data-collection/collect-linked-pulls";
import { GITHUB_PAYLOAD_LIMIT } from "./helpers/constants";
import { GITHUB_DISPATCH_PAYLOAD_LIMIT } from "./helpers/constants";
import githubCommentModuleInstance from "./helpers/github-comment-module-instance";
import { getSortedPrices } from "./helpers/label-price-extractor";
import logger from "./helpers/logger";
Expand Down Expand Up @@ -35,7 +35,7 @@ export async function run() {
const processor = new Processor();
await processor.run(activity);
let result = processor.dump();
if (result.length > GITHUB_PAYLOAD_LIMIT) {
if (result.length > GITHUB_DISPATCH_PAYLOAD_LIMIT) {
const resultObject = JSON.parse(result) as Result;
for (const [key, value] of Object.entries(resultObject)) {
resultObject[key] = {
Expand Down

0 comments on commit 84124a5

Please sign in to comment.