Skip to content

Commit 27aa12b

Browse files
Parse multiline strings in main.ts
1 parent 0bcb5a2 commit 27aa12b

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
@@ -98,7 +98,7 @@ jobs:
9898
# Any matrix combinations with latest-nightly should add the appropriate release channel
9999
- plan:
100100
ghc: latest-nightly
101-
ghcup_release_channels: >
101+
ghcup_release_channels: |
102102
https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml
103103
104104
# Test deprecated release channel still works for now
@@ -110,10 +110,10 @@ jobs:
110110

111111
# Test ghcup release channels
112112
- os: ubuntu-latest
113-
ghcup_release_channels: >
114-
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml,
115-
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml,
116-
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.7.yaml,
113+
ghcup_release_channels: |
114+
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml
115+
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml
116+
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.7.yaml
117117
plan:
118118
ghc: "9.6.0.20230111"
119119
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
@@ -13639,7 +13639,7 @@ const getToggleInput = (name) => core.getInput(name) !== '';
1363913639
stackNoGlobal: getToggleInput('stack-no-global'),
1364013640
stackSetupGhc: getToggleInput('stack-setup-ghc'),
1364113641
cabalUpdate: core.getBooleanInput('cabal-update'),
13642-
ghcupReleaseChannels: core.getInput('ghcup-release-channels'),
13642+
ghcupReleaseChannels: core.getMultilineInput('ghcup-release-channels'),
1364313643
ghcupReleaseChannel: core.getInput('ghcup-release-channel'),
1364413644
disableMatcher: getToggleInput('disable-matcher')
1364513645
});
@@ -13755,15 +13755,6 @@ function releaseRevision(version, tool, os) {
1375513755
return result;
1375613756
}
1375713757
exports.releaseRevision = releaseRevision;
13758-
/**
13759-
* Parse a string as a comma-separated list.
13760-
*/
13761-
function parseCSV(val) {
13762-
return val
13763-
.split(',')
13764-
.map(s => s.trim())
13765-
.filter(s => s != '');
13766-
}
1376713758
function getOpts({ ghc, cabal, stack }, os, inputs) {
1376813759
core.debug(`Inputs are: ${JSON.stringify(inputs)}`);
1376913760
const stackNoGlobal = inputs.stackNoGlobal ?? false;
@@ -13773,9 +13764,9 @@ function getOpts({ ghc, cabal, stack }, os, inputs) {
1377313764
const matcherDisable = inputs.disableMatcher ?? false;
1377413765
if (inputs.ghcupReleaseChannel) {
1377513766
core.warning('ghcup-release-channel is deprecated in favor of ghcup-release-channels');
13776-
inputs.ghcupReleaseChannels = inputs.ghcupReleaseChannel;
13767+
inputs.ghcupReleaseChannels = [inputs.ghcupReleaseChannel];
1377713768
}
13778-
const ghcupReleaseChannels = parseCSV(inputs.ghcupReleaseChannels ?? '').map(v => {
13769+
const ghcupReleaseChannels = (inputs.ghcupReleaseChannels ?? []).map(v => {
1377913770
try {
1378013771
return new URL(v);
1378113772
}

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)