Skip to content

Commit 9474567

Browse files
committed
Enable setting up of go on ppc64/ppc64le systems
1 parent 41dfa10 commit 9474567

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

__tests__/setup-go.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import osm, {type} from 'os';
77
import path from 'path';
88
import * as main from '../src/main';
99
import * as im from '../src/installer';
10+
import {getArch} from '../src/system';
1011

1112
import goJsonData from './data/golang-dl.json';
1213
import matchers from '../matchers.json';
@@ -31,6 +32,7 @@ describe('setup-go', () => {
3132
let getSpy: jest.SpyInstance;
3233
let platSpy: jest.SpyInstance;
3334
let archSpy: jest.SpyInstance;
35+
let endianSpy: jest.SpyInstance;
3436
let joinSpy: jest.SpyInstance;
3537
let dlSpy: jest.SpyInstance;
3638
let extractTarSpy: jest.SpyInstance;
@@ -69,6 +71,8 @@ describe('setup-go', () => {
6971
archSpy = jest.spyOn(osm, 'arch');
7072
archSpy.mockImplementation(() => os['arch']);
7173
execSpy = jest.spyOn(cp, 'execSync');
74+
endianSpy = jest.spyOn(osm, 'endianness');
75+
endianSpy.mockImplementation(() => os['endianness']);
7276

7377
// switch path join behaviour based on set os.platform
7478
joinSpy = jest.spyOn(path, 'join');
@@ -965,5 +969,17 @@ use .
965969
);
966970
}
967971
);
972+
973+
it('should return ppc64 when architecture is ppc64 and system is Big Endian', () => {
974+
endianSpy.mockReturnValue('BE');
975+
const result = getArch('ppc64');
976+
expect(result).toBe('ppc64');
977+
});
978+
979+
it('should return ppc64le when architecture is ppc64 and system is Little Endian', () => {
980+
endianSpy.mockReturnValue('LE');
981+
const result = getArch('ppc64');
982+
expect(result).toBe('ppc64le');
983+
});
968984
});
969985
});

dist/setup/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88815,15 +88815,23 @@ function getPlatform() {
8881588815
exports.getPlatform = getPlatform;
8881688816
function getArch(arch) {
8881788817
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
88818-
// wants amd64, 386, arm64, armv61, ppc641e, s390x
88818+
// wants amd64, 386, arm64, armv6l, ppc64le, s390x
8881988819
// currently not supported by runner but future proofed mapping
8882088820
switch (arch) {
8882188821
case 'x64':
8882288822
arch = 'amd64';
8882388823
break;
88824-
// case 'ppc':
88825-
// arch = 'ppc64';
88826-
// break;
88824+
// In case of ppc64, further distinction is needed to determine the endianness
88825+
// of the host as it can either be ppc64(Big Endian) or ppc64le (Little Endian) to download
88826+
// the correct bundle.
88827+
case 'ppc64':
88828+
if (os_1.default.endianness() === 'LE') {
88829+
arch = 'ppc64le';
88830+
}
88831+
else {
88832+
arch = 'ppc64';
88833+
}
88834+
break;
8882788835
case 'x32':
8882888836
arch = '386';
8882988837
break;

src/system.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ export function getPlatform(): string {
1818
export function getArch(arch: string): string {
1919
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
2020

21-
// wants amd64, 386, arm64, armv61, ppc641e, s390x
21+
// wants amd64, 386, arm64, armv6l, ppc64le, s390x
2222
// currently not supported by runner but future proofed mapping
2323
switch (arch) {
2424
case 'x64':
2525
arch = 'amd64';
2626
break;
27-
// case 'ppc':
28-
// arch = 'ppc64';
29-
// break;
27+
// In case of ppc64, further distinction is needed to determine the endianness
28+
// of the host as it can either be ppc64(Big Endian) or ppc64le (Little Endian) to download
29+
// the correct bundle.
30+
case 'ppc64':
31+
if (os.endianness() === 'LE') {
32+
arch = 'ppc64le';
33+
} else {
34+
arch = 'ppc64';
35+
}
36+
break;
3037
case 'x32':
3138
arch = '386';
3239
break;

0 commit comments

Comments
 (0)