@kakarot-ci/core 0.6.5 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ var KakarotConfigSchema = z.object({
21
21
  enableAutoCommit: z.boolean().default(true),
22
22
  commitStrategy: z.enum(["direct", "branch-pr"]).default("direct"),
23
23
  enablePRComments: z.boolean().default(true),
24
+ enableCoverage: z.boolean().default(false),
24
25
  debug: z.boolean().default(false)
25
26
  });
26
27
 
@@ -164,8 +165,6 @@ var GitHubClient = class {
164
165
  this.retryDelay = 1e3;
165
166
  this.owner = options.owner;
166
167
  this.repo = options.repo;
167
- const originalConsoleError = console.error;
168
- const originalConsoleWarn = console.warn;
169
168
  this.octokit = new Octokit({
170
169
  auth: options.token,
171
170
  request: {
@@ -173,8 +172,6 @@ var GitHubClient = class {
173
172
  retryAfter: this.retryDelay / 1e3
174
173
  }
175
174
  });
176
- console.error = originalConsoleError;
177
- console.warn = originalConsoleWarn;
178
175
  }
179
176
  /**
180
177
  * Retry wrapper with exponential backoff
@@ -375,21 +372,23 @@ var GitHubClient = class {
375
372
  async fileExists(ref, path) {
376
373
  const originalError = console.error;
377
374
  const originalWarn = console.warn;
378
- const suppressedError = (...args) => {
379
- const message = args.join(" ");
380
- if (!message.includes("404") && !message.includes("Not Found")) {
381
- originalError(...args);
375
+ const suppress404 = (...args) => {
376
+ const message = String(args[0] || "");
377
+ if (message.includes("404") || message.includes("Not Found")) {
378
+ return;
382
379
  }
380
+ originalError(...args);
383
381
  };
384
- const suppressedWarn = (...args) => {
385
- const message = args.join(" ");
386
- if (!message.includes("404") && !message.includes("Not Found")) {
387
- originalWarn(...args);
382
+ const suppress404Warn = (...args) => {
383
+ const message = String(args[0] || "");
384
+ if (message.includes("404") || message.includes("Not Found")) {
385
+ return;
388
386
  }
387
+ originalWarn(...args);
389
388
  };
390
389
  try {
391
- console.error = suppressedError;
392
- console.warn = suppressedWarn;
390
+ console.error = suppress404;
391
+ console.warn = suppress404Warn;
393
392
  await this.octokit.rest.repos.getContent({
394
393
  owner: this.owner,
395
394
  repo: this.repo,
@@ -1936,7 +1935,7 @@ async function runPullRequest(context) {
1936
1935
  })),
1937
1936
  errors
1938
1937
  };
1939
- if (testFiles.size > 0) {
1938
+ if (config.enableCoverage && testFiles.size > 0) {
1940
1939
  const testRunner = createTestRunner(framework);
1941
1940
  const writtenPaths = Array.from(testFiles.keys());
1942
1941
  try {
@@ -1954,13 +1953,12 @@ async function runPullRequest(context) {
1954
1953
  summary.coverageReport = coverageReport;
1955
1954
  summary.testResults = finalTestResults;
1956
1955
  } else {
1957
- warn("Could not read coverage report");
1956
+ warn("Could not read coverage report (coverage package may be missing)");
1958
1957
  }
1959
1958
  } catch (err) {
1960
1959
  const errorMessage = err instanceof Error ? err.message : String(err);
1961
1960
  if (errorMessage.includes("coverage") || errorMessage.includes("MISSING DEPENDENCY")) {
1962
- warn(`Coverage collection failed (likely missing coverage package): ${errorMessage}`);
1963
- warn("Continuing without coverage report");
1961
+ warn(`Coverage collection failed (coverage package may be missing): ${errorMessage.split("\n")[0]}`);
1964
1962
  } else {
1965
1963
  throw err;
1966
1964
  }
@@ -2057,7 +2055,8 @@ async function commitTests(githubClient, pr, testFiles, config, summary) {
2057
2055
  info(`Committing ${testFiles.length} test file(s)`);
2058
2056
  try {
2059
2057
  if (config.commitStrategy === "branch-pr") {
2060
- const branchName = `kakarot-ci/tests-pr-${pr.number}`;
2058
+ const timestamp = Date.now();
2059
+ const branchName = `kakarot-ci/tests-pr-${pr.number}-${timestamp}`;
2061
2060
  const baseSha = await githubClient.createBranch(branchName, pr.head.ref);
2062
2061
  await githubClient.commitFiles({
2063
2062
  files: testFiles.map((file) => ({