mirror of
https://github.com/joaquinjsb/gitea-release-please-action
synced 2026-05-10 23:11:16 +02:00
fix(release-please): uses factory from latest version (#222)
This commit is contained in:
30
index.js
30
index.js
@@ -1,8 +1,9 @@
|
||||
const core = require('@actions/core')
|
||||
const { GitHubRelease } = require('release-please/build/src/github-release')
|
||||
const { ReleasePR } = require('release-please/build/src/release-pr')
|
||||
const { factory } = require('release-please/build/src')
|
||||
|
||||
const RELEASE_LABEL = 'autorelease: pending'
|
||||
const GITHUB_RELEASE_COMMAND = 'github-release'
|
||||
const GITHUB_RELEASE_PR_COMMAND = 'release-pr'
|
||||
|
||||
async function main () {
|
||||
const bumpMinorPreMajor = Boolean(core.getInput('bump-minor-pre-major'))
|
||||
@@ -26,9 +27,8 @@ async function main () {
|
||||
|
||||
// First we check for any merged release PRs (PRs merged with the label
|
||||
// "autorelease: pending"):
|
||||
if (!command || command === 'github-release') {
|
||||
const Release = releasePlease.getGitHubRelease()
|
||||
const gr = new Release({
|
||||
if (!command || command === GITHUB_RELEASE_COMMAND) {
|
||||
const releaseCreated = await factory.runCommand(GITHUB_RELEASE_COMMAND, {
|
||||
label: RELEASE_LABEL,
|
||||
repoUrl: process.env.GITHUB_REPOSITORY,
|
||||
packageName,
|
||||
@@ -39,7 +39,7 @@ async function main () {
|
||||
releaseType,
|
||||
defaultBranch
|
||||
})
|
||||
const releaseCreated = await gr.run()
|
||||
|
||||
if (releaseCreated) {
|
||||
core.setOutput('release_created', true)
|
||||
for (const key of Object.keys(releaseCreated)) {
|
||||
@@ -50,9 +50,8 @@ async function main () {
|
||||
|
||||
// Next we check for PRs merged since the last release, and groom the
|
||||
// release PR:
|
||||
if (!command || command === 'release-pr') {
|
||||
const GithubReleasePR = releasePlease.getReleasePR()
|
||||
const release = new GithubReleasePR({
|
||||
if (!command || command === GITHUB_RELEASE_PR_COMMAND) {
|
||||
const pr = await factory.runCommand(GITHUB_RELEASE_PR_COMMAND, {
|
||||
releaseType,
|
||||
monorepoTags,
|
||||
packageName,
|
||||
@@ -68,25 +67,14 @@ async function main () {
|
||||
defaultBranch
|
||||
})
|
||||
|
||||
const pr = await release.run()
|
||||
if (pr) {
|
||||
core.setOutput('pr', pr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getGitHubRelease () {
|
||||
return GitHubRelease
|
||||
}
|
||||
|
||||
function getReleasePR () {
|
||||
return ReleasePR
|
||||
}
|
||||
|
||||
const releasePlease = {
|
||||
main,
|
||||
getGitHubRelease,
|
||||
getReleasePR
|
||||
main
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
62
package-lock.json
generated
62
package-lock.json
generated
@@ -164,9 +164,9 @@
|
||||
}
|
||||
},
|
||||
"@octokit/openapi-types": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-4.0.1.tgz",
|
||||
"integrity": "sha512-k2hRcfcLRyPJjtYfJLzg404n7HZ6sUpAWAR/uNI8tf96NgatWOpw1ocdF+WFfx/trO1ivBh7ckynO1rn+xAw/Q=="
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-4.0.3.tgz",
|
||||
"integrity": "sha512-CXCe1Zzc/WhjpuAEgoUktAinZJ02l6W8q1hDkwBtaonEtO6cjo/3Pyb2J1t5y2q/SvjESDJ77xZ9UVHqQVvihw=="
|
||||
},
|
||||
"@octokit/plugin-paginate-rest": {
|
||||
"version": "2.9.1",
|
||||
@@ -182,11 +182,11 @@
|
||||
"integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ=="
|
||||
},
|
||||
"@octokit/plugin-rest-endpoint-methods": {
|
||||
"version": "4.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.10.1.tgz",
|
||||
"integrity": "sha512-YGMiEidTORzgUmYZu0eH4q2k8kgQSHQMuBOBYiKxUYs/nXea4q/Ze6tDzjcRAPmHNJYXrENs1bEMlcdGKT+8ug==",
|
||||
"version": "4.10.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.10.3.tgz",
|
||||
"integrity": "sha512-CsNQeVY34Vs9iea2Z9/TCPlebxv6KpjO9f1BUPz+14qundTSYT9kgf8j5wA1k37VstfBQ4xnuURYdnbGzJBJXw==",
|
||||
"requires": {
|
||||
"@octokit/types": "^6.8.2",
|
||||
"@octokit/types": "^6.8.3",
|
||||
"deprecation": "^2.3.1"
|
||||
}
|
||||
},
|
||||
@@ -216,22 +216,22 @@
|
||||
}
|
||||
},
|
||||
"@octokit/rest": {
|
||||
"version": "18.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.1.0.tgz",
|
||||
"integrity": "sha512-YQfpTzWV3jdzDPyXQVO54f5I2t1zxk/S53Vbe+Aa5vQj6MdTx6sNEWzmUzUO8lSVowbGOnjcQHzW1A8ATr+/7g==",
|
||||
"version": "18.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.1.1.tgz",
|
||||
"integrity": "sha512-ZcCHMyfGT1qtJD72usigAfUQ6jU89ZUPFb2AOubR6WZ7/RRFVZUENVm1I2yvJBUicqTujezPW9cY1+o3Mb4rNA==",
|
||||
"requires": {
|
||||
"@octokit/core": "^3.2.3",
|
||||
"@octokit/plugin-paginate-rest": "^2.6.2",
|
||||
"@octokit/plugin-request-log": "^1.0.2",
|
||||
"@octokit/plugin-rest-endpoint-methods": "4.10.1"
|
||||
"@octokit/plugin-rest-endpoint-methods": "4.10.3"
|
||||
}
|
||||
},
|
||||
"@octokit/types": {
|
||||
"version": "6.8.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.8.2.tgz",
|
||||
"integrity": "sha512-RpG0NJd7OKSkWptiFhy1xCLkThs5YoDIKM21lEtDmUvSpbaIEfrxzckWLUGDFfF8RydSyngo44gDv8m2hHruUg==",
|
||||
"version": "6.8.4",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.8.4.tgz",
|
||||
"integrity": "sha512-iKAMx//mBk74NwXdeKg8kdYO5zb1n6Ypk5uxwM96U35rJQv4Y8lMQxfzhN8QyzQHaZkxQsl28bn+MPEhiqXb7w==",
|
||||
"requires": {
|
||||
"@octokit/openapi-types": "^4.0.0",
|
||||
"@octokit/openapi-types": "^4.0.3",
|
||||
"@types/node": ">= 8"
|
||||
}
|
||||
},
|
||||
@@ -299,9 +299,9 @@
|
||||
"integrity": "sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.14.25",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.25.tgz",
|
||||
"integrity": "sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ=="
|
||||
"version": "14.14.27",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.27.tgz",
|
||||
"integrity": "sha512-Ecfmo4YDQPwuqTCl1yBxLV5ihKfRlkBmzUEDcfIRvDxOTGQEeikr317Ln7Gcv0tjA8dVgKI3rniqW2G1OyKDng=="
|
||||
},
|
||||
"@types/normalize-package-data": {
|
||||
"version": "2.4.0",
|
||||
@@ -2903,9 +2903,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"release-please": {
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/release-please/-/release-please-10.1.0.tgz",
|
||||
"integrity": "sha512-o9EzcfVtiNmF8M+73zBfmT3Lymx36KkYW7QE0swUDXpUzrtXcLx3pKhf1ZlfdNKazoZTWK/WfySvP559gQCr5g==",
|
||||
"version": "11.0.0-candidate.1",
|
||||
"resolved": "https://registry.npmjs.org/release-please/-/release-please-11.0.0-candidate.1.tgz",
|
||||
"integrity": "sha512-LYAFw7IxH1CZdQ2OAz9jm8nuAO+lZ4sVP8Oq5b4k1GVH4gm1T4gEHyMiluAR3U35jOfNa/EQGG5kgDPS3pPr7w==",
|
||||
"requires": {
|
||||
"@conventional-commits/parser": "^0.4.1",
|
||||
"@iarna/toml": "^2.2.5",
|
||||
@@ -2920,7 +2920,8 @@
|
||||
"figures": "^3.0.0",
|
||||
"parse-github-repo-url": "^1.4.1",
|
||||
"semver": "^7.0.0",
|
||||
"type-fest": "^0.20.0",
|
||||
"type-fest": "^0.21.0",
|
||||
"typescript": "^3.8.3",
|
||||
"unist-util-visit": "^2.0.3",
|
||||
"unist-util-visit-parents": "^3.1.1",
|
||||
"yargs": "^16.0.0"
|
||||
@@ -3388,14 +3389,19 @@
|
||||
"dev": true
|
||||
},
|
||||
"type-fest": {
|
||||
"version": "0.20.2",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
|
||||
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ=="
|
||||
"version": "0.21.0",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.0.tgz",
|
||||
"integrity": "sha512-1l9DXlbflV880ZijiK9qx4jdD0VOqogKx5i33t3hDN+ZiaqMOr7aSwH/jzmnBXPQon+SNvr+cH6wltATEzGJEg=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.9.9",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.9.tgz",
|
||||
"integrity": "sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w=="
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "3.12.7",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.7.tgz",
|
||||
"integrity": "sha512-SIZhkoh+U/wjW+BHGhVwE9nt8tWJspncloBcFapkpGRwNPqcH8pzX36BXe3TPBjzHWPMUZotpCigak/udWNr1Q==",
|
||||
"version": "3.12.8",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.8.tgz",
|
||||
"integrity": "sha512-fvBeuXOsvqjecUtF/l1dwsrrf5y2BCUk9AOJGzGcm6tE7vegku5u/YvqjyDaAGr422PLoLnrxg3EnRvTqsdC1w==",
|
||||
"optional": true
|
||||
},
|
||||
"unist-util-is": {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"homepage": "https://github.com/bcoe/release-please-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"release-please": "^10.1.0"
|
||||
"release-please": "11.0.0-candidate.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.27.0",
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
const { describe, it } = require('mocha')
|
||||
const { describe, it, afterEach } = require('mocha')
|
||||
const action = require('../')
|
||||
const assert = require('assert')
|
||||
const core = require('@actions/core')
|
||||
const sinon = require('sinon')
|
||||
const { factory } = require('release-please/build/src')
|
||||
|
||||
const sandbox = sinon.createSandbox()
|
||||
process.env.GITHUB_REPOSITORY = 'google/cloud'
|
||||
|
||||
describe('release-please-action', () => {
|
||||
afterEach(() => {
|
||||
sandbox.restore()
|
||||
})
|
||||
|
||||
it('both opens PR to the default branch and tags GitHub releases by default', async () => {
|
||||
const output = {}
|
||||
core.setOutput = (name, value) => {
|
||||
@@ -17,43 +25,23 @@ describe('release-please-action', () => {
|
||||
return input[name]
|
||||
}
|
||||
|
||||
let GithubReleaseStub = sinon.stub()
|
||||
const githubReleaseRunStub = sinon.stub().returns({
|
||||
upload_url: 'http://example.com',
|
||||
tag_name: 'v1.0.0'
|
||||
})
|
||||
action.getGitHubRelease = () => {
|
||||
class GithubRelease {
|
||||
run () {}
|
||||
}
|
||||
GithubReleaseStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubRelease)
|
||||
instance.run = githubReleaseRunStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleaseStub
|
||||
}
|
||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const githubReleasePRRunStub = sinon.stub().returns(25)
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = githubReleasePRRunStub
|
||||
return instance
|
||||
const githubReleaseStub = runCommandStub.withArgs('github-release')
|
||||
.returns({
|
||||
upload_url: 'http://example.com',
|
||||
tag_name: 'v1.0.0'
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
|
||||
const githubReleasePRStub = runCommandStub.withArgs('release-pr')
|
||||
.returns(25)
|
||||
|
||||
await action.main()
|
||||
|
||||
sinon.assert.calledOnce(githubReleaseRunStub)
|
||||
sinon.assert.calledWith(GithubReleaseStub, sinon.match.hasOwn('defaultBranch', undefined))
|
||||
sinon.assert.calledOnce(githubReleasePRRunStub)
|
||||
sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', undefined))
|
||||
sinon.assert.calledOnce(githubReleaseStub)
|
||||
sinon.assert.calledOnce(githubReleasePRStub)
|
||||
sinon.assert.calledWith(githubReleaseStub, 'github-release', sinon.match.hasOwn('defaultBranch', undefined))
|
||||
sinon.assert.calledWith(githubReleasePRStub, 'release-pr', sinon.match.hasOwn('defaultBranch', undefined))
|
||||
assert.deepStrictEqual(output, {
|
||||
release_created: true,
|
||||
upload_url: 'http://example.com',
|
||||
@@ -75,43 +63,23 @@ describe('release-please-action', () => {
|
||||
return input[name]
|
||||
}
|
||||
|
||||
let GithubReleaseStub = sinon.stub()
|
||||
const githubReleaseRunStub = sinon.stub().returns({
|
||||
upload_url: 'http://example.com',
|
||||
tag_name: 'v1.0.0'
|
||||
})
|
||||
action.getGitHubRelease = () => {
|
||||
class GithubRelease {
|
||||
run () {}
|
||||
}
|
||||
GithubReleaseStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubRelease)
|
||||
instance.run = githubReleaseRunStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleaseStub
|
||||
}
|
||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const githubReleasePRRunStub = sinon.stub().returns(25)
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = githubReleasePRRunStub
|
||||
return instance
|
||||
const githubReleaseStub = runCommandStub.withArgs('github-release')
|
||||
.returns({
|
||||
upload_url: 'http://example.com',
|
||||
tag_name: 'v1.0.0'
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
|
||||
const githubReleasePRStub = runCommandStub.withArgs('release-pr')
|
||||
.returns(25)
|
||||
|
||||
await action.main()
|
||||
|
||||
sinon.assert.calledOnce(githubReleaseRunStub)
|
||||
sinon.assert.calledWith(GithubReleaseStub, sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||
sinon.assert.calledOnce(githubReleasePRRunStub)
|
||||
sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||
sinon.assert.calledOnce(githubReleaseStub)
|
||||
sinon.assert.calledWith(githubReleaseStub, 'github-release', sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||
sinon.assert.calledOnce(githubReleasePRStub)
|
||||
sinon.assert.calledWith(githubReleasePRStub, 'release-pr', sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||
|
||||
assert.deepStrictEqual(output, {
|
||||
release_created: true,
|
||||
@@ -134,40 +102,20 @@ describe('release-please-action', () => {
|
||||
return input[name]
|
||||
}
|
||||
|
||||
let GithubReleaseStub = sinon.stub()
|
||||
const githubReleaseRunStub = sinon.stub().returns({
|
||||
upload_url: 'http://example.com',
|
||||
tag_name: 'v1.0.0'
|
||||
})
|
||||
action.getGitHubRelease = () => {
|
||||
class GithubRelease {
|
||||
run () {}
|
||||
}
|
||||
GithubReleaseStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubRelease)
|
||||
instance.run = githubReleaseRunStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleaseStub
|
||||
}
|
||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const githubReleasePRRunStub = sinon.stub().returns(25)
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = githubReleasePRRunStub
|
||||
return instance
|
||||
const githubReleaseStub = runCommandStub.withArgs('github-release')
|
||||
.returns({
|
||||
upload_url: 'http://example.com',
|
||||
tag_name: 'v1.0.0'
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
|
||||
const githubReleasePRStub = runCommandStub.withArgs('release-pr')
|
||||
.returns(25)
|
||||
|
||||
await action.main()
|
||||
sinon.assert.notCalled(githubReleaseRunStub)
|
||||
sinon.assert.calledOnce(githubReleasePRRunStub)
|
||||
sinon.assert.notCalled(githubReleaseStub)
|
||||
sinon.assert.calledOnce(githubReleasePRStub)
|
||||
})
|
||||
|
||||
it('only creates GitHub release, if command set to github-release', async () => {
|
||||
@@ -183,40 +131,20 @@ describe('release-please-action', () => {
|
||||
return input[name]
|
||||
}
|
||||
|
||||
let GithubReleaseStub = sinon.stub()
|
||||
const githubReleaseRunStub = sinon.stub().returns({
|
||||
upload_url: 'http://example.com',
|
||||
tag_name: 'v1.0.0'
|
||||
})
|
||||
action.getGitHubRelease = () => {
|
||||
class GithubRelease {
|
||||
run () {}
|
||||
}
|
||||
GithubReleaseStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubRelease)
|
||||
instance.run = githubReleaseRunStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleaseStub
|
||||
}
|
||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const githubReleasePRRunStub = sinon.stub().returns(25)
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = githubReleasePRRunStub
|
||||
return instance
|
||||
const githubReleaseStub = runCommandStub.withArgs('github-release')
|
||||
.returns({
|
||||
upload_url: 'http://example.com',
|
||||
tag_name: 'v1.0.0'
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
|
||||
const githubReleasePRStub = runCommandStub.withArgs('release-pr')
|
||||
.returns(25)
|
||||
|
||||
await action.main()
|
||||
sinon.assert.calledOnce(githubReleaseRunStub)
|
||||
sinon.assert.notCalled(githubReleasePRRunStub)
|
||||
sinon.assert.calledOnce(githubReleaseStub)
|
||||
sinon.assert.notCalled(githubReleasePRStub)
|
||||
})
|
||||
|
||||
it('sets approprite outputs when GitHub release created', async () => {
|
||||
@@ -244,33 +172,13 @@ describe('release-please-action', () => {
|
||||
return input[name]
|
||||
}
|
||||
|
||||
let GithubReleaseStub = sinon.stub()
|
||||
const githubReleaseRunStub = sinon.stub().returns(expected)
|
||||
action.getGitHubRelease = () => {
|
||||
class GithubRelease {
|
||||
run () {}
|
||||
}
|
||||
GithubReleaseStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubRelease)
|
||||
instance.run = githubReleaseRunStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleaseStub
|
||||
}
|
||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const githubReleasePRRunStub = sinon.stub().returns(25)
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = githubReleasePRRunStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
runCommandStub.withArgs('github-release')
|
||||
.returns(expected)
|
||||
|
||||
runCommandStub.withArgs('release-pr')
|
||||
.returns(25)
|
||||
|
||||
await action.main()
|
||||
assert.deepStrictEqual(output, expected)
|
||||
@@ -289,19 +197,10 @@ describe('release-please-action', () => {
|
||||
return input[name]
|
||||
}
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const githubReleasePRRunStub = sinon.stub().returns(95)
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = githubReleasePRRunStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||
|
||||
runCommandStub.withArgs('release-pr')
|
||||
.returns(95)
|
||||
|
||||
await action.main()
|
||||
assert.strictEqual(output.pr, 95)
|
||||
@@ -320,19 +219,10 @@ describe('release-please-action', () => {
|
||||
return input[name]
|
||||
}
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const githubReleasePRRunStub = sinon.stub().returns(undefined)
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = githubReleasePRRunStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
const runCommandStub = sandbox.stub(factory, 'runCommand')
|
||||
|
||||
runCommandStub.withArgs('release-pr')
|
||||
.returns(undefined)
|
||||
|
||||
await action.main()
|
||||
assert.strictEqual(Object.hasOwnProperty.call(output, 'pr'), false)
|
||||
|
||||
Reference in New Issue
Block a user