From 381a73b90e3723733951097a61680c255006e70b Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 9 May 2022 10:48:49 +0200 Subject: [PATCH] add licenses --- .licenses/npm/@actions/core.dep.yml | 2 +- .../npm/@actions/http-client-1.0.8.dep.yml | 32 ------------------- ...ent-1.0.11.dep.yml => http-client.dep.yml} | 0 __tests__/finder.test.ts | 22 ++++++------- dist/setup/index.js | 2 +- src/find-pypy.ts | 10 ++++-- src/find-python.ts | 14 ++++++-- src/install-pypy.ts | 3 +- src/install-python.ts | 13 ++++++-- src/setup-python.ts | 12 +++++-- 10 files changed, 52 insertions(+), 58 deletions(-) delete mode 100644 .licenses/npm/@actions/http-client-1.0.8.dep.yml rename .licenses/npm/@actions/{http-client-1.0.11.dep.yml => http-client.dep.yml} (100%) diff --git a/.licenses/npm/@actions/core.dep.yml b/.licenses/npm/@actions/core.dep.yml index b1152f59..6ef1a3d4 100644 --- a/.licenses/npm/@actions/core.dep.yml +++ b/.licenses/npm/@actions/core.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/core" -version: 1.2.6 +version: 1.7.0 type: npm summary: Actions core lib homepage: https://github.com/actions/toolkit/tree/main/packages/core diff --git a/.licenses/npm/@actions/http-client-1.0.8.dep.yml b/.licenses/npm/@actions/http-client-1.0.8.dep.yml deleted file mode 100644 index d18a24ff..00000000 --- a/.licenses/npm/@actions/http-client-1.0.8.dep.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: "@actions/http-client" -version: 1.0.8 -type: npm -summary: Actions Http Client -homepage: https://github.com/actions/http-client#readme -license: mit -licenses: -- sources: LICENSE - text: | - Actions Http Client for Node.js - - Copyright (c) GitHub, Inc. - - All rights reserved. - - MIT License - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT - LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -notices: [] diff --git a/.licenses/npm/@actions/http-client-1.0.11.dep.yml b/.licenses/npm/@actions/http-client.dep.yml similarity index 100% rename from .licenses/npm/@actions/http-client-1.0.11.dep.yml rename to .licenses/npm/@actions/http-client.dep.yml diff --git a/__tests__/finder.test.ts b/__tests__/finder.test.ts index ada16c51..ed0a4e46 100644 --- a/__tests__/finder.test.ts +++ b/__tests__/finder.test.ts @@ -34,7 +34,7 @@ describe('Finder tests', () => { it('Finds Python if it is installed', async () => { const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput'); - getBooleanInputSpy.mockImplementation((input) => false); + getBooleanInputSpy.mockImplementation(input => false); const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64'); await io.mkdirP(pythonDir); @@ -48,7 +48,7 @@ describe('Finder tests', () => { findSpy.mockImplementation(() => manifestData); const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput'); - getBooleanInputSpy.mockImplementation((input) => false); + getBooleanInputSpy.mockImplementation(input => false); const installSpy: jest.SpyInstance = jest.spyOn( installer, @@ -68,7 +68,7 @@ describe('Finder tests', () => { findSpy.mockImplementation(() => manifestData); const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput'); - getBooleanInputSpy.mockImplementation((input) => false); + getBooleanInputSpy.mockImplementation(input => false); const installSpy: jest.SpyInstance = jest.spyOn( installer, @@ -93,7 +93,7 @@ describe('Finder tests', () => { findSpy.mockImplementation(() => manifestData); const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput'); - getBooleanInputSpy.mockImplementation((input) => true); + getBooleanInputSpy.mockImplementation(input => true); const cnSpy: jest.SpyInstance = jest.spyOn(process.stdout, 'write'); cnSpy.mockImplementation(line => { @@ -102,14 +102,10 @@ describe('Finder tests', () => { }); const infoSpy: jest.SpyInstance = jest.spyOn(core, 'info'); - infoSpy.mockImplementation(() => { - - }); + infoSpy.mockImplementation(() => {}); const debugSpy: jest.SpyInstance = jest.spyOn(core, 'debug'); - debugSpy.mockImplementation(() => { - - }); + debugSpy.mockImplementation(() => {}); const pythonDir: string = path.join(toolDir, 'Python', '1.2.2', 'x64'); const expPath: string = path.join(toolDir, 'Python', '1.2.3', 'x64'); @@ -125,13 +121,15 @@ describe('Finder tests', () => { await io.mkdirP(pythonDir); await io.rmRF(expPath); - + fs.writeFileSync(`${pythonDir}.complete`, 'hello'); // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) await finder.useCpythonVersion('1.2', 'x64', true); expect(infoSpy).toHaveBeenCalledWith("Resolved as '1.2.3'"); - expect(infoSpy).toHaveBeenCalledWith('Version 1.2.3 was not found in the local cache'); + expect(infoSpy).toHaveBeenCalledWith( + 'Version 1.2.3 was not found in the local cache' + ); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${os.EOL}`); }); diff --git a/dist/setup/index.js b/dist/setup/index.js index e961f7e7..e593a59a 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -9752,7 +9752,7 @@ const utils_1 = __webpack_require__(163); function installPyPy(pypyVersion, pythonVersion, architecture, releases) { return __awaiter(this, void 0, void 0, function* () { let downloadDir; - releases !== null && releases !== void 0 ? releases : (releases = yield getAvailablePyPyVersions()); + releases = releases !== null && releases !== void 0 ? releases : (yield getAvailablePyPyVersions()); if (!releases || releases.length === 0) { throw new Error('No release was found in PyPy version.json'); } diff --git a/src/find-pypy.ts b/src/find-pypy.ts index a4124cc8..024c5666 100644 --- a/src/find-pypy.ts +++ b/src/find-pypy.ts @@ -41,12 +41,16 @@ export async function findPyPyVersion( architecture ); - if(releaseData) { - core.info(`Resolved as PyPy ${releaseData.resolvedPyPyVersion} with Python (${releaseData.resolvedPythonVersion})`); + if (releaseData) { + core.info( + `Resolved as PyPy ${releaseData.resolvedPyPyVersion} with Python (${releaseData.resolvedPythonVersion})` + ); pypyVersionSpec.pythonVersion = releaseData.resolvedPythonVersion; pypyVersionSpec.pypyVersion = releaseData.resolvedPyPyVersion; } else { - core.info(`Failed to resolve PyPy ${pypyVersionSpec.pypyVersion} with Python (${pypyVersionSpec.pythonVersion}) from manifest`); + core.info( + `Failed to resolve PyPy ${pypyVersionSpec.pypyVersion} with Python (${pypyVersionSpec.pythonVersion}) from manifest` + ); } } } diff --git a/src/find-python.ts b/src/find-python.ts index 76bd6a6f..88ebae5b 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -42,13 +42,21 @@ export async function useCpythonVersion( if (checkLatest) { manifest = await installer.getManifest(); - const resolvedVersion = (await installer.findReleaseFromManifest(semanticVersionSpec, architecture, manifest))?.version; + const resolvedVersion = ( + await installer.findReleaseFromManifest( + semanticVersionSpec, + architecture, + manifest + ) + )?.version; - if(resolvedVersion) { + if (resolvedVersion) { semanticVersionSpec = resolvedVersion; core.info(`Resolved as '${semanticVersionSpec}'`); } else { - core.info(`Failed to resolve version ${semanticVersionSpec} from manifest`); + core.info( + `Failed to resolve version ${semanticVersionSpec} from manifest` + ); } } diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 37e27a17..4c49e115 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -24,7 +24,8 @@ export async function installPyPy( ) { let downloadDir; - releases ??= await getAvailablePyPyVersions(); + releases = releases ?? (await getAvailablePyPyVersions()); + if (!releases || releases.length === 0) { throw new Error('No release was found in PyPy version.json'); } diff --git a/src/install-python.ts b/src/install-python.ts index 5fd9f988..6e5c8518 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -17,7 +17,7 @@ export async function findReleaseFromManifest( architecture: string, manifest: tc.IToolRelease[] | null ): Promise { - if(!manifest) { + if (!manifest) { manifest = await getManifest(); } @@ -32,8 +32,15 @@ export async function findReleaseFromManifest( } export function getManifest(): Promise { - core.debug(`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`); - return tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH); + core.debug( + `Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}` + ); + return tc.getManifestFromRepo( + MANIFEST_REPO_OWNER, + MANIFEST_REPO_NAME, + AUTH, + MANIFEST_REPO_BRANCH + ); } async function installPython(workingDirectory: string) { diff --git a/src/setup-python.ts b/src/setup-python.ts index a68b10d8..38459781 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -39,13 +39,21 @@ async function run() { let pythonVersion: string; const arch: string = core.getInput('architecture') || os.arch(); if (isPyPyVersion(version)) { - const installed = await finderPyPy.findPyPyVersion(version, arch, checkLatest); + const installed = await finderPyPy.findPyPyVersion( + version, + arch, + checkLatest + ); pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`; core.info( `Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})` ); } else { - const installed = await finder.useCpythonVersion(version, arch, checkLatest); + const installed = await finder.useCpythonVersion( + version, + arch, + checkLatest + ); pythonVersion = installed.version; core.info(`Successfully set up ${installed.impl} (${pythonVersion})`); }