Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/check-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check for latest_release of deps

on :
push :
schedule :
- cron : '*/5 * * * *'

workflow_dispatch :

jobs :
build :
runs-on : ubuntu-latest
steps :
- name : checkout
uses : actions/checkout/@v2
with :
ref : ${{ github.head_ref }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install virtualenv

- name: setting up virtualenv
run : |
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
./tools/dependency/release_dates.sh bazel/repository_locations.bzl
Comment thread
ME-ON1 marked this conversation as resolved.
Outdated
46 changes: 46 additions & 0 deletions tools/dependency/release_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@
from colorama import Fore, Style
from packaging import version

# Tag issues created with these labels.
LABELS = ['deprecation', 'tech debt', 'no stalebot']
Comment thread
asraa marked this conversation as resolved.
Outdated


# Thrown on errors related to release date or version.
class ReleaseDateVersionError(Exception):
pass


# Errors that happen during issue creation.
class DeprecateVersionError(Exception):
Comment thread
ME-ON1 marked this conversation as resolved.
Outdated
pass


# Format a datetime object as UTC YYYY-MM-DD.
def format_utc_date(date):
# We only handle naive datetime objects right now, which is what PyGithub
Expand All @@ -51,6 +59,44 @@ def verify_and_print_latest_release(dep, repo, metadata_version, release_date):
print(
f'{Fore.YELLOW}*WARNING* {dep} has a newer release than {metadata_version}@<{release_date}>: '
f'{latest_release.tag_name}@<{latest_release.created_at}>{Style.RESET_ALL}')
create_issues(dep, repo, metadata_version, release_date, latest_release)
Comment thread
ME-ON1 marked this conversation as resolved.
Outdated


# create issue for stale dependency
def create_issues(dep, repo, metadata_version, release_date, latest_release):
"""Create issues in GitHub.

Args:
dep : name of the deps
repo : BaseURL of the repo
metadata_version :
release_date : old release_date
latest_release : latest_release (name and date )
"""
access_token = os.getenv('GITHUB_TOKEN')
git = github.Github(access_token)
repo = git.get_repo('envoyproxy/envoy')

# Find GitHub label objects for LABELS.
labels = []
for label in repo.get_labels():
Comment thread
ME-ON1 marked this conversation as resolved.
if label.name in LABELS:
labels.append(label)
if len(labels) != len(LABELS):
raise DeprecateVersionError('Unknown labels (expected %s, got %s)' % (LABELS, labels))

print('Creating issues...')
body = f'*WARNING* {dep} has a newer release than {metadata_version}@<{release_date}>:{latest_release.tag_name}@<{latest_release.created_at}>'
title = f'{dep} has a newer release {latest_release.tag_name}'
Comment thread
ME-ON1 marked this conversation as resolved.
Outdated
Comment thread
ME-ON1 marked this conversation as resolved.
Outdated
try:
repo.create_issue(title, body=body, labels=labels)
except github.GithubException as e:
try:
repo.create_issue(title, body=body, labels=labels)
Comment thread
ME-ON1 marked this conversation as resolved.
Outdated
print('unable to assign issue . Add them to the Envoy proxy org')
except github.GithubException as e:
print('GithubException while creating issue.')
raise


# Print GitHub release date, throw ReleaseDateVersionError on mismatch with metadata release date.
Expand Down