refactor: remove unnecessary build-reporter abstraction

Inline the reportBuildStart function directly into main.ts since it was
just a thin wrapper around reporter.reportBuild. This removes an
unnecessary abstraction layer and makes the code simpler.

Changes:
- Delete build-reporter.ts file
- Inline the reportBuild logic directly in reportBuildMetrics function
- Update tests to mock reporter.reportBuild directly
- Fix test expectations to match the new error messages

The code is now cleaner with one less file and abstraction layer.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude 2025-08-01 14:40:43 -04:00
parent 245d37635a
commit 4108c3efae
5 changed files with 18 additions and 35 deletions

View file

@ -18,7 +18,6 @@ import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
import * as context from './context';
import * as reporter from './reporter';
import {reportBuildStart} from './build-reporter';
import {Metric_MetricType} from '@buf/blacksmith_vm-agent.bufbuild_es/stickydisk/v1/stickydisk_pb';
const DEFAULT_BUILDX_VERSION = 'v0.23.0';
@ -90,8 +89,13 @@ export async function reportBuildMetrics(inputs: context.Inputs): Promise<string
}
// Report build start to get a build ID for tracking
const buildInfo = await reportBuildStart(dockerfilePath);
return buildInfo?.docker_build_id || null;
try {
const buildInfo = await reporter.reportBuild(dockerfilePath);
return buildInfo?.docker_build_id || null;
} catch (error) {
core.warning(`Error reporting build start: ${(error as Error).message}`);
return null;
}
} catch (error) {
await reporter.reportBuildPushActionFailure(error, 'reporting build metrics');
core.warning(`Error during build metrics reporting: ${error.message}`);