diff --git a/README.md b/README.md index a0018a5..3548164 100644 --- a/README.md +++ b/README.md @@ -230,9 +230,9 @@ 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)). +or the first entry that matches exactly, +or otherwise the first entry that is a (string-)extension of the requested version extended by a `.`. +E.g., `8.10` will be resolved to `8.10.7`, and so will `8`. **GHC:** diff --git a/__tests__/find-haskell.test.ts b/__tests__/find-haskell.test.ts index acd9193..5aaa396 100644 --- a/__tests__/find-haskell.test.ts +++ b/__tests__/find-haskell.test.ts @@ -96,13 +96,13 @@ describe('haskell/actions/setup', () => { }); }); - it('Versions resolve as string prefix (resolving 8.1 to 8.10.x should be considered a bug)', () => { + it('Versions resolve as version prefix', () => { 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', + 'ghc-version': '8.10', 'cabal-version': '2' }); forAllTools(t => expect(options[t].resolved).toBe(v[t])); diff --git a/dist/index.js b/dist/index.js index c9523e5..c9dc01b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13750,7 +13750,11 @@ function resolve(version, supported, tool, os, verbose // If resolution isn't th ) { const result = version === 'latest' ? supported[0] - : supported.find(v => v.startsWith(version)) ?? version; + : supported.find(v => v === version) ?? + supported.find(v => v.startsWith(version + '.')) ?? + // Andreas, 2023-05-19, issue #248 + // Append "." so that eg stack "2.1" resolves to "2.1.3" and not "2.11.1". + version; // Andreas 2022-12-29, issue #144: inform about resolution here where we can also output ${tool}. if (verbose === true && version !== result) core.info(`Resolved ${tool} ${version} to ${result}`); diff --git a/lib/opts.js b/lib/opts.js index 599f4ec..fb933de 100644 --- a/lib/opts.js +++ b/lib/opts.js @@ -84,7 +84,11 @@ function resolve(version, supported, tool, os, verbose // If resolution isn't th ) { const result = version === 'latest' ? supported[0] - : supported.find(v => v.startsWith(version)) ?? version; + : supported.find(v => v === version) ?? + supported.find(v => v.startsWith(version + '.')) ?? + // Andreas, 2023-05-19, issue #248 + // Append "." so that eg stack "2.1" resolves to "2.1.3" and not "2.11.1". + version; // Andreas 2022-12-29, issue #144: inform about resolution here where we can also output ${tool}. if (verbose === true && version !== result) core.info(`Resolved ${tool} ${version} to ${result}`); diff --git a/src/opts.ts b/src/opts.ts index 4fff340..9fe2dc1 100644 --- a/src/opts.ts +++ b/src/opts.ts @@ -97,7 +97,11 @@ function resolve( const result = version === 'latest' ? supported[0] - : supported.find(v => v.startsWith(version)) ?? version; + : supported.find(v => v === version) ?? + supported.find(v => v.startsWith(version + '.')) ?? + // Andreas, 2023-05-19, issue #248 + // Append "." so that eg stack "2.1" resolves to "2.1.3" and not "2.11.1". + version; // Andreas 2022-12-29, issue #144: inform about resolution here where we can also output ${tool}. if (verbose === true && version !== result) core.info(`Resolved ${tool} ${version} to ${result}`);