Skip to content

Commit

Permalink
only log next-version for scripting
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyrohrbough committed Jan 27, 2023
1 parent 8d72157 commit 7e33096
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 36 deletions.
3 changes: 2 additions & 1 deletion scripts/binary/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
// store the cwd
const cwd = process.cwd()

Expand Down Expand Up @@ -194,7 +195,7 @@ const deploy = {

return askMissingOptions(['version', 'platform'])(options)
.then(() => {
debug('building binary: platform %s version %s', options.platform, options.version)
console.log('building binary: platform %s version %s', options.platform, options.version)

return build.buildCypressApp(options)
})
Expand Down
7 changes: 3 additions & 4 deletions scripts/get-next-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ const { promisify } = require('util')

const checkedInBinaryVersion = require('../package.json').version
const { changeCatagories } = require('./semantic-commits/change-categories')
const { getCurrentReleaseData } = require('./semantic-commits/get-binary-release-data')
const { getCurrentReleaseData } = require('./semantic-commits/get-current-release-data')

const bump = promisify(bumpCb)
const paths = ['packages', 'cli']

const getNextVersionForPath = async (path) => {
const { version: releasedVersion } = await getCurrentReleaseData()
const { version: releasedVersion } = await getCurrentReleaseData(false)

let commits
const whatBump = (foundCommits) => {
Expand Down Expand Up @@ -56,10 +57,8 @@ const getNextVersionForPath = async (path) => {
// See ../guides/next-version.md for documentation.
// for the time being, honoring this ENV -- ideally this will be deleted to remove manually overriding without a PR
if (process.env.NEXT_VERSION) {
console.log('honoring process.env.NEXT_VERSION')
nextVersion = process.env.NEXT_VERSION
} else if (hasVersionBump) {
console.log('honoring the approved binary version bump')
nextVersion = checkedInBinaryVersion
}

Expand Down
21 changes: 1 addition & 20 deletions scripts/semantic-commits/get-binary-release-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,12 @@ const execa = require('execa')
const _ = require('lodash')
const { Octokit } = require('@octokit/core')

const { getCurrentReleaseData } = require('../get-current-release-data')
const { getNextVersionForBinary } = require('../get-next-version')
const { getLinkedIssues } = require('./get-linked-issues')

const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })

/**
* Get the version, commit date and git sha of the latest tag published on npm.
*/
const getCurrentReleaseData = async () => {
console.log('Get Current Release Information\n')
const { stdout } = await execa('npm', ['info', 'cypress', '--json'])
const npmInfo = JSON.parse(stdout)

const latestReleaseInfo = {
version: npmInfo['dist-tags'].latest,
commitDate: npmInfo.buildInfo.commitDate,
buildSha: npmInfo.buildInfo.commitSha,
}

console.log({ latestReleaseInfo })

return latestReleaseInfo
}

/**
* Get the list of file names that have been added, deleted or changed since the git
* sha associated with the latest tag published on npm.
Expand Down Expand Up @@ -117,7 +99,6 @@ const getReleaseData = async (latestReleaseInfo) => {

if (require.main !== module) {
module.exports = {
getCurrentReleaseData,
getReleaseData,
}

Expand Down
25 changes: 25 additions & 0 deletions scripts/semantic-commits/get-current-release-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable no-console */
const execa = require('execa')

/**
* Get the version, commit date and git sha of the latest tag published on npm.
*/
const getCurrentReleaseData = async (verbose = true) => {
verbose && console.log('Get Current Release Information\n')
const { stdout } = await execa('npm', ['info', 'cypress', '--json'])
const npmInfo = JSON.parse(stdout)

const latestReleaseInfo = {
version: npmInfo['dist-tags'].latest,
commitDate: npmInfo.buildInfo.commitDate,
buildSha: npmInfo.buildInfo.commitSha,
}

verbose && console.log({ latestReleaseInfo })

return latestReleaseInfo
}

module.exports = {
getCurrentReleaseData,
}
3 changes: 2 additions & 1 deletion scripts/semantic-commits/validate-binary-changelog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-console */
const { validateChangelog } = require('./validate-changelog')
const { getCurrentReleaseData, getReleaseData } = require('./get-binary-release-data')
const { getCurrentReleaseData } = require('./get-current-release-data')
const { getReleaseData } = require('./get-binary-release-data')
const checkedInBinaryVersion = require('../../package.json').version

const changelog = async () => {
Expand Down
23 changes: 13 additions & 10 deletions scripts/unit/get-next-version-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ describe('get-next-version', () => {

bumpStub = sinon.stub()
getCurrentReleaseDataStub = sinon.stub()
getCurrentReleaseDataStub.resolves({
version: releasedVersion,
})

const npmRelease = proxyquire('../get-next-version', {
'conventional-recommended-bump': bumpStub,
'./semantic-commits/get-binary-release-data': {
'./semantic-commits/get-current-release-data': {
getCurrentReleaseData: getCurrentReleaseDataStub,
},
'../package.json': sinon.stub({ version: '12.2.0' }),
Expand All @@ -47,7 +50,7 @@ describe('get-next-version', () => {
return cb(undefined, { releaseType: 'patch' })
})

const { nextVersion, commits } = await getNextVersionForPath('packages', releasedVersion)
const { nextVersion, commits } = await getNextVersionForPath('packages')

expect(nextVersion).to.eq('12.2.1')
expect(commits).to.contain.members(semanticCommits)
Expand All @@ -67,7 +70,7 @@ describe('get-next-version', () => {
return cb(undefined, { releaseType: 'minor' })
})

const { nextVersion, commits } = await getNextVersionForPath('packages', releasedVersion)
const { nextVersion, commits } = await getNextVersionForPath('packages')

expect(nextVersion).to.eq('12.3.0')
expect(commits).to.contain.members(semanticCommits)
Expand All @@ -88,7 +91,7 @@ describe('get-next-version', () => {
return cb(undefined, { releaseType: 'major' })
})

const { nextVersion, commits } = await getNextVersionForPath('packages', releasedVersion)
const { nextVersion, commits } = await getNextVersionForPath('packages')

expect(nextVersion).to.eq('13.0.0')
expect(commits).to.contain.members(semanticCommits)
Expand All @@ -107,8 +110,12 @@ describe('get-next-version', () => {
return cb(undefined, { releaseType: 'patch' })
})

// package version !== release version assumed check in version is correct
const { nextVersion, commits } = await getNextVersionForPath('packages', '12.2.2')
getCurrentReleaseDataStub.resolves({
// package version !== release version assumed check in version is correct
version: '12.2.2',
})

const { nextVersion, commits } = await getNextVersionForPath('packages')

expect(nextVersion).to.eq('12.2.0')
expect(commits).to.contain.members(semanticCommits)
Expand Down Expand Up @@ -148,10 +155,6 @@ describe('get-next-version', () => {
{ type: 'feat', title: 'feat: add new command' },
]

getCurrentReleaseDataStub.resolves({
version: releasedVersion,
})

bumpStub.callsFake(async ({ whatBump, _path }, cb) => {
if (calls === 0) {
const { level } = whatBump(packagesSemanticCommits)
Expand Down

1 comment on commit 7e33096

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7e33096 Jan 27, 2023

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.4.1/linux-x64/emily/next-version-7e330969fe6360a46a539221e5c471f39c2c8aee/cypress.tgz

Please sign in to comment.