Skip to content

Commit

Permalink
VCI-40: Update docs for vc-build (VirtoCommerce#2271)
Browse files Browse the repository at this point in the history
* VCI-40: Update docs

* VCI-40: Update changelog

* VCI-40: Add additional example for  install target
  • Loading branch information
krankenbro authored May 26, 2021
1 parent 1eb82b1 commit 0d7de24
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 38 deletions.
53 changes: 26 additions & 27 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.Git;
using Nuke.Common.Tools.Npm;
using Nuke.Common.Tools.NuGet;
using Nuke.Common.Utilities;
using Nuke.Common.Utilities.Collections;
using VirtoCommerce.Platform.Core.Common;
Expand Down Expand Up @@ -248,37 +249,35 @@ void SonarLogger(OutputType type, string text)
.Executes(() =>
{
var dotnetPath = ToolPathResolver.GetPathExecutable("dotnet");
var testProjects = Solution.GetProjects("*.Tests|*.Testing");
//
var testProjects = Solution.GetProjects("*.Test|*.Tests|*.Testing");
var OutPath = RootDirectory / ".tmp";
testProjects.ForEach((testProject, index) =>
{
DotNetTasks.DotNet($"add {testProject.Path} package coverlet.collector");
var testSetting = new DotNetTestSettings()
.SetProjectFile(testProject.Path)
.SetConfiguration(Configuration)
.SetLogger("trx")
.SetFilter(TestsFilter)
.SetNoBuild(true)
.SetCollectCoverage(true)
.SetProcessLogOutput(true)
.SetResultsDirectory(OutPath);
var testProjectBinDir = testProject.Directory / "bin";
var testAssemblies = testProjectBinDir.GlobFiles($"**/{testProject.Name}.dll");
if(testAssemblies.Count < 1)
{
ControlFlow.Fail("Tests Assemblies not found!");
}

CoverletTasks.Coverlet(s => s
.SetTargetSettings(testSetting)
.SetAssembly(testAssemblies.First())
.SetTarget(dotnetPath)
.When(index == 0, ss => ss.SetOutput(CoverageReportPath))
.When(index > 0 && index < testProjects.Count() - 1, ss => ss.SetMergeWith(CoverageReportPath))
.When(index == testProjects.Count() - 1, ss => ss.SetOutput(CoverageReportPath).SetMergeWith(CoverageReportPath).SetFormat(CoverletOutputFormat.opencover))
);

.SetProjectFile(testProject.Path)
.SetConfiguration(Configuration)
.SetFilter(TestsFilter)
.SetNoBuild(true)
.SetProcessLogOutput(true)
.SetResultsDirectory(OutPath)
.SetDataCollector("XPlat Code Coverage");
DotNetTasks.DotNetTest(testSetting);
});
var coberturaReports = OutPath.GlobFiles("**/coverage.cobertura.xml");
if (coberturaReports.Count > 0)
{
var reportGenerator = ToolResolver.GetPackageTool("dotnet-reportgenerator-globaltool", "ReportGenerator.dll", "4.8.8", "netcoreapp3.0");
reportGenerator.Invoke($"-reports:{OutPath / "**/coverage.cobertura.xml"} -targetdir:{OutPath} -reporttypes:SonarQube");
var sonarCoverageReportPath = OutPath.GlobFiles("SonarQube.xml").FirstOrDefault();
if (sonarCoverageReportPath == null)
ControlFlow.Fail("No Coverage Report found");
FileSystemTasks.MoveFile(sonarCoverageReportPath, CoverageReportPath);
}
else
{
Logger.Warn("No Coverage Reports found");
}
});

public void CustomDotnetLogger(OutputType type, string text)
Expand Down Expand Up @@ -790,7 +789,7 @@ private async Task<string> SendSwaggerSchemaToValidator(HttpClient httpClient, s
var projectVersionParam = $"/v:\"{ReleaseVersion}\"";
var hostParam = $"/d:sonar.host.url={SonarUrl}";
var tokenParam = $"/d:sonar.login={SonarAuthToken}";
var sonarReportPathParam = $"/d:sonar.cs.opencover.reportsPaths={CoverageReportPath}";
var sonarReportPathParam = FileSystemTasks.FileExists(CoverageReportPath) ? $"/d:sonar.coverageReportPaths={CoverageReportPath}" : string.Empty;
var orgParam = $"/o:{SonarOrg}";

var startCmd = $"sonarscanner begin {orgParam} {branchParam} {branchTargetParam} {projectKeyParam} {projectNameParam} {projectVersionParam} {hostParam} {tokenParam} {sonarReportPathParam} {prBaseParam} {prBranchParam} {prKeyParam} {ghRepoArg} {prProviderArg}";
Expand Down
8 changes: 8 additions & 0 deletions build/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.7.3] - 2021-05-26
### Changed
- Updated help
- Extended install target
- Removed coverlet.console dependency
### Fixed
- Coverage report generation method

## [1.7.0] - 2021-04-21
### Added
- Targets: Init, Install, InstallPlatform, InstallModules, Uninstall
Expand Down
2 changes: 1 addition & 1 deletion build/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Copyright>Copyright © VirtoCommerce 2011-2020</Copyright>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.7.2</VersionPrefix>
<VersionPrefix>1.7.3</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>

Expand Down
24 changes: 18 additions & 6 deletions build/Docs/Targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ vc-build Init -PlatformVersion 3.52.0
:::
:::
## Install
Gets the -Module parameter, which is an array of module ids, and updates vc-package.json.
Also module id can be supplemented with the version number.
Discovery and Probing directories can be overrided via -DiscoveryPath and -ProbingPath
This command downloads and install into the current folder the platform or modules with versions that are passed as the command parameters or defined in vc-package.json.

vc-package.json - file is used to maintain the list of installed modules with their versions. This allows vc-build to easily restore the platform with the modules when on a different machine, such as a build server, without all those packages.

vc-build install (with no args)
This target downloads and install into the current folder the platform and modules with versions described in vc-package.json. If vc-package.json is not found in the local folder, by default the command will download and install the latest platform and modules versions that are marked with the commerce group.

By default, install target will install all modules listed as dependencies in vc-package.json.
Path to vc-package.json, discovery and probing paths can be overridden with PackageManifestPath, DiscoveryPath, ProbingPath parameters. Also we can skip dependency solving with SkipDependencySolving parameter.
Examples:
```console
vc-build install -Module VirtoCommerce.Cart VirtoCommerce.Catalog
vc-build install -Module VirtoCommerce.Cart VirtoCommerce.Catalog:3.38.0
vc-build install (with no args)
vc-build install -platform -version <version>
vc-build install -module <module> -version <version>
vc-build install -module <module>:<version>
vc-build install -PackageManifestPath some_directory/vc-package.json -DiscoveryPath ../modules -ProbingPath platform_dir/app_data/modules -SkipDependencySolving
```
:::
:::
Expand Down Expand Up @@ -130,8 +139,11 @@ vc-build PublishModuleManifest
:::
:::
## SonarQubeStart
Starts sonar scanner by executing "dotnet sonarscanner begin"
Starts sonar scanner by executing "dotnet sonarscanner begin".
Gets parameters: SonarBranchName, SonarPRBase, SonarPRBranch, SonarPRNumber, SonarGithubRepo, SonarPRProvider, SonarAuthToken
```console
vc-build SonarQubeStart -SonarBranchName dev -SonarAuthToken *** -RepoName vc-module-marketing
```
:::
:::
## SonarQubeEnd
Expand Down
2 changes: 1 addition & 1 deletion build/HelpProvider/Build.HelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private string GetHelpForTarget(string target)
{
var pipeline = new MarkdownPipelineBuilder().UseCustomContainers().Build();
var vcbuildRoot = AppDomain.CurrentDomain.BaseDirectory;
var docsPath = Path.Combine(vcbuildRoot, "Docs", "Targets.md");
var docsPath = Path.Combine(vcbuildRoot, "docs", "targets.md");
var md = Markdown.Parse(File.ReadAllText(docsPath), pipeline);
var containers = md.Descendants<CustomContainer>();
var container = containers.FirstOrDefault(c =>
Expand Down
6 changes: 3 additions & 3 deletions build/_build.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>VirtoCommerce.GlobalTool</PackageId>
<OutputType>Exe</OutputType>
Expand Down Expand Up @@ -35,7 +35,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.console" Version="1.7.2">
<PackageReference Include="dotnet-reportgenerator-globaltool" Version="4.8.8">
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore.Cli" Version="5.6.3">
Expand Down Expand Up @@ -73,7 +73,7 @@
</ItemGroup>

<ItemGroup>
<None Update="Docs\Targets.md">
<None Update="docs\targets.md">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down

0 comments on commit 0d7de24

Please sign in to comment.