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

Refactor Build, Versioning into azure-sdk-tools #25454

Merged
merged 78 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
0d799b0
patching conda version to current. removing pin of azure-mgmt-resources
scbedd Feb 23, 2022
ce5839c
Merge remote-tracking branch 'upstream/main'
scbedd Feb 25, 2022
1620a58
Merge remote-tracking branch 'upstream/main'
scbedd Feb 25, 2022
147885f
Merge remote-tracking branch 'upstream/main'
scbedd Feb 28, 2022
f21c9c3
Merge remote-tracking branch 'upstream/main'
scbedd Mar 1, 2022
1d5f071
Merge remote-tracking branch 'upstream/main'
scbedd Mar 1, 2022
718e502
Merge remote-tracking branch 'upstream/main'
scbedd Mar 2, 2022
5df1ebf
Merge remote-tracking branch 'upstream/main'
scbedd Mar 4, 2022
a6829de
Merge remote-tracking branch 'upstream/main'
scbedd Mar 4, 2022
0b2da34
Merge remote-tracking branch 'upstream/main'
scbedd Mar 4, 2022
0aaa7b7
Merge remote-tracking branch 'upstream/main'
scbedd Mar 8, 2022
54080da
Beginning of SDK-Tools refactor (#23410)
semick-dev Mar 8, 2022
d8ab42d
stepping back from some of the MASSIVE changes. need to get tests wor…
scbedd Jul 9, 2022
b5ca950
starting to move some stuff from tox into here
semick-dev Jul 9, 2022
304ad89
additional work on refactoring how functions are required. writing do…
semick-dev Jul 10, 2022
4f63503
resolving a bunch of the errors, we're still not ready to try running…
semick-dev Jul 11, 2022
d950d01
cutting down sanitize_setup.py. updating refactor_TODO to include som…
semick-dev Jul 11, 2022
3ceb034
process for the night. still hammering on shape of the build tooling!
semick-dev Jul 11, 2022
cbaa2d2
few references updates. more notes
semick-dev Jul 11, 2022
847dc6f
beginning to add some details
semick-dev Jul 14, 2022
927fb8b
build.py now has the code to entirely build a package including setti…
semick-dev Jul 15, 2022
0fb4419
building with dev classifiers and all
semick-dev Jul 16, 2022
1880b09
versioning module is almost entirely isolated. now need to rip all th…
semick-dev Jul 16, 2022
7ea4b38
set_dev_version is working properly. need to work through the rest of…
scbedd Jul 22, 2022
9a93bc0
update version_increment and version_set to consume new ParsedSetup o…
scbedd Jul 22, 2022
9dcdeff
enable to --devbuild to not work as a flag
scbedd Jul 22, 2022
2e687a7
more updates. version_set isn't working quite correctly
scbedd Jul 22, 2022
2a5fe94
more readme updates
scbedd Jul 22, 2022
1b81931
updated remaining SIMPLE scripts within scripts/devops_tasks. pending…
scbedd Jul 23, 2022
3d87be7
refactor usage of process_glob_string and parse_setup across all 3 pr…
scbedd Jul 25, 2022
da54915
remove building of py27-specific artifacts
scbedd Jul 25, 2022
43a7f39
update get_package_properties and the installation of required toolin…
scbedd Jul 25, 2022
3381c1a
remove erroneous line of code form get_package_properties and add whe…
scbedd Jul 25, 2022
f04036c
we need the tools installation to be quiet if we want the PackageProp…
scbedd Jul 25, 2022
0d240a3
updating create_package_and_install to remove dep on removed code. up…
scbedd Jul 25, 2022
1ad59df
remove typo
scbedd Jul 27, 2022
11afc3b
resolving the weird issue with ConfigArgParse>=0.12.0 messing with th…
scbedd Jul 27, 2022
b4a94e0
resolve a few of the requirements conflicts we were hitting before.
scbedd Jul 27, 2022
aee5d31
resolve issues with verifywhl
scbedd Jul 27, 2022
b573c3c
eliminate conflict on dependency to pluggy. adding sdk_find_invalid_v…
scbedd Jul 27, 2022
62975ce
Merge remote-tracking branch 'upstream/main' into feature/tools-revamp
scbedd Jul 27, 2022
e51bf73
update all of the scripts within the eng/tox directory to remove any …
scbedd Jul 27, 2022
6a10ba7
fix call to ParsedSetup
scbedd Jul 27, 2022
3f1e412
resolve the problem in parse_setup, create_package_and_install, and t…
scbedd Jul 28, 2022
1c7504b
correct issue with create_package_and_install that was breaking doc b…
scbedd Jul 28, 2022
319ccdb
accidentally renamed an argument name in run_sphinx_apidoc
scbedd Jul 28, 2022
d700122
handling case where there is no specifier.
scbedd Jul 28, 2022
5cbcd70
add requests to build requirements for azure-sdk-tools. resolve an in…
scbedd Jul 28, 2022
8f19509
only import requests in the actual package init. requests is not requ…
scbedd Jul 28, 2022
9554560
updating requirements for azure-sdk-tools to ensure we install build …
scbedd Jul 28, 2022
bfef722
adding dependency tests
scbedd Jul 28, 2022
f29315b
unbreaking ci_tools.txt
scbedd Jul 28, 2022
946a3fb
resolving issue with Verify-Changelog
semick-dev Jul 29, 2022
be40e76
dependency tools can't be surrounded in quotes
semick-dev Jul 29, 2022
9ce6954
allow the requirement processor to handle targeted extras install
semick-dev Jul 29, 2022
e4cdabf
ensure that azure-sdk-tools is installed so that it can be used in en…
semick-dev Jul 29, 2022
13fa645
need a real relative path
scbedd Jul 29, 2022
41f8982
given that it is a script invocation. surround the target install in …
scbedd Jul 29, 2022
7a0d567
delete the refactor TODO file. it has been mostly transferred to the …
scbedd Jul 29, 2022
ff243bb
make requirements processing a native part of version_set_dev. no rea…
scbedd Jul 29, 2022
7727544
need to add azure-sdk-tools to the regression checkout
scbedd Jul 29, 2022
71d2370
resolve the targeted regression services
scbedd Jul 29, 2022
ef2e067
remove duplicate requirements from build extra for azure-sdk-tools. u…
scbedd Jul 29, 2022
0763cb9
Merge branch 'main' into build-revamp
scbedd Jul 30, 2022
d5c64fc
handling cspell errors
scbedd Aug 1, 2022
d7f812c
bring patch over from main
semick-dev Aug 4, 2022
fb5e8fc
mocking not working out
semick-dev Aug 4, 2022
2596d47
revert patching to rational method
scbedd Aug 4, 2022
2ed7e42
resolve faulty patch path. update sample. ensure test remains passing
scbedd Aug 8, 2022
4612f3b
updating language, removing indicators of progress. time to resolve l…
scbedd Aug 15, 2022
ea1248e
Merge branch 'main' into build-revamp
scbedd Aug 15, 2022
162a5b0
ensure that we handle dependent service properly within test_regression
scbedd Aug 15, 2022
3ee4eef
update the call to find_package_dependency within azure-sdk-tools
scbedd Aug 15, 2022
55faa88
pass the proper service argument when generating a regression matrix.…
scbedd Aug 15, 2022
2a640f5
repair the call when adding a sanitizer
scbedd Aug 15, 2022
98efc0f
final repare of update_regression_services.py
scbedd Aug 15, 2022
5f4afba
resolve one spelling error and update cspell ignores
scbedd Aug 16, 2022
f932838
adding additional ignore paths
scbedd Aug 16, 2022
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ coverage-*.xml
stderr.txt
stdout.txt
_proxy_log_*.log
_azci_*.log
.artifacts
.tmp_whl_dir

# tox environment folders
.tox/
Expand Down
12 changes: 11 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,17 @@
"westcentralus",
"westus",
"wfile",
"westus"
"westus",
"BUILDID",
"documentdb",
"chdir",
"reqs",
"rgpy",
"swaggertosdk",
"rgname",
"mtype",
"venvtools",
"ispkg"
],
"overrides": [
{
Expand Down
34 changes: 0 additions & 34 deletions build_package.py

This file was deleted.

9 changes: 6 additions & 3 deletions doc/eng_sys_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@

There are various tests currently enabled in Azure pipeline for Python SDK and some of them are enabled only for nightly CI checks. We also run some static analysis tool to verify code completeness, security and lint check.

Check the [contributing guide](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md#building-and-testing) for an intro to `tox`.
Check the [contributing guide](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md#building-and-testing) for an intro to `tox`. For a deeper dive into the tooling that enables the CI checks below and additional detail on reproducing builds locally please refer to the azure-sdk-tools README.md.

TODO: publish github.io
The development documentation for this repository is published at []().
scbedd marked this conversation as resolved.
Show resolved Hide resolved

As a contributor, you will see the build jobs run in two modes: `Nightly Scheduled` and `Pull Request`.

Expand All @@ -45,7 +48,7 @@ Example PR build:
* `Analyze` tox envs run during the `Analyze job.
* `Test <platform>_<pyversion>` runs PR/Nightly tox envs, depending on context.

## Targeting a specific package at build time
## Targeting a specific package in build queue time

In both `public` and `internal` projects, all builds allow a filter to be introduced at build time to narrow the set of packages build/tested.

Expand All @@ -54,7 +57,7 @@ In both `public` and `internal` projects, all builds allow a filter to be introd
1. For example, setting filter string `azure-mgmt-*` will filter a build to only management packages. A value of `azure-keyvault-secrets` will result in only building THAT specific package.
3. Once it's set, run the build!

## Skipping a tox test environment at queue time
## Skipping a tox test environment at build queue time

All build definitions allow choice at queue time as to which `tox` environments actually run during the test phase.

Expand Down
4 changes: 2 additions & 2 deletions eng/ci_tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ virtualenv==20.13.2
wheel==0.37.0
Jinja2==2.11.2
packaging==20.4
tox==3.15.0
tox==3.25.1
tox-monorepo==0.1.2
twine==3.1.1; python_version >= '3.6'
pathlib2==2.3.5
Expand Down Expand Up @@ -38,4 +38,4 @@ pytest-cov==2.8.1

# local dev packages
./tools/azure-devtools
./tools/azure-sdk-tools
./tools/azure-sdk-tools[build]
4 changes: 2 additions & 2 deletions eng/dependency_tools.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
../../../tools/azure-sdk-tools
../../../tools/azure-sdk-tools[build]
../../../tools/azure-devtools
aiohttp>=3.0; python_version >= '3.5'
aiohttp>=3.0; python_version >= '3.5'
6 changes: 3 additions & 3 deletions eng/pipelines/templates/jobs/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ jobs:
parameters:
JobTemplatePath: /eng/pipelines/templates/jobs/regression.yml
GenerateJobName: generate_regression_matrix
SparseCheckoutPaths: [ "scripts/", "sdk/" ]
SparseCheckoutPaths: [ "scripts/", "sdk/", "tools/azure-sdk-tools/" ]
MatrixConfigs:
- Name: Python_regression_envs
Path: eng/pipelines/templates/stages/regression-job-matrix.json
Selection: sparse
GenerateVMJobs: true
PreGenerationSteps:
- script: |
pip install packaging==20.4
- pwsh: |
pip install "./tools/azure-sdk-tools[build]"
displayName: 'Prep Environment'
- template: /eng/pipelines/templates/steps/targeting-string-resolve.yml
parameters:
Expand Down
8 changes: 3 additions & 5 deletions eng/pipelines/templates/stages/archetype-python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,11 @@ stages:
- checkout: self
- task: UsePythonVersion@0
- script: |
pip install -r ./eng/versioning/requirements.txt
pip install "./tools/azure-sdk-tools[build]"
displayName: Install versioning tool dependencies
- task: PythonScript@0
- pwsh: |
sdk_increment_version --package-name ${{ artifact.name }} --service ${{ parameters.ServiceDirectory }}
displayName: Increment package version
inputs:
scriptPath: 'eng/versioning/version_increment.py'
arguments: '--package-name ${{ artifact.name }} --service ${{ parameters.ServiceDirectory }}'
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml
parameters:
RepoName: azure-sdk-for-python
Expand Down
5 changes: 2 additions & 3 deletions eng/pipelines/templates/steps/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ steps:
condition: succeededOrFailed()

- script: |
cd eng/versioning
pip install -r requirements.txt
python find_invalid_versions.py --always-succeed --service=${{parameters.ServiceDirectory}}
pip install "./tools/azure-sdk-tools[build]" -q -I
sdk_find_invalid_versions --always-succeed --service=${{parameters.ServiceDirectory}}
displayName: Find Invalid Versions
condition: succeededOrFailed()

Expand Down
7 changes: 3 additions & 4 deletions eng/pipelines/templates/steps/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ steps:
workingDirectory: $(Pipeline.Workspace)
displayName: Update package properties with dev version
condition: and(succeeded(),eq(variables['SetDevVersion'],'true'))
- task: PythonScript@0

- pwsh: |
sdk_build -d "$(Build.ArtifactStagingDirectory)" "$(TargetingString)" --service=${{parameters.ServiceDirectory}}
displayName: 'Generate Packages'
inputs:
scriptPath: 'scripts/devops_tasks/build_packages.py'
arguments: '-d "$(Build.ArtifactStagingDirectory)" "$(TargetingString)" --service=${{parameters.ServiceDirectory}} --devbuild="$(SetDevVersion)"'

- script: |
twine check $(Build.ArtifactStagingDirectory)/**/*.whl
Expand Down
8 changes: 3 additions & 5 deletions eng/pipelines/templates/steps/set-dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ steps:
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}

- task: PythonScript@0
condition: and(succeededOrFailed(), eq(variables['SetDevVersion'],'true'))
- pwsh: |
pip install "tools/azure-sdk-tools[build]"
sdk_set_dev_version "$(TargetingString)" --service="${{parameters.ServiceDirectory}}" --build-id="$(Build.BuildNumber)"
displayName: "Update package versions for dev build"
inputs:
scriptPath: 'eng/versioning/version_set_dev.py'
arguments: '"$(TargetingString)" --service="${{parameters.ServiceDirectory}}" --build-id="$(Build.BuildNumber)"'
2 changes: 1 addition & 1 deletion eng/regression_tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ virtualenv==20.0.23
wheel==0.34.2
Jinja2==2.11.2
packaging==20.4
tox==3.15.0
tox==3.25.1
tox-monorepo==0.1.2
twine==1.15.0; python_version == '2.7' or python_version == '3.5'
twine==3.1.1; python_version >= '3.6'
Expand Down
6 changes: 3 additions & 3 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Get-AllPackageInfoFromRepo ($serviceDirectory)
try
{
Push-Location $RepoRoot
pip install packaging==20.4 setuptools==44.1.1 -q -I
pip install "./tools/azure-sdk-tools[build]" -q -I
$allPkgPropLines = python (Join-path eng scripts get_package_properties.py) -s $searchPath
}
catch
Expand Down Expand Up @@ -523,8 +523,8 @@ function SetPackageVersion ($PackageName, $Version, $ServiceDirectory, $ReleaseD
{
$ReleaseDate = Get-Date -Format "yyyy-MM-dd"
}
pip install -r "$EngDir/versioning/requirements.txt" -q -I
python "$EngDir/versioning/version_set.py" --package-name $PackageName --new-version $Version `
pip install "$RepoRoot/tools/azure-sdk-tools[build]" -q -I
sdk_set_version --package-name $PackageName --new-version $Version `
--service $ServiceDirectory --release-date $ReleaseDate --replace-latest-entry-title $ReplaceLatestEntryTitle
}

Expand Down
19 changes: 11 additions & 8 deletions eng/scripts/get_package_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@
import os
import re

sys.path.append(os.path.join('scripts', 'devops_tasks'))
from common_tasks import get_package_properties
from ci_tools.parsing import ParsedSetup

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Get package version details from the repo')
parser.add_argument('-s', '--search_path', required=True, help='The scope of the search')
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Get package version details from the repo")
parser.add_argument("-s", "--search_path", required=True, help="The scope of the search")
args = parser.parse_args()

# Use abspath for the os.walk because if setup parsing fails it often changes cwd which throws off the relative walk
for root, dirs, files in os.walk(os.path.abspath(args.search_path)):
if re.search(r"sdk[\\/][^\\/]+[\\/][^\\/]+$", root):
if "setup.py" in files:
try:
pkgName, version, is_new_sdk, setup_py_path = get_package_properties(root)
print("{0} {1} {2} {3}".format(pkgName, version, is_new_sdk, setup_py_path))
parsed = ParsedSetup.from_path(root)
print(
"{0} {1} {2} {3}".format(
parsed.name, parsed.version, parsed.is_new_sdk, os.path.dirname(parsed.setup_filename)
)
)
except:
# Skip setup.py if the package cannot be parsed
pass
pass
50 changes: 17 additions & 33 deletions eng/tox/create_package_and_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
import sys
import glob
import shutil
import pdb
from pkg_resources import parse_version

from tox_helper_tasks import find_whl, find_sdist, get_package_details, get_pip_list_output, parse_req
from tox_helper_tasks import find_whl, find_sdist, get_pip_list_output
from ci_tools.parsing import ParsedSetup, parse_require
from ci_tools.build import create_package

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

setup_parser_path = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "versioning"))
sys.path.append(setup_parser_path)
from setup_parser import get_install_requires

from ci_tools.parsing import ParsedSetup

def cleanup_build_artifacts(build_folder):
# clean up egginfo
Expand Down Expand Up @@ -57,16 +57,16 @@ def discover_packages(setuppy_path, args):

def discover_prebuilt_package(dist_directory, setuppy_path, package_type):
packages = []
pkg_name, _, version, _, _ = get_package_details(setuppy_path)
pkg = ParsedSetup.from_path(setuppy_path)
if package_type == "wheel":
prebuilt_package = find_whl(dist_directory, pkg_name, version)
prebuilt_package = find_whl(dist_directory, pkg.name, pkg.version)
else:
prebuilt_package = find_sdist(dist_directory, pkg_name, version)
prebuilt_package = find_sdist(dist_directory, pkg.name, pkg.version)

if prebuilt_package is None:
logging.error(
"Package is missing in prebuilt directory {0} for package {1} and version {2}".format(
dist_directory, pkg_name, version
dist_directory, pkg.name, pkg.version
)
)
exit(1)
Expand All @@ -80,29 +80,9 @@ def in_ci():

def build_and_discover_package(setuppy_path, dist_dir, target_setup, package_type):
if package_type == "wheel":
check_call(
[
sys.executable,
setuppy_path,
"bdist_wheel",
"-d",
dist_dir,
],
cwd = os.path.dirname(setuppy_path)
)
create_package(setuppy_path, dist_dir, enable_sdist=False)
else:
check_call(
[
sys.executable,
setuppy_path,
"sdist",
"--format",
"zip",
"-d",
dist_dir,
],
cwd = os.path.dirname(setuppy_path)
)
create_package(setuppy_path, dist_dir, enable_wheel=False)

prebuilt_packages = [
f for f in os.listdir(args.distribution_directory) if f.endswith(".whl" if package_type == "wheel" else ".zip")
Expand Down Expand Up @@ -217,7 +197,7 @@ def build_and_discover_package(setuppy_path, dist_dir, target_setup, package_typ
logging.info("Installing {w} from fresh built package.".format(w=built_package))

if not args.pre_download_disabled:
requirements = get_install_requires(os.path.join(os.path.abspath(args.target_setup), "setup.py"))
requirements = ParsedSetup.from_path(os.path.join(os.path.abspath(args.target_setup), "setup.py")).requires
azure_requirements = [req.split(";")[0] for req in requirements if req.startswith("azure")]

if azure_requirements:
Expand Down Expand Up @@ -245,10 +225,14 @@ def build_and_discover_package(setuppy_path, dist_dir, target_setup, package_typ
installed_pkgs = get_pip_list_output()

# parse the specifier
req_name, req_specifier = parse_req(req)
req_name, req_specifier = parse_require(req)

# if we have the package already present...
if req_name in installed_pkgs:
# if there is no specifier for the requirement, we can ignore it
if req_specifier is None:
addition_necessary = False

# ...do we need to install the new version? if the existing specifier matches, we're fine
if installed_pkgs[req_name] in req_specifier:
addition_necessary = False
Expand Down
15 changes: 8 additions & 7 deletions eng/tox/import_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import argparse
import logging
import os
from tox_helper_tasks import get_package_details
from subprocess import check_call

from ci_tools.parsing import ParsedSetup

logging.getLogger().setLevel(logging.INFO)
root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))

Expand Down Expand Up @@ -41,16 +42,16 @@ def should_run_import_all(package_name):

# get target package name from target package path
pkg_dir = os.path.abspath(args.target_package)
package_name, namespace, _, _, _ = get_package_details(os.path.join(pkg_dir, 'setup.py'))

if should_run_import_all(package_name):
pkg_details = ParsedSetup.from_path(pkg_dir)
if should_run_import_all(pkg_details.name):
# import all modules from current package
logging.info(
"Importing all modules from namespace [{0}] to verify dependency".format(
namespace
pkg_details.namespace
)
)
import_script_all = "from {0} import *".format(namespace)
import_script_all = "from {0} import *".format(pkg_details.namespace)
commands = [
sys.executable,
"-c",
Expand All @@ -61,4 +62,4 @@ def should_run_import_all(package_name):
logging.info("Verified module dependency, no issues found")
else:
pass
logging.error("Package {} is excluded from dependency check".format(package_name))
logging.error("Package {} is excluded from dependency check".format(pkg_details.name))
Loading