Skip to content

Commit

Permalink
Merge branch '10.0-release' into marktnoonan/backmerge-develop-3-8-22
Browse files Browse the repository at this point in the history
  • Loading branch information
marktnoonan authored Mar 9, 2022
2 parents 6d83e83 + e1a647b commit 3a63b92
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 7 deletions.
41 changes: 34 additions & 7 deletions packages/data-context/src/sources/VersionsDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,28 @@ export class VersionsDataSource {
}

private async getVersionMetadata (): Promise<Record<string, string>> {
const DEFAULT_RESPONSE = {
[pkg.version]: new Date().toISOString(),
}

if (this.ctx.isRunMode) {
return {
[pkg.version]: new Date().toISOString(),
}
return DEFAULT_RESPONSE
}

let response

try {
response = await this.ctx.util.fetch(NPM_CYPRESS_REGISTRY)
} catch (e) {
// ignore any error from this fetch, they are gracefully handled
// by showing the current version only
debug('Error fetching %o', NPM_CYPRESS_REGISTRY, e)
}

if (!response) {
return DEFAULT_RESPONSE
}

const response = await this.ctx.util.fetch(NPM_CYPRESS_REGISTRY)
const responseJson = await response.json() as { time: Record<string, string>}

debug('NPM release dates %o', responseJson.time)
Expand Down Expand Up @@ -116,9 +131,21 @@ export class VersionsDataSource {
manifestHeaders['x-machine-id'] = id
}

const manifestResponse = await this.ctx.util.fetch(url, {
headers: manifestHeaders,
})
let manifestResponse

try {
manifestResponse = await this.ctx.util.fetch(url, {
headers: manifestHeaders,
})
} catch (e) {
// ignore any error from this fetch, they are gracefully handled
// by showing the current version only
debug('Error fetching %o', url, e)
}

if (!manifestResponse) {
return pkg.version
}

debug('retrieving latest version information with headers: %o', manifestHeaders)

Expand Down
26 changes: 26 additions & 0 deletions packages/data-context/test/unit/sources/VersionsDataSource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,31 @@ describe('VersionsDataSource', () => {

expect(latestVersion).to.eql('16.0.0')
})

it('handles errors fetching version data', async () => {
nmiStub.resolves('abcd123')

fetchStub
.withArgs('https://download.cypress.io/desktop.json', {
headers: {
'Content-Type': 'application/json',
'x-cypress-version': currentCypressVersion,
'x-os-name': 'darwin',
'x-arch': 'x64',
'x-initial-launch': String(true),
'x-machine-id': 'abcd123',
'x-testing-type': 'e2e',
},
})
.rejects()
.withArgs('https://registry.npmjs.org/cypress')
.rejects()

versionsDataSource = new VersionsDataSource(ctx)

const versionInfo = await versionsDataSource.versionData()

expect(versionInfo.current).to.eql(versionInfo.latest)
})
})
})

3 comments on commit 3a63b92

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3a63b92 Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.0/linux-x64/marktnoonan/backmerge-develop-3-8-22-3a63b923b84376c1e7cc7a4385f97b40dbc329f3/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3a63b92 Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.0/win32-x64/marktnoonan/backmerge-develop-3-8-22-3a63b923b84376c1e7cc7a4385f97b40dbc329f3/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3a63b92 Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.0/darwin-x64/marktnoonan/backmerge-develop-3-8-22-3a63b923b84376c1e7cc7a4385f97b40dbc329f3/cypress.tgz

Please sign in to comment.