Skip to content

Commit

Permalink
chore: fix changlelog section parsing and reference right ENV (#25633)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyrohrbough authored Jan 31, 2023
1 parent 660ff67 commit 6f1653c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
6 changes: 5 additions & 1 deletion scripts/semantic-commits/get-binary-release-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ 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 })
if (process.env.CIRCLECI && !process.env.GH_TOKEN) {
throw new Error('The GITHUB_TOKEN env is not set.')
}

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

/**
* Get the list of file names that have been added, deleted or changed since the git
Expand Down
27 changes: 13 additions & 14 deletions scripts/semantic-commits/parse-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
const fs = require('fs')
const path = require('path')
const { userFacingChanges } = require('./change-categories')

const isValidSection = (section) => {
return Object.values(userFacingChanges).some((set) => {
return set.section === section
})
}
const userFacingSections = Object.values(userFacingChanges).map(({ section }) => section)

async function parseChangelog (pendingRelease = true) {
const changelog = fs.readFileSync(path.join(__dirname, '..', '..', 'cli', 'CHANGELOG.md'), 'utf8')
Expand Down Expand Up @@ -38,35 +33,39 @@ async function parseChangelog (pendingRelease = true) {

if (index === 1) {
if (!/^## \d+\.\d+\.\d+/.test(line)) {
throw new Error(`Expected line number ${index} to include "## x.x.x"`)
throw new Error(`Expected line number ${index + 1} to include "## x.x.x"`)
}

sections['version'] = line
} else if (index === 3) {
nextKnownLineBreak = index + 1
if (pendingRelease && !/_Released \d+\/\d+\/\d+ \(PENDING\)_/.test(line)) {
throw new Error(`Expected line number ${index} to include "_Released xx/xx/xxxx (PENDING)_"`)
throw new Error(`Expected line number ${index + 1} to include "_Released xx/xx/xxxx (PENDING)_"`)
} else if (!pendingRelease && !/_Released \d+\/\d+\/\d+__/.test(line)) {
throw new Error(`Expected line number ${index} to include "_Released xx/xx/xxxx_"`)
throw new Error(`Expected line number ${index + 1} to include "_Released xx/xx/xxxx_"`)
}

sections['releaseDate'] = line
} else if (index === nextKnownLineBreak) {
if (line !== '') {
throw new Error(`Expected line number ${index} to be a line break`)
throw new Error(`Expected line number ${index + 1} to be a line break`)
}
} else {
const result = /\*\*([A-Z])\w+:\*\*/.exec(line)
const result = /\*\*.+?:\*\*/.exec(line)

if (currentSection === '' && !result) {
throw new Error(`Expected line number ${index + 1} to be a valid section header. Received ${line}. Expected one of ...\n - ${userFacingSections.join('\n - ')}`)
}

if (result) {
const section = result[0]

if (!isValidSection(section)) {
throw new Error(`Expected line number ${index} to be a valid section header. Received ${section}. Expected one of ...`)
if (!userFacingSections.includes(section)) {
throw new Error(`Expected line number ${index + 1} to be a valid section header. Received ${section}. Expected one of ...\n - ${userFacingSections.join('\n - ')}`)
}

if (result === currentSection || sections[section]) {
throw new Error(`Duplicate section header of "${section}" on line number ${index}. Condense change content under a single section header.`)
throw new Error(`Duplicate section header of "${section}" on line number ${index + 1}. Condense change content under a single section header.`)
}

if (currentSection !== '') {
Expand Down
2 changes: 1 addition & 1 deletion scripts/semantic-commits/validate-binary-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const changelog = async () => {

const hasVersionBump = checkedInBinaryVersion !== latestReleaseInfo.version

if (process.env.CIRCLE_BRANCH !== 'develop' && !/^release\/\d+\.\d+\.\d+$/.test(process.env.CIRCLE_BRANCH) && !hasVersionBump) {
if (process.env.CIRCLE_BRANCH !== 'develop' && process.env.CIRCLE_BRANCH !== 'emily/changelog2' && !/^release\/\d+\.\d+\.\d+$/.test(process.env.CIRCLE_BRANCH) && !hasVersionBump) {
console.log('Only verify the entire changelog for develop, a release branch or any branch that bumped to the Cypress version in the package.json.')

return
Expand Down

3 comments on commit 6f1653c

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6f1653c Jan 31, 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 arm64 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.5.0/linux-arm64/develop-6f1653cf6d4c2543b14ba4bf3ac4b73ff16bab18/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6f1653c Jan 31, 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.5.0/linux-x64/develop-6f1653cf6d4c2543b14ba4bf3ac4b73ff16bab18/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6f1653c Jan 31, 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 darwin 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.5.0/darwin-x64/develop-6f1653cf6d4c2543b14ba4bf3ac4b73ff16bab18/cypress.tgz

Please sign in to comment.