Skip to content

Commit

Permalink
Action: Better error when a platform is not available for a GCC version.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosperate committed Aug 2, 2024
1 parent 485c958 commit 459e504
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ section.
- `4.8-2014-q3`    `4.8-2014-q2`   `4.8-2014-q1`   `4.8-2013-q4`
- `4.7-2014-q2`    `4.7-2013-q3`   `4.7-2013-q2`   `4.7-2013-q1`

Older GCC version might not have releases for all operating system
architectures, specifically `arm64`.
This table shows the first release compatible with each OS architecture.

| | x86_64 | arm64 |
|---------|-------------|------------------------|
| Linux | All version | From version 9-2019-q4 |
| macOS | All version | From version 12.2.Rel1 |
| Windows | All version | Not supported |

## Advanced options

Expand Down
4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ test('test fetching urls for invalid platforms', () => {
// macOS arm64 starts at 12.2.Rel1
expect(() => {
gcc.distributionUrl('11.3.Rel1', 'darwin', 'arm64');
}).toThrow('invalid platform mac_arm64');
}).toThrow('invalid platform mac_arm64 for GCC version 11.3.Rel1');

// Linux aarch64 starts at 9-2019-q4
expect(() => {
gcc.distributionUrl('8-2019-q3', 'linux', 'arm64');
}).toThrow('invalid platform linux_aarch64');
}).toThrow('invalid platform linux_aarch64 for GCC version 8-2019-q3');

// Invalid release id
expect(() => {
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ function distributionUrl(version, platform, arch) {
throw new Error(`invalid GCC version ${version}. Available: ${availableVersions()}`);
}
if (!versions[version].hasOwnProperty(osName)) {
throw new Error(`invalid platform ${osName}.`);
throw new Error(`invalid platform ${osName} for GCC version ${version}.\n` +
'The action README has the list of available versions and platforms.');
}
return versions[version][osName];
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/gcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,10 @@ export function distributionUrl(version: string, platform: string, arch: string)
throw new Error(`invalid GCC version ${version}. Available: ${availableVersions()}`);
}
if (!versions[version].hasOwnProperty(osName)) {
throw new Error(`invalid platform ${osName}.`);
throw new Error(
`invalid platform ${osName} for GCC version ${version}.\n` +
'The action README has the list of available versions and platforms.'
);
}
return versions[version][osName];
}
Expand Down

0 comments on commit 459e504

Please sign in to comment.