Skip to content

Commit f89ad3b

Browse files
committed
Enable setting up of go on ppc64/ppc64le systems
1 parent 3041bf5 commit f89ad3b

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
@@ -8,6 +8,7 @@ import path from 'path';
88
import * as main from '../src/main';
99
import * as im from '../src/installer';
1010
import * as httpm from '@actions/http-client';
11+
import {getArch} from '../src/system';
1112

1213
import goJsonData from './data/golang-dl.json';
1314
import matchers from '../matchers.json';
@@ -32,6 +33,7 @@ describe('setup-go', () => {
3233
let getSpy: jest.SpyInstance;
3334
let platSpy: jest.SpyInstance;
3435
let archSpy: jest.SpyInstance;
36+
let endianSpy: jest.SpyInstance;
3537
let joinSpy: jest.SpyInstance;
3638
let dlSpy: jest.SpyInstance;
3739
let extractTarSpy: jest.SpyInstance;
@@ -71,6 +73,8 @@ describe('setup-go', () => {
7173
archSpy = jest.spyOn(osm, 'arch');
7274
archSpy.mockImplementation(() => os['arch']);
7375
execSpy = jest.spyOn(cp, 'execSync');
76+
endianSpy = jest.spyOn(osm, 'endianness');
77+
endianSpy.mockImplementation(() => os['endianness']);
7478

7579
// switch path join behaviour based on set os.platform
7680
joinSpy = jest.spyOn(path, 'join');
@@ -988,5 +992,17 @@ use .
988992
);
989993
}
990994
);
995+
996+
it('should return ppc64 when architecture is ppc64 and system is Big Endian', () => {
997+
endianSpy.mockReturnValue('BE');
998+
const result = getArch('ppc64');
999+
expect(result).toBe('ppc64');
1000+
});
1001+
1002+
it('should return ppc64le when architecture is ppc64 and system is Little Endian', () => {
1003+
endianSpy.mockReturnValue('LE');
1004+
const result = getArch('ppc64');
1005+
expect(result).toBe('ppc64le');
1006+
});
9911007
});
9921008
});

dist/setup/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88843,15 +88843,23 @@ function getPlatform() {
8884388843
exports.getPlatform = getPlatform;
8884488844
function getArch(arch) {
8884588845
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
88846-
// wants amd64, 386, arm64, armv61, ppc641e, s390x
88846+
// wants amd64, 386, arm64, armv6l, ppc64le, s390x
8884788847
// currently not supported by runner but future proofed mapping
8884888848
switch (arch) {
8884988849
case 'x64':
8885088850
arch = 'amd64';
8885188851
break;
88852-
// case 'ppc':
88853-
// arch = 'ppc64';
88854-
// break;
88852+
// In case of ppc64, further distinction is needed to determine the endianness
88853+
// of the host as it can either be ppc64(Big Endian) or ppc64le (Little Endian) to download
88854+
// the correct bundle.
88855+
case 'ppc64':
88856+
if (os_1.default.endianness() === 'LE') {
88857+
arch = 'ppc64le';
88858+
}
88859+
else {
88860+
arch = 'ppc64';
88861+
}
88862+
break;
8885588863
case 'x32':
8885688864
arch = '386';
8885788865
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)