Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync extensions for JEDI #1418

Merged
merged 22 commits into from
Mar 24, 2020
Merged

Conversation

fengzhou-msft
Copy link
Member

This script will be used in an internal pipeline to sync up new extensions, triggered by new commits in master branch.

It also supports cleaning up and syncing all extensions from the master branch index.json file.


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update src/index.json automatically.
The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify src/index.json.

@yungezz yungezz self-assigned this Mar 19, 2020


def _get_updated_extension_names():
cmd = 'git --no-pager diff --diff-filter=ACMRT HEAD~1 -- src/index.json'
Copy link
Member

Choose a reason for hiding this comment

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

I'm still little concern on replying on change on index.json. what if the pipeline run failed? new run need to catch up extension blob changes in last several index.json change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added environment variable to control commit numbers to diff. So in case of failure, we can manually trigger the pipeline and pick up all the changes for the last n commits.

def _get_updated_extension_names():
cmd = 'git --no-pager diff --diff-filter=ACMRT HEAD~1 -- src/index.json'
updated_content = check_output(cmd.split()).decode('utf-8')
updated_urls = [line.replace('+', '') for line in updated_content.splitlines() if line.startswith('+') and not line.startswith('+++') and 'downloadUrl' in line]
Copy link
Member

Choose a reason for hiding this comment

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

why not load the json content and get from key directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Here we only extract updated downloadUrl from git diff for incremental sync.

the_ex = None
while count > 0:
try:
response = requests.get(url, allow_redirects=True)
Copy link
Member

Choose a reason for hiding this comment

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

since whl package size may be very big, is this lib supporting resume from break-point? if there any more reliable/dedicated package downloading library?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to stream downloading so we can handle big files well.

@yungezz yungezz requested a review from arrownj March 19, 2020 14:27
@haroldrandom
Copy link
Contributor

haroldrandom commented Mar 20, 2020

Can't we move this inside ADO?

@fengzhou-msft
Copy link
Member Author

Can't we move this inside ADO

code too long, ADO inline script will truncate it.

@haroldrandom
Copy link
Contributor

Can't we move this inside ADO

code too long, ADO inline script will truncate it.

I was wondering whether there is a better place to place this script instead of exposing it to the public because user don't need it.

def main():
import shutil
import tempfile
from azure.storage.blob import BlockBlobService
Copy link
Contributor

Choose a reason for hiding this comment

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

install azure.storage.blob in Bash task?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, as a prerequisite.

if not updated_urls:
return updated_exts
for line in updated_urls:
search_result = re.search(r'"downloadUrl":\s+"(.*?)"', line)
Copy link
Contributor

@haroldrandom haroldrandom Mar 20, 2020

Choose a reason for hiding this comment

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

What if user manually update src/index.json and enter 'downloadUrl'?

Copy link
Member Author

Choose a reason for hiding this comment

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

This also detects such case and is the same process as update by bot.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the re expression r'"downloadUrl":\s+"(.*?)" won't be ablt to search 'download'

Copy link
Member Author

Choose a reason for hiding this comment

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

no, it won't.

Copy link
Contributor

@haroldrandom haroldrandom left a comment

Choose a reason for hiding this comment

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

Generally okay with me.

@yonzhan yonzhan added this to the S167 milestone Mar 23, 2020
@fengzhou-msft fengzhou-msft merged commit 6f007cb into Azure:master Mar 24, 2020
ManuInNZ pushed a commit to ManuInNZ/azure-cli-extensions that referenced this pull request Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants