Skip to content

Commit

Permalink
feat(inputs): additional input support: command & approve
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Aug 25, 2020
1 parent 5faae7d commit 1538a97
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -79,7 +79,9 @@ steps:

### Inputs

| output | required | default | description |
| input | required | default | description |
| -------------- | -------- | -------------- | --------------------------------------------------- |
| `target` || `patch` | The version comparison target (major, minor, patch) |
| `github-token` || `github.token` | The GitHub token used to merge the pull-request |
| `command` || `merge` | The command to pass to Dependabot |
| `approve` || `true` | Auto-approve pull-requests |
3 changes: 2 additions & 1 deletion action/lib/parse.js
Expand Up @@ -35,8 +35,9 @@ module.exports = function (title, target) {
if ((weight[target] || 0) >= (weight[result] || 0)) {
// tell dependabot to merge
core.info(`dependency update target is "${target}", found "${result}", will auto-merge`)
return 'merge'
return true
}

core.info('manual merging required')
return false
}
4 changes: 2 additions & 2 deletions action/test/in-range.js
Expand Up @@ -11,14 +11,14 @@ test('title -> parse', async assert => {

sinon.stub(core, 'info')

const command = parse('chore(deps): bump api-problem from 6.1.2 to 6.1.4 in /path', 'major')
const proceed = parse('chore(deps): bump api-problem from 6.1.2 to 6.1.4 in /path', 'major')

assert.ok(proceed)
assert.ok(core.info.called)
assert.equal(core.info.getCall(0).args[0], 'title: "chore(deps): bump api-problem from 6.1.2 to 6.1.4 in /path"')
assert.equal(core.info.getCall(1).args[0], 'from: 6.1.2')
assert.equal(core.info.getCall(2).args[0], 'to: 6.1.4')
assert.equal(core.info.getCall(3).args[0], 'dependency update target is "major", found "patch", will auto-merge')
assert.equal(command, 'merge')

core.info.restore()
})
4 changes: 2 additions & 2 deletions action/test/no-merge.js
Expand Up @@ -11,13 +11,13 @@ test('title -> parse', async assert => {

sinon.stub(core, 'info')

const command = parse('chore(deps): bump api-problem from 6.1.2 to 7.0.0 in /path', 'patch')
const proceed = parse('chore(deps): bump api-problem from 6.1.2 to 7.0.0 in /path', 'patch')

assert.notOk(proceed, false)
assert.ok(core.info.called)
assert.equal(core.info.getCall(1).args[0], 'from: 6.1.2')
assert.equal(core.info.getCall(2).args[0], 'to: 7.0.0')
assert.equal(core.info.getCall(3).args[0], 'manual merging required')
assert.same(command, null)

core.info.restore()
})
4 changes: 2 additions & 2 deletions action/test/pre-release-target.js
Expand Up @@ -11,12 +11,12 @@ test('title -> parse', async assert => {

sinon.stub(core, 'info')

const command = parse('chore(deps): bump api-problem from 6.1.2 to 6.1.4-prerelease in /path', 'preminor')
const proceed = parse('chore(deps): bump api-problem from 6.1.2 to 6.1.4-prerelease in /path', 'preminor')

assert.ok(proceed)
assert.ok(core.info.called)
assert.equal(core.info.getCall(2).args[0], 'to: 6.1.4-prerelease')
assert.equal(core.info.getCall(3).args[0], 'dependency update target is "preminor", found "prepatch", will auto-merge')
assert.equal(command, 'merge')

core.info.restore()
})
4 changes: 2 additions & 2 deletions action/test/pre-release-version.js
Expand Up @@ -11,12 +11,12 @@ test('title -> parse', async assert => {

sinon.stub(core, 'info')

const command = parse('chore(deps): bump api-problem from 6.1.2 to 6.1.4-prerelease in /path', 'major')
const proceed = parse('chore(deps): bump api-problem from 6.1.2 to 6.1.4-prerelease in /path', 'major')

assert.ok(proceed)
assert.ok(core.info.called)
assert.equal(core.info.getCall(2).args[0], 'to: 6.1.4-prerelease')
assert.equal(core.info.getCall(3).args[0], 'dependency update target is "major", found "prepatch", will auto-merge')
assert.equal(command, 'merge')

core.info.restore()
})
4 changes: 2 additions & 2 deletions action/test/title-valid.js
Expand Up @@ -11,14 +11,14 @@ test('title -> parse', async assert => {

sinon.stub(core, 'info')

const command = parse('chore(deps): bump api-problem from 6.1.2 to 6.1.4 in /path', 'patch')
const proceed = parse('chore(deps): bump api-problem from 6.1.2 to 6.1.4 in /path', 'patch')

assert.ok(proceed)
assert.ok(core.info.called)
assert.equal(core.info.getCall(0).args[0], 'title: "chore(deps): bump api-problem from 6.1.2 to 6.1.4 in /path"')
assert.equal(core.info.getCall(1).args[0], 'from: 6.1.2')
assert.equal(core.info.getCall(2).args[0], 'to: 6.1.4')
assert.equal(core.info.getCall(3).args[0], 'dependency update target is "patch", found "patch", will auto-merge')
assert.equal(command, 'merge')

core.info.restore()
})

0 comments on commit 1538a97

Please sign in to comment.