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

Commit

Permalink
Fix #248: resolve stack "2.1" to "2.1.3" rather than "2.11.1"
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed May 19, 2023
1 parent b53046b commit 921b0b6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down
4 changes: 2 additions & 2 deletions setup/__tests__/find-haskell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down
6 changes: 5 additions & 1 deletion setup/dist/index.js

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

6 changes: 5 additions & 1 deletion setup/lib/opts.js

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

6 changes: 5 additions & 1 deletion setup/src/opts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit 921b0b6

Please sign in to comment.