mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-25 10:19:30 -05:00
chore: remove release dates from cli/CHANGELOG.md (#33603)
This commit is contained in:
@@ -3,7 +3,7 @@ const path = require('path')
|
||||
const { userFacingChanges } = require('./change-categories')
|
||||
const userFacingSections = Object.values(userFacingChanges).map(({ section }) => section)
|
||||
|
||||
async function parseChangelog ({ pendingRelease = true, changelogContent = null } = {}) {
|
||||
async function parseChangelog ({ changelogContent = null } = {}) {
|
||||
const changelog = changelogContent || fs.readFileSync(path.join(__dirname, '..', '..', 'cli', 'CHANGELOG.md'), 'utf8')
|
||||
const changeLogLines = changelog.split('\n')
|
||||
|
||||
@@ -36,15 +36,6 @@ async function parseChangelog ({ pendingRelease = true, changelogContent = null
|
||||
}
|
||||
|
||||
sections['version'] = line
|
||||
} else if (index === 3) {
|
||||
nextKnownLineBreak = index + 1
|
||||
if (pendingRelease && !/_Released [A-Z][a-z]{2} ([1-9]|[12]\d|3[01]), \d{4} \(PENDING\)_/.test(line)) {
|
||||
throw new Error(`Expected line number ${index + 1} to include "_Released Mon D, YYYY (PENDING)_"`)
|
||||
} else if (!pendingRelease && !/_Released [A-Z][a-z]{2} ([1-9]|[12]\d|3[01]), \d{4}_/.test(line)) {
|
||||
throw new Error(`Expected line number ${index + 1} to include "_Released Mon D, YYYY_"`)
|
||||
}
|
||||
|
||||
sections['releaseDate'] = line
|
||||
} else if (index === nextKnownLineBreak) {
|
||||
if (line !== '') {
|
||||
throw new Error(`Expected line number ${index + 1} to be a line break`)
|
||||
|
||||
@@ -40,7 +40,6 @@ const changelog = async () => {
|
||||
return validateChangelog({
|
||||
nextVersion,
|
||||
changedFiles,
|
||||
pendingRelease: !hasVersionBump,
|
||||
commits,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ const _handleErrors = (errors) => {
|
||||
* environment variable in CircleCI to a branch or comma-separated list of
|
||||
* branches
|
||||
*/
|
||||
async function validateChangelog ({ changedFiles, nextVersion, pendingRelease, commits, changelogContent }) {
|
||||
async function validateChangelog ({ changedFiles, nextVersion, commits, changelogContent }) {
|
||||
if (process.env.SKIP_RELEASE_CHANGELOG_VALIDATION_FOR_BRANCHES) {
|
||||
const branches = process.env.SKIP_RELEASE_CHANGELOG_VALIDATION_FOR_BRANCHES.split(',')
|
||||
|
||||
@@ -140,7 +140,23 @@ async function validateChangelog ({ changedFiles, nextVersion, pendingRelease, c
|
||||
}
|
||||
}
|
||||
|
||||
const hasUserFacingCommits = commits.some(({ semanticType }) => hasUserFacingChange(semanticType))
|
||||
// Build a set of PR numbers that were reverted within this release window so
|
||||
// they can be excluded from changelog validation — a reverted commit should
|
||||
// not appear in the changelog since the change never shipped to users.
|
||||
const revertedPRNumbers = new Set()
|
||||
|
||||
commits.forEach(({ commitMessage }) => {
|
||||
// Revert messages look like: revert: "fix: something (#33512)" (#33611)
|
||||
const match = commitMessage && commitMessage.match(/revert.*\(#(\d+)\)"/i)
|
||||
|
||||
if (match) {
|
||||
revertedPRNumbers.add(String(match[1]))
|
||||
}
|
||||
})
|
||||
|
||||
const nonRevertedCommits = commits.filter(({ prNumber }) => !revertedPRNumbers.has(String(prNumber)))
|
||||
|
||||
const hasUserFacingCommits = nonRevertedCommits.some(({ semanticType }) => hasUserFacingChange(semanticType))
|
||||
|
||||
if (!hasUserFacingCommits) {
|
||||
console.log('Does not contain any user-facing changes that impact the next Cypress release.')
|
||||
@@ -164,20 +180,20 @@ async function validateChangelog ({ changedFiles, nextVersion, pendingRelease, c
|
||||
if (!hasChangeLogUpdate) {
|
||||
errors.push(`A changelog entry was not found in cli/CHANGELOG.md.`)
|
||||
|
||||
if (commits.length === 1) {
|
||||
errors.push(`Please add a changelog entry that describes the changes. Include this entry under the section:\n\n${_printChangeLogExample(commits[0].semanticType, commits[0].prNumber, commits[0].associatedIssues)}`)
|
||||
if (nonRevertedCommits.length === 1) {
|
||||
errors.push(`Please add a changelog entry that describes the changes. Include this entry under the section:\n\n${_printChangeLogExample(nonRevertedCommits[0].semanticType, nonRevertedCommits[0].prNumber, nonRevertedCommits[0].associatedIssues)}`)
|
||||
|
||||
return _handleErrors(errors)
|
||||
}
|
||||
}
|
||||
|
||||
const changelog = await parseChangelog({ pendingRelease, changelogContent })
|
||||
const changelog = await parseChangelog({ changelogContent })
|
||||
|
||||
if (nextVersion && !changelog.version === `## ${nextVersion}`) {
|
||||
errors.push(`The changelog version does not contain the next Cypress version of ${nextVersion}. If the changelog version is correct, please correct the pull request title to correctly reflect the change being made.`)
|
||||
}
|
||||
|
||||
commits.forEach(({ commitMessage, semanticType, prNumber, associatedIssues }) => {
|
||||
nonRevertedCommits.forEach(({ commitMessage, semanticType, prNumber, associatedIssues }) => {
|
||||
if (!Object.keys(userFacingChanges).includes(semanticType)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -143,8 +143,6 @@ describe('semantic-pull-request/validate-changelog', () => {
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
_Released Jan 7, 2033 (PENDING)_
|
||||
|
||||
**Performance:**
|
||||
|
||||
- Fixed in [#77](https://github.com/cypress-io/cypress/pull/77).`)
|
||||
@@ -169,8 +167,6 @@ _Released Jan 7, 2033 (PENDING)_
|
||||
const changelogContent = `
|
||||
## 120.2.0
|
||||
|
||||
_Released Jan 7, 2033 (PENDING)_
|
||||
|
||||
**Performance:**
|
||||
|
||||
- Fixed in [#77](https://github.com/cypress-io/cypress/pull/77).`
|
||||
@@ -196,8 +192,6 @@ _Released Jan 7, 2033 (PENDING)_
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
_Released Jan 7, 2033 (PENDING)_
|
||||
|
||||
**Misc:**
|
||||
|
||||
- Addresses [#77](https://github.com/cypress-io/cypress/issues/77) and [#88](https://github.com/cypress-io/cypress/issues/88).`)
|
||||
@@ -253,6 +247,82 @@ _Released Jan 7, 2033 (PENDING)_
|
||||
expect(console.log).to.be.calledWith('Does not contain changes that impact the next Cypress release.')
|
||||
})
|
||||
|
||||
it('when a user-facing commit was reverted within the same release (conventional revert: style)', async () => {
|
||||
const changedFiles = [
|
||||
'packages/driver/lib/index.js',
|
||||
'cli/CHANGELOG.md',
|
||||
]
|
||||
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
**Performance:**
|
||||
|
||||
- Fixed in [#77](https://github.com/cypress-io/cypress/pull/77).`)
|
||||
|
||||
await validateChangelog({
|
||||
changedFiles,
|
||||
commits: [
|
||||
{
|
||||
commitMessage: 'perf: do something faster (#77)',
|
||||
prNumber: 77,
|
||||
semanticType: 'perf',
|
||||
},
|
||||
{
|
||||
commitMessage: 'fix: a bug (#88)',
|
||||
prNumber: 88,
|
||||
semanticType: 'fix',
|
||||
},
|
||||
{
|
||||
// conventional-commits lowercase revert style
|
||||
commitMessage: 'revert: "fix: a bug (#88)" (#99)',
|
||||
prNumber: 99,
|
||||
semanticType: 'revert',
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
expect(console.log).to.be.calledWith('It appears at a high-level your changelog entry is correct! The remaining validation is left to the pull request reviewers.')
|
||||
})
|
||||
|
||||
it('when a user-facing commit was reverted within the same release (GitHub Revert style)', async () => {
|
||||
const changedFiles = [
|
||||
'packages/driver/lib/index.js',
|
||||
'cli/CHANGELOG.md',
|
||||
]
|
||||
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
**Performance:**
|
||||
|
||||
- Fixed in [#77](https://github.com/cypress-io/cypress/pull/77).`)
|
||||
|
||||
await validateChangelog({
|
||||
changedFiles,
|
||||
commits: [
|
||||
{
|
||||
commitMessage: 'perf: do something faster (#77)',
|
||||
prNumber: 77,
|
||||
semanticType: 'perf',
|
||||
},
|
||||
{
|
||||
commitMessage: 'fix: a bug (#88)',
|
||||
prNumber: '88',
|
||||
semanticType: 'fix',
|
||||
},
|
||||
{
|
||||
// GitHub UI uppercase Revert style; prNumber as string (from parser)
|
||||
commitMessage: 'Revert "fix: a bug (#88)" (#99)',
|
||||
prNumber: 99,
|
||||
semanticType: 'revert',
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
expect(console.log).to.be.calledWith('It appears at a high-level your changelog entry is correct! The remaining validation is left to the pull request reviewers.')
|
||||
})
|
||||
|
||||
it('when current branch is in SKIP_RELEASE_CHANGELOG_VALIDATION_FOR_BRANCHES env var', async () => {
|
||||
process.env.CIRCLE_BRANCH = 'this-branch'
|
||||
process.env.SKIP_RELEASE_CHANGELOG_VALIDATION_FOR_BRANCHES = 'this-branch,that-branch'
|
||||
@@ -283,8 +353,6 @@ _Released Jan 7, 2033 (PENDING)_
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
_Released Jan 7, 2033 (PENDING)_
|
||||
|
||||
`)
|
||||
|
||||
return validateChangelog({
|
||||
@@ -310,8 +378,6 @@ _Released Jan 7, 2033 (PENDING)_
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
_Released Jan 7, 2033 (PENDING)_
|
||||
|
||||
**Features:**
|
||||
|
||||
- Addresses [#75](https://github.com/cypress-io/cypress/issues/75).`)
|
||||
@@ -339,8 +405,6 @@ _Released Jan 7, 2033 (PENDING)_
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
_Released Jan 7, 2033 (PENDING)_
|
||||
|
||||
**Performance:**
|
||||
|
||||
- Some other update already added & vetted. Addresses [#32](https://github.com/cypress-io/cypress/issues/32).
|
||||
@@ -372,8 +436,6 @@ _Released Jan 7, 2033 (PENDING)_
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
_Released Jan 7, 2033 (PENDING)_
|
||||
|
||||
**Performance:**
|
||||
|
||||
- comment without link.`)
|
||||
@@ -401,8 +463,6 @@ _Released Jan 7, 2033 (PENDING)_
|
||||
fs.readFileSync.returns(`
|
||||
## 120.2.0
|
||||
|
||||
_Released Jan 7, 2033 (PENDING)_
|
||||
|
||||
**Performance:**
|
||||
|
||||
- comment without link.`)
|
||||
|
||||
Reference in New Issue
Block a user