-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extension reference doc generation scripts & CI check
- Loading branch information
1 parent
cc609f2
commit b8fb740
Showing
15 changed files
with
563 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,3 +103,6 @@ ENV/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# Sphinx | ||
_build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from __future__ import print_function | ||
|
||
import os | ||
import sys | ||
import tempfile | ||
import unittest | ||
import shutil | ||
from subprocess import check_call | ||
from pkg_resources import parse_version | ||
|
||
from six import with_metaclass | ||
|
||
from util import get_index_data, get_whl_from_url, get_repo_root | ||
|
||
|
||
REF_GEN_SCRIPT = os.path.join(get_repo_root(), 'scripts', 'refdoc', 'generate.py') | ||
|
||
REF_DOC_OUT_DIR = os.environ.get('AZ_EXT_REF_DOC_OUT_DIR', tempfile.mkdtemp()) | ||
|
||
if not os.path.isdir(REF_DOC_OUT_DIR): | ||
print('{} is not a directory'.format(REF_DOC_OUT_DIR)) | ||
sys.exit(1) | ||
|
||
ALL_TESTS = [] | ||
|
||
for extension_name, exts in get_index_data()['extensions'].items(): | ||
candidates_sorted = sorted(exts, key=lambda c: parse_version(c['metadata']['version']), reverse=True) | ||
chosen = candidates_sorted[0] | ||
ALL_TESTS.append((extension_name, chosen['downloadUrl'], chosen['filename'])) | ||
|
||
|
||
class TestIndexRefDocsMeta(type): | ||
def __new__(mcs, name, bases, _dict): | ||
|
||
def gen_test(ext_name, ext_url, filename): | ||
def test(self): | ||
ext_file = get_whl_from_url(ext_url, filename, self.whl_dir) | ||
ref_doc_out_dir = os.path.join(REF_DOC_OUT_DIR, ext_name) | ||
if not os.path.isdir(ref_doc_out_dir): | ||
os.mkdir(ref_doc_out_dir) | ||
script_args = [sys.executable, REF_GEN_SCRIPT, '--extension-file', ext_file, '--output-dir', | ||
ref_doc_out_dir] | ||
check_call(script_args) | ||
return test | ||
|
||
for ext_name, ext_url, filename in ALL_TESTS: | ||
test_name = "test_ref_doc_%s" % ext_name | ||
_dict[test_name] = gen_test(ext_name, ext_url, filename) | ||
return type.__new__(mcs, name, bases, _dict) | ||
|
||
|
||
class IndexRefDocs(with_metaclass(TestIndexRefDocsMeta, unittest.TestCase)): | ||
|
||
def setUp(self): | ||
self.whl_dir = tempfile.mkdtemp() | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.whl_dir) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# Install CLI | ||
echo "Installing azure-cli..." | ||
|
||
pip install "azure-cli" -q | ||
pip install "sphinx==1.7.0" -q | ||
echo "Installed." | ||
|
||
python ./scripts/ci/index_ref_doc.py -v | ||
|
||
echo "OK." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.