mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-22 15:12:27 -05:00
provide context in the status commit message
This commit is contained in:
+1
-1
@@ -64,7 +64,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cypress/bumpercar": "2.0.6",
|
||||
"@cypress/commit-message-install": "2.3.0",
|
||||
"@cypress/commit-message-install": "2.4.2",
|
||||
"@cypress/env-or-json-file": "2.0.0",
|
||||
"@cypress/npm-run-all": "4.0.5",
|
||||
"@cypress/questions-remain": "1.0.1",
|
||||
|
||||
+24
-25
@@ -175,39 +175,38 @@ module.exports = {
|
||||
# triggers test projects on multiple CIs
|
||||
# the test projects will exercise the new version of
|
||||
# the Cypress test runner we just built
|
||||
runTestProjects: (status, message, providerName, version) ->
|
||||
runTestProjects: (getStatusAndMessage, providerName, version) ->
|
||||
# status is {owner, repo, sha}
|
||||
|
||||
projectFilter = getFilterByProvider(providerName)
|
||||
|
||||
if not message
|
||||
message =
|
||||
"""
|
||||
Testing new Cypress version #{version}
|
||||
|
||||
"""
|
||||
if process.env.CIRCLE_BUILD_URL
|
||||
message += "\n"
|
||||
message += "Circle CI build url #{process.env.CIRCLE_BUILD_URL}"
|
||||
|
||||
if process.env.APPVEYOR
|
||||
slug = process.env.APPVEYOR_PROJECT_SLUG
|
||||
build = process.env.APPVEYOR_BUILD_ID
|
||||
message += "\n"
|
||||
message += "AppVeyor CI #{slug} #{build}"
|
||||
|
||||
makeCommit = (project, provider, creds) ->
|
||||
# instead of triggering CI via API
|
||||
# car.runProject(project, provider)
|
||||
# make empty commit to trigger CIs
|
||||
|
||||
# project is owner/repo string like cypress-io/cypress-test-tiny
|
||||
|
||||
## make empty commit to trigger CIs
|
||||
## project is owner/repo string like cypress-io/cypress-test-tiny
|
||||
console.log("making commit to project", project)
|
||||
|
||||
parsedRepo = parse(project)
|
||||
owner = parsedRepo[0]
|
||||
repo = parsedRepo[1]
|
||||
|
||||
{ status, message } = getStatusAndMessage(repo)
|
||||
|
||||
if not message
|
||||
message =
|
||||
"""
|
||||
Testing new Cypress version #{version}
|
||||
|
||||
"""
|
||||
if process.env.CIRCLE_BUILD_URL
|
||||
message += "\n"
|
||||
message += "Circle CI build url #{process.env.CIRCLE_BUILD_URL}"
|
||||
|
||||
if process.env.APPVEYOR
|
||||
slug = process.env.APPVEYOR_PROJECT_SLUG
|
||||
build = process.env.APPVEYOR_BUILD_ID
|
||||
message += "\n"
|
||||
message += "AppVeyor CI #{slug} #{build}"
|
||||
|
||||
defaultOptions = {
|
||||
owner,
|
||||
repo,
|
||||
@@ -224,9 +223,9 @@ module.exports = {
|
||||
owner: status.owner,
|
||||
repo: status.repo,
|
||||
sha: status.sha,
|
||||
context: status.context,
|
||||
state: 'pending',
|
||||
description: "#{owner}/#{repo}",
|
||||
context: "[#{os.platform()}-#{os.arch()}] #{repo}"
|
||||
}
|
||||
|
||||
console.log(
|
||||
@@ -234,7 +233,7 @@ module.exports = {
|
||||
commitStatusOptions.description,
|
||||
commitStatusOptions.context
|
||||
)
|
||||
|
||||
|
||||
setCommitStatus(commitStatusOptions)
|
||||
|
||||
if not version
|
||||
|
||||
@@ -90,54 +90,62 @@ const env = {
|
||||
CYPRESS_INSTALL_BINARY: binary,
|
||||
}
|
||||
|
||||
// also pass "status" object that points back at this repo and this commit
|
||||
// so that other projects can report their test success as GitHub commit status check
|
||||
let status = null
|
||||
const commit = commitInfo && commitInfo.sha
|
||||
const getStatusAndMessage = (projectRepoName) => {
|
||||
// also pass "status" object that points back at this repo and this commit
|
||||
// so that other projects can report their test success as GitHub commit status check
|
||||
let status = null
|
||||
const commit = commitInfo && commitInfo.sha
|
||||
|
||||
if (commit && is.commitId(commit)) {
|
||||
// commit is full 40 character hex string
|
||||
status = {
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
sha: commit,
|
||||
if (commit && is.commitId(commit)) {
|
||||
// commit is full 40 character hex string
|
||||
status = {
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
sha: commit,
|
||||
context: `[${os.platform()}-${os.arch()}] ${projectRepoName}`,
|
||||
}
|
||||
}
|
||||
|
||||
const commitMessageInstructions = getInstallJson({
|
||||
packages: npm,
|
||||
env,
|
||||
platform,
|
||||
arch,
|
||||
branch: shortNpmVersion, // use as version as branch name on test projects
|
||||
commit,
|
||||
status,
|
||||
})
|
||||
const jsonBlock = toMarkdownJsonBlock(commitMessageInstructions)
|
||||
const footer = 'Use tool `@cypress/commit-message-install` to install from above block'
|
||||
let message = `${subject}\n\n${jsonBlock}\n${footer}\n`
|
||||
|
||||
if (process.env.CIRCLE_BUILD_URL) {
|
||||
message += '\n'
|
||||
message += stripIndent`
|
||||
CircleCI job url: ${process.env.CIRCLE_BUILD_URL}
|
||||
`
|
||||
}
|
||||
|
||||
if (process.env.APPVEYOR) {
|
||||
const account = process.env.APPVEYOR_ACCOUNT_NAME
|
||||
const slug = process.env.APPVEYOR_PROJECT_SLUG
|
||||
const build = process.env.APPVEYOR_BUILD_NUMBER
|
||||
|
||||
message += '\n'
|
||||
message += stripIndent`
|
||||
AppVeyor: ${account}/${slug} ${build}
|
||||
`
|
||||
}
|
||||
|
||||
console.log('commit message:')
|
||||
console.log(message)
|
||||
|
||||
return {
|
||||
status,
|
||||
message,
|
||||
}
|
||||
}
|
||||
|
||||
const commitMessageInstructions = getInstallJson({
|
||||
packages: npm,
|
||||
env,
|
||||
platform,
|
||||
arch,
|
||||
branch: shortNpmVersion, // use as version as branch name on test projects
|
||||
commit,
|
||||
status,
|
||||
})
|
||||
const jsonBlock = toMarkdownJsonBlock(commitMessageInstructions)
|
||||
const footer = 'Use tool `@cypress/commit-message-install` to install from above block'
|
||||
let message = `${subject}\n\n${jsonBlock}\n${footer}\n`
|
||||
|
||||
if (process.env.CIRCLE_BUILD_URL) {
|
||||
message += '\n'
|
||||
message += stripIndent`
|
||||
CircleCI job url: ${process.env.CIRCLE_BUILD_URL}
|
||||
`
|
||||
}
|
||||
|
||||
if (process.env.APPVEYOR) {
|
||||
const account = process.env.APPVEYOR_ACCOUNT_NAME
|
||||
const slug = process.env.APPVEYOR_PROJECT_SLUG
|
||||
const build = process.env.APPVEYOR_BUILD_NUMBER
|
||||
|
||||
message += '\n'
|
||||
message += stripIndent`
|
||||
AppVeyor: ${account}/${slug} ${build}
|
||||
`
|
||||
}
|
||||
|
||||
console.log('commit message')
|
||||
console.log(message)
|
||||
|
||||
const onError = (e) => {
|
||||
console.error('could not bump test projects')
|
||||
console.error(e)
|
||||
@@ -145,5 +153,5 @@ const onError = (e) => {
|
||||
}
|
||||
|
||||
bump
|
||||
.runTestProjects(status, message, cliOptions.provider, shortNpmVersion)
|
||||
.runTestProjects(getStatusAndMessage, cliOptions.provider, shortNpmVersion)
|
||||
.catch(onError)
|
||||
|
||||
Reference in New Issue
Block a user