Merge pull request #118 from useblacksmith/builder-misconfig
fix: use correct platform when creating remote buildx builderpull/1393/head
commit
4fac79897d
@ -0,0 +1,99 @@
|
|||||||
|
name: Builder platform matrix tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# 1) Build AMD image on default (amd64) runner
|
||||||
|
amd_on_amd:
|
||||||
|
name: linux/amd64 build on blacksmith runner
|
||||||
|
runs-on: blacksmith
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Write sample Dockerfile
|
||||||
|
run: |
|
||||||
|
cat <<'EOF' > Dockerfile
|
||||||
|
FROM alpine:3.20
|
||||||
|
# Install something non-trivial so that layer caching is observable
|
||||||
|
RUN apk add --no-cache curl git
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build image (linux/amd64)
|
||||||
|
uses: useblacksmith/build-push-action@builder-misconfig
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: false
|
||||||
|
tags: test/amd_on_amd:${{ github.sha }}
|
||||||
|
|
||||||
|
# 2) Build ARM image on default (amd64) runner
|
||||||
|
arm_on_amd:
|
||||||
|
name: linux/arm64 build on blacksmith runner
|
||||||
|
runs-on: blacksmith
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Write sample Dockerfile
|
||||||
|
run: |
|
||||||
|
cat <<'EOF' > Dockerfile
|
||||||
|
FROM alpine:3.20
|
||||||
|
RUN apk add --no-cache curl git
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build image (linux/arm64)
|
||||||
|
uses: useblacksmith/build-push-action@builder-misconfig
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/arm64
|
||||||
|
push: false
|
||||||
|
tags: test/arm_on_amd:${{ github.sha }}
|
||||||
|
|
||||||
|
# 3) Build AMD image on ARM runner
|
||||||
|
amd_on_arm:
|
||||||
|
name: linux/amd64 build on blacksmith-arm runner
|
||||||
|
runs-on: blacksmith-arm
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Write sample Dockerfile
|
||||||
|
run: |
|
||||||
|
cat <<'EOF' > Dockerfile
|
||||||
|
FROM alpine:3.20
|
||||||
|
RUN apk add --no-cache curl git
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build image (linux/amd64)
|
||||||
|
uses: useblacksmith/build-push-action@builder-misconfig
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: false
|
||||||
|
tags: test/amd_on_arm:${{ github.sha }}
|
||||||
|
|
||||||
|
# 4) Build ARM image on ARM runner
|
||||||
|
arm_on_arm:
|
||||||
|
name: linux/arm64 build on blacksmith-arm runner
|
||||||
|
runs-on: blacksmith-arm
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Write sample Dockerfile
|
||||||
|
run: |
|
||||||
|
cat <<'EOF' > Dockerfile
|
||||||
|
FROM alpine:3.20
|
||||||
|
RUN apk add --no-cache curl git
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build image (linux/arm64)
|
||||||
|
uses: useblacksmith/build-push-action@builder-misconfig
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/arm64
|
||||||
|
push: false
|
||||||
|
tags: test/arm_on_arm:${{ github.sha }}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,23 +1,23 @@
|
|||||||
export class StickyDiskService {
|
export class StickyDiskService {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
async commitStickyDisk() {
|
async commitStickyDisk() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStickyDisk() {
|
async getStickyDisk() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
async queueDockerJob() {
|
async queueDockerJob() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
async reportMetric() {
|
async reportMetric() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
async up() {
|
async up() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
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 () => {
|
||||||
|
const platformStr = resolveRemoteBuilderPlatforms([]);
|
||||||
|
const expectedPlatform = os.arch() === 'arm64' ? 'linux/arm64' : 'linux/amd64';
|
||||||
|
expect(platformStr).toBe(expectedPlatform);
|
||||||
|
|
||||||
|
const args = await getRemoteBuilderArgs(builderName, builderUrl, []);
|
||||||
|
const idx = args.indexOf('--platform');
|
||||||
|
expect(idx).toBeGreaterThan(-1);
|
||||||
|
expect(args[idx + 1]).toBe(expectedPlatform);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue