Skip to content

Commit ee17719

Browse files
authored
fix: windows CI with Vite 3 (#23052)
* chore: patch vite * remove readJsonSync methods * rename patch * fix tests * reduce flake by using a timeout * update test * do not build mac and linux binaries
1 parent 51ef99a commit ee17719

File tree

13 files changed

+124
-103
lines changed

13 files changed

+124
-103
lines changed

circle.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ macWorkflowFilters: &darwin-workflow-filters
3636
when:
3737
or:
3838
- equal: [ develop, << pipeline.git.branch >> ]
39-
- equal: [ 'revert-22742', << pipeline.git.branch >> ]
4039
- matches:
4140
pattern: "-release$"
4241
value: << pipeline.git.branch >>
@@ -45,7 +44,6 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
4544
when:
4645
or:
4746
- equal: [ develop, << pipeline.git.branch >> ]
48-
- equal: [ 'revert-22742', << pipeline.git.branch >> ]
4947
- matches:
5048
pattern: "-release$"
5149
value: << pipeline.git.branch >>
@@ -65,7 +63,7 @@ windowsWorkflowFilters: &windows-workflow-filters
6563
or:
6664
- equal: [ develop, << pipeline.git.branch >> ]
6765
- equal: [ linux-arm64, << pipeline.git.branch >> ]
68-
- equal: [ 'fix-system-test-glob-pattern', << pipeline.git.branch >> ]
66+
- equal: [ 'lmiller/windows-vite-fix', << pipeline.git.branch >> ]
6967
- matches:
7068
pattern: "-release$"
7169
value: << pipeline.git.branch >>
@@ -129,7 +127,7 @@ commands:
129127
- run:
130128
name: Check current branch to persist artifacts
131129
command: |
132-
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "revert-22742" ]]; then
130+
if [[ "$CIRCLE_BRANCH" != "develop" ]]; then
133131
echo "Not uploading artifacts or posting install comment for this branch."
134132
circleci-agent step halt
135133
fi

packages/app/cypress/e2e/specs.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ describe('App: Specs', () => {
711711
})
712712

713713
// Timeout is increased here to allow ample time for the config change to be processed
714-
cy.contains('No Specs Found', { timeout: 10000 }).should('be.visible')
715-
cy.findByRole('button', { name: 'New Spec' }).click()
714+
cy.contains('No Specs Found', { timeout: 12000 }).should('be.visible')
715+
cy.findByRole('button', { name: 'New Spec' }).click({ timeout: 12000 })
716716

717717
cy.findByRole('dialog', {
718718
name: 'Enter the path for your new spec',

packages/data-context/src/actions/ProjectActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ export class ProjectActions {
444444
async reconfigureProject () {
445445
await this.ctx.actions.browser.closeBrowser()
446446
this.ctx.actions.wizard.resetWizard()
447-
this.ctx.actions.wizard.initialize()
447+
await this.ctx.actions.wizard.initialize()
448448
this.ctx.actions.electron.refreshBrowserWindow()
449449
this.ctx.actions.electron.showBrowserWindow()
450450
}

packages/data-context/src/actions/WizardActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ export class WizardActions {
8080
return this.ctx.coreData.wizard
8181
}
8282

83-
initialize () {
83+
async initialize () {
8484
if (!this.ctx.currentProject) {
8585
return
8686
}
8787

8888
this.resetWizard()
8989

90-
const detected = detectFramework(this.ctx.currentProject)
90+
const detected = await detectFramework(this.ctx.currentProject)
9191

9292
debug('detected %o', detected)
9393

packages/data-context/src/data/ProjectConfigManager.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CypressEnv } from './CypressEnv'
1111
import { autoBindDebug } from '../util/autoBindDebug'
1212
import type { EventRegistrar } from './EventRegistrar'
1313
import type { DataContext } from '../DataContext'
14-
import { DependencyToInstall, inPkgJson, WIZARD_BUNDLERS, WIZARD_DEPENDENCIES, WIZARD_FRAMEWORKS } from '@packages/scaffold-config'
14+
import { DependencyToInstall, isDependencyInstalled, WIZARD_BUNDLERS, WIZARD_DEPENDENCIES, WIZARD_FRAMEWORKS } from '@packages/scaffold-config'
1515

1616
const debug = debugLib(`cypress:lifecycle:ProjectConfigManager`)
1717

@@ -155,16 +155,16 @@ export class ProjectConfigManager {
155155
this.options.refreshLifecycle().catch(this.onLoadError)
156156
} else if (this._eventsIpc && !this._registeredEventsTarget && this._cachedLoadConfig) {
157157
this.setupNodeEvents(this._cachedLoadConfig)
158-
.then(() => {
158+
.then(async () => {
159159
if (this._testingType === 'component') {
160-
this.checkDependenciesForComponentTesting()
160+
await this.checkDependenciesForComponentTesting()
161161
}
162162
})
163163
.catch(this.onLoadError)
164164
}
165165
}
166166

167-
checkDependenciesForComponentTesting () {
167+
async checkDependenciesForComponentTesting () {
168168
// if it's a function, for example, the user is created their own dev server,
169169
// and not using one of our presets. Assume they know what they are doing and
170170
// what dependencies they require.
@@ -184,15 +184,15 @@ export class ProjectConfigManager {
184184
return
185185
}
186186

187-
const result = inPkgJson(bundler, this.options.projectRoot)
187+
const result = await isDependencyInstalled(bundler, this.options.projectRoot)
188188

189189
if (!result.satisfied) {
190190
unsupportedDeps.set(result.dependency.type, result)
191191
}
192192

193-
const isFrameworkSatisfied = (bundler: typeof WIZARD_BUNDLERS[number], framework: typeof WIZARD_FRAMEWORKS[number]) => {
194-
for (const dep of framework.dependencies(bundler.type, this.options.projectRoot)) {
195-
const res = inPkgJson(dep.dependency, this.options.projectRoot)
193+
const isFrameworkSatisfied = async (bundler: typeof WIZARD_BUNDLERS[number], framework: typeof WIZARD_FRAMEWORKS[number]) => {
194+
for (const dep of await (framework.dependencies(bundler.type, this.options.projectRoot))) {
195+
const res = await isDependencyInstalled(dep.dependency, this.options.projectRoot)
196196

197197
if (!res.satisfied) {
198198
return false
@@ -209,11 +209,11 @@ export class ProjectConfigManager {
209209
let isSatisfied = false
210210

211211
for (const framework of frameworks) {
212-
if (isFrameworkSatisfied(bundler, framework)) {
212+
if (await isFrameworkSatisfied(bundler, framework)) {
213213
isSatisfied = true
214214
break
215215
} else {
216-
for (const dep of framework.dependencies(bundler.type, this.options.projectRoot)) {
216+
for (const dep of await framework.dependencies(bundler.type, this.options.projectRoot)) {
217217
mismatchedFrameworkDeps.set(dep.dependency.type, dep)
218218
}
219219
}

packages/data-context/src/sources/WizardDataSource.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
import {
22
WIZARD_DEPENDENCY_TYPESCRIPT,
33
DependencyToInstall,
4-
inPkgJson,
4+
isDependencyInstalled,
55
} from '@packages/scaffold-config'
66
import type { DataContext } from '..'
77

88
export class WizardDataSource {
99
constructor (private ctx: DataContext) {}
1010

11-
packagesToInstall (): DependencyToInstall[] {
11+
async packagesToInstall (): Promise<DependencyToInstall[]> {
1212
if (!this.ctx.coreData.wizard.chosenFramework || !this.ctx.coreData.wizard.chosenBundler || !this.ctx.currentProject) {
1313
return []
1414
}
1515

1616
const packages: DependencyToInstall[] = [
17-
...this.ctx.coreData.wizard.chosenFramework.dependencies(
17+
...(await this.ctx.coreData.wizard.chosenFramework.dependencies(
1818
this.ctx.coreData.wizard.chosenBundler.type, this.ctx.currentProject,
19-
),
19+
)),
2020
]
2121

2222
if (this.ctx.lifecycleManager.metaState.isUsingTypeScript) {
2323
packages.push({
24-
...inPkgJson(WIZARD_DEPENDENCY_TYPESCRIPT, this.ctx.currentProject),
24+
...await (isDependencyInstalled(WIZARD_DEPENDENCY_TYPESCRIPT, this.ctx.currentProject)),
2525
dependency: WIZARD_DEPENDENCY_TYPESCRIPT,
2626
})
2727
}
2828

2929
return packages
3030
}
3131

32-
installDependenciesCommand () {
32+
async installDependenciesCommand () {
3333
const commands = {
3434
'npm': 'npm install -D',
3535
'pnpm': 'pnpm install -D',
3636
'yarn': 'yarn add -D',
3737
} as const
3838

39-
const deps = this.ctx.wizard.packagesToInstall()
39+
const deps = (await this.ctx.wizard.packagesToInstall())
4040
.filter((pack) => !pack.satisfied)
4141
.map((pack) => pack.dependency.installer)
4242
.join(' ')

packages/data-context/test/unit/sources/WizardDataSource.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('packagesToInstall', () => {
2525
coreData.wizard.chosenBundler = findBundler('webpack')
2626
})
2727

28-
const actual = ctx.wizard.installDependenciesCommand()
28+
const actual = await ctx.wizard.installDependenciesCommand()
2929

3030
expect(actual).to.eq(`npm install -D react-scripts webpack react-dom react`)
3131
})
@@ -41,7 +41,7 @@ describe('packagesToInstall', () => {
4141
coreData.wizard.chosenBundler = findBundler('webpack')
4242
})
4343

44-
const actual = ctx.wizard.installDependenciesCommand()
44+
const actual = await ctx.wizard.installDependenciesCommand()
4545

4646
expect(actual).to.eq(`npm install -D @vue/cli-service webpack vue@2`)
4747
})
@@ -57,7 +57,7 @@ describe('packagesToInstall', () => {
5757
coreData.wizard.chosenBundler = findBundler('webpack')
5858
})
5959

60-
const actual = ctx.wizard.installDependenciesCommand()
60+
const actual = await ctx.wizard.installDependenciesCommand()
6161

6262
expect(actual).to.eq(`npm install -D @vue/cli-service webpack vue`)
6363
})
@@ -73,7 +73,7 @@ describe('packagesToInstall', () => {
7373
coreData.wizard.chosenBundler = findBundler('webpack')
7474
})
7575

76-
const actual = ctx.wizard.installDependenciesCommand()
76+
const actual = await ctx.wizard.installDependenciesCommand()
7777

7878
expect(actual).to.eq(`npm install -D @vue/cli-service webpack vue`)
7979
})
@@ -89,7 +89,7 @@ describe('packagesToInstall', () => {
8989
coreData.wizard.chosenBundler = findBundler('vite')
9090
})
9191

92-
const actual = ctx.wizard.installDependenciesCommand()
92+
const actual = await ctx.wizard.installDependenciesCommand()
9393

9494
expect(actual).to.eq(`npm install -D vite react react-dom`)
9595
})
@@ -105,7 +105,7 @@ describe('packagesToInstall', () => {
105105
coreData.wizard.chosenBundler = findBundler('vite')
106106
})
107107

108-
const actual = ctx.wizard.installDependenciesCommand()
108+
const actual = await ctx.wizard.installDependenciesCommand()
109109

110110
expect(actual).to.eq(`npm install -D vite vue`)
111111
})
@@ -121,7 +121,7 @@ describe('packagesToInstall', () => {
121121
coreData.wizard.chosenBundler = findBundler('webpack')
122122
})
123123

124-
const actual = ctx.wizard.installDependenciesCommand()
124+
const actual = await ctx.wizard.installDependenciesCommand()
125125

126126
expect(actual).to.eq(`npm install -D next react react-dom`)
127127
})
@@ -137,7 +137,7 @@ describe('packagesToInstall', () => {
137137
coreData.wizard.chosenBundler = findBundler('webpack')
138138
})
139139

140-
const actual = ctx.wizard.installDependenciesCommand()
140+
const actual = await ctx.wizard.installDependenciesCommand()
141141

142142
expect(actual).to.eq('npm install -D nuxt@2 vue@2')
143143
})
@@ -153,7 +153,7 @@ describe('packagesToInstall', () => {
153153
coreData.wizard.chosenBundler = null
154154
})
155155

156-
const actual = ctx.wizard.installDependenciesCommand()
156+
const actual = await ctx.wizard.installDependenciesCommand()
157157

158158
expect(actual).to.eq('')
159159
})

packages/graphql/src/schemaTypes/objectTypes/gql-Mutation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export const mutation = mutationType({
176176
if (ctx.coreData.currentTestingType && !ctx.lifecycleManager.isTestingTypeConfigured(ctx.coreData.currentTestingType)) {
177177
// Component Testing has a wizard to help users configure their project
178178
if (ctx.coreData.currentTestingType === 'component') {
179-
ctx.actions.wizard.initialize()
179+
await ctx.actions.wizard.initialize()
180180
} else {
181181
// E2E doesn't have such a wizard, we just create/update their cypress.config.js.
182182
await ctx.actions.wizard.scaffoldTestingType()

packages/graphql/src/schemaTypes/objectTypes/gql-Wizard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export const Wizard = objectType({
3333
t.nonNull.list.nonNull.field('packagesToInstall', {
3434
type: WizardNpmPackage,
3535
description: 'A list of packages to install, null if we have not chosen both a framework and bundler',
36-
resolve: (source, args, ctx) => {
37-
return ctx.wizard.packagesToInstall().map((pkg) => {
36+
resolve: async (source, args, ctx) => {
37+
return (await ctx.wizard.packagesToInstall()).map((pkg) => {
3838
return {
3939
name: pkg.dependency.name,
4040
package: pkg.dependency.package,

packages/launchpad/cypress/e2e/config-warning.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('component testing dependency warnings', () => {
122122
cy.get('[data-cy="warning-alert"]').should('not.exist')
123123
cy.get('a').contains('Projects').click()
124124
cy.get('[data-cy-testingtype="component"]').click()
125-
cy.get('[data-cy="warning-alert"]').should('exist')
125+
cy.get('[data-cy="warning-alert"]', { timeout: 12000 }).should('exist')
126126
.should('contain.text', 'Warning: Component Testing Mismatched Dependencies')
127127
.should('contain.text', 'vite. Expected ^=2.0.0 || ^=3.0.0, found 2.0.0-beta.70')
128128
.should('contain.text', 'react. Expected ^=16.0.0 || ^=17.0.0 || ^=18.0.0, found 15.6.2.')
@@ -140,7 +140,7 @@ describe('component testing dependency warnings', () => {
140140
cy.get('[data-cy="warning-alert"]').should('not.exist')
141141
cy.get('a').contains('Projects').click()
142142
cy.get('[data-cy-testingtype="component"]').click()
143-
cy.get('[data-cy="warning-alert"]').should('exist')
143+
cy.get('[data-cy="warning-alert"]', { timeout: 12000 }).should('exist')
144144
.should('contain.text', 'Warning: Component Testing Mismatched Dependencies')
145145
.should('contain.text', '@vue/cli-service. Expected ^=4.0.0 || ^=5.0.0, found 3.12.1.')
146146
.should('contain.text', 'vue. Expected ^3.0.0, found 2.7.8.')
@@ -159,7 +159,7 @@ describe('component testing dependency warnings', () => {
159159
cy.get('[data-cy-testingtype="component"]').click()
160160

161161
// Wait until launch browser screen and assert warning does not exist
162-
cy.contains('Choose a Browser')
162+
cy.contains('Choose a Browser', { timeout: 12000 })
163163
cy.get('[data-cy="warning-alert"]').should('not.exist')
164164
})
165165
})

0 commit comments

Comments
 (0)