Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/gh/workers/merge.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import { OPEN_PR } from '../types.mjs'

export const type = OPEN_PR

export const filter = [
'status: SUCCESS',
{ value: 'reviewDecision: REVIEW_REQUIRED', reject: true },
]

export const args = {
desc: 'Merge pull requests',
builder: (yargs) =>
Expand All @@ -27,7 +22,19 @@ export const args = {
desc: 'whether to approve the pr',
type: 'boolean',
},
requireSuccess: {
default: true,
desc: 'only merge PRs with successful CI status',
type: 'boolean',
},
}),
filter: (argv) => {
const filters = [{ value: 'reviewDecision: REVIEW_REQUIRED', reject: true }]
if (argv.requireSuccess) {
filters.push('status: SUCCESS')
}
return filters
},
}

export const success = ({ item }) => item.url
Expand Down
14 changes: 12 additions & 2 deletions lib/gh/workers/review.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { apiOnlyOptions } from '../yargs/utils.mjs'

export const type = OPEN_PR

export const filter = ['status: SUCCESS', 'reviewDecision: REVIEW_REQUIRED']

export const args = {
desc: 'Review pull requests',
builder: (yargs) =>
Expand All @@ -14,8 +12,20 @@ export const args = {
desc: 'whether to approve the pr',
type: 'boolean',
},
requireSuccess: {
default: true,
desc: 'only review PRs with successful CI status',
type: 'boolean',
},
...apiOnlyOptions(),
}),
filter: (argv) => {
const filters = ['reviewDecision: REVIEW_REQUIRED']
if (argv.requireSuccess) {
filters.push('status: SUCCESS')
}
return filters
},
}

export const success = ({ item }) => item.url
Expand Down
74 changes: 42 additions & 32 deletions tap-snapshots/test/gh.mjs.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ Command Options:
--merge-strategy strategy to use when merging the pull request [required] [choices: "squash", "rebase"]
--remote name of the remote [required] [default: "origin"]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only merge PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: "$HOME/projects"]
Expand Down Expand Up @@ -353,12 +354,13 @@ npx -p @npmcli/stafftools gh dependabot review
Review pull requests

Command Options:
--cache how long for gh to cache the query [string] [default: "1m"]
--repos query to filter repos [string] [required] [default: "org:npm topic:npm-cli fork:true archived:false"]
--table shorthand for --template=table [boolean] [default: false]
--confirm shorthand for --template=confirm [boolean] [default: false]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--cache how long for gh to cache the query [string] [default: "1m"]
--repos query to filter repos [string] [required] [default: "org:npm topic:npm-cli fork:true archived:false"]
--table shorthand for --template=table [boolean] [default: false]
--confirm shorthand for --template=confirm [boolean] [default: false]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only review PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: null]
Expand Down Expand Up @@ -549,6 +551,7 @@ Command Options:
--merge-strategy strategy to use when merging the pull request [required] [choices: "squash", "rebase"]
--remote name of the remote [required] [default: "origin"]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only merge PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: "$HOME/projects"]
Expand Down Expand Up @@ -796,10 +799,11 @@ npx -p @npmcli/stafftools gh graphql review
Review pull requests

Command Options:
--query path to a query file passed directly to gh api graphql [string] [required]
--cache how long for gh to cache the query [string] [default: "1m"]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--query path to a query file passed directly to gh api graphql [string] [required]
--cache how long for gh to cache the query [string] [default: "1m"]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only review PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: null]
Expand Down Expand Up @@ -992,6 +996,7 @@ Command Options:
--merge-strategy strategy to use when merging the pull request [required] [choices: "squash", "rebase"]
--remote name of the remote [required] [default: "origin"]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only merge PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: "$HOME/projects"]
Expand Down Expand Up @@ -1141,14 +1146,15 @@ npx -p @npmcli/stafftools gh pending-release review
Review pull requests

Command Options:
--cache how long for gh to cache the query [string] [default: "1m"]
--repos query to filter repos [string] [required] [default: "org:npm topic:npm-cli fork:true archived:false"]
--noDeps Only return items that do not depend on any other items returned [boolean] [default: false]
--depsPrs Only return items that have no open deps PRs [string] [choices: "", "none", "any"] [default: ""]
--table shorthand for --template=table [boolean] [default: false]
--confirm shorthand for --template=confirm [boolean] [default: false]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--cache how long for gh to cache the query [string] [default: "1m"]
--repos query to filter repos [string] [required] [default: "org:npm topic:npm-cli fork:true archived:false"]
--noDeps Only return items that do not depend on any other items returned [boolean] [default: false]
--depsPrs Only return items that have no open deps PRs [string] [choices: "", "none", "any"] [default: ""]
--table shorthand for --template=table [boolean] [default: false]
--confirm shorthand for --template=confirm [boolean] [default: false]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only review PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: null]
Expand Down Expand Up @@ -1251,6 +1257,7 @@ Command Options:
--merge-strategy strategy to use when merging the pull request [required] [choices: "squash", "rebase"]
--remote name of the remote [required] [default: "origin"]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only merge PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: "$HOME/projects"]
Expand Down Expand Up @@ -1367,14 +1374,15 @@ npx -p @npmcli/stafftools gh pull-requests review
Review pull requests

Command Options:
--cache how long for gh to cache the query [string] [default: "1m"]
--repos query to filter repos [string] [required] [default: "org:npm topic:npm-cli fork:true archived:false"]
--label label to filter pull requests [string]
--state state to filter pull requests [string] [choices: "CLOSED", "MERGED", "OPEN"] [default: "OPEN"]
--table shorthand for --template=table [boolean] [default: false]
--confirm shorthand for --template=confirm [boolean] [default: false]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--cache how long for gh to cache the query [string] [default: "1m"]
--repos query to filter repos [string] [required] [default: "org:npm topic:npm-cli fork:true archived:false"]
--label label to filter pull requests [string]
--state state to filter pull requests [string] [choices: "CLOSED", "MERGED", "OPEN"] [default: "OPEN"]
--table shorthand for --template=table [boolean] [default: false]
--confirm shorthand for --template=confirm [boolean] [default: false]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only review PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: null]
Expand Down Expand Up @@ -1760,6 +1768,7 @@ Command Options:
--merge-strategy strategy to use when merging the pull request [required] [choices: "squash", "rebase"]
--remote name of the remote [required] [default: "origin"]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only merge PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: "$HOME/projects"]
Expand Down Expand Up @@ -1870,12 +1879,13 @@ npx -p @npmcli/stafftools gh template-oss review
Review pull requests

Command Options:
--cache how long for gh to cache the query [string] [default: "1m"]
--repos query to filter repos [string] [required] [default: "org:npm topic:npm-cli fork:true archived:false"]
--table shorthand for --template=table [boolean] [default: false]
--confirm shorthand for --template=confirm [boolean] [default: false]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--cache how long for gh to cache the query [string] [default: "1m"]
--repos query to filter repos [string] [required] [default: "org:npm topic:npm-cli fork:true archived:false"]
--table shorthand for --template=table [boolean] [default: false]
--confirm shorthand for --template=confirm [boolean] [default: false]
--report shorthand for --template=report [boolean] [default: false]
--approve whether to approve the pr [boolean] [default: false]
--requireSuccess only review PRs with successful CI status [boolean] [default: true]

Global Options:
-c, --cwd base directory to run filesystem related commands [string] [default: null]
Expand Down
Loading