From e071f85804f8168eb8abc3153ad3a32fdf3a49f9 Mon Sep 17 00:00:00 2001 From: Philip Lehmann Date: Sun, 15 Dec 2024 19:45:34 +0100 Subject: [PATCH] always use currentArch for tests --- apps/mailcatcher/project.json | 4 --- apps/maildev/project.json | 4 --- apps/mailhog/project.json | 4 --- apps/pdftk/project.json | 4 --- apps/poppler/project.json | 4 --- apps/puppeteer/project.json | 4 --- apps/tesseract/project.json | 4 --- apps/unoserver/project.json | 4 --- libs/docker/src/executors/test/executor.ts | 38 ++++++++++------------ libs/docker/src/executors/test/schema.d.ts | 1 - libs/docker/src/executors/test/schema.json | 8 +---- 11 files changed, 18 insertions(+), 61 deletions(-) diff --git a/apps/mailcatcher/project.json b/apps/mailcatcher/project.json index 070bdeb4..b12826a1 100644 --- a/apps/mailcatcher/project.json +++ b/apps/mailcatcher/project.json @@ -30,10 +30,6 @@ "docker-test": { "executor": "@container/docker:test", "options": { - "platforms": [ - "amd64", - "arm64" - ], "tag": "philiplehmann/mailcatcher:test", "file": "apps/mailcatcher/Dockerfile" } diff --git a/apps/maildev/project.json b/apps/maildev/project.json index d7545134..95fe03dc 100644 --- a/apps/maildev/project.json +++ b/apps/maildev/project.json @@ -30,10 +30,6 @@ "docker-test": { "executor": "@container/docker:test", "options": { - "platforms": [ - "amd64", - "arm64" - ], "tag": "philiplehmann/maildev:test", "file": "apps/maildev/Dockerfile" } diff --git a/apps/mailhog/project.json b/apps/mailhog/project.json index f073fd6a..a756636c 100644 --- a/apps/mailhog/project.json +++ b/apps/mailhog/project.json @@ -30,10 +30,6 @@ "docker-test": { "executor": "@container/docker:test", "options": { - "platforms": [ - "amd64", - "arm64" - ], "tag": "philiplehmann/mailhog:test", "file": "apps/mailhog/Dockerfile" } diff --git a/apps/pdftk/project.json b/apps/pdftk/project.json index 763229ed..de07f52d 100644 --- a/apps/pdftk/project.json +++ b/apps/pdftk/project.json @@ -98,10 +98,6 @@ "build" ], "options": { - "platforms": [ - "amd64", - "arm64" - ], "tag": "philiplehmann/pdftk:test", "file": "apps/pdftk/Dockerfile" } diff --git a/apps/poppler/project.json b/apps/poppler/project.json index 3a78a010..51902ffe 100644 --- a/apps/poppler/project.json +++ b/apps/poppler/project.json @@ -87,10 +87,6 @@ "build" ], "options": { - "platforms": [ - "amd64", - "arm64" - ], "tag": "philiplehmann/poppler-server:test", "file": "apps/poppler/Dockerfile" } diff --git a/apps/puppeteer/project.json b/apps/puppeteer/project.json index 0f54b8d5..f8206e80 100644 --- a/apps/puppeteer/project.json +++ b/apps/puppeteer/project.json @@ -135,10 +135,6 @@ "build" ], "options": { - "platforms": [ - "amd64", - "arm64" - ], "tag": "philiplehmann/puppeteer:test", "file": "apps/puppeteer/Dockerfile" } diff --git a/apps/tesseract/project.json b/apps/tesseract/project.json index 7acafb98..a6155cd4 100644 --- a/apps/tesseract/project.json +++ b/apps/tesseract/project.json @@ -86,10 +86,6 @@ "build" ], "options": { - "platforms": [ - "amd64", - "arm64" - ], "tag": "philiplehmann/tesseract:test", "file": "apps/tesseract/Dockerfile" } diff --git a/apps/unoserver/project.json b/apps/unoserver/project.json index 2387503a..25779222 100644 --- a/apps/unoserver/project.json +++ b/apps/unoserver/project.json @@ -100,10 +100,6 @@ "build" ], "options": { - "platforms": [ - "amd64", - "arm64" - ], "tag": "philiplehmann/unoserver:test", "file": "apps/unoserver/Dockerfile" } diff --git a/libs/docker/src/executors/test/executor.ts b/libs/docker/src/executors/test/executor.ts index 43049ee1..5e6b20f3 100644 --- a/libs/docker/src/executors/test/executor.ts +++ b/libs/docker/src/executors/test/executor.ts @@ -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 = 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 = 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; diff --git a/libs/docker/src/executors/test/schema.d.ts b/libs/docker/src/executors/test/schema.d.ts index cf02a58e..ccdff3b6 100644 --- a/libs/docker/src/executors/test/schema.d.ts +++ b/libs/docker/src/executors/test/schema.d.ts @@ -1,7 +1,6 @@ import type { DockerPlatform } from '../../docker-helper'; export interface DockerTestExecutorSchema { - platforms: DockerPlatform[]; tag: string; file: string; } diff --git a/libs/docker/src/executors/test/schema.json b/libs/docker/src/executors/test/schema.json index 5eb23a2f..83355762 100644 --- a/libs/docker/src/executors/test/schema.json +++ b/libs/docker/src/executors/test/schema.json @@ -8,15 +8,9 @@ "tag": { "type": "string" }, - "platforms": { - "type": "array", - "items": { - "type": "string" - } - }, "file": { "type": "string" } }, "required": [] -} +} \ No newline at end of file