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

Fixes for linking errors on 7.10.3 and cleaning up symlinks #83

Merged
merged 7 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
ghc: ["latest", "8.4.4"]
cabal: ["latest", "3.2.0.0", "3.4.0.0"]
cabal: ["latest", "3.2.0.0"]
include:
- os: ubuntu-latest
ghc: "8.2.2"
cabal: "2.4.0.1"
- os: ubuntu-18.04
ghc: "7.4.1"
cabal: "3.4"
- os: ubuntu-latest
ghc: "7.10.3"
cabal: "3.6"
steps:
- uses: actions/checkout@v2
- uses: ./setup
Expand Down
6 changes: 5 additions & 1 deletion setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ That is, setting any "boolean" to a value other than the empty string (`""`) wil

- `head`<sup>[[1]](#ghc-head-note-1)</sup>
- `latest` (default, recommended)
- `9.2.1` `9.2`
- `9.0.1` `9.0`
- `8.10.7` `8.10`
- `8.10.6`
Expand Down Expand Up @@ -162,7 +163,10 @@ Suggestion: Try to support the three latest major versions of GHC.
**Cabal:**

- `latest` (default, recommended)
- `3.4.0.0` `3.4`
- `3.6.2.0` `3.6`
- `3.6.0.0`
- `3.4.1.0` `3.4`
- `3.4.0.0`
- `3.2.0.0` `3.2`
- `3.0.0.0` `3.0`
- `2.4.1.0` `2.4`
Expand Down
53 changes: 46 additions & 7 deletions setup/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions setup/lib/installer.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion setup/lib/installer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 21 additions & 5 deletions setup/lib/setup-haskell.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions setup/lib/versions.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions setup/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,34 @@ export async function installTool(
return failed(tool, version);
}

export async function resetTool(
tool: Tool,
_version: string,
os: OS
): Promise<void> {
if (tool === 'stack') {
// We don't need to do anything here... yet
// (Once we switch to utilizing ghcup for stack when possible, we can
// remove this early return)
return;
}

let bin = '';
switch (os) {
case 'linux':
bin = await ghcupBin(os);
await exec(bin, ['unset', tool]);
return;
case 'darwin':
bin = await ghcupBin(os);
await exec(bin, ['unset', tool]);
return;
case 'win32':
// We don't need to do anything here... yet
return;
}
}

async function stack(version: string, os: OS): Promise<void> {
core.info(`Attempting to install stack ${version}`);
const build = {
Expand Down
38 changes: 32 additions & 6 deletions setup/src/setup-haskell.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as core from '@actions/core';
import * as fs from 'fs';
import * as path from 'path';
import {EOL} from 'os';
import {getOpts, getDefaults, Tool} from './opts';
import {installTool} from './installer';
import {installTool, resetTool} from './installer';
import type {OS} from './opts';
import {exec} from '@actions/exec';

Expand All @@ -24,10 +25,16 @@ export default async function run(
const os = process.platform as OS;
const opts = getOpts(getDefaults(os), os, inputs);

for (const [t, {resolved}] of Object.entries(opts).filter(o => o[1].enable))
for (const [t, {resolved}] of Object.entries(opts).filter(
o => o[1].enable
)) {
await core.group(`Preparing ${t} environment`, async () =>
resetTool(t as Tool, resolved, os)
);
await core.group(`Installing ${t} version ${resolved}`, async () =>
installTool(t as Tool, resolved, os)
);
}

if (opts.stack.setup)
await core.group('Pre-installing GHC with stack', async () =>
Expand All @@ -36,16 +43,35 @@ export default async function run(

if (opts.cabal.enable)
await core.group('Setting up cabal', async () => {
// Create config only if it doesn't exist.
await exec('cabal', ['user-config', 'init'], {
silent: true,
ignoreReturnCode: true
});
// Blindly appending is fine.
// Cabal merges these and picks the last defined option.
const configFile = await cabalConfig();
if (process.platform === 'win32') {
await exec('cabal', ['user-config', 'update'], {silent: true});
const configFile = await cabalConfig();
fs.appendFileSync(configFile, 'store-dir: C:\\sr\n');
fs.appendFileSync(configFile, `store-dir: C:\\sr${EOL}`);
core.setOutput('cabal-store', 'C:\\sr');
await exec('cabal user-config update');
} else {
core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`);
}

// Workaround the GHC nopie linking errors for ancient GHC verions
// NB: Is this _just_ for GHC 7.10.3?
if (opts.ghc.resolved === '7.10.3') {
fs.appendFileSync(
configFile,
['program-default-options', ' ghc-options: -optl-no-pie'].join(
EOL
) + EOL
);

// We cannot use cabal user-config to normalize the config because of:
// https://github.com/haskell/cabal/issues/6823
// await exec('cabal user-config update');
}
if (!opts.stack.enable) await exec('cabal update');
});

Expand Down
13 changes: 11 additions & 2 deletions setup/src/versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"ghc": [
"9.2.1",
"9.0.1",
"8.10.7",
"8.10.6",
Expand All @@ -25,7 +26,15 @@
"8.0.2",
"7.10.3"
],
"cabal": ["3.4.0.0", "3.2.0.0", "3.0.0.0", "2.4.1.0"],
"cabal": [
"3.6.2.0",
"3.6.0.0",
"3.4.1.0",
"3.4.0.0",
"3.2.0.0",
"3.0.0.0",
"2.4.1.0"
],
"stack": [
"2.7.3",
"2.7.1",
Expand All @@ -47,5 +56,5 @@
"1.3.0",
"1.2.0"
],
"ghcup": ["0.1.16.2"]
"ghcup": ["0.1.17.3"]
}