Skip to content

Commit 04084e1

Browse files
authored
[DependencyUpdater] Allow to run from different organizations (#42)
1 parent e022a04 commit 04084e1

File tree

7 files changed

+391
-278
lines changed

7 files changed

+391
-278
lines changed

azure-pipelines.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,32 @@ jobs:
227227
condition: succeeded()
228228
workingDirectory: '$(System.DefaultWorkingDirectory)/tools/DependencyUpdater'
229229

230+
- task: DotNetCoreCLI@2
231+
condition: succeeded()
232+
displayName: 'Running Unit Tests'
233+
inputs:
234+
command: 'test'
235+
projects: |
236+
**/*Tests.csproj
237+
!**/obj/**
238+
!**/bin/**/ref/**
239+
arguments: '--configuration Release --collect "XPlat Code coverage"'
240+
testRunTitle: 'Unit Tests'
241+
242+
# First install the tool on the machine, then run it
243+
- script: |
244+
dotnet tool install -g dotnet-reportgenerator-globaltool
245+
reportgenerator -reports:$(Agent.WorkFolder)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage "-reporttypes:HtmlInline_AzurePipelines;Cobertura"
246+
displayName: 'Create code coverage report'
247+
condition: always()
248+
249+
- task: PublishCodeCoverageResults@1
250+
displayName: 'Publish code coverage results'
251+
inputs:
252+
codeCoverageTool: Cobertura
253+
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
254+
condition: always()
255+
230256
- task: CopyFiles@1
231257
condition: succeeded()
232258
displayName: Collecting deployable artifacts
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0"/>
13+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8"/>
14+
<PackageReference Include="MSTest.TestFramework" Version="2.2.8"/>
15+
<PackageReference Include="coverlet.collector" Version="3.1.2"/>
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\DependencyUpdater.csproj" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace DependencyUpdater.Tests;
7+
8+
[TestClass]
9+
public class ProgramTests
10+
{
11+
[DataTestMethod]
12+
[DataRow("origin https://github.com/torbacz/nf-tools.git (fetch) origin https://github.com/torbacz/nf-tools.git (push)", "nf-tools")]
13+
[DataRow("origin https://github.com/nanoframework/nf-tools.git (fetch) origin https://github.com/nanoframework/nf-tools.git (push)", "nf-tools")]
14+
public void GetLibNameFromGitString_Should_ReturnValidData(string inputData, string expectedResult)
15+
{
16+
var result = nanoFramework.Tools.DependencyUpdater.Program.GetRepoNameFromInputString(inputData);
17+
Assert.IsTrue(result.Success);
18+
19+
var libName = nanoFramework.Tools.DependencyUpdater.Program.GetLibNameFromRegexMatch(result);
20+
Assert.AreEqual(expectedResult, libName);
21+
}
22+
23+
[DataTestMethod]
24+
[DataRow("origin https://github.com/torbacz/nf-tools.git (fetch) origin https://github.com/torbacz/nf-tools.git (push)", "torbacz")]
25+
[DataRow("origin https://github.com/nanoframework/nf-tools.git (fetch) origin https://github.com/nanoframework/nf-tools.git (push)", "nanoframework")]
26+
[DataRow("origin https://github.com/nanoframework-test/nf-tools.git (fetch) origin https://github.com/nanoframework/nf-tools.git (push)", "nanoframework-test")]
27+
public void GetRepoOwnerFromInputString_Should_ReturnValidData(string inputData, string expectedResult)
28+
{
29+
var result = nanoFramework.Tools.DependencyUpdater.Program.GetRepoOwnerFromInputString(inputData);
30+
Assert.AreEqual(expectedResult, result);
31+
}
32+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global using Microsoft.VisualStudio.TestTools.UnitTesting;

tools/DependencyUpdater/DependencyUpdater.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<Pack>True</Pack>
3333
<PackagePath></PackagePath>
3434
</None>
35+
<None Remove="DependencyUpdater.Tests\**" />
3536
</ItemGroup>
3637

3738
<ItemGroup>
@@ -56,5 +57,19 @@
5657
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
5758
</Content>
5859
</ItemGroup>
60+
61+
<ItemGroup>
62+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
63+
<_Parameter1>DependencyUpdater.Tests</_Parameter1>
64+
</AssemblyAttribute>
65+
</ItemGroup>
66+
67+
<ItemGroup>
68+
<Compile Remove="DependencyUpdater.Tests\**" />
69+
</ItemGroup>
70+
71+
<ItemGroup>
72+
<EmbeddedResource Remove="DependencyUpdater.Tests\**" />
73+
</ItemGroup>
5974

6075
</Project>

tools/DependencyUpdater/DependencyUpdater.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.32014.148
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyUpdater", "DependencyUpdater.csproj", "{96810A57-0356-4ED3-91DB-9811A4A553A1}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyUpdater.Tests", "DependencyUpdater.Tests\DependencyUpdater.Tests.csproj", "{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{96810A57-0356-4ED3-91DB-9811A4A553A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{96810A57-0356-4ED3-91DB-9811A4A553A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{96810A57-0356-4ED3-91DB-9811A4A553A1}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{DFCC960B-6B6E-4A11-B5ED-DA9D1A682CDD}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)