fix: use correct platform when creating remote buildx builder
The remote builder was hardcoded to use --platform linux/amd64 regardless of user input or runner architecture. This caused performance issues on ARM runners and cache inefficiencies. Now properly uses the platforms input or detects host architecture to avoid unnecessary QEMU emulation and improve build performance. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>pull/1393/head
parent
6fe3b1c366
commit
a7fa33c366
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@
|
||||
import * as os from 'os';
|
||||
import {getRemoteBuilderArgs, resolveRemoteBuilderPlatforms} from '../context';
|
||||
|
||||
jest.mock('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
error: jest.fn()
|
||||
}));
|
||||
|
||||
describe('Remote builder platform argument resolution', () => {
|
||||
const builderName = 'test-builder';
|
||||
const builderUrl = 'tcp://127.0.0.1:1234';
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
test('returns comma-separated list when platforms are supplied', async () => {
|
||||
const platforms = ['linux/arm64', 'linux/amd64'];
|
||||
const platformStr = resolveRemoteBuilderPlatforms(platforms);
|
||||
expect(platformStr).toBe('linux/arm64,linux/amd64');
|
||||
|
||||
const args = await getRemoteBuilderArgs(builderName, builderUrl, platforms);
|
||||
const idx = args.indexOf('--platform');
|
||||
expect(idx).toBeGreaterThan(-1);
|
||||
expect(args[idx + 1]).toBe('linux/arm64,linux/amd64');
|
||||
});
|
||||
|
||||
test('falls back to host architecture when no platforms supplied', async () => {
|
||||
jest.spyOn(os, 'arch').mockReturnValue('arm64' as any);
|
||||
|
||||
const platformStr = resolveRemoteBuilderPlatforms([]);
|
||||
expect(platformStr).toBe('linux/arm64');
|
||||
|
||||
const args = await getRemoteBuilderArgs(builderName, builderUrl, []);
|
||||
const idx = args.indexOf('--platform');
|
||||
expect(idx).toBeGreaterThan(-1);
|
||||
expect(args[idx + 1]).toBe('linux/arm64');
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue