mirror of
https://github.com/joaquinjsb/gitea-release-please-action
synced 2026-05-12 15:41:34 +02:00
feat: add pull-request-title-pattern option (#259)
This commit is contained in:
@@ -46,6 +46,7 @@ Automate releases with Conventional Commit Messages.
|
|||||||
| `fork` | Should the PR be created from a fork. Default `false`|
|
| `fork` | Should the PR be created from a fork. Default `false`|
|
||||||
| `command` | release-please command to run, either `github-release`, or `release-pr` (_defaults to running both_) |
|
| `command` | release-please command to run, either `github-release`, or `release-pr` (_defaults to running both_) |
|
||||||
| `default-branch` | branch to open pull release PR against (detected by default) |
|
| `default-branch` | branch to open pull release PR against (detected by default) |
|
||||||
|
| `pull-request-title-pattern` | title pattern used to make release PR, defaults to using `chore${scope}: release${component} ${version}`. |
|
||||||
|
|
||||||
| output | description |
|
| output | description |
|
||||||
|:---:|---|
|
|:---:|---|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
fork:
|
fork:
|
||||||
description: 'should the PR be proposed from a fork (does not work with secrets.GITHUB_TOKEN)'
|
description: 'should the PR be proposed from a fork, Default to false'
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
clean:
|
clean:
|
||||||
@@ -52,6 +52,11 @@ inputs:
|
|||||||
description: 'branch to open pull release PR against (detected by default)'
|
description: 'branch to open pull release PR against (detected by default)'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
pull-request-title-pattern:
|
||||||
|
description: 'add title pattern to make release PR, defaults to using "chore${scope}: release${component} ${version}".'
|
||||||
|
required: false
|
||||||
|
default: 'chore${scope}: release${component} ${version}'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
10
index.js
10
index.js
@@ -23,11 +23,12 @@ async function main () {
|
|||||||
const token = core.getInput('token', { required: true })
|
const token = core.getInput('token', { required: true })
|
||||||
const fork = getBooleanInput('fork')
|
const fork = getBooleanInput('fork')
|
||||||
const changelogPath = core.getInput('changelog-path') || undefined
|
const changelogPath = core.getInput('changelog-path') || undefined
|
||||||
const changelogTypes = core.getInput('changelog-types')
|
const changelogTypes = core.getInput('changelog-types') || undefined
|
||||||
const changelogSections = changelogTypes && JSON.parse(changelogTypes)
|
const changelogSections = changelogTypes && JSON.parse(changelogTypes)
|
||||||
const command = core.getInput('command') || undefined
|
const command = core.getInput('command') || undefined
|
||||||
const versionFile = core.getInput('version-file') || undefined
|
const versionFile = core.getInput('version-file') || undefined
|
||||||
const defaultBranch = core.getInput('default-branch') || undefined
|
const defaultBranch = core.getInput('default-branch') || undefined
|
||||||
|
const pullRequestTitlePattern = core.getInput('pull-request-title-pattern') || undefined
|
||||||
|
|
||||||
// First we check for any merged release PRs (PRs merged with the label
|
// First we check for any merged release PRs (PRs merged with the label
|
||||||
// "autorelease: pending"):
|
// "autorelease: pending"):
|
||||||
@@ -41,7 +42,8 @@ async function main () {
|
|||||||
token,
|
token,
|
||||||
changelogPath,
|
changelogPath,
|
||||||
releaseType,
|
releaseType,
|
||||||
defaultBranch
|
defaultBranch,
|
||||||
|
pullRequestTitlePattern
|
||||||
})
|
})
|
||||||
|
|
||||||
if (releaseCreated) {
|
if (releaseCreated) {
|
||||||
@@ -68,7 +70,8 @@ async function main () {
|
|||||||
bumpMinorPreMajor,
|
bumpMinorPreMajor,
|
||||||
changelogSections,
|
changelogSections,
|
||||||
versionFile,
|
versionFile,
|
||||||
defaultBranch
|
defaultBranch,
|
||||||
|
pullRequestTitlePattern
|
||||||
})
|
})
|
||||||
|
|
||||||
if (pr) {
|
if (pr) {
|
||||||
@@ -82,6 +85,7 @@ const releasePlease = {
|
|||||||
getBooleanInput
|
getBooleanInput
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* c8 ignore next 4 */
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
main().catch(err => {
|
main().catch(err => {
|
||||||
core.setFailed(`release-please failed: ${err.message}`)
|
core.setFailed(`release-please failed: ${err.message}`)
|
||||||
|
|||||||
28
package-lock.json
generated
28
package-lock.json
generated
@@ -182,11 +182,11 @@
|
|||||||
"integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ=="
|
"integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ=="
|
||||||
},
|
},
|
||||||
"@octokit/plugin-rest-endpoint-methods": {
|
"@octokit/plugin-rest-endpoint-methods": {
|
||||||
"version": "4.12.0",
|
"version": "4.12.2",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.12.0.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.12.2.tgz",
|
||||||
"integrity": "sha512-RgnQ1aoetdOJjZYC37LV5FNlL7GY/v1CdC5dur1Zp/UiADJlbRFbAz/xLx26ovXw67dK7EUtwCghS+6QyiI9RA==",
|
"integrity": "sha512-5+MmGusB7wPw7OholtcGaMyjfrsFSpFqtJW8VsrbfU/TuaiQepY4wgVkS7P3TAObX257jrTbbGo/sJLcoGf16g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@octokit/types": "^6.10.0",
|
"@octokit/types": "^6.10.1",
|
||||||
"deprecation": "^2.3.1"
|
"deprecation": "^2.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -216,20 +216,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@octokit/rest": {
|
"@octokit/rest": {
|
||||||
"version": "18.2.0",
|
"version": "18.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.2.1.tgz",
|
||||||
"integrity": "sha512-xsp6bIqL2sb/NmgLXTxw96caegobRw+YHnzdIi70ruquHtPPDW2cBAONhDYMUuAOeXx0JH2auOeplpk4SQJy1w==",
|
"integrity": "sha512-DdQ1vps41JSyB2axyL1mBwJiXAPibgugIQPOmt0mL/yhwheQ6iuq2aKiJWgGWa9ldMfe3v9gIFYlrFgxQ5ThGQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@octokit/core": "^3.2.3",
|
"@octokit/core": "^3.2.3",
|
||||||
"@octokit/plugin-paginate-rest": "^2.6.2",
|
"@octokit/plugin-paginate-rest": "^2.6.2",
|
||||||
"@octokit/plugin-request-log": "^1.0.2",
|
"@octokit/plugin-request-log": "^1.0.2",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "4.12.0"
|
"@octokit/plugin-rest-endpoint-methods": "4.12.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@octokit/types": {
|
"@octokit/types": {
|
||||||
"version": "6.10.0",
|
"version": "6.10.1",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.10.1.tgz",
|
||||||
"integrity": "sha512-aMDo10kglofejJ96edCBIgQLVuzMDyjxmhdgEcoUUD64PlHYSrNsAGqN0wZtoiX4/PCQ3JLA50IpkP1bcKD/cA==",
|
"integrity": "sha512-hgNC5jxKG8/RlqxU/6GThkGrvFpz25+cPzjQjyiXTNBvhyltn2Z4GhFY25+kbtXwZ4Co4zM0goW5jak1KLp1ug==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@octokit/openapi-types": "^5.1.0"
|
"@octokit/openapi-types": "^5.1.0"
|
||||||
}
|
}
|
||||||
@@ -2897,9 +2897,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"release-please": {
|
"release-please": {
|
||||||
"version": "11.0.1",
|
"version": "11.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/release-please/-/release-please-11.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/release-please/-/release-please-11.1.0.tgz",
|
||||||
"integrity": "sha512-14mZ6SD3a+QKkfSbtMpi6AM14ZfxWcsPI6+mrKot41lG98Sg/ri29c7pQNO7uwLwT7z2JiYPuHvGvOW29duS8w==",
|
"integrity": "sha512-0hGcGcxA23kweKtyb1mkhfjFY6JmDTi5qCESLZcS6HGo4ryGnlUcq8AaFGDogReO5yCOcyUi6lInf9Y3/XMFzw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@conventional-commits/parser": "^0.4.1",
|
"@conventional-commits/parser": "^0.4.1",
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"homepage": "https://github.com/bcoe/release-please-action#readme",
|
"homepage": "https://github.com/bcoe/release-please-action#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"release-please": "^11.0.1"
|
"release-please": "^11.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.27.0",
|
"@vercel/ncc": "^0.27.0",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const { describe, it, afterEach } = require('mocha')
|
const { describe, it, beforeEach, afterEach } = require('mocha')
|
||||||
const action = require('../')
|
const action = require('../')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
@@ -16,13 +16,32 @@ const defaultInput = {
|
|||||||
'changelog-types': '',
|
'changelog-types': '',
|
||||||
command: '',
|
command: '',
|
||||||
'version-file': '',
|
'version-file': '',
|
||||||
'default-branch': ''
|
'default-branch': '',
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
'pull-request-title-pattern': 'chore${scope}: release${component} ${version}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let input
|
||||||
|
let output
|
||||||
|
|
||||||
const sandbox = sinon.createSandbox()
|
const sandbox = sinon.createSandbox()
|
||||||
process.env.GITHUB_REPOSITORY = 'google/cloud'
|
process.env.GITHUB_REPOSITORY = 'google/cloud'
|
||||||
|
|
||||||
describe('release-please-action', () => {
|
describe('release-please-action', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
input = {}
|
||||||
|
output = {}
|
||||||
|
core.setOutput = (name, value) => {
|
||||||
|
output[name] = value
|
||||||
|
}
|
||||||
|
core.getInput = name => {
|
||||||
|
if (input[name] === undefined || input[name] == null) {
|
||||||
|
return defaultInput[name]
|
||||||
|
} else {
|
||||||
|
return input[name]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
sandbox.restore()
|
sandbox.restore()
|
||||||
})
|
})
|
||||||
@@ -32,12 +51,9 @@ describe('release-please-action', () => {
|
|||||||
|
|
||||||
trueValue.forEach(value => {
|
trueValue.forEach(value => {
|
||||||
it(`get the boolean true with the input of '${value}'`, () => {
|
it(`get the boolean true with the input of '${value}'`, () => {
|
||||||
const input = {
|
input = {
|
||||||
fork: value
|
fork: value
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
const actual = action.getBooleanInput('fork')
|
const actual = action.getBooleanInput('fork')
|
||||||
assert.strictEqual(actual, true)
|
assert.strictEqual(actual, true)
|
||||||
})
|
})
|
||||||
@@ -45,58 +61,100 @@ describe('release-please-action', () => {
|
|||||||
|
|
||||||
falseValue.forEach(value => {
|
falseValue.forEach(value => {
|
||||||
it(`get the boolean with the input of '${value}'`, () => {
|
it(`get the boolean with the input of '${value}'`, () => {
|
||||||
const input = {
|
input = {
|
||||||
fork: value
|
fork: value
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
const actual = action.getBooleanInput('fork')
|
const actual = action.getBooleanInput('fork')
|
||||||
assert.strictEqual(actual, false)
|
assert.strictEqual(actual, false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('get an error when inputting the wrong boolean value', () => {
|
it('get an error when inputting the wrong boolean value', () => {
|
||||||
const input = {
|
input = {
|
||||||
fork: 'wrong'
|
fork: 'wrong'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
assert.throws(
|
||||||
return input[name] || defaultInput[name]
|
() => {
|
||||||
|
action.getBooleanInput('fork')
|
||||||
|
},
|
||||||
|
{ name: 'TypeError', message: "Wrong boolean value of the input 'fork'" }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets pull pullRequestTitlePattern to undefined, if empty string provided', async () => {
|
||||||
|
input = {
|
||||||
|
'release-type': 'node',
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
'pull-request-title-pattern': ''
|
||||||
}
|
}
|
||||||
assert.throws(() => {
|
|
||||||
action.getBooleanInput('fork')
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
}, { name: 'TypeError', message: 'Wrong boolean value of the input \'fork\'' })
|
const githubReleasePRStub = runCommandStub.withArgs('release-pr').returns(25)
|
||||||
|
|
||||||
|
await action.main()
|
||||||
|
|
||||||
|
sinon.assert.calledOnce(githubReleasePRStub)
|
||||||
|
sinon.assert.calledWith(
|
||||||
|
githubReleasePRStub,
|
||||||
|
'release-pr',
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
sinon.match.hasOwn('pullRequestTitlePattern', undefined)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('opens PR with custom changelogSections', async () => {
|
||||||
|
input = {
|
||||||
|
'release-type': 'node',
|
||||||
|
'changelog-types':
|
||||||
|
'[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'
|
||||||
|
}
|
||||||
|
|
||||||
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
|
const githubReleasePRStub = runCommandStub.withArgs('release-pr').returns(25)
|
||||||
|
|
||||||
|
await action.main()
|
||||||
|
|
||||||
|
sinon.assert.calledOnce(githubReleasePRStub)
|
||||||
|
sinon.assert.calledWith(
|
||||||
|
githubReleasePRStub,
|
||||||
|
'release-pr',
|
||||||
|
sinon.match.hasOwn(
|
||||||
|
'changelogSections',
|
||||||
|
JSON.parse(
|
||||||
|
'[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('both opens PR to the default branch and tags GitHub releases by default', async () => {
|
it('both opens PR to the default branch and tags GitHub releases by default', async () => {
|
||||||
const output = {}
|
input = {
|
||||||
core.setOutput = (name, value) => {
|
|
||||||
output[name] = value
|
|
||||||
}
|
|
||||||
const input = {
|
|
||||||
'release-type': 'node'
|
'release-type': 'node'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
|
|
||||||
const githubReleaseStub = runCommandStub.withArgs('github-release')
|
const githubReleaseStub = runCommandStub.withArgs('github-release').returns({
|
||||||
.returns({
|
upload_url: 'http://example.com',
|
||||||
upload_url: 'http://example.com',
|
tag_name: 'v1.0.0'
|
||||||
tag_name: 'v1.0.0'
|
})
|
||||||
})
|
|
||||||
|
|
||||||
const githubReleasePRStub = runCommandStub.withArgs('release-pr')
|
const githubReleasePRStub = runCommandStub.withArgs('release-pr').returns(25)
|
||||||
.returns(25)
|
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
|
|
||||||
sinon.assert.calledOnce(githubReleaseStub)
|
sinon.assert.calledOnce(githubReleaseStub)
|
||||||
sinon.assert.calledOnce(githubReleasePRStub)
|
sinon.assert.calledOnce(githubReleasePRStub)
|
||||||
sinon.assert.calledWith(githubReleaseStub, 'github-release', sinon.match.hasOwn('defaultBranch', undefined))
|
sinon.assert.calledWith(
|
||||||
sinon.assert.calledWith(githubReleasePRStub, 'release-pr', sinon.match.hasOwn('defaultBranch', undefined))
|
githubReleaseStub,
|
||||||
|
'github-release',
|
||||||
|
sinon.match.hasOwn('defaultBranch', undefined)
|
||||||
|
)
|
||||||
|
sinon.assert.calledWith(
|
||||||
|
githubReleasePRStub,
|
||||||
|
'release-pr',
|
||||||
|
sinon.match.hasOwn('defaultBranch', undefined)
|
||||||
|
)
|
||||||
assert.deepStrictEqual(output, {
|
assert.deepStrictEqual(output, {
|
||||||
release_created: true,
|
release_created: true,
|
||||||
upload_url: 'http://example.com',
|
upload_url: 'http://example.com',
|
||||||
@@ -106,35 +164,34 @@ describe('release-please-action', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('both opens PR to a different default branch and tags GitHub releases by default', async () => {
|
it('both opens PR to a different default branch and tags GitHub releases by default', async () => {
|
||||||
const output = {}
|
input = {
|
||||||
core.setOutput = (name, value) => {
|
|
||||||
output[name] = value
|
|
||||||
}
|
|
||||||
const input = {
|
|
||||||
'release-type': 'node',
|
'release-type': 'node',
|
||||||
'default-branch': 'dev'
|
'default-branch': 'dev'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
|
|
||||||
const githubReleaseStub = runCommandStub.withArgs('github-release')
|
const githubReleaseStub = runCommandStub.withArgs('github-release').returns({
|
||||||
.returns({
|
upload_url: 'http://example.com',
|
||||||
upload_url: 'http://example.com',
|
tag_name: 'v1.0.0'
|
||||||
tag_name: 'v1.0.0'
|
})
|
||||||
})
|
|
||||||
|
|
||||||
const githubReleasePRStub = runCommandStub.withArgs('release-pr')
|
const githubReleasePRStub = runCommandStub.withArgs('release-pr').returns(25)
|
||||||
.returns(25)
|
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
|
|
||||||
sinon.assert.calledOnce(githubReleaseStub)
|
sinon.assert.calledOnce(githubReleaseStub)
|
||||||
sinon.assert.calledWith(githubReleaseStub, 'github-release', sinon.match.hasOwn('defaultBranch', 'dev'))
|
sinon.assert.calledWith(
|
||||||
|
githubReleaseStub,
|
||||||
|
'github-release',
|
||||||
|
sinon.match.hasOwn('defaultBranch', 'dev')
|
||||||
|
)
|
||||||
sinon.assert.calledOnce(githubReleasePRStub)
|
sinon.assert.calledOnce(githubReleasePRStub)
|
||||||
sinon.assert.calledWith(githubReleasePRStub, 'release-pr', sinon.match.hasOwn('defaultBranch', 'dev'))
|
sinon.assert.calledWith(
|
||||||
|
githubReleasePRStub,
|
||||||
|
'release-pr',
|
||||||
|
sinon.match.hasOwn('defaultBranch', 'dev')
|
||||||
|
)
|
||||||
|
|
||||||
assert.deepStrictEqual(output, {
|
assert.deepStrictEqual(output, {
|
||||||
release_created: true,
|
release_created: true,
|
||||||
@@ -145,28 +202,19 @@ describe('release-please-action', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('only opens PR, if command set to release-pr', async () => {
|
it('only opens PR, if command set to release-pr', async () => {
|
||||||
const output = {}
|
input = {
|
||||||
core.setOutput = (name, value) => {
|
|
||||||
output[name] = value
|
|
||||||
}
|
|
||||||
const input = {
|
|
||||||
'release-type': 'node',
|
'release-type': 'node',
|
||||||
command: 'release-pr'
|
command: 'release-pr'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
|
|
||||||
const githubReleaseStub = runCommandStub.withArgs('github-release')
|
const githubReleaseStub = runCommandStub.withArgs('github-release').returns({
|
||||||
.returns({
|
upload_url: 'http://example.com',
|
||||||
upload_url: 'http://example.com',
|
tag_name: 'v1.0.0'
|
||||||
tag_name: 'v1.0.0'
|
})
|
||||||
})
|
|
||||||
|
|
||||||
const githubReleasePRStub = runCommandStub.withArgs('release-pr')
|
const githubReleasePRStub = runCommandStub.withArgs('release-pr').returns(25)
|
||||||
.returns(25)
|
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
sinon.assert.notCalled(githubReleaseStub)
|
sinon.assert.notCalled(githubReleaseStub)
|
||||||
@@ -174,35 +222,26 @@ describe('release-please-action', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('only creates GitHub release, if command set to github-release', async () => {
|
it('only creates GitHub release, if command set to github-release', async () => {
|
||||||
const output = {}
|
input = {
|
||||||
core.setOutput = (name, value) => {
|
|
||||||
output[name] = value
|
|
||||||
}
|
|
||||||
const input = {
|
|
||||||
'release-type': 'node',
|
'release-type': 'node',
|
||||||
command: 'github-release'
|
command: 'github-release'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
|
|
||||||
const githubReleaseStub = runCommandStub.withArgs('github-release')
|
const githubReleaseStub = runCommandStub.withArgs('github-release').returns({
|
||||||
.returns({
|
upload_url: 'http://example.com',
|
||||||
upload_url: 'http://example.com',
|
tag_name: 'v1.0.0'
|
||||||
tag_name: 'v1.0.0'
|
})
|
||||||
})
|
|
||||||
|
|
||||||
const githubReleasePRStub = runCommandStub.withArgs('release-pr')
|
const githubReleasePRStub = runCommandStub.withArgs('release-pr').returns(25)
|
||||||
.returns(25)
|
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
sinon.assert.calledOnce(githubReleaseStub)
|
sinon.assert.calledOnce(githubReleaseStub)
|
||||||
sinon.assert.notCalled(githubReleasePRStub)
|
sinon.assert.notCalled(githubReleasePRStub)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets approprite outputs when GitHub release created', async () => {
|
it('sets appropriate outputs when GitHub release created', async () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
release_created: true,
|
release_created: true,
|
||||||
upload_url: 'http://example.com',
|
upload_url: 'http://example.com',
|
||||||
@@ -215,69 +254,44 @@ describe('release-please-action', () => {
|
|||||||
sha: 'abc123',
|
sha: 'abc123',
|
||||||
pr: 33
|
pr: 33
|
||||||
}
|
}
|
||||||
const output = {}
|
input = {
|
||||||
core.setOutput = (name, value) => {
|
|
||||||
output[name] = value
|
|
||||||
}
|
|
||||||
const input = {
|
|
||||||
'release-type': 'node',
|
'release-type': 'node',
|
||||||
command: 'github-release'
|
command: 'github-release'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
|
|
||||||
runCommandStub.withArgs('github-release')
|
runCommandStub.withArgs('github-release').returns(expected)
|
||||||
.returns(expected)
|
|
||||||
|
|
||||||
runCommandStub.withArgs('release-pr')
|
runCommandStub.withArgs('release-pr').returns(25)
|
||||||
.returns(25)
|
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
assert.deepStrictEqual(output, expected)
|
assert.deepStrictEqual(output, expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets appropriate outputs when release PR opened', async () => {
|
it('sets appropriate outputs when release PR opened', async () => {
|
||||||
const output = {}
|
input = {
|
||||||
core.setOutput = (name, value) => {
|
|
||||||
output[name] = value
|
|
||||||
}
|
|
||||||
const input = {
|
|
||||||
'release-type': 'node',
|
'release-type': 'node',
|
||||||
command: 'release-pr'
|
command: 'release-pr'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
|
|
||||||
runCommandStub.withArgs('release-pr')
|
runCommandStub.withArgs('release-pr').returns(95)
|
||||||
.returns(95)
|
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
assert.strictEqual(output.pr, 95)
|
assert.strictEqual(output.pr, 95)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not set PR output, when no release PR is returned', async () => {
|
it('does not set PR output, when no release PR is returned', async () => {
|
||||||
const output = {}
|
input = {
|
||||||
core.setOutput = (name, value) => {
|
|
||||||
output[name] = value
|
|
||||||
}
|
|
||||||
const input = {
|
|
||||||
'release-type': 'node',
|
'release-type': 'node',
|
||||||
command: 'release-pr'
|
command: 'release-pr'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||||
|
|
||||||
runCommandStub.withArgs('release-pr')
|
runCommandStub.withArgs('release-pr').returns(undefined)
|
||||||
.returns(undefined)
|
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
assert.strictEqual(Object.hasOwnProperty.call(output, 'pr'), false)
|
assert.strictEqual(Object.hasOwnProperty.call(output, 'pr'), false)
|
||||||
@@ -285,32 +299,26 @@ describe('release-please-action', () => {
|
|||||||
|
|
||||||
it('creates and runs a ReleasePR instance, using factory', async () => {
|
it('creates and runs a ReleasePR instance, using factory', async () => {
|
||||||
let maybeReleasePR
|
let maybeReleasePR
|
||||||
sandbox.replace(factory, 'call', (runnable) => {
|
sandbox.replace(factory, 'call', runnable => {
|
||||||
maybeReleasePR = runnable
|
maybeReleasePR = runnable
|
||||||
})
|
})
|
||||||
const input = {
|
input = {
|
||||||
'release-type': 'node',
|
'release-type': 'node',
|
||||||
command: 'release-pr'
|
command: 'release-pr'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
await action.main()
|
await action.main()
|
||||||
assert.ok(maybeReleasePR instanceof Node)
|
assert.ok(maybeReleasePR instanceof Node)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates and runs a GitHubRelease, using factory', async () => {
|
it('creates and runs a GitHubRelease, using factory', async () => {
|
||||||
let maybeGitHubRelease
|
let maybeGitHubRelease
|
||||||
sandbox.replace(factory, 'call', (runnable) => {
|
sandbox.replace(factory, 'call', runnable => {
|
||||||
maybeGitHubRelease = runnable
|
maybeGitHubRelease = runnable
|
||||||
})
|
})
|
||||||
const input = {
|
input = {
|
||||||
'release-type': 'node',
|
'release-type': 'node',
|
||||||
command: 'github-release'
|
command: 'github-release'
|
||||||
}
|
}
|
||||||
core.getInput = (name) => {
|
|
||||||
return input[name] || defaultInput[name]
|
|
||||||
}
|
|
||||||
await action.main()
|
await action.main()
|
||||||
assert.ok(maybeGitHubRelease instanceof GitHubRelease)
|
assert.ok(maybeGitHubRelease instanceof GitHubRelease)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user