Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testarm64 #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as tc from '@actions/tool-cache';
import * as cache from '@actions/cache';
import * as io from '@actions/io';

import fs from 'fs';
import path from 'path';
Expand All @@ -24,6 +25,7 @@ describe('main tests', () => {
let startGroupSpy: jest.SpyInstance;
let endGroupSpy: jest.SpyInstance;

let whichSpy: jest.SpyInstance;
let getExecOutputSpy: jest.SpyInstance;

let getNodeVersionFromFileSpy: jest.SpyInstance;
Expand Down Expand Up @@ -55,6 +57,8 @@ describe('main tests', () => {
inSpy = jest.spyOn(core, 'getInput');
inSpy.mockImplementation(name => inputs[name]);

whichSpy = jest.spyOn(io, 'which');

getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');

findSpy = jest.spyOn(tc, 'find');
Expand Down Expand Up @@ -140,6 +144,10 @@ describe('main tests', () => {
return {stdout: obj[command], stderr: '', exitCode: 0};
});

whichSpy.mockImplementation(cmd => {
return `some/${cmd}/path`;
});

await util.printEnvDetailsAndSetOutput();

expect(setOutputSpy).toHaveBeenCalledWith('node-version', obj['node']);
Expand Down
4 changes: 4 additions & 0 deletions __tests__/official-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ describe('setup-node', () => {
exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath);

whichSpy.mockImplementation(cmd => {
return `some/${cmd}/path`;
});

await main.run();

const expPath = path.join(toolPath, 'bin');
Expand Down
4 changes: 3 additions & 1 deletion dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83336,6 +83336,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0;
const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const io = __importStar(__nccwpck_require__(7436));
const fs_1 = __importDefault(__nccwpck_require__(7147));
const path_1 = __importDefault(__nccwpck_require__(1017));
function getNodeVersionFromFile(versionFilePath) {
Expand Down Expand Up @@ -83387,7 +83388,8 @@ function printEnvDetailsAndSetOutput() {
return __awaiter(this, void 0, void 0, function* () {
core.startGroup('Environment details');
const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
const output = yield getToolVersion(tool, ['--version']);
const pathTool = yield io.which(tool, false);
const output = pathTool ? yield getToolVersion(tool, ['--version']) : '';
return { tool, output };
}));
const tools = yield Promise.all(promises);
Expand Down
36 changes: 30 additions & 6 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93110,7 +93110,11 @@ class BaseDistribution {
const fileName = this.osPlat == 'win32'
? `node-v${version}-win-${osArch}`
: `node-v${version}-${this.osPlat}-${osArch}`;
const urlFileName = this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
const urlFileName = this.osPlat == 'win32'
? this.nodeInfo.arch === 'arm64'
? `${fileName}.zip`
: `${fileName}.7z`
: `${fileName}.tar.gz`;
const initialUrl = this.getDistributionUrl();
const url = `${initialUrl}/v${version}/${urlFileName}`;
return {
Expand Down Expand Up @@ -93194,10 +93198,23 @@ class BaseDistribution {
let extPath;
info = info || {}; // satisfy compiler, never null when reaches here
if (this.osPlat == 'win32') {
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
const extension = this.nodeInfo.arch === 'arm64' ? '.zip' : '.7z';
// Rename archive to add extension because after downloading
// archive does not contain extension type and it leads to some issues
// on Windows runners without PowerShell Core.
//
// For default PowerShell Windows it should contain extension type to unpack it.
if (extension === '.zip') {
const renamedArchive = `${downloadPath}.zip`;
fs_1.default.renameSync(downloadPath, renamedArchive);
extPath = yield tc.extractZip(renamedArchive);
}
else {
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
}
// 7z extracts to folder matching file name
const nestedPath = path.join(extPath, path.basename(info.fileName, '.7z'));
const nestedPath = path.join(extPath, path.basename(info.fileName, extension));
if (fs_1.default.existsSync(nestedPath)) {
extPath = nestedPath;
}
Expand Down Expand Up @@ -93229,7 +93246,12 @@ class BaseDistribution {
dataFileName = `osx-${osArch}-tar`;
break;
case 'win32':
dataFileName = `win-${osArch}-exe`;
if (this.nodeInfo.arch === 'arm64') {
dataFileName = `win-${osArch}-zip`;
}
else {
dataFileName = `win-${osArch}-exe`;
}
break;
default:
throw new Error(`Unexpected OS '${this.osPlat}'`);
Expand Down Expand Up @@ -93784,6 +93806,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0;
const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const io = __importStar(__nccwpck_require__(7436));
const fs_1 = __importDefault(__nccwpck_require__(7147));
const path_1 = __importDefault(__nccwpck_require__(1017));
function getNodeVersionFromFile(versionFilePath) {
Expand Down Expand Up @@ -93835,7 +93858,8 @@ function printEnvDetailsAndSetOutput() {
return __awaiter(this, void 0, void 0, function* () {
core.startGroup('Environment details');
const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
const output = yield getToolVersion(tool, ['--version']);
const pathTool = yield io.which(tool, false);
const output = pathTool ? yield getToolVersion(tool, ['--version']) : '';
return { tool, output };
}));
const tools = yield Promise.all(promises);
Expand Down
30 changes: 25 additions & 5 deletions src/distributions/base-distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ export default abstract class BaseDistribution {
? `node-v${version}-win-${osArch}`
: `node-v${version}-${this.osPlat}-${osArch}`;
const urlFileName: string =
this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
this.osPlat == 'win32'
? this.nodeInfo.arch === 'arm64'
? `${fileName}.zip`
: `${fileName}.7z`
: `${fileName}.tar.gz`;
const initialUrl = this.getDistributionUrl();
const url = `${initialUrl}/v${version}/${urlFileName}`;

Expand Down Expand Up @@ -215,12 +219,24 @@ export default abstract class BaseDistribution {
let extPath: string;
info = info || ({} as INodeVersionInfo); // satisfy compiler, never null when reaches here
if (this.osPlat == 'win32') {
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
extPath = await tc.extract7z(downloadPath, undefined, _7zPath);
const extension = this.nodeInfo.arch === 'arm64' ? '.zip' : '.7z';
// Rename archive to add extension because after downloading
// archive does not contain extension type and it leads to some issues
// on Windows runners without PowerShell Core.
//
// For default PowerShell Windows it should contain extension type to unpack it.
if (extension === '.zip') {
const renamedArchive = `${downloadPath}.zip`;
fs.renameSync(downloadPath, renamedArchive);
extPath = await tc.extractZip(renamedArchive);
} else {
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
extPath = await tc.extract7z(downloadPath, undefined, _7zPath);
}
// 7z extracts to folder matching file name
const nestedPath = path.join(
extPath,
path.basename(info.fileName, '.7z')
path.basename(info.fileName, extension)
);
if (fs.existsSync(nestedPath)) {
extPath = nestedPath;
Expand Down Expand Up @@ -260,7 +276,11 @@ export default abstract class BaseDistribution {
dataFileName = `osx-${osArch}-tar`;
break;
case 'win32':
dataFileName = `win-${osArch}-exe`;
if (this.nodeInfo.arch === 'arm64') {
dataFileName = `win-${osArch}-zip`;
} else {
dataFileName = `win-${osArch}-exe`;
}
break;
default:
throw new Error(`Unexpected OS '${this.osPlat}'`);
Expand Down
4 changes: 3 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as io from '@actions/io';

import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -63,7 +64,8 @@ export async function printEnvDetailsAndSetOutput() {
core.startGroup('Environment details');

const promises = ['node', 'npm', 'yarn'].map(async tool => {
const output = await getToolVersion(tool, ['--version']);
const pathTool = await io.which(tool, false);
const output = pathTool ? await getToolVersion(tool, ['--version']) : '';

return {tool, output};
});
Expand Down
Loading