mirror of
https://code.forgejo.org/docker/build-push-action.git
synced 2025-08-17 17:20:53 +00:00
refactor: remove unused stickydisk setup logic and rename setup_builder
This commit completes the cleanup of build-push-action by removing all the buildkit and sticky disk setup logic that has been moved to the separate setup-docker-builder action. Changes: - Delete setup_builder.ts which contained 380+ lines of unused code - Create new build-reporter.ts with only the reportBuildStart function - Update all imports to use the new build-reporter module - The new file name better reflects its single responsibility The action is now cleaner and more focused, with infrastructure setup logic properly separated into the setup-docker-builder action. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
cc46a915dd
commit
245d37635a
7 changed files with 44 additions and 941 deletions
|
@ -2,7 +2,7 @@ import * as core from '@actions/core';
|
|||
import * as main from '../main';
|
||||
import * as reporter from '../reporter';
|
||||
import {getDockerfilePath} from '../context';
|
||||
import * as setupBuilder from '../setup_builder';
|
||||
import * as buildReporter from '../build-reporter';
|
||||
|
||||
jest.mock('@actions/core', () => ({
|
||||
debug: jest.fn(),
|
||||
|
@ -28,7 +28,7 @@ jest.mock('../reporter', () => {
|
|||
};
|
||||
});
|
||||
|
||||
jest.mock('../setup_builder', () => ({
|
||||
jest.mock('../build-reporter', () => ({
|
||||
reportBuildStart: jest.fn()
|
||||
}));
|
||||
|
||||
|
@ -57,29 +57,29 @@ describe('reportBuildMetrics', () => {
|
|||
test('should successfully report build start', async () => {
|
||||
const mockBuildId = 'test-build-id';
|
||||
(getDockerfilePath as jest.Mock).mockReturnValue('/path/to/Dockerfile');
|
||||
(setupBuilder.reportBuildStart as jest.Mock).mockResolvedValue({ docker_build_id: mockBuildId });
|
||||
(buildReporter.reportBuildStart as jest.Mock).mockResolvedValue({ docker_build_id: mockBuildId });
|
||||
|
||||
const result = await main.reportBuildMetrics(mockInputs);
|
||||
|
||||
expect(result).toBe(mockBuildId);
|
||||
expect(setupBuilder.reportBuildStart).toHaveBeenCalledWith('/path/to/Dockerfile');
|
||||
expect(buildReporter.reportBuildStart).toHaveBeenCalledWith('/path/to/Dockerfile');
|
||||
expect(reporter.reportBuildPushActionFailure).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('should handle reportBuildStart returning null', async () => {
|
||||
(getDockerfilePath as jest.Mock).mockReturnValue('/path/to/Dockerfile');
|
||||
(setupBuilder.reportBuildStart as jest.Mock).mockResolvedValue(null);
|
||||
(buildReporter.reportBuildStart as jest.Mock).mockResolvedValue(null);
|
||||
|
||||
const result = await main.reportBuildMetrics(mockInputs);
|
||||
|
||||
expect(result).toBeNull();
|
||||
expect(setupBuilder.reportBuildStart).toHaveBeenCalledWith('/path/to/Dockerfile');
|
||||
expect(buildReporter.reportBuildStart).toHaveBeenCalledWith('/path/to/Dockerfile');
|
||||
expect(reporter.reportBuildPushActionFailure).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('should handle error in reportBuildStart', async () => {
|
||||
(getDockerfilePath as jest.Mock).mockReturnValue('/path/to/Dockerfile');
|
||||
(setupBuilder.reportBuildStart as jest.Mock).mockRejectedValue(new Error('API error'));
|
||||
(buildReporter.reportBuildStart as jest.Mock).mockRejectedValue(new Error('API error'));
|
||||
|
||||
const result = await main.reportBuildMetrics(mockInputs);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue