Skip to content

Commit 4e0c33c

Browse files
authored
chore(release): make notebook by default for RCs and handle deleted release ntoes (#6893)
Gave this a few iterations of testing. During the release of 1.19 we realized that if you forgot to make a notebook for the RC1 and fully published the release, it was a hassle to make the script publish a notebook after the fact. This makes the script always create a notebook for RC1 so it can't be missed. In addition, prior to this, if a release note had been added and then deleted, we would get an error when searching for that file's contents. This PR handles those errors and prints a message so the user can look at the commit if they need to do discern what happened with the release note. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [ ] Title is accurate. - [ ] No unnecessary changes are introduced. - [ ] Description motivates each change. - [ ] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [ ] Testing strategy adequately addresses listed risk(s). - [ ] Change is maintainable (easy to change, telemetry, documentation). - [ ] Release note makes sense to a user of the library. - [ ] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [ ] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [ ] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [ ] This PR doesn't touch any of that.
1 parent f3beaf4 commit 4e0c33c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

scripts/release.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
PATCH - Whether or not this a patch release. e.g. PATCH=1 or PATCH=0
4141
PRINT - Whether or not the release notes should be printed to CLI or be used to create a Github release. Default is 0 e.g. PRINT=1 or PRINT=0
4242
NOTEBOOK - Whether or not to create a notebook in staging. Note this only works for RC1s since those are usually what we create notebooks for.
43-
Default is 0 e.g. NOTEBOOK=0 or NOTEBOOK=1
43+
Default is 1 for RC1s, 0 for everything else e.g. NOTEBOOK=0 or NOTEBOOK=1
4444
Examples:
4545
Generate release notes and staging testing notebook for next release candidate version of 1.11: `BASE=1.11 RC=1 NOTEBOOK=1 python release.py`
4646
@@ -234,7 +234,7 @@ def setup_gh():
234234
def create_notebook(dd_repo, name, rn, base, rc, patch):
235235
dd_api_key = os.getenv("DD_API_KEY_STAGING")
236236
dd_app_key = os.getenv("DD_APP_KEY_STAGING")
237-
if not dd_api_key and dd_app_key:
237+
if not dd_api_key or not dd_app_key:
238238
raise ValueError(
239239
"We need DD_API_KEY_STAGING and DD_APP_KEY_STAGING values. Please follow the instructions in the script."
240240
)
@@ -282,12 +282,20 @@ def create_notebook(dd_repo, name, rn, base, rc, patch):
282282
for file in files:
283283
filename = file.filename
284284
if filename.startswith("releasenotes/notes/"):
285-
# we need to make another api call to get ContentFile object so we can see what's in there
286-
rn_file_content = dd_repo.get_contents(filename).decoded_content.decode("utf8")
287-
# try to grab a good portion of the release note for us to use to insert in our reno release notes
288-
# this is a bit hacky, will only attach to one section if you have multiple sections in a release note
289-
# (e.g. a features and a fix section):
290-
# for example: https://github.com/DataDog/dd-trace-py/blob/1.x/releasenotes/notes/asm-user-id-blocking-5048b1cef07c80fd.yaml # noqa
285+
try:
286+
# we need to make another api call to get ContentFile object so we can see what's in there
287+
rn_file_content = dd_repo.get_contents(filename).decoded_content.decode("utf8")
288+
# try to grab a good portion of the release note for us to use to insert in our reno release notes
289+
# this is a bit hacky, will only attach to one section if you have multiple sections
290+
# in a release note
291+
# (e.g. a features and a fix section):
292+
# for example: https://github.com/DataDog/dd-trace-py/blob/1.x/releasenotes/notes/asm-user-id-blocking-5048b1cef07c80fd.yaml # noqa
293+
except Exception:
294+
print(
295+
"""File contents were not obtained for {file} in commit {commit}."""
296+
"""It's likely this file was deleted in a PR""".format(file=file, commit=commit)
297+
)
298+
continue
291299
try:
292300
rn_piece = re.findall(
293301
r" - \|\n ((.|\n)*)\n(((issues|features|upgrade|deprecations|fixes|other):\n)|.*)",
@@ -426,7 +434,7 @@ def create_notebook(dd_repo, name, rn, base, rc, patch):
426434
dd_repo = setup_gh()
427435
name, rn = create_release_draft(dd_repo, base, rc, patch)
428436

429-
if os.getenv("NOTEBOOK"):
437+
if os.getenv("NOTEBOOK", 1):
430438
if rc:
431439
print("Creating Notebook")
432440
create_notebook(dd_repo, name, rn, base, rc, patch)

0 commit comments

Comments
 (0)