Skip to content

Commit fbdf6f4

Browse files
authored
Resolve Installation Ordering during dev build (Azure#21025)
* resolve installation failures during regression checks. * clean up eng_sys_checks.md. removing a bunch of formatting issues, adding additional detail. * during nightly alpha, force install from dev feed to ensure we're testing what we expect
1 parent 808b31a commit fbdf6f4

File tree

7 files changed

+220
-174
lines changed

7 files changed

+220
-174
lines changed

doc/eng_sys_checks.md

Lines changed: 73 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ Example PR build:
1919

2020
![res/job_snippet.png](res/job_snippet.png)
2121

22-
- `Analyze` tox envs run during the `Analyze job.
23-
- `Test <platform>_<pyversion>` runs PR/Nightly tox envs, depending on context.
24-
22+
* `Analyze` tox envs run during the `Analyze job.
23+
* `Test <platform>_<pyversion>` runs PR/Nightly tox envs, depending on context.
2524

2625
## Targeting a specific package at build time
2726

@@ -47,48 +46,59 @@ This is an example setting of that narrows the default set from `whl, sdist, dep
4746

4847
Any combination of valid valid tox environments will work. Reference either this document or the file present at `eng/tox/tox.ini` to find what options are available.
4948

49+
## Environment variables important to CI
50+
51+
There are a few differences from a standard local invocation of `tox <env>`. Primarily, these differences adjust the checks to be friendly to parallel invocation. These adjustments are necessary to prevent random CI crashes.
52+
53+
| Environment Variable | Affect on Build |
54+
|---|---|
55+
| `TF_BUILD` | EngSys uses the presence of any value in this variable as the bit indicating "in CI" or not. The primary effect of this is that all relative dev dependencies will be prebuilt prior to running the tox environments. |
56+
| `PREBUILT_WHEEL_DIR` | Setting this env variables means that instead of generating a fresh wheel or sdist to test, `tox` will look in this directory for the targeted package. |
57+
| `PIP_INDEX_URL` | Standard `pip` environment variable. During nightly `alpha` builds, this environment variable is set to a public dev feed. |
58+
59+
The various tooling abstracted by the environments within `eng/tox/tox.ini` take the above variables into account automatically.
60+
5061
## Analyze Checks
62+
5163
Analyze job in both nightly CI and pull request validation pipeline runs a set of static analysis using external and internal tools. Following are the list of these static analysis.
5264

53-
#### MyPy
65+
### MyPy
66+
5467
[`MyPy`](https://pypi.org/project/mypy/) is a static analysis tool that runs type checking of python package. MyPy is an opt-in check for packages. Following are the steps to run `MyPy` locally for a specific package:
5568

5669
1. Add the package name to the end of the [`mypy_hard_failure_packages.py`](https://github.com/Azure/azure-sdk-for-python/blob/main/eng/tox/mypy_hard_failure_packages.py) file:
57-
```python
58-
MYPY_HARD_FAILURE_OPTED = [
59-
...,
60-
"azure-my-package",
61-
]
62-
```
63-
1. Go to root of the package
64-
2. Execute following command:
65-
```tox -e mypy -c ../../../eng/tox/tox.ini ```
70+
```python
71+
MYPY_HARD_FAILURE_OPTED = [
72+
...,
73+
"azure-my-package",
74+
]
75+
```
76+
2. Go to root of the package
77+
3. Execute following command: `tox -e mypy -c ../../../eng/tox/tox.ini`
6678

79+
### Pylint
6780

68-
#### Pylint
6981
[`Pylint`](https://pypi.org/project/pylint/) is a static analysis tool to run lint checking, it is automatically run on all PRs. Following are the steps to run `pylint` locally for a specific package.
7082

7183
1. Go to root of the package.
72-
2. Execute following command:
73-
```tox -e pylint -c ../../../eng/tox/tox.ini```
84+
2. Execute following command: `tox -e pylint -c ../../../eng/tox/tox.ini`
7485

86+
### Bandit
7587

76-
#### Bandit
7788
`Bandit` is static security analysis tool. This check is triggered for all Azure SDK package as part of analyze job. Following are the steps to `Bandit` tool locally for a specific package.
7889

7990
1. Got to package root directory.
80-
2. Execute following command
81-
```tox -e bandit -c ../../../eng/tox/tox.ini```
91+
2. Execute command: `tox -e bandit -c ../../../eng/tox/tox.ini`
8292

93+
### ApiStubGen
8394

84-
#### ApiStubGen
8595
`ApiStubGen` is an internal tool used to create API stub to help reviewing public APIs in our SDK package using [`APIViewTool`.](https://apiview.dev/) This tool also has some built in lint checks available and purpose of having this step in analyze job is to ensure any change in code is not impacting stubbing process and also to have more and more custom lint checks added in future.
8696

87-
#### black
97+
### black
8898

8999
[black](https://pypi.org/project/black) is an opinionated code formatter for Python source code.
90100

91-
#### Opt-in
101+
#### Opt-in to formatting validation
92102

93103
Make the following change to your projects `ci.yml`:
94104

@@ -102,19 +112,21 @@ extends:
102112
```
103113

104114
#### Running locally
115+
105116
To run locally first install `black` from pip if you do not have it already (the pipeline uses version 21.6b0). Currently, we use the `-l 120` option to allow lines up to 120 characters (consistent with our `pylint` check).
117+
106118
```bash
107119
python -m pip install black==21.6b0
108120
python -m black -l 120 <path/to/service_directory>
109121
```
110122

111-
#### Change log verification
123+
### Change log verification
112124

113125
Change log verification is added to ensure package has valid change log for current version. Guidelines to properly maintain the change log is documented [here](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/)
114126

115127
## PR Validation Checks
116-
Each pull request runs various tests using `pytest` in addition to all the tests mentioned above in analyze check. Pull request validation performs 3 different types of test: `whl, sdist and depends`. The following section explains the purpose of each of these tests and how to execute them locally. All pull requests are validated on multiple python versions across different platforms. Find the test matrix below.
117128

129+
Each pull request runs various tests using `pytest` in addition to all the tests mentioned above in analyze check. Pull request validation performs 3 different types of test: `whl, sdist and depends`. The following section explains the purpose of each of these tests and how to execute them locally. All pull requests are validated on multiple python versions across different platforms. Find the test matrix below.
118130

119131
|`Python Version`|`Platform` |
120132
|--|--|
@@ -123,22 +135,27 @@ Each pull request runs various tests using `pytest` in addition to all the tests
123135
|3.8|Linux|
124136

125137
### PR validation tox test environments
138+
126139
Tests are executed using tox environment and following are the tox test names that are part of pull request validation
140+
127141
#### whl
142+
128143
This test installs wheel of the package being tested and runs all tests cases in the package using `pytest`. Following is the command to run this test environment locally.
129144

130145
1. Go to package root folder on a command line
131146
2. Run following command
132147
``tox -e whl -c ../../../eng/tox/tox.ini``
133148

134149
#### sdist
150+
135151
This test installs sdist of the package being tested and runs all tests cases in the package using `pytest`. Following is the command to run this test environment locally.
136152

137153
1. Go to package root folder on a command line
138154
2. Run following command
139155
``tox -e sdist -c ../../../eng/tox/tox.ini``
140156

141157
#### depends
158+
142159
The `depends` check ensures all modules in a target package can be successfully imported. Actually installing and importing will verify that all package requirements are properly set in setup.py and that the `__all__` set for the package is properly defined. This test installs the package and its required packages, then executes `from <package-root-namespace> import *`. For example from `azure-core`, the following would be invoked: `from azure.core import *`.
143160

144161
Following is the command to run this test environment locally.
@@ -147,7 +164,6 @@ Following is the command to run this test environment locally.
147164
2. Run following command
148165
``tox -e sdist -c ../../../eng/tox/tox.ini``
149166

150-
151167
## Nightly CI Checks
152168

153169
Nightly continuous integration checks run all tests mentioned above in Analyze and Pull request checks in addition to multiple other tests. Nightly CI checks run on all python versions that are supported by Azure SDK packages across multiple platforms.
@@ -167,8 +183,7 @@ As a developer of package `XYZ`, we need to ensure that our package works fine w
167183

168184
Another scenario where regression test( reverse dependency) is required. Let's take same example above and assume we are developers of package `ABC` which is taken as required package by another package `XYZ`
169185

170-
Package `ABC is required by package `XYZ`
171-
186+
Package `ABC` is required by package `XYZ`
172187

173188
As a developer of `ABC`, we need to ensure that any new change in `ABC` is not breaking the use of `XYZ` and hence ensures backward compatibility.
174189

@@ -185,35 +200,34 @@ Following are the additional tests we run during nightly CI checks.
185200

186201
This test makes sure that a package being developed works absolutely fine using latest released version of required Azure SDK package as long as there is a released version which satisfies the requirement specification. Workflow of this test is as follows:
187202

188-
1. Identify if any azure SDK package is marked as required package in setup.py of current package being tested.
203+
1. Identify if any azure SDK package is marked as required package in setup.py of current package being tested.
189204
Note: Any dependency mentioned only in dev_requirements are not considered to identify dependency.
190-
2. Identify latest released version of required azure sdk package on PyPI
191-
3. Install latest released version of required package instead of dev dependency to package in code repo
192-
4. Install current package that is being tested
193-
5. Run pytest of all test cases in current package
205+
2. Identify latest released version of required azure sdk package on PyPI
206+
3. Install latest released version of required package instead of dev dependency to package in code repo
207+
4. Install current package that is being tested
208+
5. Run pytest of all test cases in current package
194209

195210
Tox name of this test is `latestdependency` and steps to manually run this test locally is as follows.
196-
1. Go to package root. For e.g azure-storage-blob or azure-identity
197-
2. Run following command
198-
`Tox –e latestdependency –c ../../../tox/tox.ini`
199211

212+
1. Go to package root. For e.g azure-storage-blob or azure-identity
213+
2. Run command `Tox –e latestdependency –c ../../../tox/tox.ini`
200214

201215
#### Minimum Dependency Test
202216

203217
This test makes sure that a package being developed works absolutely fine using oldest released version of required Azure SDK package as long as there is a released version which satisfies the requirement specification. Workflow of this test is as follows:
204218

205-
1. Identify if any azure SDK package is marked as required package in setup.py of current package being tested.
219+
1. Identify if any azure SDK package is marked as required package in setup.py of current package being tested.
206220
Note: Any dependency mentioned only in dev_requirements are not considered to identify dependency.
207-
2. Identify oldest released version of required azure sdk package on PyPI
208-
3. Install oldest released version of required package instead of dev dependency to package in code repo
209-
4. Install current package that is being tested
210-
5. Run pytest of all test cases in current package
221+
2. Identify oldest released version of required azure sdk package on PyPI
222+
3. Install oldest released version of required package instead of dev dependency to package in code repo
223+
4. Install current package that is being tested
224+
5. Run pytest of all test cases in current package
211225

212226
Tox name of this test is `mindependency` and steps to manually run this test locally is as follows.
213-
1. Go to package root. For e.g azure-storage-blob or azure-identity
214-
2. Run following command
215-
`Tox –e mindependency –c ../../../tox/tox.ini`
216227

228+
1. Go to package root. For e.g azure-storage-blob or azure-identity
229+
2. Run following command
230+
`Tox –e mindependency –c ../../../tox/tox.ini`
217231

218232
#### Regression Test
219233

@@ -233,37 +247,32 @@ One main difference between regression tests and forward dependency test( latest
233247
Let's assume that we are testing regression for azure-core and this test is for regression against latest released dependent packages. Test will identify all packages that takes azure-core as required package and finds latest released version of those packages. Test framework install currently being developed azure-core and latest released dependent package and runs the test cases in dependent package, for e.g. azure-identity, that were part of repo at the time of releasing depending package.
234248

235249
Workflow of this test is as follows when running regression for an SDK package.
236-
1. Identify any packages that takes currently being tested package as required package
237-
2. Find latest and oldest released versions of dependent package from PyPI
238-
3. Install currently being developed version of package we are testing regression for. E.g. azure-core
239-
4. Checkout the release tag of dependent package from github
240-
5. Install latest/oldest version of dependent package. For e.g. azure-identity
241-
6. Run test cases within dependent package from checked out branch.
242250

251+
1. Identify any packages that takes currently being tested package as required package
252+
2. Find latest and oldest released versions of dependent package from PyPI
253+
3. Install currently being developed version of package we are testing regression for. E.g. azure-core
254+
4. Checkout the release tag of dependent package from github
255+
5. Install latest/oldest version of dependent package. For e.g. azure-identity
256+
6. Run test cases within dependent package from checked out branch.
243257

244258
Steps to manually run regression test locally:
245-
1. Run below command from your git code repo to generate the wheel of package being developed. Currently we have restricted to have prebuilt wheel.
259+
260+
1. Run below command from your git code repo to generate the wheel of package being developed. Currently we have restricted to have prebuilt wheel.
246261
`./scripts/devops_tasks/build_packages.py --service= <service-name> -d <out-folder>`
247-
2. Run below command to start regression test locally
262+
2. Run below command to start regression test locally
248263
`./scripts/devops_tasks/test_regression.py azure-* --service=<service-name> --whl-dir=<out-folder given above in step 2>`
249264

265+
The following variables can be set at queueing time in order to run these additional tests. By default regression tests execute only on scheduled runs.
250266

251-
How to run these additional tests on azure pipelines manually
252-
253-
Following variables can be set at queueing time in order to run these additional tests which are by default run only for scheduled runs.
254-
255-
• Latest and oldest dependency test in addition to basic testing
256-
Variable name: `Run.DependencyTest`
257-
Value: true
258-
259-
• Regression test
267+
Regression test
260268
Variable name: `Run.Regression`
261269
Value: true
262270

263271
#### Autorest Automation
272+
264273
This check will automatically create PRs with updated generated code whenever autorest has made an update that results in a change to the generated code for a package.
265274

266-
##### Opt-in
275+
##### Opt-in to autorest automation
267276

268277
Make the following change to your projects `ci.yml`:
269278

@@ -279,6 +288,7 @@ extends:
279288
##### Running locally
280289

281290
To run autorest automation locally run the following command from the home of `azure-sdk-for-python`
291+
282292
```bash
283293
azure-sdk-for-python> python scripts/devop_tasks/verify_autorest.py --service_directory <your_service_directory>
284294
```
@@ -287,9 +297,10 @@ azure-sdk-for-python> python scripts/devop_tasks/verify_autorest.py --service_di
287297

288298
There are additional checks that run in live tests.
289299

290-
#### Running Samples
300+
### Running Samples
291301

292302
Samples for a library can be run as part of the nightly checks. To opt-in to the check edit the `tests.yml` file to look like:
303+
293304
```yml
294305
stages:
295306
- template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml

eng/pipelines/templates/steps/set-dev-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ steps:
1212
displayName: "Update package versions for dev build"
1313
inputs:
1414
scriptPath: 'eng/versioning/version_set_dev.py'
15-
arguments: '"${{ parameters.BuildTargetingString }}" --service="${{parameters.ServiceDirectory}}" --build-id="$(Build.BuildNumber)"'
15+
arguments: '"${{ parameters.BuildTargetingString }}" --service="${{parameters.ServiceDirectory}}" --build-id="$(Build.BuildNumber)"'

0 commit comments

Comments
 (0)