Skip to content

Commit 3b8222b

Browse files
Parse multiline strings in main.ts
1 parent e7ee536 commit 3b8222b

File tree

8 files changed

+26
-56
lines changed

8 files changed

+26
-56
lines changed

.github/workflows/workflow.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
# Any matrix combinations with latest-nightly should add the appropriate release channel
9797
- plan:
9898
ghc: latest-nightly
99-
ghcup_release_channels: >
99+
ghcup_release_channels: |
100100
https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml
101101
102102
# Test deprecated release channel still works for now
@@ -108,10 +108,10 @@ jobs:
108108

109109
# Test ghcup release channels
110110
- os: ubuntu-latest
111-
ghcup_release_channels: >
112-
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml,
113-
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml,
114-
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.7.yaml,
111+
ghcup_release_channels: |
112+
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml
113+
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml
114+
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.7.yaml
115115
plan:
116116
ghc: "9.6.0.20230111"
117117
cabal: "3.8"

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,15 @@ Notes:
201201
- `Toggle` inputs are booleans that are false when set as the empty string and true when set to _anything_.
202202
However, to avoid confusion and for forward compatibility, it is still recommended to **only use value `true` to set a `Toggle` input.**
203203

204-
- Inputs that can take multiple values (like `ghcup-release-channels`) should be specified as a comma separated list, e.g.
204+
- Inputs that can take multiple values (like `ghcup-release-channels`) should be specified as a multiline list, e.g.
205205

206206
```yaml
207207
- uses: haskell-actions/setup@v2
208208
with:
209-
ghcup-release-channels: >
210-
https://example.com/channel1,
211-
https://example.com/channel2,
212-
https://example.com/channel3,
209+
ghcup-release-channels: |
210+
https://example.com/channel1
211+
https://example.com/channel2
212+
https://example.com/channel3
213213
```
214214

215215
## Outputs

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ inputs:
3232
# which are true as soon as they are not null.
3333
ghcup-release-channels:
3434
required: false
35-
description: "Release channel URLs to add to ghcup via `ghcup config add-release-channel`."
35+
description: "Release channel URLs to add to ghcup via `ghcup config add-release-channel`, as a multiline string"
3636
ghcup-release-channel:
3737
required: false
3838
description: "Deprecated by ghcup-release-channels."

dist/index.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -13675,7 +13675,7 @@ const getToggleInput = (name) => core.getInput(name) !== '';
1367513675
stackNoGlobal: getToggleInput('stack-no-global'),
1367613676
stackSetupGhc: getToggleInput('stack-setup-ghc'),
1367713677
cabalUpdate: core.getBooleanInput('cabal-update'),
13678-
ghcupReleaseChannels: core.getInput('ghcup-release-channels'),
13678+
ghcupReleaseChannels: core.getMultilineInput('ghcup-release-channels'),
1367913679
ghcupReleaseChannel: core.getInput('ghcup-release-channel'),
1368013680
disableMatcher: getToggleInput('disable-matcher')
1368113681
});
@@ -13791,15 +13791,6 @@ function releaseRevision(version, tool, os) {
1379113791
return result;
1379213792
}
1379313793
exports.releaseRevision = releaseRevision;
13794-
/**
13795-
* Parse a string as a comma-separated list.
13796-
*/
13797-
function parseCSV(val) {
13798-
return val
13799-
.split(',')
13800-
.map(s => s.trim())
13801-
.filter(s => s != '');
13802-
}
1380313794
function getOpts({ ghc, cabal, stack }, os, inputs) {
1380413795
core.debug(`Inputs are: ${JSON.stringify(inputs)}`);
1380513796
const stackNoGlobal = inputs.stackNoGlobal ?? false;
@@ -13809,9 +13800,9 @@ function getOpts({ ghc, cabal, stack }, os, inputs) {
1380913800
const matcherDisable = inputs.disableMatcher ?? false;
1381013801
if (inputs.ghcupReleaseChannel) {
1381113802
core.warning('ghcup-release-channel is deprecated in favor of ghcup-release-channels');
13812-
inputs.ghcupReleaseChannels = inputs.ghcupReleaseChannel;
13803+
inputs.ghcupReleaseChannels = [inputs.ghcupReleaseChannel];
1381313804
}
13814-
const ghcupReleaseChannels = parseCSV(inputs.ghcupReleaseChannels ?? '').map(v => {
13805+
const ghcupReleaseChannels = (inputs.ghcupReleaseChannels ?? []).map(v => {
1381513806
try {
1381613807
return new URL(v);
1381713808
}

lib/opts.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export type RawInputs = {
8282
stackNoGlobal?: boolean;
8383
stackSetupGhc?: boolean;
8484
cabalUpdate?: boolean;
85-
ghcupReleaseChannels?: string;
85+
ghcupReleaseChannels?: string[];
8686
ghcupReleaseChannel?: string;
8787
disableMatcher?: boolean;
8888
};

lib/opts.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ function releaseRevision(version, tool, os) {
102102
return result;
103103
}
104104
exports.releaseRevision = releaseRevision;
105-
/**
106-
* Parse a string as a comma-separated list.
107-
*/
108-
function parseCSV(val) {
109-
return val
110-
.split(',')
111-
.map(s => s.trim())
112-
.filter(s => s != '');
113-
}
114105
function getOpts({ ghc, cabal, stack }, os, inputs) {
115106
core.debug(`Inputs are: ${JSON.stringify(inputs)}`);
116107
const stackNoGlobal = inputs.stackNoGlobal ?? false;
@@ -120,9 +111,9 @@ function getOpts({ ghc, cabal, stack }, os, inputs) {
120111
const matcherDisable = inputs.disableMatcher ?? false;
121112
if (inputs.ghcupReleaseChannel) {
122113
core.warning('ghcup-release-channel is deprecated in favor of ghcup-release-channels');
123-
inputs.ghcupReleaseChannels = inputs.ghcupReleaseChannel;
114+
inputs.ghcupReleaseChannels = [inputs.ghcupReleaseChannel];
124115
}
125-
const ghcupReleaseChannels = parseCSV(inputs.ghcupReleaseChannels ?? '').map(v => {
116+
const ghcupReleaseChannels = (inputs.ghcupReleaseChannels ?? []).map(v => {
126117
try {
127118
return new URL(v);
128119
}

src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ run({
1111
stackNoGlobal: getToggleInput('stack-no-global'),
1212
stackSetupGhc: getToggleInput('stack-setup-ghc'),
1313
cabalUpdate: core.getBooleanInput('cabal-update'),
14-
ghcupReleaseChannels: core.getInput('ghcup-release-channels'),
14+
ghcupReleaseChannels: core.getMultilineInput('ghcup-release-channels'),
1515
ghcupReleaseChannel: core.getInput('ghcup-release-channel'),
1616
disableMatcher: getToggleInput('disable-matcher')
1717
});

src/opts.ts

+8-20
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ export function releaseRevision(version: string, tool: Tool, os: OS): string {
117117
return result;
118118
}
119119

120-
/**
121-
* Parse a string as a comma-separated list.
122-
*/
123-
function parseCSV(val: string): string[] {
124-
return val
125-
.split(',')
126-
.map(s => s.trim())
127-
.filter(s => s != '');
128-
}
129-
130120
export type RawInputs = {
131121
ghcVersion?: string;
132122
cabalVersion?: string;
@@ -135,7 +125,7 @@ export type RawInputs = {
135125
stackNoGlobal?: boolean;
136126
stackSetupGhc?: boolean;
137127
cabalUpdate?: boolean;
138-
ghcupReleaseChannels?: string;
128+
ghcupReleaseChannels?: string[];
139129
ghcupReleaseChannel?: string;
140130
disableMatcher?: boolean;
141131
};
@@ -157,18 +147,16 @@ export function getOpts(
157147
core.warning(
158148
'ghcup-release-channel is deprecated in favor of ghcup-release-channels'
159149
);
160-
inputs.ghcupReleaseChannels = inputs.ghcupReleaseChannel;
150+
inputs.ghcupReleaseChannels = [inputs.ghcupReleaseChannel];
161151
}
162152

163-
const ghcupReleaseChannels = parseCSV(inputs.ghcupReleaseChannels ?? '').map(
164-
v => {
165-
try {
166-
return new URL(v);
167-
} catch (e) {
168-
throw new TypeError(`Not a valid URL: ${v}`);
169-
}
153+
const ghcupReleaseChannels = (inputs.ghcupReleaseChannels ?? []).map(v => {
154+
try {
155+
return new URL(v);
156+
} catch (e) {
157+
throw new TypeError(`Not a valid URL: ${v}`);
170158
}
171-
);
159+
});
172160

173161
core.debug(`${stackNoGlobal}/${stackSetupGhc}/${stackEnable}`);
174162
const verInpt = {

0 commit comments

Comments
 (0)