Skip to content

Commit

Permalink
always use currentArch for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philiplehmann committed Dec 15, 2024
1 parent 14932fe commit e071f85
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 61 deletions.
4 changes: 0 additions & 4 deletions apps/mailcatcher/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
"docker-test": {
"executor": "@container/docker:test",
"options": {
"platforms": [
"amd64",
"arm64"
],
"tag": "philiplehmann/mailcatcher:test",
"file": "apps/mailcatcher/Dockerfile"
}
Expand Down
4 changes: 0 additions & 4 deletions apps/maildev/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
"docker-test": {
"executor": "@container/docker:test",
"options": {
"platforms": [
"amd64",
"arm64"
],
"tag": "philiplehmann/maildev:test",
"file": "apps/maildev/Dockerfile"
}
Expand Down
4 changes: 0 additions & 4 deletions apps/mailhog/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
"docker-test": {
"executor": "@container/docker:test",
"options": {
"platforms": [
"amd64",
"arm64"
],
"tag": "philiplehmann/mailhog:test",
"file": "apps/mailhog/Dockerfile"
}
Expand Down
4 changes: 0 additions & 4 deletions apps/pdftk/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@
"build"
],
"options": {
"platforms": [
"amd64",
"arm64"
],
"tag": "philiplehmann/pdftk:test",
"file": "apps/pdftk/Dockerfile"
}
Expand Down
4 changes: 0 additions & 4 deletions apps/poppler/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@
"build"
],
"options": {
"platforms": [
"amd64",
"arm64"
],
"tag": "philiplehmann/poppler-server:test",
"file": "apps/poppler/Dockerfile"
}
Expand Down
4 changes: 0 additions & 4 deletions apps/puppeteer/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@
"build"
],
"options": {
"platforms": [
"amd64",
"arm64"
],
"tag": "philiplehmann/puppeteer:test",
"file": "apps/puppeteer/Dockerfile"
}
Expand Down
4 changes: 0 additions & 4 deletions apps/tesseract/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@
"build"
],
"options": {
"platforms": [
"amd64",
"arm64"
],
"tag": "philiplehmann/tesseract:test",
"file": "apps/tesseract/Dockerfile"
}
Expand Down
4 changes: 0 additions & 4 deletions apps/unoserver/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@
"build"
],
"options": {
"platforms": [
"amd64",
"arm64"
],
"tag": "philiplehmann/unoserver:test",
"file": "apps/unoserver/Dockerfile"
}
Expand Down
38 changes: 17 additions & 21 deletions libs/docker/src/executors/test/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,28 @@ import type { DockerTestExecutorSchema } from './schema';
import { dockerBuildxBuild } from '../../docker-buildx-build';
import { dockerImageRemove } from '../../docker-image-remove';
import type { Executor } from '@nx/devkit';
import { currentArch } from '../../docker-helper';

const runExecutor: Executor<DockerTestExecutorSchema> = async ({
file,
tag,
platforms,
}): Promise<{ success: boolean }> => {
const promises = await Promise.allSettled(
platforms.map(async (platform) => {
const tagWithPlatform = `${tag}-${platform}`;
await dockerImageRemove(tagWithPlatform);
await dockerBuildxBuild({
platforms: [platform],
output: 'load',
file,
tags: [tagWithPlatform],
});
}),
);
if (promises.some((promise) => promise.status === 'rejected')) {
const runExecutor: Executor<DockerTestExecutorSchema> = async ({ file, tag }): Promise<{ success: boolean }> => {
try {
const platform = currentArch();
const tagWithPlatform = `${tag}-${platform}`;
await dockerImageRemove(tagWithPlatform);
await dockerBuildxBuild({
platforms: [platform],
output: 'load',
file,
tags: [tagWithPlatform],
});
return {
success: true,
};
} catch (error) {
console.error(error);
return {
success: false,
};
}
return {
success: true,
};
};

export default runExecutor;
1 change: 0 additions & 1 deletion libs/docker/src/executors/test/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { DockerPlatform } from '../../docker-helper';

export interface DockerTestExecutorSchema {
platforms: DockerPlatform[];
tag: string;
file: string;
}
8 changes: 1 addition & 7 deletions libs/docker/src/executors/test/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@
"tag": {
"type": "string"
},
"platforms": {
"type": "array",
"items": {
"type": "string"
}
},
"file": {
"type": "string"
}
},
"required": []
}
}

0 comments on commit e071f85

Please sign in to comment.