-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP * Updated some Nett reference -> Toml * More changes for Nett to Tomlyn * Changing ref back to Nett since project_assets_2_2 is only used in tests * Updated Data attributes and removed unnecessary comments * Updated Data attributes in PoetryLock file * Made property type more specific * Formatting fixes * Made updates to add or ignore rproperties used in Toml Deserialization * Added documentation for running verification tests Co-authored-by: Jamie Magee <[email protected]>
- Loading branch information
1 parent
7d5668e
commit 65463b4
Showing
11 changed files
with
167 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Running Verification Tests On Your Local Machine | ||
Verification tests are used to confirm that no detectors are lost when changes are made to the project. The tests are run on every PR build. They work by comparing the detection results from the main branch to detection results from the new changes on your PR. You can follow the steps below to run them locally. | ||
|
||
## Step 1 : Run Detection on the main branch | ||
|
||
- Checkout the main branch in your local repo | ||
- Create a folder to store detection results (e.g C:\old-output-folder) | ||
- Use command line to run detection on the main branch with the code below: | ||
|
||
```dotnet run scan --Verbosity Verbose --SourceDirectory {path to your local repo} --Output {path to the output folder you created}``` | ||
|
||
For Example: | ||
|
||
```dotnet run scan --Verbosity Verbose --SourceDirectory C:\componentdetection --Output C:\old-output-folder``` | ||
|
||
|
||
## Step 2 : Run Detection on your new branch | ||
|
||
- Checkout the branch with the new changes you are trying to merge | ||
- Create a folder to store detection results. This folder should be seperate from the one you used in Step 1 (e.g C:\new-output-folder) | ||
- Use command line to run detection on the main branch with the code below: | ||
|
||
```dotnet run scan --Verbosity Verbose --SourceDirectory {path to your local repo} --Output {path to the output folder you created}``` | ||
|
||
For Example: | ||
|
||
```dotnet run scan --Verbosity Verbose --SourceDirectory C:\componentdetection --Output C:\new-output-folder``` | ||
|
||
## Step 3 : Update variables in the test | ||
|
||
- Open the Microsoft.ComponentDetection.VerificationTests project in VS Studio | ||
- Navigate to `GatherResources()` in `ComponentDetectionIntegrationTests.cs` | ||
- Update the following variables: | ||
- `oldGithubArtifactsDir` : This should be the output folder you created in Step 1 | ||
- `newGithubArtifactsDir` : This should be the output folder you created in Step 2 | ||
- `allowedTimeDriftRatioString`: This should be ".75" | ||
|
||
|
||
## Step 4: Run The tests | ||
You can run the tests in two ways: | ||
- Run or Debug the tests in test explorer. | ||
- Use the command line to navigate to the Microsoft.ComponentDetection.VerificationTests folder, and run `dotnet test`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
src/Microsoft.ComponentDetection.Detectors/poetry/Contracts/PoetryLock.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Microsoft.ComponentDetection.Detectors.Poetry.Contracts | ||
{ | ||
// Represents Poetry.Lock file structure. | ||
[DataContract] | ||
public class PoetryLock | ||
{ | ||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
public PoetryPackage[] package { get; set; } | ||
[DataMember(Name = "Package")] | ||
public List<PoetryPackage> Package { get; set; } | ||
|
||
[DataMember(Name = "metadata")] | ||
public Dictionary<string, object> Metadata { get; set; } | ||
} | ||
} |
26 changes: 17 additions & 9 deletions
26
src/Microsoft.ComponentDetection.Detectors/poetry/Contracts/PoetryPackage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Microsoft.ComponentDetection.Detectors.Poetry.Contracts | ||
{ | ||
[DataContract] | ||
public class PoetryPackage | ||
{ | ||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
public string category { get; set; } | ||
[DataMember(Name = "category")] | ||
public string Category { get; set; } | ||
|
||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
public string name { get; set; } | ||
[DataMember(Name = "name")] | ||
public string Name { get; set; } | ||
|
||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
public string version { get; set; } | ||
[DataMember(Name = "version")] | ||
public string Version { get; set; } | ||
|
||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
public PoetrySource source { get; set; } | ||
[DataMember(Name = "source")] | ||
public PoetrySource Source { get; set; } | ||
|
||
[DataMember(Name = "dependencies")] | ||
public Dictionary<string, object> Dependencies { get; set; } | ||
|
||
[DataMember(Name = "extras")] | ||
public Dictionary<string, object> Extras { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 10 additions & 6 deletions
16
src/Microsoft.ComponentDetection.Detectors/rust/Contracts/CargoLock.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Nett; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Microsoft.ComponentDetection.Detectors.Rust.Contracts | ||
{ | ||
using System.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
using Tomlyn.Model; | ||
|
||
// Represents Cargo.Lock file structure. | ||
[DataContract] | ||
public class CargoLock | ||
{ | ||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
public CargoPackage[] package { get; set; } | ||
[DataMember(Name = "package")] | ||
public List<CargoPackage> Package { get; set; } | ||
|
||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Deserialization contract. Casing cannot be overwritten.")] | ||
public TomlTable metadata { get; set; } | ||
[DataMember(Name = "metadata")] | ||
public Dictionary<string, object> Metadata { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.