From 34a0e3fa5ca9b125de915dac220f025982d91567 Mon Sep 17 00:00:00 2001 From: Willie Hung Date: Fri, 13 Oct 2023 00:01:50 -0500 Subject: [PATCH 1/3] Add platform "darwin-arm64" to unit test Signed-off-by: Willie Hung --- src/dev/build/lib/config.test.ts | 16 ++++++++++++---- src/dev/build/lib/config.ts | 3 ++- src/dev/build/lib/platform.ts | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/dev/build/lib/config.test.ts b/src/dev/build/lib/config.test.ts index 145954c1fb40..51c7f66be893 100644 --- a/src/dev/build/lib/config.test.ts +++ b/src/dev/build/lib/config.test.ts @@ -52,6 +52,7 @@ const setup = async ({ targetAllPlatforms = true, targetPlatforms = { darwin: false, + darwinArm: false, linux: false, linuxArm: false, windows: false, @@ -60,6 +61,7 @@ const setup = async ({ targetAllPlatforms?: boolean; targetPlatforms?: { darwin: boolean; + darwinArm: boolean; linux: boolean; linuxArm: boolean; windows: boolean; @@ -89,9 +91,7 @@ describe('#getNodeRange()', () => { describe('#getRepoRelativePath()', () => { it('converts an absolute path to relative path, from the root of the repo', async () => { const config = await setup(); - expect(config.getRepoRelativePath(__dirname)).toMatchInlineSnapshot( - `"${standardize('src/dev/build/lib', false, true)}"` - ); + expect(config.getRepoRelativePath(__dirname)).toMatchInlineSnapshot(`"src/dev/build/lib"`); }); }); @@ -117,6 +117,7 @@ describe('#hasSpecifiedPlatform', () => { targetAllPlatforms: false, targetPlatforms: { darwin: true, + darwinArm: false, linux: false, linuxArm: false, windows: false, @@ -130,6 +131,7 @@ describe('#hasSpecifiedPlatform', () => { targetAllPlatforms: false, targetPlatforms: { darwin: false, + darwinArm: false, linux: false, linuxArm: true, windows: false, @@ -143,6 +145,7 @@ describe('#hasSpecifiedPlatform', () => { targetAllPlatforms: false, targetPlatforms: { darwin: false, + darwinArm: false, linux: true, linuxArm: false, windows: false, @@ -197,6 +200,7 @@ describe('#getTargetPlatforms()', () => { .sort() ).toMatchInlineSnapshot(` Array [ + "darwin-arm64", "darwin-x64", "linux-arm64", "linux-x64", @@ -210,6 +214,7 @@ describe('#getTargetPlatforms()', () => { targetAllPlatforms: false, targetPlatforms: { darwin: true, + darwinArm: false, linux: false, linuxArm: false, windows: false, @@ -233,6 +238,7 @@ describe('#getTargetPlatforms()', () => { targetAllPlatforms: false, targetPlatforms: { darwin: false, + darwinArm: false, linux: true, linuxArm: false, windows: false, @@ -256,6 +262,7 @@ describe('#getTargetPlatforms()', () => { targetAllPlatforms: false, targetPlatforms: { darwin: false, + darwinArm: false, linux: false, linuxArm: true, windows: false, @@ -279,6 +286,7 @@ describe('#getTargetPlatforms()', () => { targetAllPlatforms: false, targetPlatforms: { darwin: true, + darwinArm: false, linux: false, linuxArm: true, windows: false, @@ -315,7 +323,7 @@ describe('#getNodePlatforms()', () => { .getTargetPlatforms() .map((p) => p.getNodeArch()) .sort() - ).toEqual(['darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']); + ).toEqual(['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']); }); it('returns this platform and linux, when targetAllPlatforms = false', async () => { diff --git a/src/dev/build/lib/config.ts b/src/dev/build/lib/config.ts index 6af5b8e6901a..c8750e9234b3 100644 --- a/src/dev/build/lib/config.ts +++ b/src/dev/build/lib/config.ts @@ -155,9 +155,10 @@ export class Config { const platforms: Platform[] = []; if (this.targetPlatforms.darwin) platforms.push(this.getPlatform('darwin', 'x64')); + if (this.targetPlatforms.darwinArm) platforms.push(this.getPlatform('darwin', 'arm64')); if (this.targetPlatforms.linux) platforms.push(this.getPlatform('linux', 'x64')); - if (this.targetPlatforms.windows) platforms.push(this.getPlatform('win32', 'x64')); if (this.targetPlatforms.linuxArm) platforms.push(this.getPlatform('linux', 'arm64')); + if (this.targetPlatforms.windows) platforms.push(this.getPlatform('win32', 'x64')); if (platforms.length > 0) return platforms; diff --git a/src/dev/build/lib/platform.ts b/src/dev/build/lib/platform.ts index 673356ec6205..f83107f73734 100644 --- a/src/dev/build/lib/platform.ts +++ b/src/dev/build/lib/platform.ts @@ -33,6 +33,7 @@ export type PlatformArchitecture = 'x64' | 'arm64'; export interface TargetPlatforms { darwin: boolean; + darwinArm: boolean; linuxArm: boolean; linux: boolean; windows: boolean; @@ -78,5 +79,6 @@ export const ALL_PLATFORMS = [ new Platform('linux', 'x64', 'linux-x64'), new Platform('linux', 'arm64', 'linux-arm64'), new Platform('darwin', 'x64', 'darwin-x64'), + new Platform('darwin', 'arm64', 'darwin-arm64'), new Platform('win32', 'x64', 'windows-x64'), ]; From a3352ff6d2efbe2a95d1798b11500cf7276429b4 Mon Sep 17 00:00:00 2001 From: Willie Hung Date: Fri, 13 Oct 2023 16:11:10 -0500 Subject: [PATCH 2/3] Update CHANGELOG Signed-off-by: Willie Hung --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4b1bf70e1b..71cd6f514ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [BUG][Data Explorer][Discover] Allow filter and query persist when refresh page or paste url to a new tab ([#5206](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5206)) - [Data Explorer] Remove the `X` icon in data source selection field ([#5238](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5238)) - [BUG][Fuctional Test] Make setDefaultAbsoluteRange more robust and update doc views tests ([#5242](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5242)) +- [BUG] Add platform "darwin-arm64" to unit test ([#5290](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5290)) ### 🚞 Infrastructure From 7ada18e714338ba0ed75949f9af129807164db35 Mon Sep 17 00:00:00 2001 From: Willie Hung Date: Sat, 14 Oct 2023 22:17:28 -0500 Subject: [PATCH 3/3] Update related snapshots Signed-off-by: Willie Hung --- .../nodejs/download_node_builds_task.test.ts | 18 +++++++++++++ .../nodejs/extract_node_builds_task.test.ts | 14 +++++++++++ .../verify_existing_node_builds_task.test.ts | 25 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/src/dev/build/tasks/nodejs/download_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/download_node_builds_task.test.ts index f5905534e121..dea396b77639 100644 --- a/src/dev/build/tasks/nodejs/download_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/download_node_builds_task.test.ts @@ -137,6 +137,15 @@ it('downloads node builds for each platform', async () => { "url": "darwin:url", }, ], + Array [ + Object { + "destination": "darwin:downloadPath", + "log": , + "retries": 3, + "sha256": "darwin:sha256", + "url": "darwin:url", + }, + ], Array [ Object { "destination": "win32:downloadPath", @@ -173,6 +182,15 @@ it('downloads node builds for each platform', async () => { "url": "https://mirrors.nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-x64.tar.gz", }, ], + Array [ + Object { + "destination": "/mocked/path/.node_binaries/14.21.3/node-v14.21.3-darwin-arm64.tar.gz", + "log": , + "retries": 3, + "sha256": undefined, + "url": "https://mirrors.nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-arm64.tar.gz", + }, + ], Array [ Object { "destination": "/mocked/path/.node_binaries/14.21.3/node-v14.21.3-win32-x64.tar.gz", diff --git a/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts index e68539310903..2782da06bdba 100644 --- a/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts @@ -123,6 +123,13 @@ it('runs expected fs operations', async () => { "strip": 1, }, ], + Array [ + /.node_binaries//node-v-darwin-arm64.tar.gz, + /.node_binaries//darwin-arm64, + Object { + "strip": 1, + }, + ], Array [ /.node_binaries/14.21.3/node-v14.21.3-linux-x64.tar.gz, /.node_binaries/14.21.3/linux-x64, @@ -144,6 +151,13 @@ it('runs expected fs operations', async () => { "strip": 1, }, ], + Array [ + /.node_binaries/14.21.3/node-v14.21.3-darwin-arm64.tar.gz, + /.node_binaries/14.21.3/darwin-arm64, + Object { + "strip": 1, + }, + ], ], "unzip": Array [ Array [ diff --git a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts index 1d516ce457ad..bbffaafbe455 100644 --- a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts @@ -120,6 +120,7 @@ it('checks shasums for each downloaded node build', async () => { Object { "type": "return", "value": Object { + "darwin:darwin-arm64:downloadName": "valid shasum", "darwin:darwin-x64:downloadName": "valid shasum", "linux:linux-arm64:downloadName": "valid shasum", "linux:linux-x64:downloadName": "valid shasum", @@ -156,6 +157,14 @@ it('checks shasums for each downloaded node build', async () => { "name": "darwin", }, ], + Array [ + , + Platform { + "architecture": "arm64", + "buildName": "darwin-arm64", + "name": "darwin", + }, + ], Array [ , Platform { @@ -190,6 +199,14 @@ it('checks shasums for each downloaded node build', async () => { "version": "", }, }, + Object { + "type": "return", + "value": Object { + "downloadName": "darwin:darwin-arm64:downloadName", + "downloadPath": "darwin:darwin-arm64:downloadPath", + "version": "", + }, + }, Object { "type": "return", "value": Object { @@ -216,6 +233,10 @@ it('checks shasums for each downloaded node build', async () => { "darwin:darwin-x64:downloadPath", "sha256", ], + Array [ + "darwin:darwin-arm64:downloadPath", + "sha256", + ], Array [ "win32:win32-x64:downloadPath", "sha256", @@ -238,6 +259,10 @@ it('checks shasums for each downloaded node build', async () => { "type": "return", "value": "valid shasum", }, + Object { + "type": "return", + "value": "valid shasum", + }, ], } `);