Skip to content

[WIP][python] add verifytypes check in CI #7261

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
55 changes: 55 additions & 0 deletions packages/http-client-python/eng/scripts/ci/run_verifytypes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/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.
# --------------------------------------------------------------------------------------------

# This script is used to execute verifytypes within a tox environment. Depending on which package is being executed against,
# a failure may be suppressed.

import os
from subprocess import check_output, CalledProcessError
import logging
import sys
import time
from util import run_check

logging.getLogger().setLevel(logging.INFO)


def _single_dir_verifytypes(mod):
inner_class = next(d for d in mod.iterdir() if d.is_dir() and not str(d).endswith("egg-info"))
retries = 3
while retries:
try:
check_output(
[
sys.executable,
"-m",
"pyright",
"--verifytypes",
"-p",
str(inner_class.absolute()),
"--ignoreexternal",
],
text=True,
)
return True
except CalledProcessError as e:
logging.exception("{} exited with verifytypes error {}".format(inner_class.stem, e.returncode))
logging.error(f"Verifytypes stdout:\n{e.stdout}\n===========")
logging.error(f"Verifytypes stderr:\n{e.stderr}\n===========")
# Verifytypes has shown to randomly failed with a 217, retry the same folder 3 times should help
retries -= 1
time.sleep(5)

return False


if __name__ == "__main__":
if os.name == "nt":
# Before https://github.com/microsoft/typespec/issues/4667 fixed, skip running Verifytypes on Windows
logging.info("Skip running Verifytypes on Windows for now")
sys.exit(0)
run_check("verifytypes", _single_dir_verifytypes, "Verifytypes")
9 changes: 9 additions & 0 deletions packages/http-client-python/generator/test/azure/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ commands =
# pyright
python ../../../eng/scripts/ci/run_pyright.py -t azure -s "generated" {posargs}

# verifytypes
python ../../../eng/scripts/ci/run_verifytypes.py -t azure -s "generated" {posargs}

# apiview
pip install apiview-stub-generator==0.3.13 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
python ../../../eng/scripts/ci/run_apiview.py -t azure -s "generated" {posargs}
Expand Down Expand Up @@ -48,6 +51,12 @@ deps=
commands =
python ../../../eng/scripts/ci/run_pyright.py -t azure -s "generated" {posargs}

[testenv:verifytypes]
deps=
-r requirements.txt
commands =
python ../../../eng/scripts/ci/run_verifytypes.py -t azure -s "generated" {posargs}

[testenv:apiview]
deps=
-r requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions packages/http-client-python/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading