@@ -181,18 +181,34 @@ def post_pr_comment(self, missing: Set[str]) -> bool:
181181 if not requests :
182182 print ('requests not installed; skipping post' )
183183 return False
184+
185+ print (f'GitHub token present: { bool (self .github_token )} ' )
186+ print (f'GitHub repo: { self .github_repo } ' )
187+ print (f'PR number: { self .pr_number } ' )
188+
184189 if not (self .github_token and self .github_repo and self .pr_number ):
185190 print ('Missing GitHub env variables; cannot post comment' )
191+ print ('Required env vars: GITHUB_TOKEN, GITHUB_REPOSITORY, PR_NUMBER' )
186192 return False
193+
187194 url = f"https://api.github.com/repos/{ self .github_repo } /issues/{ self .pr_number } /comments"
188195 headers = {'Authorization' : f'token { self .github_token } ' , 'Accept' : 'application/vnd.github.v3+json' }
196+
197+ print (f'Posting comment to: { url } ' )
198+
189199 try :
190200 r = requests .post (url , headers = headers , json = {'body' : self .create_comment_body (missing )})
201+ print (f'Response status: { r .status_code } ' )
202+ if r .status_code != 201 :
203+ print (f'Response body: { r .text } ' )
191204 r .raise_for_status ()
192- print ('Posted PR comment' )
205+ print ('Posted PR comment successfully ' )
193206 return True
194207 except Exception as e :
195208 print (f'Failed to post PR comment: { e } ' )
209+ if hasattr (e , 'response' ):
210+ print (f'Response status: { e .response .status_code } ' )
211+ print (f'Response body: { e .response .text } ' )
196212 return False
197213
198214 def check_contributors (self ) -> bool :
@@ -205,7 +221,7 @@ def check_contributors(self) -> bool:
205221 citation_cff = self .parse_citation_cff ()
206222 codemeta_json = self .parse_codemeta_json ()
207223
208- print (f '\n Checking CITATION.cff:' )
224+ print ('\n Checking CITATION.cff:' )
209225 if citation_cff :
210226 print (f' Found { len (citation_cff )} contributors in CITATION.cff' )
211227 for c in sorted (citation_cff ):
@@ -218,7 +234,7 @@ def check_contributors(self) -> bool:
218234 else :
219235 print (' CITATION.cff not found or empty' )
220236
221- print (f '\n Checking codemeta.json:' )
237+ print ('\n Checking codemeta.json:' )
222238 if codemeta_json :
223239 print (f' Found { len (codemeta_json )} contributors in codemeta.json' )
224240 for c in sorted (codemeta_json ):
@@ -235,13 +251,27 @@ def check_contributors(self) -> bool:
235251 metadata = citation_cff | codemeta_json
236252 missing = self .find_missing_contributors (pr_contribs , metadata )
237253
238- print (f'\n Overall result:' )
254+ print ('\n Overall result:' )
255+ current_mode = self .config .get ('mode' , 'warn' )
256+ print (f'Running in mode: { current_mode } ' )
257+
239258 if missing :
240259 print (f'Missing contributors (not in any metadata file): { sorted (missing )} ' )
241- self .post_pr_comment (missing )
242- return False if self .config .get ('mode' ) == 'fail' else True
243- print ('All PR contributors present in at least one metadata file' )
244- return True
260+ print ('Attempting to post PR comment...' )
261+ comment_posted = self .post_pr_comment (missing )
262+ if not comment_posted :
263+ print ('Failed to post PR comment - check GitHub token and permissions' )
264+
265+ # Only fail if mode is 'fail', otherwise just warn
266+ if current_mode == 'fail' :
267+ print ('Mode is "fail" - exiting with error code' )
268+ return False
269+ else :
270+ print ('Mode is "warn" - posting warning but not failing' )
271+ return True
272+ else :
273+ print ('All PR contributors present in at least one metadata file' )
274+ return True
245275
246276 def check_all_contributors_in_metadata (self ) -> bool :
247277 allc = self .get_all_contributors ()
0 commit comments