From 7bfeeb6466c5f861859067e86712460d4f64d35b Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sat, 6 May 2023 10:21:22 +0200 Subject: [PATCH] Document current resolution of versions (string prefix) See https://github.com/haskell/actions/issues/248 --- setup/README.md | 9 +++++++++ setup/__tests__/find-haskell.test.ts | 19 ++++++++++++++++--- setup/dist/index.js | 1 + setup/lib/opts.js | 1 + setup/src/opts.ts | 1 + 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/setup/README.md b/setup/README.md index 055b07ab..511c2408 100644 --- a/setup/README.md +++ b/setup/README.md @@ -224,6 +224,15 @@ In contrast, a proper `boolean` input like `cabal-update` only accepts values `t ## Version Support +This action is conscious about the tool versions specified in [`versions.json`](src/versions.json). +This list is replicated (hopefully correctly) below. + +Versions specified by the inputs, e.g. `ghc-version`, are resolved against this list, +by taking the first entry from the list if `latest` is requested, +or the first entry that is a (string-)extension of the requested version otherwise. +E.g., `8.10` will be resolved to `8.10.7`, and so will `8.10.`, `8.` and `8` +(and incorrectly, [even `8.1`](github.com/haskell/actions/issues/248)). + **GHC:** - `latest` (default) diff --git a/setup/__tests__/find-haskell.test.ts b/setup/__tests__/find-haskell.test.ts index 4f1f023d..acd91933 100644 --- a/setup/__tests__/find-haskell.test.ts +++ b/setup/__tests__/find-haskell.test.ts @@ -67,13 +67,13 @@ describe('haskell/actions/setup', () => { }); it('Versions resolve correctly', () => { - const v = {ghc: '8.6.5', cabal: '2.4.1.0', stack: '2.1.3'}; + const v = {ghc: '8.6.5', cabal: '3.4.1.0', stack: '1.9.3'}; forAllOS(os => { const options = getOpts(def(os), os, { 'enable-stack': 'true', - 'stack-version': '2.1', + 'stack-version': '1', 'ghc-version': '8.6', - 'cabal-version': '2.4' + 'cabal-version': '3.4' }); forAllTools(t => expect(options[t].resolved).toBe(v[t])); }); @@ -96,6 +96,19 @@ describe('haskell/actions/setup', () => { }); }); + it('Versions resolve as string prefix (resolving 8.1 to 8.10.x should be considered a bug)', () => { + const v = {ghc: '8.10.7', cabal: '2.4.1.0', stack: '2.1.3'}; + forAllOS(os => { + const options = getOpts(def(os), os, { + 'enable-stack': 'true', + 'stack-version': '2.1', + 'ghc-version': '8.1', + 'cabal-version': '2' + }); + forAllTools(t => expect(options[t].resolved).toBe(v[t])); + }); + }); + it('Enabling stack does not disable GHC or Cabal', () => { forAllOS(os => { const {ghc, cabal, stack} = getOpts(def(os), os, { diff --git a/setup/dist/index.js b/setup/dist/index.js index bdce096a..ab1427b0 100644 --- a/setup/dist/index.js +++ b/setup/dist/index.js @@ -13744,6 +13744,7 @@ function getDefaults(os) { } exports.getDefaults = getDefaults; // E.g. resolve ghc latest to 9.4.2 +// resolve ghc 8.1 to 8.10.7 (bug, https://github.com/haskell/actions/issues/248) function resolve(version, supported, tool, os, verbose // If resolution isn't the identity, print what resolved to what. ) { const result = version === 'latest' diff --git a/setup/lib/opts.js b/setup/lib/opts.js index 4ec91ee4..599f4ec0 100644 --- a/setup/lib/opts.js +++ b/setup/lib/opts.js @@ -79,6 +79,7 @@ function getDefaults(os) { } exports.getDefaults = getDefaults; // E.g. resolve ghc latest to 9.4.2 +// resolve ghc 8.1 to 8.10.7 (bug, https://github.com/haskell/actions/issues/248) function resolve(version, supported, tool, os, verbose // If resolution isn't the identity, print what resolved to what. ) { const result = version === 'latest' diff --git a/setup/src/opts.ts b/setup/src/opts.ts index 568aa1b3..4fff340c 100644 --- a/setup/src/opts.ts +++ b/setup/src/opts.ts @@ -86,6 +86,7 @@ export function getDefaults(os: OS): Defaults { } // E.g. resolve ghc latest to 9.4.2 +// resolve ghc 8.1 to 8.10.7 (bug, https://github.com/haskell/actions/issues/248) function resolve( version: string, supported: string[],