Skip to content

Commit

Permalink
Support latest-nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 committed Jul 12, 2023
1 parent 14547ab commit 487fb79
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 30 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ E.g., `8.10` will be resolved to `8.10.7`, and so will `8`.

**GHC:**

- `latest-nightly`
- `latest` (default)
- `9.6.2` `9.6`
- `9.6.1`
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: 'GitHub'
inputs:
ghc-version:
required: false
description: 'Version of GHC to use. If set to "latest", it will always get the latest stable version.'
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'
default: 'latest'
cabal-version:
required: false
Expand Down
28 changes: 20 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13400,12 +13400,14 @@ async function installTool(tool, version, os) {
}
switch (os) {
case 'linux':
if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) {
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
// Atm, I do not know how to check whether we are on ubuntu-20.04.
// So, ignore the error.
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
if (tool === 'ghc') {
if (version !== 'latest-nightly' && (0, compare_versions_1.compareVersions)('8.3', version)) {
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
// Atm, I do not know how to check whether we are on ubuntu-20.04.
// So, ignore the error.
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
}
}
await ghcup(tool, version, os);
if (await isInstalled(tool, version, os))
Expand Down Expand Up @@ -13862,8 +13864,18 @@ async function run(inputs) {
core.debug(`run: inputs = ${JSON.stringify(inputs)}`);
core.debug(`run: os = ${JSON.stringify(os)}`);
core.debug(`run: opts = ${JSON.stringify(opts)}`);
if (opts.ghcup.releaseChannel) {
await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os));
const releaseChannels = [
opts.ghcup.releaseChannel,
opts.ghc.raw === 'latest-nightly'
? new URL('https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml')
: null
].filter((v) => v !== null);
if (releaseChannels.length > 0) {
await core.group(`Setting release channels`, async () => {
for (const channel of releaseChannels) {
await (0, installer_1.addGhcupReleaseChannel)(channel, os);
}
});
}
for (const [t, { resolved }] of Object.entries(opts).filter(o => o[1].enable)) {
await core.group(`Preparing ${t} environment`, async () => (0, installer_1.resetTool)(t, resolved, os));
Expand Down
14 changes: 8 additions & 6 deletions lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ async function installTool(tool, version, os) {
}
switch (os) {
case 'linux':
if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) {
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
// Atm, I do not know how to check whether we are on ubuntu-20.04.
// So, ignore the error.
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
if (tool === 'ghc') {
if (version !== 'latest-nightly' && (0, compare_versions_1.compareVersions)('8.3', version)) {
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
// Atm, I do not know how to check whether we are on ubuntu-20.04.
// So, ignore the error.
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
}
}
await ghcup(tool, version, os);
if (await isInstalled(tool, version, os))
Expand Down
4 changes: 2 additions & 2 deletions lib/opts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ProgramOpt {
export interface Options {
ghc: ProgramOpt;
ghcup: {
releaseChannel?: URL;
releaseChannel: URL | null;
};
cabal: ProgramOpt & {
update: boolean;
Expand Down Expand Up @@ -85,6 +85,6 @@ export declare function releaseRevision(version: string, tool: Tool, os: OS): st
* @returns boolean
*/
export declare function parseYAMLBoolean(name: string, val: string): boolean;
export declare function parseURL(name: string, val: string): URL | undefined;
export declare function parseURL(name: string, val: string): URL | null;
export declare function getOpts({ ghc, cabal, stack }: Defaults, os: OS, inputs: Record<string, string>): Options;
export {};
2 changes: 1 addition & 1 deletion lib/opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function parseYAMLBoolean(name, val) {
exports.parseYAMLBoolean = parseYAMLBoolean;
function parseURL(name, val) {
if (val === '')
return undefined;
return null;
try {
return new URL(val);
}
Expand Down
14 changes: 12 additions & 2 deletions lib/setup-haskell.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ async function run(inputs) {
core.debug(`run: inputs = ${JSON.stringify(inputs)}`);
core.debug(`run: os = ${JSON.stringify(os)}`);
core.debug(`run: opts = ${JSON.stringify(opts)}`);
if (opts.ghcup.releaseChannel) {
await core.group(`Preparing ghcup environment`, async () => (0, installer_1.addGhcupReleaseChannel)(opts.ghcup.releaseChannel, os));
const releaseChannels = [
opts.ghcup.releaseChannel,
opts.ghc.raw === 'latest-nightly'
? new URL('https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml')
: null
].filter((v) => v !== null);
if (releaseChannels.length > 0) {
await core.group(`Setting release channels`, async () => {
for (const channel of releaseChannels) {
await (0, installer_1.addGhcupReleaseChannel)(channel, os);
}
});
}
for (const [t, { resolved }] of Object.entries(opts).filter(o => o[1].enable)) {
await core.group(`Preparing ${t} environment`, async () => (0, installer_1.resetTool)(t, resolved, os));
Expand Down
14 changes: 8 additions & 6 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ export async function installTool(

switch (os) {
case 'linux':
if (tool === 'ghc' && compareVersions('8.3', version)) {
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
// Atm, I do not know how to check whether we are on ubuntu-20.04.
// So, ignore the error.
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
if (tool === 'ghc') {
if (version !== 'latest-nightly' && compareVersions('8.3', version)) {
// Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04.
// Atm, I do not know how to check whether we are on ubuntu-20.04.
// So, ignore the error.
// if (!(await aptLibCurses5())) break;
await aptLibNCurses5();
}
}
await ghcup(tool, version, os);
if (await isInstalled(tool, version, os)) return;
Expand Down
18 changes: 14 additions & 4 deletions src/setup-haskell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,20 @@ export default async function run(
core.debug(`run: os = ${JSON.stringify(os)}`);
core.debug(`run: opts = ${JSON.stringify(opts)}`);

if (opts.ghcup.releaseChannel) {
await core.group(`Preparing ghcup environment`, async () =>
addGhcupReleaseChannel(opts.ghcup.releaseChannel!, os)
);
const releaseChannels = [
opts.ghcup.releaseChannel,
opts.ghc.raw === 'latest-nightly'
? new URL(
'https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml'
)
: null
].filter((v): v is URL => v !== null);
if (releaseChannels.length > 0) {
await core.group(`Setting release channels`, async () => {
for (const channel of releaseChannels) {
await addGhcupReleaseChannel(channel, os);
}
});
}

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

0 comments on commit 487fb79

Please # to comment.