Skip to content
Merged
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
73 changes: 73 additions & 0 deletions eng/tools/dependency-testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## Min-max dependency testing:

When a library has dependencies with semantic version or semver ranges, how do you ensure and validate that your library actually supports the version ranges you claim? For instance, if we have @azure/keyvault-keys that supports 1.0.0 to 1.0.4 version ranges of @azure/core-http, how would you ensure that this library is actually compatible with all versions of core-http from 1.0.0 to 1.0.4 ( 1.0.0 , 1.0.1, 1.0.2, 1.0.3 and 1.0.4)? One solution is to test the library against each version of the dependency that you claim to support.

But as we keep releasing newer versions, the list of versions that we want to test will keep increasing. Given this, the testing of the entire version range for all dependencies may not always be feasible and we want to find an optimum scalable solution for the dependency testing in this scenario. One approach to this is “min-max” testing, or testing the library against the minimum version of dependency version range and against the maximum version of the dependency version range.

To read in-depth design decisions made during the min-max dependency testing and what it does, read [the blog post](https://devblogs.microsoft.com/azure-sdk/testing-semver-dependency-ranges/).

### Running dependency tests

The minimum and maximum semver dependency testing for Azure SDK packages runs every night along with the nightly live test pipelines.
In order to run the minimum and maximum semver dependency testing **locally on your machine, you can follow these steps:**
Comment thread
beltr0n marked this conversation as resolved.

### Setup your local dev environment to simulate min/max testing

1. Go to the repo root (e.g. `C:\repos\azure-sdk-for-js`) and run rush update and build package along with all its dependencies.

```
rush update
rush build -t "package-name" --verbose
```

For example:

```
rush build -t "@azure/communication-sms" --verbose
```

2. Install the dependency-testing package dependencies:

```
cd eng\tools\dependency-testing

npm install
```

3. Run the dependency-testing script

```
node index.js --artifact-name "package-name" --version-type "{min | max}" --source-dir "path_to_js_repo" --test-folder "test/public"
```

For example,

```
node index.js --artifact-name "@azure/communication-sms" --version-type "min" --source-dir "C:\repos\azure-sdk-for-js\" --test-folder "test/public"
```

(Note: You may not need to do `npm install` every time you are testing, only once should be enough).

4. Go back to the repo root (e.g. `C:\repos\azure-sdk-for-js`) and run `rush update`
5. Go to your package's `test\public` folder and run these steps from inside it:

```
cd sdk/communication/communication-sms/test/public
rushx build
rushx integration-test:node
```

### Restore your local dev environment

1. Go to your package's `test\public` folder
2. Revert the modified test files: run `git checkout -- .`
3. Delete the uncommitted files added to the test folder: (package.json, tsconfig.json etc.)
4. Delete the `node_modules` folder under the package's `test\public` folder
5. Run the fowing steps from the root of the repo (e.g. `C:\repos\azure-sdk-for-js`)

```
rush update
rush rebuild
```

Note : If the above step fails, you can reset the repo: `git clean -f -x -d` (Warning: this will delete all unversioned files including those ignored by gitignore. Backup any .env files and push any commits you wanted to etc)