@@ -8,6 +8,7 @@ const checkIssueAcceptance = require('./check_issue_acceptance.cjs');
88async function check ( {
99 permission = 'read' , issues = [ ] , body = '' , permissionError,
1010 number = 7 , headSha = 'pr-head' , pullError, issueError, labelError,
11+ author = 'contributor' , actor = 'maintainer' ,
1112} = { } ) {
1213 const failures = [ ] ;
1314 const github = {
@@ -17,13 +18,13 @@ async function check({
1718 assert . equal ( pull_number , number ) ;
1819 if ( pullError ) throw new Error ( 'PR lookup failed' ) ;
1920 return { data : {
20- number, user : { login : 'contributor' } , head : { sha : headSha } , body,
21+ number, user : { login : author } , head : { sha : headSha } , body,
2122 } } ;
2223 } ,
2324 } ,
2425 repos : {
2526 getCollaboratorPermissionLevel : async ( { username } ) => {
26- assert . equal ( username , 'contributor' ) ;
27+ assert . equal ( username , author ) ;
2728 if ( permissionError ) throw Object . assign ( new Error ( 'lookup failed' ) , { status : permissionError } ) ;
2829 return { data : { permission } } ;
2930 } ,
@@ -53,13 +54,31 @@ async function check({
5354 context : {
5455 repo : { owner : 'NVIDIA' , repo : 'OpenShell' } ,
5556 payload : { pull_request : { number } } ,
56- actor : 'maintainer' , sha : 'base-commit' , serverUrl : 'https://github.com' , runId : 42 ,
57+ actor, sha : 'base-commit' , serverUrl : 'https://github.com' , runId : 42 ,
5758 } ,
5859 core : { info ( ) { } , setFailed : message => failures . push ( message ) } ,
5960 } ) ;
6061 return failures ;
6162}
6263
64+ test ( 'Dependabot PRs pass without permission or issue lookups' , async ( ) => {
65+ assert . deepEqual ( await check ( {
66+ author : 'dependabot[bot]' , permissionError : 403 , issueError : true ,
67+ } ) , [ ] ) ;
68+ } ) ;
69+
70+ test ( 'other bots still require an accepted issue' , async ( ) => {
71+ const failures = await check ( { author : 'renovate[bot]' } ) ;
72+ assert . equal ( failures . length , 1 ) ;
73+ assert . match ( failures [ 0 ] , / m u s t l i n k a n i s s u e w i t h s t a t e : a c c e p t e d / ) ;
74+ } ) ;
75+
76+ test ( 'Dependabot triggering another author\'s PR does not bypass acceptance' , async ( ) => {
77+ const failures = await check ( { actor : 'dependabot[bot]' } ) ;
78+ assert . equal ( failures . length , 1 ) ;
79+ assert . match ( failures [ 0 ] , / m u s t l i n k a n i s s u e w i t h s t a t e : a c c e p t e d / ) ;
80+ } ) ;
81+
6382for ( const permission of [ 'write' , 'maintain' , 'admin' ] ) {
6483 test ( `${ permission } access allows an issue-less PR` , async ( ) => {
6584 assert . deepEqual ( await check ( { permission } ) , [ ] ) ;
0 commit comments