From fab017e0e143bb87979f37f422006bb3d3620f5d Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Tue, 3 Jan 2023 20:51:30 +0100 Subject: [PATCH] Fix #29: new input 'cabal-update: false' to turn off 'cabal update' --- setup/action.yml | 12 ++++++++---- setup/dist/index.js | 6 ++++-- setup/lib/opts.d.ts | 4 +++- setup/lib/opts.js | 4 +++- setup/lib/setup-haskell.js | 2 +- setup/src/opts.ts | 6 ++++-- setup/src/setup-haskell.ts | 2 +- 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/setup/action.yml b/setup/action.yml index 87df2eeb..02128abe 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -16,16 +16,20 @@ inputs: default: 'latest' enable-stack: required: false - description: 'If specified, will setup Stack' + description: 'If specified, will setup Stack.' stack-no-global: required: false - description: 'If specified, enable-stack must be set. Prevents installing GHC and Cabal globally' + description: 'If specified, enable-stack must be set. Prevents installing GHC and Cabal globally.' stack-setup-ghc: required: false - description: 'If specified, enable-stack must be set. Will run stack setup to install the specified GHC' + description: 'If specified, enable-stack must be set. Will run stack setup to install the specified GHC.' + cabal-update: + required: false + default: true + description: 'Set to false to prevent `cabal update` from being run.' disable-matcher: required: false - description: 'If specified, disables match messages from GHC as GitHub CI annotations' + description: 'If specified, disables match messages from GHC as GitHub CI annotations.' outputs: ghc-path: description: 'The path of the ghc executable _directory_' diff --git a/setup/dist/index.js b/setup/dist/index.js index 000e479b..ef10d587 100644 --- a/setup/dist/index.js +++ b/setup/dist/index.js @@ -13698,6 +13698,7 @@ function getOpts({ ghc, cabal, stack }, os, inputs) { const stackSetupGhc = (inputs['stack-setup-ghc'] || '') !== ''; const stackEnable = (inputs['enable-stack'] || '') !== ''; const matcherDisable = (inputs['disable-matcher'] || '') !== ''; + const cabalUpdate = inputs['cabal-update'] !== 'false'; core.debug(`${stackNoGlobal}/${stackSetupGhc}/${stackEnable}`); const verInpt = { ghc: inputs['ghc-version'] || ghc.version, @@ -13727,7 +13728,8 @@ function getOpts({ ghc, cabal, stack }, os, inputs) { raw: verInpt.cabal, resolved: resolve(verInpt.cabal, cabal.supported, 'cabal', os, cabalEnable // if true: inform user about resolution ), - enable: cabalEnable + enable: cabalEnable, + update: cabalUpdate }, stack: { raw: verInpt.stack, @@ -13831,7 +13833,7 @@ async function run(inputs) { // https://github.com/haskell/cabal/issues/6823 // await exec('cabal user-config update'); } - if (!opts.stack.enable) + if (opts.cabal.update && !opts.stack.enable) await (0, exec_1.exec)('cabal update'); }); core.info(`##[add-matcher]${path.join(__dirname, '..', 'matcher.json')}`); diff --git a/setup/lib/opts.d.ts b/setup/lib/opts.d.ts index 0c0937e9..cf66dedb 100644 --- a/setup/lib/opts.d.ts +++ b/setup/lib/opts.d.ts @@ -14,7 +14,9 @@ export interface ProgramOpt { } export interface Options { ghc: ProgramOpt; - cabal: ProgramOpt; + cabal: ProgramOpt & { + update: boolean; + }; stack: ProgramOpt & { setup: boolean; }; diff --git a/setup/lib/opts.js b/setup/lib/opts.js index 6dce63e3..d84b15ff 100644 --- a/setup/lib/opts.js +++ b/setup/lib/opts.js @@ -75,6 +75,7 @@ function getOpts({ ghc, cabal, stack }, os, inputs) { const stackSetupGhc = (inputs['stack-setup-ghc'] || '') !== ''; const stackEnable = (inputs['enable-stack'] || '') !== ''; const matcherDisable = (inputs['disable-matcher'] || '') !== ''; + const cabalUpdate = inputs['cabal-update'] !== 'false'; core.debug(`${stackNoGlobal}/${stackSetupGhc}/${stackEnable}`); const verInpt = { ghc: inputs['ghc-version'] || ghc.version, @@ -104,7 +105,8 @@ function getOpts({ ghc, cabal, stack }, os, inputs) { raw: verInpt.cabal, resolved: resolve(verInpt.cabal, cabal.supported, 'cabal', os, cabalEnable // if true: inform user about resolution ), - enable: cabalEnable + enable: cabalEnable, + update: cabalUpdate }, stack: { raw: verInpt.stack, diff --git a/setup/lib/setup-haskell.js b/setup/lib/setup-haskell.js index 0955e598..b9438e14 100644 --- a/setup/lib/setup-haskell.js +++ b/setup/lib/setup-haskell.js @@ -79,7 +79,7 @@ async function run(inputs) { // https://github.com/haskell/cabal/issues/6823 // await exec('cabal user-config update'); } - if (!opts.stack.enable) + if (opts.cabal.update && !opts.stack.enable) await (0, exec_1.exec)('cabal update'); }); core.info(`##[add-matcher]${path.join(__dirname, '..', 'matcher.json')}`); diff --git a/setup/src/opts.ts b/setup/src/opts.ts index f9b53dfe..c292ed50 100644 --- a/setup/src/opts.ts +++ b/setup/src/opts.ts @@ -24,7 +24,7 @@ export interface ProgramOpt { export interface Options { ghc: ProgramOpt; - cabal: ProgramOpt; + cabal: ProgramOpt & {update: boolean}; stack: ProgramOpt & {setup: boolean}; general: {matcher: {enable: boolean}}; } @@ -93,6 +93,7 @@ export function getOpts( const stackSetupGhc = (inputs['stack-setup-ghc'] || '') !== ''; const stackEnable = (inputs['enable-stack'] || '') !== ''; const matcherDisable = (inputs['disable-matcher'] || '') !== ''; + const cabalUpdate = inputs['cabal-update'] !== 'false'; core.debug(`${stackNoGlobal}/${stackSetupGhc}/${stackEnable}`); const verInpt = { ghc: inputs['ghc-version'] || ghc.version, @@ -136,7 +137,8 @@ export function getOpts( os, cabalEnable // if true: inform user about resolution ), - enable: cabalEnable + enable: cabalEnable, + update: cabalUpdate }, stack: { raw: verInpt.stack, diff --git a/setup/src/setup-haskell.ts b/setup/src/setup-haskell.ts index 9e5c5ab3..077c0c6b 100644 --- a/setup/src/setup-haskell.ts +++ b/setup/src/setup-haskell.ts @@ -73,7 +73,7 @@ export default async function run( // https://github.com/haskell/cabal/issues/6823 // await exec('cabal user-config update'); } - if (!opts.stack.enable) await exec('cabal update'); + if (opts.cabal.update && !opts.stack.enable) await exec('cabal update'); }); core.info(`##[add-matcher]${path.join(__dirname, '..', 'matcher.json')}`);