From 7e99af0127bfb35175a8240644480c4fb6025d8a Mon Sep 17 00:00:00 2001 From: mahabaleshwars Date: Tue, 20 Feb 2024 17:28:38 +0530 Subject: [PATCH] microsoft test file update and tool-version test file --- .DS_Store | Bin 0 -> 6148 bytes .github/.tool-versions | 1 + .github/workflows/e2e-versions.yml | 12 +++-- __tests__/data/microsoft.json | 6 +++ .../distributors/microsoft-installer.test.ts | 50 +++++++++++++++++- package.json | 1 - 6 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 .DS_Store create mode 100644 .github/.tool-versions diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d41ef3971195d22e202bbaee03da19a87032c371 GIT binary patch literal 6148 zcmeHKF>V4u473vpqBN8#_Y3@Bh2RBw04O1;B2fVSRlJL*F=M*`UDA;TjV15wdOf?^ zDb8mz^TlyHH=CK+6i&1ghp};=KC-8ZI1r9A_I7};ZT-C+W&a)^_k|2FzpnZF&yU^i zhubnKAO)m=6p#W^;EoDZah<;2@k|{h1*E`ZD8TPSgA;qLiOx_LDpUN?JnC?2=t{1)lvJyD|+kOH>~Jm+%8 z`oDtz(f{9)w2}f+;Gq=o$?|=})BjvmKa+u$2GbIx!Y=0U*_u;w@Avo Z#yR$T;gA?~#Dfmh&j59iNrC@X-~wMc6?Fgr literal 0 HcmV?d00001 diff --git a/.github/.tool-versions b/.github/.tool-versions new file mode 100644 index 00000000..c2893147 --- /dev/null +++ b/.github/.tool-versions @@ -0,0 +1 @@ +java jdk17.0.7 \ No newline at end of file diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 1f9d6e77..6e025f25 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -288,6 +288,7 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['temurin', 'microsoft', 'corretto'] + java-version-file-array: [.java-version, .tool-versions] steps: - name: Checkout uses: actions/checkout@v4 @@ -300,7 +301,7 @@ jobs: with: distribution: ${{ matrix.distribution }} java-version: 11 - java-version-file: '.java-version' + java-version-file: './${{ matrix.java-version-file-array }}' - name: Verify Java run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" shell: bash @@ -313,6 +314,7 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto'] + java-version-file-array: [.java-version, .tool-versions] steps: - name: Checkout uses: actions/checkout@v4 @@ -324,7 +326,7 @@ jobs: id: setup-java with: distribution: ${{ matrix.distribution }} - java-version-file: '.java-version' + java-version-file: './${{ matrix.java-version-file-array }}' - name: Verify Java run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" shell: bash @@ -337,6 +339,7 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['adopt', 'adopt-openj9', 'zulu'] + java-version-file-array: [.java-version, .tool-versions] steps: - name: Checkout uses: actions/checkout@v4 @@ -348,7 +351,7 @@ jobs: id: setup-java with: distribution: ${{ matrix.distribution }} - java-version-file: '.java-version' + java-version-file: './${{ matrix.java-version-file-array }}' - name: Verify Java run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" shell: bash @@ -361,6 +364,7 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['adopt', 'zulu', 'liberica'] + java-version-file-array: [.java-version, .tool-versions] steps: - name: Checkout uses: actions/checkout@v4 @@ -372,7 +376,7 @@ jobs: id: setup-java with: distribution: ${{ matrix.distribution }} - java-version-file: '.java-version' + java-version-file: './${{ matrix.java-version-file-array }}' - name: Verify Java run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" shell: bash diff --git a/__tests__/data/microsoft.json b/__tests__/data/microsoft.json index d9136311..18e67d9d 100644 --- a/__tests__/data/microsoft.json +++ b/__tests__/data/microsoft.json @@ -70,6 +70,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.7-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-aarch64.zip" } ] }, diff --git a/__tests__/distributors/microsoft-installer.test.ts b/__tests__/distributors/microsoft-installer.test.ts index 011df1b1..dbb1d2b8 100644 --- a/__tests__/distributors/microsoft-installer.test.ts +++ b/__tests__/distributors/microsoft-installer.test.ts @@ -89,6 +89,30 @@ describe('findPackageForDownload', () => { expect(result.url).toBe(url); }); + it.each([ + ['amd64', 'x64'], + ['arm64', 'aarch64'] + ])( + 'defaults to os.arch(): %s mapped to distro arch: %s', + async (osArch: string, distroArch: string) => { + jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest.spyOn(os, 'platform').mockReturnValue('darwin'); + + const version = '17'; + const distro = new MicrosoftDistributions({ + version, + architecture: '', // to get default value + packageType: 'jdk', + checkLatest: false + }); + + const result = await distro['findPackageForDownload'](version); + const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macos-${distroArch}.tar.gz`; + + expect(result.url).toBe(expectedUrl); + } + ); + it.each([ ['amd64', 'x64'], ['arm64', 'aarch64'] @@ -108,11 +132,35 @@ describe('findPackageForDownload', () => { const result = await distro['findPackageForDownload'](version); const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-${distroArch}.tar.gz`; - + expect(result.url).toBe(expectedUrl); } ); + it.each([ + ['amd64', 'x64'], + ['arm64', 'aarch64'] + ])( + 'defaults to os.arch(): %s mapped to distro arch: %s', + async (osArch: string, distroArch: string) => { + jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest.spyOn(os, 'platform').mockReturnValue('win32'); + + const version = '17'; + const distro = new MicrosoftDistributions({ + version, + architecture: '', // to get default value + packageType: 'jdk', + checkLatest: false + }); + + const result = await distro['findPackageForDownload'](version); + const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-${distroArch}.zip`; + + expect(result.url).toBe(expectedUrl); + } + ); + it('should throw an error', async () => { await expect(distribution['findPackageForDownload']('8')).rejects.toThrow( /Could not find satisfied version for SemVer */ diff --git a/package.json b/package.json index 3f6eb92f..dba2d047 100644 --- a/package.json +++ b/package.json @@ -57,5 +57,4 @@ "url": "https://github.com/actions/setup-java/issues" }, "homepage": "https://github.com/actions/setup-java#readme" - }