2
2
This script is part of the pytest release process which is triggered by comments
3
3
in issues.
4
4
5
- This script is started by the `release-on-comment.yml` workflow, which is triggered by two comment
6
- related events:
5
+ This script is started by the `release-on-comment.yml` workflow, which always executes on
6
+ `master` and is triggered by two comment related events:
7
7
8
8
* https://help.github.com/en/actions/reference/events-that-trigger-workflows#issue-comment-event-issue_comment
9
9
* https://help.github.com/en/actions/reference/events-that-trigger-workflows#issues-event-issues
30
30
import json
31
31
import os
32
32
import re
33
- import sys
33
+ import traceback
34
34
from pathlib import Path
35
35
from subprocess import CalledProcessError
36
36
from subprocess import check_call
@@ -94,7 +94,6 @@ def print_and_exit(msg) -> None:
94
94
95
95
96
96
def trigger_release (payload_path : Path , token : str ) -> None :
97
- error_contents = "" # to be used to store error output in case any command fails
98
97
payload , base_branch , is_major = validate_and_get_issue_comment_payload (
99
98
payload_path
100
99
)
@@ -119,6 +118,7 @@ def trigger_release(payload_path: Path, token: str) -> None:
119
118
issue .create_comment (str (e ))
120
119
print_and_exit (f"{ Fore .RED } { e } " )
121
120
121
+ error_contents = ""
122
122
try :
123
123
print (f"Version: { Fore .CYAN } { version } " )
124
124
@@ -146,11 +146,12 @@ def trigger_release(payload_path: Path, token: str) -> None:
146
146
147
147
print (f"Branch { Fore .CYAN } { release_branch } { Fore .RESET } created." )
148
148
149
+ # important to use tox here because we have changed branches, so dependencies
150
+ # might have changed as well
151
+ cmdline = ["tox" , "-e" , "release" , "--" , version , "--skip-check-links" ]
152
+ print ("Running" , " " .join (cmdline ))
149
153
run (
150
- [sys .executable , "scripts/release.py" , version , "--skip-check-links" ],
151
- text = True ,
152
- check = True ,
153
- capture_output = True ,
154
+ cmdline , text = True , check = True , capture_output = True ,
154
155
)
155
156
156
157
oauth_url = f"https://{ token } :[email protected] /{ SLUG } .git"
@@ -178,43 +179,31 @@ def trigger_release(payload_path: Path, token: str) -> None:
178
179
)
179
180
print (f"Notified in original comment { Fore .CYAN } { comment .url } { Fore .RESET } ." )
180
181
181
- print (f"{ Fore .GREEN } Success." )
182
182
except CalledProcessError as e :
183
- error_contents = e .output
184
- except Exception as e :
185
- error_contents = str (e )
186
- link = f"https://github.com/{ SLUG } /actions/runs/{ os .environ ['GITHUB_RUN_ID' ]} "
187
- issue .create_comment (
188
- dedent (
189
- f"""
190
- Sorry, the request to prepare release `{ version } ` from { base_branch } failed with:
191
-
192
- ```
193
- { e }
194
- ```
195
-
196
- See: { link } .
197
- """
198
- )
199
- )
200
- print_and_exit (f"{ Fore .RED } { e } " )
183
+ error_contents = f"CalledProcessError\n output:\n { e .output } \n stderr:\n { e .stderr } "
184
+ except Exception :
185
+ error_contents = f"Exception:\n { traceback .format_exc ()} "
201
186
202
187
if error_contents :
203
188
link = f"https://github.com/{ SLUG } /actions/runs/{ os .environ ['GITHUB_RUN_ID' ]} "
204
- issue .create_comment (
205
- dedent (
206
- f"""
207
- Sorry, the request to prepare release `{ version } ` from { base_branch } failed with:
208
-
209
- ```
210
- { error_contents }
211
- ```
212
-
213
- See: { link } .
214
- """
215
- )
189
+ msg = ERROR_COMMENT .format (
190
+ version = version , base_branch = base_branch , contents = error_contents , link = link
216
191
)
192
+ issue .create_comment (msg )
217
193
print_and_exit (f"{ Fore .RED } { error_contents } " )
194
+ else :
195
+ print (f"{ Fore .GREEN } Success." )
196
+
197
+
198
+ ERROR_COMMENT = """\
199
+ The request to prepare release `{version}` from {base_branch} failed with:
200
+
201
+ ```
202
+ {contents}
203
+ ```
204
+
205
+ See: {link}.
206
+ """
218
207
219
208
220
209
def find_next_version (base_branch : str , is_major : bool ) -> str :
0 commit comments