Fix macos ghcup and cabal flags (#4)

* fix short-circuit logic for ghcup based installs of ghc

* fix unrecognized user-config option for cabal v2.0

* update dependencies
This commit is contained in:
Jared Weakly
2020-06-09 09:58:15 -07:00
committed by GitHub
parent c1b48c3995
commit cfefe70615
7 changed files with 6821 additions and 6158 deletions

View File

@@ -1,7 +1,7 @@
{
"root": true,
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/es6"],
"extends": ["plugin:github/typescript"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
@@ -20,7 +20,6 @@
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "warn",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-ignore": "error",
"camelcase": "off",
"@typescript-eslint/explicit-function-return-type": [
"warn",

View File

@@ -35,12 +35,15 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
ghc: ['8.8', '8.4.4']
cabal: ['3.0.0.0']
ghc: ['latest', '8.4.4']
cabal: ['latest']
include:
- os: ubuntu-latest
ghc: '7.10.3'
cabal: '3.0.0.0'
- os: ubuntu-latest
ghc: '8.2.2'
cabal: '2.0'
steps:
- uses: actions/checkout@v2
@@ -56,6 +59,11 @@ jobs:
- run: |
cabal --version
ghc --version
- shell: bash
if: matrix.ghc != 'latest'
# this check depends on the ghc versions being "exact" in the matrix
run: |
[[ $(ghc --numeric-version) == ${{ matrix.ghc }} ]]
install-stack:
name: Stack ${{ matrix.stack }} ${{ matrix.os }}

8115
dist/index.js vendored

File diff suppressed because it is too large Load Diff

4766
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -21,30 +21,30 @@
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.3",
"@actions/exec": "^1.0.3",
"@actions/core": "^1.2.4",
"@actions/exec": "^1.0.4",
"@actions/glob": "^0.1.0",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.3.3",
"js-yaml": "^3.13.1"
"@actions/tool-cache": "^1.5.5",
"js-yaml": "^3.14.0"
},
"devDependencies": {
"@types/jest": "^25.2.1",
"@types/js-yaml": "^3.12.3",
"@types/node": "^13.13.2",
"@typescript-eslint/parser": "^2.29.0",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@zeit/ncc": "^0.22.1",
"eslint": "^6.8.0",
"eslint-plugin-github": "^3.4.1",
"eslint-plugin-jest": "^23.8.2",
"@types/jest": "^25.2.3",
"@types/js-yaml": "^3.12.4",
"@types/node": "^14.0.11",
"@typescript-eslint/parser": "^3.1.0",
"@typescript-eslint/eslint-plugin": "^3.1.0",
"@zeit/ncc": "^0.22.3",
"eslint": "^7.1.0",
"eslint-plugin-github": "^4.0.1",
"eslint-plugin-jest": "^23.13.2",
"husky": "^4.2.5",
"jest": "^25.4.0",
"jest-circus": "^25.4.0",
"lint-staged": "^10.1.7",
"jest": "^26.0.1",
"jest-circus": "^26.0.1",
"lint-staged": "^10.2.9",
"prettier": "^2.0.5",
"ts-jest": "^25.4.0",
"typescript": "^3.8.3"
"ts-jest": "^26.1.0",
"typescript": "^3.9.5"
},
"husky": {
"hooks": {

View File

@@ -85,7 +85,14 @@ async function isInstalled(
.then(() => p)
.catch(() => undefined);
if (installedPath) return success(tool, version, installedPath);
if (installedPath) {
// Make sure that the correct ghc is used, even if ghcup has set a
// default prior to this action being ran.
if (tool === 'ghc' && installedPath === ghcupPath)
await exec(await ghcupBin(os), ['set', version]);
return success(tool, version, installedPath);
}
}
if (tool === 'cabal' && os !== 'win32') {
@@ -172,17 +179,23 @@ async function choco(tool: Tool, version: string): Promise<void> {
]);
}
async function ghcup(tool: Tool, version: string, os: OS): Promise<void> {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
async function ghcupBin(os: OS): Promise<string> {
const v = '0.1.5';
const cachedBin = tc.find('ghcup', v);
if (cachedBin) return join(cachedBin, 'ghcup');
const v = '0.1.4';
const bin = await tc.downloadTool(
`https://downloads.haskell.org/~ghcup/${v}/x86_64-${
`https://downloads.haskell.org/ghcup/${v}/x86_64-${
os === 'darwin' ? 'apple-darwin' : 'linux'
}-ghcup-${v}`
);
await fs.chmod(bin, 0o755);
return join(await tc.cacheFile(bin, 'ghcup', 'ghcup', v), 'ghcup');
}
async function ghcup(tool: Tool, version: string, os: OS): Promise<void> {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
const bin = await ghcupBin(os);
await exec(bin, [tool === 'ghc' ? 'install' : 'install-cabal', version]);
if (tool === 'ghc') await exec(bin, ['set', version]);
}

View File

@@ -1,9 +1,20 @@
import * as core from '@actions/core';
import * as fs from 'fs';
import {getOpts, getDefaults, Tool} from './opts';
import {installTool} from './installer';
import type {OS} from './opts';
import {exec} from '@actions/exec';
async function cabalConfig(): Promise<string> {
let out = Buffer.from('');
const append = (b: Buffer): Buffer => (out = Buffer.concat([out, b]));
await exec('cabal', ['--help'], {
silent: true,
listeners: {stdout: append, stderr: append}
});
return out.toString().trim().split('\n').slice(-1)[0].trim();
}
(async () => {
try {
core.info('Preparing to setup a Haskell environment');
@@ -21,16 +32,19 @@ import {exec} from '@actions/exec';
if (opts.cabal.enable)
await core.group('Setting up cabal', async () => {
await exec(
'cabal user-config update -a "http-transport: plain-http" -v3'
);
await exec('cabal', ['update']);
await exec('cabal', ['user-config', 'update'], {silent: true});
const configFile = await cabalConfig();
fs.appendFileSync(configFile, 'http-transport: plain-http\n');
if (process.platform === 'win32') {
await exec('cabal user-config update -a "store-dir: C:\\sr" -v3');
fs.appendFileSync(configFile, 'store-dir: C:\\sr\n');
core.setOutput('cabal-store', 'C:\\sr');
} else {
core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`);
}
await exec('cabal user-config update');
if (!opts.stack.enable) await exec('cabal update');
});
} catch (error) {
core.setFailed(error.message);