Skip to content

Commit

Permalink
[CI] Move Travis CI job "syncing available extensions to Microsoft/az…
Browse files Browse the repository at this point in the history
…ure-docs-cli" to ADO (Azure#1314)
  • Loading branch information
Jianhui Harold authored Feb 25, 2020
1 parent c1837fd commit 4dab494
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 14 deletions.
28 changes: 14 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ jobs:
env: PURPOSE='IndexRefDocVerify'
script: ./scripts/ci/test_index_ref_doc.sh
python: 3.6
- stage: publish
script: |
docker run \
--rm \
-e TRAVIS_BUILD_ID=$TRAVIS_BUILD_ID \
-e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
-e TRAVIS_COMMIT=$TRAVIS_COMMIT \
-e GH_TOKEN=$GH_TOKEN \
-e DOC_REPO_SLUG='MicrosoftDocs/azure-docs-cli' \
-e REPO_LOCATION=/repo \
-v $PWD:/repo \
mcr.microsoft.com/azure-cli-ext/ext-list-publisher:0.3.0
env: PURPOSE='SyncAvailableExtensionsDoc'
if: repo = Azure/azure-cli-extensions and branch = master and type = cron
# - stage: publish
# script: |
# docker run \
# --rm \
# -e TRAVIS_BUILD_ID=$TRAVIS_BUILD_ID \
# -e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
# -e TRAVIS_COMMIT=$TRAVIS_COMMIT \
# -e GH_TOKEN=$GH_TOKEN \
# -e DOC_REPO_SLUG='MicrosoftDocs/azure-docs-cli' \
# -e REPO_LOCATION=/repo \
# -v $PWD:/repo \
# mcr.microsoft.com/azure-cli-ext/ext-list-publisher:0.3.0
# env: PURPOSE='SyncAvailableExtensionsDoc'
# if: repo = Azure/azure-cli-extensions and branch = master and type = cron
fast_finish: true
3 changes: 3 additions & 0 deletions scripts/ci/avail-ext-doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This scripts is used in a Pipeline named **Azure CLI Extensions Sync** of Azure DevOps.

It's for syncing available extensions list to Microsoft/azure-cli-docs.
26 changes: 26 additions & 0 deletions scripts/ci/avail-ext-doc/list-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Available extensions for the Azure CLI
description: A complete list of the officially supported extensions for the Azure CLI.
author: haroldrandom
ms.author: jianzen
manager: yonzhan,yungezz
ms.date: {{ date }}
ms.topic: article
ms.prod: azure
ms.technology: azure-cli
ms.devlang: azure-cli
---

# Available extensions for the Azure CLI

This article is a complete list of the available extensions for the Azure CLI which are supported by Microsoft.

The list of extensions is also available from the CLI. To get it, run [az extension list-available](/cli/azure/extension?view=azure-cli-latest#az-extension-list-available):

```azurecli-interactive
az extension list-available --output table
```

| Name | Version | Summary | Preview |
|------|---------|---------|---------|{% for extension in extensions %}
| [{{ extension.name }}]({{ extension.project_url }}) | {{ extension.version }} | {{ extension.desc }} | {{ extension.preview }} |{% endfor %}
2 changes: 2 additions & 0 deletions scripts/ci/avail-ext-doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Jinja2~=2.10.1
wheel==0.31.1
63 changes: 63 additions & 0 deletions scripts/ci/avail-ext-doc/update_extension_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

"""
This script must be run at the root of repo folder, which is azure-cli-extensions/
It's used to update a file "azure-cli-extensions-list.md" of MicrosoftDocs/azure-cli-docs.
The file content is list of all available latest extensions.
"""

import os
import sys

import collections
import datetime
from pkg_resources import parse_version

from jinja2 import Template # pylint: disable=import-error


SCRIPTS_LOCATION = os.path.abspath(os.path.join('.', 'scripts'))

AZURE_DOCS_CLI_REPO_PATH = os.path.join('.', 'azure-docs-cli')
AVAILABLE_EXTENSIONS_DOC = os.path.join(AZURE_DOCS_CLI_REPO_PATH, 'docs-ref-conceptual', 'azure-cli-extensions-list.md')
TEMPLATE_FILE = os.path.join(SCRIPTS_LOCATION, "ci", "avail-ext-doc", "list-template.md")

sys.path.insert(0, SCRIPTS_LOCATION)
from ci.util import get_index_data, INDEX_PATH


def get_extensions():
extensions = []
index_extensions = collections.OrderedDict(sorted(get_index_data()['extensions'].items()))
for _, exts in index_extensions.items():
# Get latest version
exts = sorted(exts, key=lambda c: parse_version(c['metadata']['version']), reverse=True)
extensions.append({
'name': exts[0]['metadata']['name'],
'desc': exts[0]['metadata']['summary'],
'version': exts[0]['metadata']['version'],
'project_url': exts[0]['metadata']['extensions']['python.details']['project_urls']['Home'],
'preview': 'Yes' if exts[0]['metadata'].get('azext.isPreview') else ''
})
return extensions


def update_extensions_list(output_file):
with open(TEMPLATE_FILE, 'r') as doc_template:
template = Template(doc_template.read())
if template is None:
raise RuntimeError("Failed to read template file {}".format(TEMPLATE_FILE))
with open(output_file, 'w') as output:
output.write(template.render(extensions=get_extensions(), date=datetime.date.today().strftime("%m/%d/%Y")))


def main():
update_extensions_list(AVAILABLE_EXTENSIONS_DOC)


if __name__ == '__main__':
main()

0 comments on commit 4dab494

Please sign in to comment.