Skip to content

Commit 3db8260

Browse files
authored
Update DVC Setup Version Details (#3850)
* remove information about max version in setup details * adds information about latest tested version setup details * removes latest tested version toast
1 parent 2342997 commit 3db8260

File tree

6 files changed

+31
-88
lines changed

6 files changed

+31
-88
lines changed

extension/src/cli/dvc/discovery.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { LATEST_TESTED_CLI_VERSION } from './contract'
21
import { CliCompatible, isVersionCompatible } from './version'
32
import { IExtensionSetup } from '../../interfaces'
43
import { Toast } from '../../vscode/toast'
@@ -37,12 +36,6 @@ const warnVersionIncompatible = (setup: IExtensionSetup): void => {
3736
)
3837
}
3938

40-
const warnAheadOfLatestTested = (): void => {
41-
void Toast.warnWithOptions(
42-
`The located DVC CLI is at least a minor version ahead of the latest version the extension was tested with (${LATEST_TESTED_CLI_VERSION}). This could lead to unexpected behaviour. Please upgrade to the most recent version of the extension and reload this window.`
43-
)
44-
}
45-
4639
const warnUserCLIInaccessible = async (
4740
setup: IExtensionSetup
4841
): Promise<void> => {
@@ -79,9 +72,6 @@ const warnUser = (
7972
return
8073
case CliCompatible.NO_NOT_FOUND:
8174
void warnUserCLIInaccessible(setup)
82-
return
83-
case CliCompatible.YES_MINOR_VERSION_AHEAD_OF_TESTED:
84-
return warnAheadOfLatestTested()
8575
}
8676
}
8777

@@ -96,10 +86,7 @@ const isCliCompatible = (cliCompatible: CliCompatible): boolean | undefined => {
9686
return
9787
}
9888

99-
return [
100-
CliCompatible.YES,
101-
CliCompatible.YES_MINOR_VERSION_AHEAD_OF_TESTED
102-
].includes(cliCompatible)
89+
return cliCompatible === CliCompatible.YES
10390
}
10491

10592
const getVersionDetails = async (

extension/src/cli/dvc/version.test.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,40 +91,34 @@ describe('isVersionCompatible', () => {
9191
expect(isCompatible).toStrictEqual(CliCompatible.YES)
9292
})
9393

94-
it('should return not found if the version provided is undefined', () => {
95-
const isCompatible = isVersionCompatible(undefined)
96-
97-
expect(isCompatible).toStrictEqual(CliCompatible.NO_NOT_FOUND)
98-
})
99-
100-
it('should return minor version ahead of tested for a version with a minor higher as the latest tested minor and any patch', () => {
94+
it('should be compatible for a version with a minor higher as the latest tested minor and any patch', () => {
10195
expect(0).toBeLessThan(latestTestedPatch)
10296

10397
let isCompatible = isVersionCompatible(
10498
[latestTestedMajor, latestTestedMinor + 1, 0].join('.')
10599
)
106100

107-
expect(isCompatible).toStrictEqual(
108-
CliCompatible.YES_MINOR_VERSION_AHEAD_OF_TESTED
109-
)
101+
expect(isCompatible).toStrictEqual(CliCompatible.YES)
110102

111103
isCompatible = isVersionCompatible(
112104
[latestTestedMajor, latestTestedMinor + 1, latestTestedPatch + 1000].join(
113105
'.'
114106
)
115107
)
116108

117-
expect(isCompatible).toStrictEqual(
118-
CliCompatible.YES_MINOR_VERSION_AHEAD_OF_TESTED
119-
)
109+
expect(isCompatible).toStrictEqual(CliCompatible.YES)
120110

121111
isCompatible = isVersionCompatible(
122112
[latestTestedMajor, latestTestedMinor + 1, latestTestedPatch].join('.')
123113
)
124114

125-
expect(isCompatible).toStrictEqual(
126-
CliCompatible.YES_MINOR_VERSION_AHEAD_OF_TESTED
127-
)
115+
expect(isCompatible).toStrictEqual(CliCompatible.YES)
116+
})
117+
118+
it('should return not found if the version provided is undefined', () => {
119+
const isCompatible = isVersionCompatible(undefined)
120+
121+
expect(isCompatible).toStrictEqual(CliCompatible.NO_NOT_FOUND)
128122
})
129123

130124
it('should return behind incompatible if the provided version is a patch version before the minimum expected version', () => {

extension/src/cli/dvc/version.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import {
2-
MAX_CLI_VERSION,
3-
LATEST_TESTED_CLI_VERSION,
4-
MIN_CLI_VERSION
5-
} from './contract'
1+
import { MAX_CLI_VERSION, MIN_CLI_VERSION } from './contract'
62

73
export enum CliCompatible {
84
NO_CANNOT_VERIFY = 'no-cannot-verify',
95
NO_INCOMPATIBLE = 'no-incompatible',
106
NO_NOT_FOUND = 'no-not-found',
11-
YES_MINOR_VERSION_AHEAD_OF_TESTED = 'yes-minor-version-ahead-of-tested',
127
YES = 'yes'
138
}
149

@@ -23,21 +18,6 @@ export const extractSemver = (stdout: string): ParsedSemver | undefined => {
2318
return { major: Number(major), minor: Number(minor), patch: Number(patch) }
2419
}
2520

26-
const cliIsCompatible = (
27-
currentMajor: number,
28-
currentMinor: number
29-
): CliCompatible => {
30-
const { major: latestTestedMajor, minor: latestTestedMinor } = extractSemver(
31-
LATEST_TESTED_CLI_VERSION
32-
) as ParsedSemver
33-
34-
if (currentMajor === latestTestedMajor && currentMinor > latestTestedMinor) {
35-
return CliCompatible.YES_MINOR_VERSION_AHEAD_OF_TESTED
36-
}
37-
38-
return CliCompatible.YES
39-
}
40-
4121
const checkCLIVersion = (currentSemVer: {
4222
major: number
4323
minor: number
@@ -64,7 +44,7 @@ const checkCLIVersion = (currentSemVer: {
6444
return CliCompatible.NO_INCOMPATIBLE
6545
}
6646

67-
return cliIsCompatible(currentMajor, currentMinor)
47+
return CliCompatible.YES
6848
}
6949

7050
export const isVersionCompatible = (

extension/src/setup/runner.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { Response } from '../vscode/response'
2020
import { VscodePython } from '../extensions/python'
2121
import { executeProcess } from '../process/execution'
2222
import { LATEST_TESTED_CLI_VERSION, MIN_CLI_VERSION } from '../cli/dvc/contract'
23-
import { extractSemver, ParsedSemver } from '../cli/dvc/version'
2423
import { delay } from '../util/time'
2524
import { Title } from '../vscode/title'
2625

@@ -494,31 +493,6 @@ describe('run', () => {
494493
expect(mockedInitialize).not.toHaveBeenCalled()
495494
})
496495

497-
it('should send a specific message and initialize if the Python extension is being used, the CLI is not available in the virtual environment and the global CLI is a minor version ahead of the expected version', async () => {
498-
const { major, minor, patch } = extractSemver(
499-
LATEST_TESTED_CLI_VERSION
500-
) as ParsedSemver
501-
mockedGetFirstWorkspaceFolder.mockReturnValueOnce(mockedCwd)
502-
mockedHasRoots.mockReturnValueOnce(true)
503-
mockedShouldWarnUserIfCLIUnavailable
504-
.mockReturnValueOnce(true)
505-
.mockReturnValueOnce(true)
506-
mockedIsPythonExtensionUsed.mockResolvedValueOnce(true)
507-
mockedGetCliVersion
508-
.mockResolvedValueOnce(undefined)
509-
.mockResolvedValueOnce([major, minor + 1, patch].join('.'))
510-
511-
await run(setup)
512-
await flushPromises()
513-
expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1)
514-
expect(mockedWarnWithOptions).toHaveBeenCalledWith(
515-
`The located DVC CLI is at least a minor version ahead of the latest version the extension was tested with (${LATEST_TESTED_CLI_VERSION}). This could lead to unexpected behaviour. Please upgrade to the most recent version of the extension and reload this window.`
516-
)
517-
expect(mockedGetCliVersion).toHaveBeenCalledTimes(2)
518-
expect(mockedResetMembers).not.toHaveBeenCalled()
519-
expect(mockedInitialize).toHaveBeenCalledTimes(1)
520-
})
521-
522496
it('should send a specific message to the user if the Python extension is not being used and the CLI is not available', async () => {
523497
mockedGetFirstWorkspaceFolder.mockReturnValueOnce(mockedCwd)
524498
mockedShouldWarnUserIfCLIUnavailable.mockReturnValueOnce(true)

webview/src/setup/components/App.test.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import {
33
MessageFromWebviewType,
44
MessageToWebviewType
55
} from 'dvc/src/webview/contract'
6-
import { MAX_CLI_VERSION, MIN_CLI_VERSION } from 'dvc/src/cli/dvc/contract'
6+
import {
7+
LATEST_TESTED_CLI_VERSION,
8+
MIN_CLI_VERSION
9+
} from 'dvc/src/cli/dvc/contract'
710
import '@testing-library/jest-dom/extend-expect'
811
import React from 'react'
912
import { SetupSection, SetupData } from 'dvc/src/setup/webview/contract'
@@ -492,7 +495,7 @@ describe('App', () => {
492495
expect(studioDetails).toHaveAttribute('open')
493496
})
494497

495-
it('should show the user the version if dvc is installed', () => {
498+
it('should show the user the version, min version, and latested tested version if dvc is installed', () => {
496499
renderApp({
497500
canGitInitialize: false,
498501
cliCompatible: true,
@@ -512,10 +515,10 @@ describe('App', () => {
512515
})
513516

514517
const envDetails = screen.getByTestId('dvc-env-details')
515-
const command = `1.0.0 (${MIN_CLI_VERSION} <= required < ${MAX_CLI_VERSION}.0.0)`
518+
const firstVersionLine = `1.0.0 (required ${MIN_CLI_VERSION} and above, tested with ${LATEST_TESTED_CLI_VERSION})`
516519

517520
expect(within(envDetails).getByText('Version')).toBeInTheDocument()
518-
expect(within(envDetails).getByText(command)).toBeInTheDocument()
521+
expect(within(envDetails).getByText(firstVersionLine)).toBeInTheDocument()
519522
})
520523

521524
it('should tell the user that version is not found if dvc is not installed', () => {
@@ -537,10 +540,10 @@ describe('App', () => {
537540
shareLiveToStudio: false
538541
})
539542
const envDetails = screen.getByTestId('dvc-env-details')
540-
const command = `Not found (${MIN_CLI_VERSION} <= required < ${MAX_CLI_VERSION}.0.0)`
543+
const version = `Not found (required ${MIN_CLI_VERSION} and above, tested with ${LATEST_TESTED_CLI_VERSION})`
541544

542545
expect(within(envDetails).getByText('Version')).toBeInTheDocument()
543-
expect(within(envDetails).getByText(command)).toBeInTheDocument()
546+
expect(within(envDetails).getByText(version)).toBeInTheDocument()
544547
})
545548

546549
it('should show the user an example command if dvc is installed', () => {

webview/src/setup/components/dvc/DvcEnvDetails.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from 'react'
22
import { DvcCliDetails } from 'dvc/src/setup/webview/contract'
3-
import { MAX_CLI_VERSION, MIN_CLI_VERSION } from 'dvc/src/cli/dvc/contract'
3+
import {
4+
LATEST_TESTED_CLI_VERSION,
5+
MIN_CLI_VERSION
6+
} from 'dvc/src/cli/dvc/contract'
47
import { DvcEnvInfoRow } from './DvcEnvInfoRow'
58
import styles from './styles.module.scss'
69
import { DvcEnvCommandRow } from './DvcEnvCommandRow'
@@ -14,9 +17,11 @@ export const DvcEnvDetails: React.FC<DvcEnvDetailsProps> = ({
1417
version,
1518
isPythonExtensionUsed
1619
}) => {
17-
const versionText = `${
18-
version || 'Not found'
19-
} (${MIN_CLI_VERSION} <= required < ${MAX_CLI_VERSION}.0.0)`
20+
const versionText = (
21+
<span>{`${
22+
version || 'Not found'
23+
} (required ${MIN_CLI_VERSION} and above, tested with ${LATEST_TESTED_CLI_VERSION})`}</span>
24+
)
2025

2126
return (
2227
<table data-testid="dvc-env-details" className={styles.envDetails}>

0 commit comments

Comments
 (0)