Clean up logs

This commit is contained in:
Colin McDonnell
2025-12-17 12:43:08 -08:00
parent 479e066492
commit 4826e9acb1
8 changed files with 78 additions and 115 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ export function buildPullfrogFooter(params: BuildPullfrogFooterParams): string {
if (params.workflowRun) {
const baseUrl = `https://github.com/${params.workflowRun.owner}/${params.workflowRun.repo}/actions/runs/${params.workflowRun.runId}`;
const url = params.workflowRun.jobId ? `${baseUrl}/job/${params.workflowRun.jobId}` : baseUrl;
parts.push(`[View workflow run](${url})`);
parts.push(`[workflow run](${url})`);
}
const allParts = [
+5 -5
View File
@@ -48,14 +48,14 @@ function isGitHubActionsEnvironment(): boolean {
}
async function acquireTokenViaOIDC(): Promise<string> {
log.info("Generating OIDC token...");
log.debug("» generating OIDC token...");
const oidcToken = await core.getIDToken("pullfrog-api");
log.info("OIDC token generated successfully");
log.debug("» OIDC token generated successfully");
const apiUrl = process.env.API_URL || "https://pullfrog.com";
log.info("Exchanging OIDC token for installation token...");
log.debug("» exchanging OIDC token for installation token...");
// Add timeout to prevent long waits (5 seconds)
const timeoutMs = 5000;
@@ -79,7 +79,7 @@ async function acquireTokenViaOIDC(): Promise<string> {
}
const tokenData = (await tokenResponse.json()) as InstallationToken;
log.info(`Installation token obtained for ${tokenData.repository || "all repositories"}`);
log.debug(`» installation token obtained for ${tokenData.repository || "all repositories"}`);
return tokenData.token;
} catch (error) {
@@ -283,7 +283,7 @@ export async function revokeGitHubInstallationToken(): Promise<void> {
"X-GitHub-Api-Version": "2022-11-28",
},
});
log.info("Installation token revoked");
log.debug("» installation token revoked");
} catch (error) {
log.warning(
`Failed to revoke installation token: ${error instanceof Error ? error.message : String(error)}`
+10 -10
View File
@@ -18,20 +18,20 @@ export function setupTestRepo(options: SetupOptions): void {
if (existsSync(tempDir)) {
if (forceClean) {
log.info("🗑️ Removing existing .temp directory...");
log.info("» removing existing .temp directory...");
rmSync(tempDir, { recursive: true, force: true });
log.info("📦 Cloning pullfrog/scratch into .temp...");
log.info("» cloning pullfrog/scratch into .temp...");
$("git", ["clone", "git@github.com:pullfrog/scratch.git", tempDir]);
} else {
log.info("📦 Resetting existing .temp repository...");
log.info("» resetting existing .temp repository...");
execSync("git reset --hard HEAD && git clean -fd", {
cwd: tempDir,
stdio: "inherit",
});
}
} else {
log.info("📦 Cloning pullfrog/scratch into .temp...");
log.info("» cloning pullfrog/scratch into .temp...");
$("git", ["clone", "git@github.com:pullfrog/scratch.git", tempDir]);
}
}
@@ -42,7 +42,7 @@ export function setupTestRepo(options: SetupOptions): void {
*/
export function setupGitConfig(): void {
const repoDir = process.cwd();
log.info("🔧 Setting up git configuration...");
log.info("» setting up git configuration...");
try {
// Use --local to scope config to this repo only, preventing leakage to user's global config
execSync('git config --local user.email "team@pullfrog.com"', {
@@ -61,7 +61,7 @@ export function setupGitConfig(): void {
stdio: "pipe",
});
}
log.debug("setupGitConfig: ✓ Git configuration set successfully (scoped to repo)");
log.debug("» git configuration set successfully (scoped to repo)");
} catch (error) {
// If git config fails, log warning but don't fail the action
// This can happen if we're not in a git repo or git isn't available
@@ -83,7 +83,7 @@ export function setupGitConfig(): void {
export async function setupGit(ctx: Context): Promise<void> {
const repoDir = process.cwd();
log.info("🔧 setting up git authentication...");
log.info("» setting up git authentication...");
// remove existing git auth headers that actions/checkout might have set
try {
@@ -91,16 +91,16 @@ export async function setupGit(ctx: Context): Promise<void> {
cwd: repoDir,
stdio: "pipe",
});
log.info(" removed existing authentication headers");
log.info("» removed existing authentication headers");
} catch {
log.debug("no existing authentication headers to remove");
log.debug("» no existing authentication headers to remove");
}
// non-PR events: set up origin with token, stay on default branch
if (ctx.payload.event.is_pr !== true || !ctx.payload.event.issue_number) {
const originUrl = `https://x-access-token:${ctx.githubInstallationToken}@github.com/${ctx.owner}/${ctx.name}.git`;
$("git", ["remote", "set-url", "origin", originUrl], { cwd: repoDir });
log.info("✓ Updated origin URL with authentication token");
log.info("» updated origin URL with authentication token");
return;
}
+1 -1
View File
@@ -14,7 +14,7 @@ export class Timer {
? now - this.lastCheckpointTimestamp
: now - this.initialTimestamp;
log.info(`${name}: ${duration}ms`);
log.debug(`» ${name}: ${duration}ms`);
this.lastCheckpointTimestamp = now;
}
}