Skip to content

Commit 487fb79

Browse files
Support latest-nightly
1 parent 14547ab commit 487fb79

File tree

9 files changed

+67
-30
lines changed

9 files changed

+67
-30
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ E.g., `8.10` will be resolved to `8.10.7`, and so will `8`.
236236

237237
**GHC:**
238238

239+
- `latest-nightly`
239240
- `latest` (default)
240241
- `9.6.2` `9.6`
241242
- `9.6.1`

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: 'GitHub'
44
inputs:
55
ghc-version:
66
required: false
7-
description: 'Version of GHC to use. If set to "latest", it will always get the latest stable version.'
7+
description: 'Version of GHC to use. If set to "latest", it will always get the latest stable version. If set to "latest-nightly", it will always get the latest nightly version of GHC'
88
default: 'latest'
99
cabal-version:
1010
required: false

dist/index.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13400,12 +13400,14 @@ async function installTool(tool, version, os) {
1340013400
}
1340113401
switch (os) {
1340213402
case 'linux':
13403-
if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) {
13404-
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
13405-
// Atm, I do not know how to check whether we are on ubuntu-20.04.
13406-
// So, ignore the error.
13407-
// if (!(await aptLibCurses5())) break;
13408-
await aptLibNCurses5();
13403+
if (tool === 'ghc') {
13404+
if (version !== 'latest-nightly' && (0, compare_versions_1.compareVersions)('8.3', version)) {
13405+
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
13406+
// Atm, I do not know how to check whether we are on ubuntu-20.04.
13407+
// So, ignore the error.
13408+
// if (!(await aptLibCurses5())) break;
13409+
await aptLibNCurses5();
13410+
}
1340913411
}
1341013412
await ghcup(tool, version, os);
1341113413
if (await isInstalled(tool, version, os))
@@ -13862,8 +13864,18 @@ async function run(inputs) {
1386213864
core.debug(`run: inputs = ${JSON.stringify(inputs)}`);
1386313865
core.debug(`run: os = ${JSON.stringify(os)}`);
1386413866
core.debug(`run: opts = ${JSON.stringify(opts)}`);
13865-
if (opts.ghcup.releaseChannel) {
13866-
await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os));
13867+
const releaseChannels = [
13868+
opts.ghcup.releaseChannel,
13869+
opts.ghc.raw === 'latest-nightly'
13870+
? new URL('https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml')
13871+
: null
13872+
].filter((v) => v !== null);
13873+
if (releaseChannels.length > 0) {
13874+
await core.group(`Setting release channels`, async () => {
13875+
for (const channel of releaseChannels) {
13876+
await (0, installer_1.addGhcupReleaseChannel)(channel, os);
13877+
}
13878+
});
1386713879
}
1386813880
for (const [t, { resolved }] of Object.entries(opts).filter(o => o[1].enable)) {
1386913881
await core.group(`Preparing ${t} environment`, async () => (0, installer_1.resetTool)(t, resolved, os));

lib/installer.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ async function installTool(tool, version, os) {
155155
}
156156
switch (os) {
157157
case 'linux':
158-
if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) {
159-
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
160-
// Atm, I do not know how to check whether we are on ubuntu-20.04.
161-
// So, ignore the error.
162-
// if (!(await aptLibCurses5())) break;
163-
await aptLibNCurses5();
158+
if (tool === 'ghc') {
159+
if (version !== 'latest-nightly' && (0, compare_versions_1.compareVersions)('8.3', version)) {
160+
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
161+
// Atm, I do not know how to check whether we are on ubuntu-20.04.
162+
// So, ignore the error.
163+
// if (!(await aptLibCurses5())) break;
164+
await aptLibNCurses5();
165+
}
164166
}
165167
await ghcup(tool, version, os);
166168
if (await isInstalled(tool, version, os))

lib/opts.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface ProgramOpt {
1616
export interface Options {
1717
ghc: ProgramOpt;
1818
ghcup: {
19-
releaseChannel?: URL;
19+
releaseChannel: URL | null;
2020
};
2121
cabal: ProgramOpt & {
2222
update: boolean;
@@ -85,6 +85,6 @@ export declare function releaseRevision(version: string, tool: Tool, os: OS): st
8585
* @returns boolean
8686
*/
8787
export declare function parseYAMLBoolean(name: string, val: string): boolean;
88-
export declare function parseURL(name: string, val: string): URL | undefined;
88+
export declare function parseURL(name: string, val: string): URL | null;
8989
export declare function getOpts({ ghc, cabal, stack }: Defaults, os: OS, inputs: Record<string, string>): Options;
9090
export {};

lib/opts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function parseYAMLBoolean(name, val) {
125125
exports.parseYAMLBoolean = parseYAMLBoolean;
126126
function parseURL(name, val) {
127127
if (val === '')
128-
return undefined;
128+
return null;
129129
try {
130130
return new URL(val);
131131
}

lib/setup-haskell.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,18 @@ async function run(inputs) {
5252
core.debug(`run: inputs = ${JSON.stringify(inputs)}`);
5353
core.debug(`run: os = ${JSON.stringify(os)}`);
5454
core.debug(`run: opts = ${JSON.stringify(opts)}`);
55-
if (opts.ghcup.releaseChannel) {
56-
await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os));
55+
const releaseChannels = [
56+
opts.ghcup.releaseChannel,
57+
opts.ghc.raw === 'latest-nightly'
58+
? new URL('https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml')
59+
: null
60+
].filter((v) => v !== null);
61+
if (releaseChannels.length > 0) {
62+
await core.group(`Setting release channels`, async () => {
63+
for (const channel of releaseChannels) {
64+
await (0, installer_1.addGhcupReleaseChannel)(channel, os);
65+
}
66+
});
5767
}
5868
for (const [t, { resolved }] of Object.entries(opts).filter(o => o[1].enable)) {
5969
await core.group(`Preparing ${t} environment`, async () => (0, installer_1.resetTool)(t, resolved, os));

src/installer.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ export async function installTool(
165165

166166
switch (os) {
167167
case 'linux':
168-
if (tool === 'ghc' && compareVersions('8.3', version)) {
169-
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
170-
// Atm, I do not know how to check whether we are on ubuntu-20.04.
171-
// So, ignore the error.
172-
// if (!(await aptLibCurses5())) break;
173-
await aptLibNCurses5();
168+
if (tool === 'ghc') {
169+
if (version !== 'latest-nightly' && compareVersions('8.3', version)) {
170+
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
171+
// Atm, I do not know how to check whether we are on ubuntu-20.04.
172+
// So, ignore the error.
173+
// if (!(await aptLibCurses5())) break;
174+
await aptLibNCurses5();
175+
}
174176
}
175177
await ghcup(tool, version, os);
176178
if (await isInstalled(tool, version, os)) return;

src/setup-haskell.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,20 @@ export default async function run(
3030
core.debug(`run: os = ${JSON.stringify(os)}`);
3131
core.debug(`run: opts = ${JSON.stringify(opts)}`);
3232

33-
if (opts.ghcup.releaseChannel) {
34-
await core.group(`Preparing ghcup environment`, async () =>
35-
addGhcupReleaseChannel(opts.ghcup.releaseChannel!, os)
36-
);
33+
const releaseChannels = [
34+
opts.ghcup.releaseChannel,
35+
opts.ghc.raw === 'latest-nightly'
36+
? new URL(
37+
'https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml'
38+
)
39+
: null
40+
].filter((v): v is URL => v !== null);
41+
if (releaseChannels.length > 0) {
42+
await core.group(`Setting release channels`, async () => {
43+
for (const channel of releaseChannels) {
44+
await addGhcupReleaseChannel(channel, os);
45+
}
46+
});
3747
}
3848

3949
for (const [t, {resolved}] of Object.entries(opts).filter(

0 commit comments

Comments
 (0)