Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 8c47402

Browse files
committed
Disable commands when choco installing and use old versions
1 parent 7b9c49b commit 8c47402

File tree

5 files changed

+26
-39
lines changed

5 files changed

+26
-39
lines changed

README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121

122122
## Version Support
123123

124-
**GHC on Mac/Ubuntu:**
124+
**GHC:**
125125

126126
- `latest` (default, recommended)
127127
- `8.10.1` `8.10`
@@ -141,15 +141,6 @@ jobs:
141141
- `8.0.2` `8.0`
142142
- `7.10.3` `7.10`
143143

144-
**GHC on Windows:**
145-
146-
- `latest` (default, recommended)
147-
- `8.10.2.2`
148-
- `8.10.1.1`
149-
- `8.8.4.1`
150-
- `8.8.3.2`
151-
- `8.8.2.1`
152-
153144
Suggestion: Try to support the three latest major versions of GHC.
154145

155146
**Cabal:**

dist/index.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ const supported_versions = __importStar(__webpack_require__(447));
877877
function getDefaults() {
878878
const inpts = js_yaml_1.safeLoad(fs_1.readFileSync(__webpack_require__.ab + "action.yml", 'utf8')).inputs;
879879
const mkVersion = (v, vs) => ({
880-
version: resolve(inpts[v].default, vs, v),
880+
version: resolve(inpts[v].default, vs),
881881
supported: vs
882882
});
883883
return {
@@ -887,12 +887,8 @@ function getDefaults() {
887887
};
888888
}
889889
exports.getDefaults = getDefaults;
890-
function resolve(version, supported, type) {
890+
function resolve(version, supported) {
891891
var _a;
892-
// Hard code default windows version to get around ghc-choco using the old add-path commands. Other cli tools don't have this issue and don't have the 8.10.2.2 version
893-
if (process.platform === 'win32' && type === 'ghc-version') {
894-
return '8.10.2.2';
895-
}
896892
return version === 'latest'
897893
? supported[0]
898894
: (_a = supported.find(v => v.startsWith(version))) !== null && _a !== void 0 ? _a : version;
@@ -919,17 +915,17 @@ function getOpts({ ghc, cabal, stack }) {
919915
const opts = {
920916
ghc: {
921917
raw: verInpt.ghc,
922-
resolved: resolve(verInpt.ghc, ghc.supported, 'ghc-version'),
918+
resolved: resolve(verInpt.ghc, ghc.supported),
923919
enable: !stackNoGlobal
924920
},
925921
cabal: {
926922
raw: verInpt.cabal,
927-
resolved: resolve(verInpt.cabal, cabal.supported, 'cabal-version'),
923+
resolved: resolve(verInpt.cabal, cabal.supported),
928924
enable: !stackNoGlobal
929925
},
930926
stack: {
931927
raw: verInpt.stack,
932-
resolved: resolve(verInpt.stack, stack.supported, 'stack-version)'),
928+
resolved: resolve(verInpt.stack, stack.supported),
933929
enable: stackEnable,
934930
setup: core.getInput('stack-setup-ghc') !== ''
935931
}
@@ -4291,7 +4287,7 @@ function escapeProperty(s) {
42914287
/***/ 447:
42924288
/***/ (function(module) {
42934289

4294-
module.exports = {"ghc":["8.10.2","8.10.2.2","8.10.1","8.10.1.1","8.8.4","8.8.4.1","8.8.3","8.8.3.2","8.8.2","8.8.2.1","8.8.1","8.6.5","8.6.4","8.6.3","8.6.2","8.6.1","8.4.4","8.4.3","8.4.2","8.4.1","8.2.2","8.0.2","7.10.3"],"cabal":["3.2.0.0","3.0.0.0","2.4.1.0","2.4.0.0","2.2.0.0"],"stack":["2.3.1","2.1.3","2.1.1","1.9.3","1.9.1","1.7.1","1.6.5","1.6.3","1.6.1","1.5.1","1.5.0","1.4.0","1.3.2","1.3.0","1.2.0"]};
4290+
module.exports = {"ghc":["8.10.2","8.10.1","8.8.4","8.8.3","8.8.2","8.8.1","8.6.5","8.6.4","8.6.3","8.6.2","8.6.1","8.4.4","8.4.3","8.4.2","8.4.1","8.2.2","8.0.2","7.10.3"],"cabal":["3.2.0.0","3.0.0.0","2.4.1.0","2.4.0.0","2.2.0.0"],"stack":["2.3.1","2.1.3","2.1.1","1.9.3","1.9.1","1.7.1","1.6.5","1.6.3","1.6.1","1.5.1","1.5.0","1.4.0","1.3.2","1.3.0","1.2.0"]};
42954291

42964292
/***/ }),
42974293

@@ -11171,6 +11167,8 @@ async function apt(tool, version) {
1117111167
}
1117211168
async function choco(tool, version) {
1117311169
core.info(`Attempting to install ${tool} ${version} using chocolatey`);
11170+
// Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this.
11171+
console.log('::stop-commands::SetupHaskellStopCommands');
1117411172
await exec_1.exec('powershell', [
1117511173
'choco',
1117611174
'install',
@@ -11183,8 +11181,11 @@ async function choco(tool, version) {
1118311181
], {
1118411182
ignoreReturnCode: true
1118511183
});
11186-
// Add to path automatically because it does not add until the end of the step.
11187-
core.addPath(getChocoPath(tool, version));
11184+
console.log('::SetupHaskellStopCommands::'); // Re-enable command execution
11185+
// Add GHC to path automatically because it does not add until the end of the step and we check the path.
11186+
if (tool == 'ghc') {
11187+
core.addPath(getChocoPath(tool, version));
11188+
}
1118811189
}
1118911190
async function ghcupBin(os) {
1119011191
const v = '0.1.8';

src/installer.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ async function apt(tool: Tool, version: string): Promise<void> {
162162

163163
async function choco(tool: Tool, version: string): Promise<void> {
164164
core.info(`Attempting to install ${tool} ${version} using chocolatey`);
165-
165+
// Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this.
166+
console.log('::stop-commands::SetupHaskellStopCommands');
166167
await exec(
167168
'powershell',
168169
[
@@ -179,8 +180,11 @@ async function choco(tool: Tool, version: string): Promise<void> {
179180
ignoreReturnCode: true
180181
}
181182
);
182-
// Add to path automatically because it does not add until the end of the step.
183-
core.addPath(getChocoPath(tool, version));
183+
console.log('::SetupHaskellStopCommands::'); // Re-enable command execution
184+
// Add GHC to path automatically because it does not add until the end of the step and we check the path.
185+
if (tool == 'ghc') {
186+
core.addPath(getChocoPath(tool, version));
187+
}
184188
}
185189

186190
async function ghcupBin(os: OS): Promise<string> {

src/opts.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function getDefaults(): Defaults {
2828
).inputs;
2929

3030
const mkVersion = (v: string, vs: string[]): Version => ({
31-
version: resolve(inpts[v].default, vs, v),
31+
version: resolve(inpts[v].default, vs),
3232
supported: vs
3333
});
3434

@@ -39,11 +39,7 @@ export function getDefaults(): Defaults {
3939
};
4040
}
4141

42-
function resolve(version: string, supported: string[], type: string): string {
43-
// Hard code default windows version to get around ghc-choco using the old add-path commands. Other cli tools don't have this issue and don't have the 8.10.2.2 version
44-
if (process.platform === 'win32' && type === 'ghc-version') {
45-
return '8.10.2.2';
46-
}
42+
function resolve(version: string, supported: string[]): string {
4743
return version === 'latest'
4844
? supported[0]
4945
: supported.find(v => v.startsWith(version)) ?? version;
@@ -75,17 +71,17 @@ export function getOpts({ghc, cabal, stack}: Defaults): Options {
7571
const opts: Options = {
7672
ghc: {
7773
raw: verInpt.ghc,
78-
resolved: resolve(verInpt.ghc, ghc.supported, 'ghc-version'),
74+
resolved: resolve(verInpt.ghc, ghc.supported),
7975
enable: !stackNoGlobal
8076
},
8177
cabal: {
8278
raw: verInpt.cabal,
83-
resolved: resolve(verInpt.cabal, cabal.supported, 'cabal-version'),
79+
resolved: resolve(verInpt.cabal, cabal.supported),
8480
enable: !stackNoGlobal
8581
},
8682
stack: {
8783
raw: verInpt.stack,
88-
resolved: resolve(verInpt.stack, stack.supported, 'stack-version)'),
84+
resolved: resolve(verInpt.stack, stack.supported),
8985
enable: stackEnable,
9086
setup: core.getInput('stack-setup-ghc') !== ''
9187
}

src/versions.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{
22
"ghc": [
33
"8.10.2",
4-
"8.10.2.2",
54
"8.10.1",
6-
"8.10.1.1",
75
"8.8.4",
8-
"8.8.4.1",
96
"8.8.3",
10-
"8.8.3.2",
117
"8.8.2",
12-
"8.8.2.1",
138
"8.8.1",
149
"8.6.5",
1510
"8.6.4",

0 commit comments

Comments
 (0)