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

Enable setting up of go on ppc64/ppc64le systems. #518

Open
wants to merge 1 commit 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
16 changes: 16 additions & 0 deletions __tests__/setup-go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import path from 'path';
import * as main from '../src/main';
import * as im from '../src/installer';
import * as httpm from '@actions/http-client';
import {getArch} from '../src/system';

import goJsonData from './data/golang-dl.json';
import matchers from '../matchers.json';
Expand All @@ -32,6 +33,7 @@ describe('setup-go', () => {
let getSpy: jest.SpyInstance;
let platSpy: jest.SpyInstance;
let archSpy: jest.SpyInstance;
let endianSpy: jest.SpyInstance;
let joinSpy: jest.SpyInstance;
let dlSpy: jest.SpyInstance;
let extractTarSpy: jest.SpyInstance;
Expand Down Expand Up @@ -71,6 +73,8 @@ describe('setup-go', () => {
archSpy = jest.spyOn(osm, 'arch');
archSpy.mockImplementation(() => os['arch']);
execSpy = jest.spyOn(cp, 'execSync');
endianSpy = jest.spyOn(osm, 'endianness');
endianSpy.mockImplementation(() => os['endianness']);

// switch path join behaviour based on set os.platform
joinSpy = jest.spyOn(path, 'join');
Expand Down Expand Up @@ -988,5 +992,17 @@ use .
);
}
);

it('should return ppc64 when architecture is ppc64 and system is Big Endian', () => {
endianSpy.mockReturnValue('BE');
const result = getArch('ppc64');
expect(result).toBe('ppc64');
});

it('should return ppc64le when architecture is ppc64 and system is Little Endian', () => {
endianSpy.mockReturnValue('LE');
const result = getArch('ppc64');
expect(result).toBe('ppc64le');
});
});
});
16 changes: 12 additions & 4 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88843,15 +88843,23 @@ function getPlatform() {
exports.getPlatform = getPlatform;
function getArch(arch) {
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
// wants amd64, 386, arm64, armv61, ppc641e, s390x
// wants amd64, 386, arm64, armv6l, ppc64le, s390x
// currently not supported by runner but future proofed mapping
switch (arch) {
case 'x64':
arch = 'amd64';
break;
// case 'ppc':
// arch = 'ppc64';
// break;
// In case of ppc64, further distinction is needed to determine the endianness
// of the host as it can either be ppc64(Big Endian) or ppc64le (Little Endian) to download
// the correct bundle.
case 'ppc64':
if (os_1.default.endianness() === 'LE') {
arch = 'ppc64le';
}
else {
arch = 'ppc64';
}
break;
case 'x32':
arch = '386';
break;
Expand Down
15 changes: 11 additions & 4 deletions src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@ export function getPlatform(): string {
export function getArch(arch: string): string {
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.

// wants amd64, 386, arm64, armv61, ppc641e, s390x
// wants amd64, 386, arm64, armv6l, ppc64le, s390x
// currently not supported by runner but future proofed mapping
switch (arch) {
case 'x64':
arch = 'amd64';
break;
// case 'ppc':
// arch = 'ppc64';
// break;
// In case of ppc64, further distinction is needed to determine the endianness
// of the host as it can either be ppc64(Big Endian) or ppc64le (Little Endian) to download
// the correct bundle.
case 'ppc64':
if (os.endianness() === 'LE') {
arch = 'ppc64le';
} else {
arch = 'ppc64';
}
break;
case 'x32':
arch = '386';
break;
Expand Down