mirror of
https://github.com/joaquinjsb/gitea-release-please-action
synced 2026-05-13 21:21:37 +02:00
fix(release-please): update github-release call to new function (#217)
This PR fixes the wrong call to createRelease now named as run. Tests are also updated.
This commit is contained in:
2
index.js
2
index.js
@@ -39,7 +39,7 @@ async function main () {
|
|||||||
releaseType,
|
releaseType,
|
||||||
defaultBranch
|
defaultBranch
|
||||||
})
|
})
|
||||||
const releaseCreated = await gr.createRelease()
|
const releaseCreated = await gr.run()
|
||||||
if (releaseCreated) {
|
if (releaseCreated) {
|
||||||
core.setOutput('release_created', true)
|
core.setOutput('release_created', true)
|
||||||
for (const key of Object.keys(releaseCreated)) {
|
for (const key of Object.keys(releaseCreated)) {
|
||||||
|
|||||||
@@ -16,33 +16,33 @@ describe('release-please-action', () => {
|
|||||||
core.getInput = (name) => {
|
core.getInput = (name) => {
|
||||||
return input[name]
|
return input[name]
|
||||||
}
|
}
|
||||||
const createRelease = sinon.stub().returns({
|
|
||||||
|
let GithubReleaseStub = sinon.stub()
|
||||||
|
const githubReleaseRunStub = sinon.stub().returns({
|
||||||
upload_url: 'http://example.com',
|
upload_url: 'http://example.com',
|
||||||
tag_name: 'v1.0.0'
|
tag_name: 'v1.0.0'
|
||||||
})
|
})
|
||||||
let ReleaseStub = sinon.stub()
|
|
||||||
action.getGitHubRelease = () => {
|
action.getGitHubRelease = () => {
|
||||||
class Release {
|
class GithubRelease {
|
||||||
createRelease () {}
|
run () {}
|
||||||
}
|
}
|
||||||
ReleaseStub = sinon.spy(function () {
|
GithubReleaseStub = sinon.spy(function () {
|
||||||
const instance = sinon.createStubInstance(Release)
|
const instance = sinon.createStubInstance(GithubRelease)
|
||||||
instance.createRelease = createRelease
|
instance.run = githubReleaseRunStub
|
||||||
return instance
|
return instance
|
||||||
})
|
})
|
||||||
return ReleaseStub
|
return GithubReleaseStub
|
||||||
}
|
}
|
||||||
|
|
||||||
let GithubReleasePRStub = sinon.stub()
|
let GithubReleasePRStub = sinon.stub()
|
||||||
const runStub = sinon.stub().returns(25)
|
const githubReleasePRRunStub = sinon.stub().returns(25)
|
||||||
|
|
||||||
action.getReleasePR = () => {
|
action.getReleasePR = () => {
|
||||||
class GithubReleasePR {
|
class GithubReleasePR {
|
||||||
run () {}
|
run () {}
|
||||||
}
|
}
|
||||||
GithubReleasePRStub = sinon.spy(function () {
|
GithubReleasePRStub = sinon.spy(function () {
|
||||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||||
instance.run = runStub
|
instance.run = githubReleasePRRunStub
|
||||||
return instance
|
return instance
|
||||||
})
|
})
|
||||||
return GithubReleasePRStub
|
return GithubReleasePRStub
|
||||||
@@ -50,9 +50,9 @@ describe('release-please-action', () => {
|
|||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
|
|
||||||
sinon.assert.calledOnce(createRelease)
|
sinon.assert.calledOnce(githubReleaseRunStub)
|
||||||
sinon.assert.calledWith(ReleaseStub, sinon.match.hasOwn('defaultBranch', undefined))
|
sinon.assert.calledWith(GithubReleaseStub, sinon.match.hasOwn('defaultBranch', undefined))
|
||||||
sinon.assert.calledOnce(runStub)
|
sinon.assert.calledOnce(githubReleasePRRunStub)
|
||||||
sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', undefined))
|
sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', undefined))
|
||||||
assert.deepStrictEqual(output, {
|
assert.deepStrictEqual(output, {
|
||||||
release_created: true,
|
release_created: true,
|
||||||
@@ -74,34 +74,33 @@ describe('release-please-action', () => {
|
|||||||
core.getInput = (name) => {
|
core.getInput = (name) => {
|
||||||
return input[name]
|
return input[name]
|
||||||
}
|
}
|
||||||
const createRelease = sinon.stub().returns({
|
|
||||||
|
let GithubReleaseStub = sinon.stub()
|
||||||
|
const githubReleaseRunStub = sinon.stub().returns({
|
||||||
upload_url: 'http://example.com',
|
upload_url: 'http://example.com',
|
||||||
tag_name: 'v1.0.0'
|
tag_name: 'v1.0.0'
|
||||||
})
|
})
|
||||||
|
|
||||||
let ReleaseStub = sinon.stub()
|
|
||||||
action.getGitHubRelease = () => {
|
action.getGitHubRelease = () => {
|
||||||
class Release {
|
class GithubRelease {
|
||||||
createRelease () {}
|
run () {}
|
||||||
}
|
}
|
||||||
ReleaseStub = sinon.spy(function () {
|
GithubReleaseStub = sinon.spy(function () {
|
||||||
const instance = sinon.createStubInstance(Release)
|
const instance = sinon.createStubInstance(GithubRelease)
|
||||||
instance.createRelease = createRelease
|
instance.run = githubReleaseRunStub
|
||||||
return instance
|
return instance
|
||||||
})
|
})
|
||||||
return ReleaseStub
|
return GithubReleaseStub
|
||||||
}
|
}
|
||||||
|
|
||||||
let GithubReleasePRStub = sinon.stub()
|
let GithubReleasePRStub = sinon.stub()
|
||||||
const runStub = sinon.stub().returns(25)
|
const githubReleasePRRunStub = sinon.stub().returns(25)
|
||||||
|
|
||||||
action.getReleasePR = () => {
|
action.getReleasePR = () => {
|
||||||
class GithubReleasePR {
|
class GithubReleasePR {
|
||||||
run () {}
|
run () {}
|
||||||
}
|
}
|
||||||
GithubReleasePRStub = sinon.spy(function () {
|
GithubReleasePRStub = sinon.spy(function () {
|
||||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||||
instance.run = runStub
|
instance.run = githubReleasePRRunStub
|
||||||
return instance
|
return instance
|
||||||
})
|
})
|
||||||
return GithubReleasePRStub
|
return GithubReleasePRStub
|
||||||
@@ -109,10 +108,11 @@ describe('release-please-action', () => {
|
|||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
|
|
||||||
sinon.assert.calledOnce(createRelease)
|
sinon.assert.calledOnce(githubReleaseRunStub)
|
||||||
sinon.assert.calledWith(ReleaseStub, sinon.match.hasOwn('defaultBranch', 'dev'))
|
sinon.assert.calledWith(GithubReleaseStub, sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||||
sinon.assert.calledOnce(runStub)
|
sinon.assert.calledOnce(githubReleasePRRunStub)
|
||||||
sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', 'dev'))
|
sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||||
|
|
||||||
assert.deepStrictEqual(output, {
|
assert.deepStrictEqual(output, {
|
||||||
release_created: true,
|
release_created: true,
|
||||||
upload_url: 'http://example.com',
|
upload_url: 'http://example.com',
|
||||||
@@ -133,34 +133,41 @@ describe('release-please-action', () => {
|
|||||||
core.getInput = (name) => {
|
core.getInput = (name) => {
|
||||||
return input[name]
|
return input[name]
|
||||||
}
|
}
|
||||||
const githubRelease = sinon.stub().returns({
|
|
||||||
|
let GithubReleaseStub = sinon.stub()
|
||||||
|
const githubReleaseRunStub = sinon.stub().returns({
|
||||||
upload_url: 'http://example.com',
|
upload_url: 'http://example.com',
|
||||||
tag_name: 'v1.0.0'
|
tag_name: 'v1.0.0'
|
||||||
})
|
})
|
||||||
action.getGitHubRelease = () => {
|
action.getGitHubRelease = () => {
|
||||||
class Release {}
|
class GithubRelease {
|
||||||
Release.prototype.createRelease = githubRelease
|
run () {}
|
||||||
return Release
|
}
|
||||||
|
GithubReleaseStub = sinon.spy(function () {
|
||||||
|
const instance = sinon.createStubInstance(GithubRelease)
|
||||||
|
instance.run = githubReleaseRunStub
|
||||||
|
return instance
|
||||||
|
})
|
||||||
|
return GithubReleaseStub
|
||||||
}
|
}
|
||||||
|
|
||||||
let GithubReleasePRStub = sinon.stub()
|
let GithubReleasePRStub = sinon.stub()
|
||||||
const runStub = sinon.stub().returns(25)
|
const githubReleasePRRunStub = sinon.stub().returns(25)
|
||||||
|
|
||||||
action.getReleasePR = () => {
|
action.getReleasePR = () => {
|
||||||
class GithubReleasePR {
|
class GithubReleasePR {
|
||||||
run () {}
|
run () {}
|
||||||
}
|
}
|
||||||
GithubReleasePRStub = sinon.spy(function () {
|
GithubReleasePRStub = sinon.spy(function () {
|
||||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||||
instance.run = runStub
|
instance.run = githubReleasePRRunStub
|
||||||
return instance
|
return instance
|
||||||
})
|
})
|
||||||
return GithubReleasePRStub
|
return GithubReleasePRStub
|
||||||
}
|
}
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
sinon.assert.notCalled(githubRelease)
|
sinon.assert.notCalled(githubReleaseRunStub)
|
||||||
sinon.assert.calledOnce(runStub)
|
sinon.assert.calledOnce(githubReleasePRRunStub)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('only creates GitHub release, if command set to github-release', async () => {
|
it('only creates GitHub release, if command set to github-release', async () => {
|
||||||
@@ -175,28 +182,41 @@ describe('release-please-action', () => {
|
|||||||
core.getInput = (name) => {
|
core.getInput = (name) => {
|
||||||
return input[name]
|
return input[name]
|
||||||
}
|
}
|
||||||
const githubRelease = sinon.stub().returns({
|
|
||||||
|
let GithubReleaseStub = sinon.stub()
|
||||||
|
const githubReleaseRunStub = sinon.stub().returns({
|
||||||
upload_url: 'http://example.com',
|
upload_url: 'http://example.com',
|
||||||
tag_name: 'v1.0.0'
|
tag_name: 'v1.0.0'
|
||||||
})
|
})
|
||||||
action.getGitHubRelease = () => {
|
action.getGitHubRelease = () => {
|
||||||
class Release {}
|
class GithubRelease {
|
||||||
Release.prototype.createRelease = githubRelease
|
run () {}
|
||||||
return Release
|
|
||||||
}
|
|
||||||
const releasePR = sinon.stub()
|
|
||||||
action.getReleasePRFactory = () => {
|
|
||||||
return {
|
|
||||||
buildStatic: () => {
|
|
||||||
return {
|
|
||||||
run: releasePR
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
GithubReleaseStub = sinon.spy(function () {
|
||||||
|
const instance = sinon.createStubInstance(GithubRelease)
|
||||||
|
instance.run = githubReleaseRunStub
|
||||||
|
return instance
|
||||||
|
})
|
||||||
|
return GithubReleaseStub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
sinon.assert.calledOnce(githubRelease)
|
sinon.assert.calledOnce(githubReleaseRunStub)
|
||||||
sinon.assert.notCalled(releasePR)
|
sinon.assert.notCalled(githubReleasePRRunStub)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets approprite outputs when GitHub release created', async () => {
|
it('sets approprite outputs when GitHub release created', async () => {
|
||||||
@@ -223,22 +243,35 @@ describe('release-please-action', () => {
|
|||||||
core.getInput = (name) => {
|
core.getInput = (name) => {
|
||||||
return input[name]
|
return input[name]
|
||||||
}
|
}
|
||||||
const githubRelease = sinon.stub().returns(expected)
|
|
||||||
|
let GithubReleaseStub = sinon.stub()
|
||||||
|
const githubReleaseRunStub = sinon.stub().returns(expected)
|
||||||
action.getGitHubRelease = () => {
|
action.getGitHubRelease = () => {
|
||||||
class Release {}
|
class GithubRelease {
|
||||||
Release.prototype.createRelease = githubRelease
|
run () {}
|
||||||
return Release
|
|
||||||
}
|
|
||||||
const releasePR = sinon.stub()
|
|
||||||
action.getReleasePRFactory = () => {
|
|
||||||
return {
|
|
||||||
buildStatic: () => {
|
|
||||||
return {
|
|
||||||
run: releasePR
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
GithubReleaseStub = sinon.spy(function () {
|
||||||
|
const instance = sinon.createStubInstance(GithubRelease)
|
||||||
|
instance.run = githubReleaseRunStub
|
||||||
|
return instance
|
||||||
|
})
|
||||||
|
return GithubReleaseStub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
assert.deepStrictEqual(output, expected)
|
assert.deepStrictEqual(output, expected)
|
||||||
})
|
})
|
||||||
@@ -255,20 +288,21 @@ describe('release-please-action', () => {
|
|||||||
core.getInput = (name) => {
|
core.getInput = (name) => {
|
||||||
return input[name]
|
return input[name]
|
||||||
}
|
}
|
||||||
let GithubReleasePRStub = sinon.stub()
|
|
||||||
const runStub = sinon.stub().returns(95)
|
|
||||||
|
|
||||||
|
let GithubReleasePRStub = sinon.stub()
|
||||||
|
const githubReleasePRRunStub = sinon.stub().returns(95)
|
||||||
action.getReleasePR = () => {
|
action.getReleasePR = () => {
|
||||||
class GithubReleasePR {
|
class GithubReleasePR {
|
||||||
run () {}
|
run () {}
|
||||||
}
|
}
|
||||||
GithubReleasePRStub = sinon.spy(function () {
|
GithubReleasePRStub = sinon.spy(function () {
|
||||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||||
instance.run = runStub
|
instance.run = githubReleasePRRunStub
|
||||||
return instance
|
return instance
|
||||||
})
|
})
|
||||||
return GithubReleasePRStub
|
return GithubReleasePRStub
|
||||||
}
|
}
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
assert.strictEqual(output.pr, 95)
|
assert.strictEqual(output.pr, 95)
|
||||||
})
|
})
|
||||||
@@ -285,20 +319,21 @@ describe('release-please-action', () => {
|
|||||||
core.getInput = (name) => {
|
core.getInput = (name) => {
|
||||||
return input[name]
|
return input[name]
|
||||||
}
|
}
|
||||||
let GithubReleasePRStub = sinon.stub()
|
|
||||||
const runStub = sinon.stub().returns(undefined)
|
|
||||||
|
|
||||||
|
let GithubReleasePRStub = sinon.stub()
|
||||||
|
const githubReleasePRRunStub = sinon.stub().returns(undefined)
|
||||||
action.getReleasePR = () => {
|
action.getReleasePR = () => {
|
||||||
class GithubReleasePR {
|
class GithubReleasePR {
|
||||||
run () {}
|
run () {}
|
||||||
}
|
}
|
||||||
GithubReleasePRStub = sinon.spy(function () {
|
GithubReleasePRStub = sinon.spy(function () {
|
||||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||||
instance.run = runStub
|
instance.run = githubReleasePRRunStub
|
||||||
return instance
|
return instance
|
||||||
})
|
})
|
||||||
return GithubReleasePRStub
|
return GithubReleasePRStub
|
||||||
}
|
}
|
||||||
|
|
||||||
await action.main()
|
await action.main()
|
||||||
assert.strictEqual(Object.hasOwnProperty.call(output, 'pr'), false)
|
assert.strictEqual(Object.hasOwnProperty.call(output, 'pr'), false)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user