Skip to content

Tools: update release date checker to check for release date vs. last commit of release#16470

Closed
moderation wants to merge 8 commits intoenvoyproxy:mainfrom
moderation:main
Closed

Tools: update release date checker to check for release date vs. last commit of release#16470
moderation wants to merge 8 commits intoenvoyproxy:mainfrom
moderation:main

Conversation

@moderation
Copy link
Copy Markdown
Contributor

Tools: update release date checker to check for release date vs. last commit of release
Additional Description:

  • change six from pythonhosted to Github location so we can verify release date
  • change layout of bazel/repository_locations.bzl and api/bazel/repository_locations.bzl so that release_date follows version and sha256 to aid with dependency maintainance
  • updated tools/dependency/release_dates.py to check for release metadata vs. current approach of checking for latest commit in a release which may not equal release date. /cc @htuch + @phlax for Python review.
  • no dependency changes in this PR

Risk Level: Low
Testing: bazel --nohome_rc test //test/..., bazel --nohome_rc test @envoy_api_canonical//test/... @envoy_api_canonical//tools/..., bazel --nohome_rc build @envoy_api_canonical//envoy/..., tools/dependency/release_dates.py bazel/repository_locations.bzl
Docs Changes: None required
Release Notes: None required

Signed-off-by: Michael Payne michael@sooper.org

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label May 12, 2021
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).

🐱

Caused by: #16470 was opened by moderation.

see: more, trace.

Signed-off-by: Michael Payne <michael@sooper.org>
Signed-off-by: Michael Payne <michael@sooper.org>
Signed-off-by: Michael Payne <michael@sooper.org>
Signed-off-by: Michael Payne <michael@sooper.org>
Signed-off-by: Michael Payne <michael@sooper.org>
@antoniovicente antoniovicente requested review from htuch and phlax and removed request for htuch May 14, 2021 20:29
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good (but noisy with all the reordering, prefer separate commits there). Some nits.

latest = ''
pass

if latest and (github_release.version <= latest.tag_name):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use parens here.

assert metadata_version == github_release.version
commit = repo.get_commit(github_release.version)
commits = repo.get_commits(since=commit.commit.committer.date)
if commits.totalCount - 1 > 0:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totalCount > 1?

for tag in tags.reversed:
if tag.name == github_release.version:
current_metadata_tag_commit_date = tag.commit.commit.committer.date
if not (version.parse(tag.name).is_prerelease) and version.parse(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @moderation - looking good - as commented i was sometimes confused by the release dates on gh <> expected

suggestions below

return tag.commit.commit.committer.date

try:
latest = repo.get_latest_release()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this explains why copypastaing release dates from gh sometimes was off-by-one - i had assumed it was a timezone issue

@@ -40,32 +42,58 @@ def verify_and_print_latest_release(dep, repo, metadata_version, release_date):
latest_release = repo.get_latest_release()
if latest_release.created_at > release_date and latest_release.tag_name != metadata_version:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i would move all of this logic after the try...except and return in the except clause

afaict none of this logic is related to the github exception and it means this chunk can be dedented

Fore.YELLOW
+ f'*WARNING* {dep} has a newer release than {metadata_version}@<{release_date}>: '
f'{latest_release.tag_name}@<{latest_release.created_at}>' + Style.RESET_ALL)
except github.GithubException as e:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this failure is silently ignored - can we add a comment explaining why it might be triggered and is safe to ignore


try:
latest = repo.get_latest_release()
except github.GithubException as e:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise here - it would be good to know why this is safe to ignore - if its due to http failure or somesuch then perhaps we should add a warning "unable to retrieve github info" or similar


# Extract release date from GitHub API.
def get_release_date(repo, metadata_version, github_release):
if github_release.tagged:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would factor out the 2 possibilities here into separate functions - ie get_tagged_release_date and get_untagged_release_date or similar - it will allow a load of dedenting and make the logic easier to follow

return None
else:
assert (metadata_version == github_release.version)
assert metadata_version == github_release.version
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert is generally just for testing - i think this should be something more like:

if metadata_version != github_release.version:
   raise UpstreamReleaseDateError(...errorinfo...)

if tag.name == github_release.version:
current_metadata_tag_commit_date = tag.commit.commit.committer.date
if not (version.parse(tag.name).is_prerelease) and version.parse(
tag.name) > version.parse(github_release.version):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i reallly dislike multiline if clauses - my suggestion is (always) to express the logic in a variable - eg:

has_newer_release_date = (
    not version.parse(tag.name).is_prerelease
    and version.parse(tag.name) > version.parse(github_release.version))

if has_newer_release_date:
   ...do something...

@moderation
Copy link
Copy Markdown
Contributor Author

Addressed comments and replaced by #16712

@moderation moderation closed this May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants