Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
Feature/ci (nmklotas#1)
Browse files Browse the repository at this point in the history
Add CI integration

* Fix tests

* Add coverage reporting

* Add tests script

* Add badge

* Don't generate package on build
  • Loading branch information
nmklotas authored Sep 16, 2017
1 parent 45dfca3 commit d37182e
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,7 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc

# Coverage files
coverage/
6 changes: 6 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<activePackageSource>
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
</activePackageSource>
</configuration>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# GitLabApiClient
[![codecov](https://codecov.io/gh/nmklotas/GitLabApiClient/branch/master/graph/badge.svg)](https://codecov.io/gh/nmklotas/GitLabApiClient)
GitLab API client
33 changes: 33 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
image: Visual Studio 2017
version: 1.0.{build}-alpha
configuration: Release
build:
verbosity: minimal

environment:
# Don't report back to the mothership
DOTNET_CLI_TELEMETRY_OPTOUT: 1


skip_branch_with_pr: true

build_script:
- cmd: dotnet restore GitLabApiClient.sln
- cmd: dotnet build src\GitLabApiClient\GitLabApiClient.csproj -c Release
- cmd: dotnet pack src\GitLabApiClient\GitLabApiClient.csproj -c Release --no-build

test_script:
- ps: .\test.ps1

artifacts:
- path: 'src\bin\Release\*.nupkg'
name: Package

deploy:
provider: NuGet
api_key:
secure: yQCX8RMr2+lMMwXS1dVF/hIi1xsEOXoEqxzmrnvdSlXS1g5vHyrEoZG+Lq+RvekE
skip_symbols: false
artifact: /.*\.nupkg/
on:
appveyor_repo_tag: true
12 changes: 11 additions & 1 deletion src/GitLabApiClient/GitLabApiClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.1.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<FileVersion>0.1.0.0</FileVersion>
<Copyright />
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\bin\Debug\</OutputPath>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\bin\Release\</OutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
Expand Down
38 changes: 38 additions & 0 deletions test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
nuget install -Verbosity quiet -OutputDirectory packages -Version 4.6.519 OpenCover
nuget install -Verbosity quiet -OutputDirectory packages -Version 2.4.5.0 ReportGenerator
nuget install -Verbosity quiet -OutputDirectory packages -Version 1.0.3 CodeCov

$coverageFolder = "$PSScriptRoot\coverage"
Remove-Item $coverageFolder -force -recurse -ErrorAction SilentlyContinue | Out-Null
New-Item $coverageFolder -type directory | Out-Null

$openCover="$PSScriptRoot\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe"
$reportGenerator="$PSScriptRoot\packages\ReportGenerator.2.4.5.0\tools\ReportGenerator.exe"
$codeCov = "$PSScriptRoot\packages\CodeCov.1.0.3\tools\codecov.exe"

Write-Host "Calculating coverage with OpenCover."
& $openCover `
-target:"c:\Program Files\dotnet\dotnet.exe" `
-targetargs:"test test\GitLabApiClient.Test\GitLabApiClient.Test.csproj" `
-mergeoutput `
-hideskipped:File `
-output:coverage/coverage.xml `
-oldStyle `
-filter:"+[GitLabApiClient*]* -[GitLabApiClient.Test]*" `
-searchdirs:$test/bin/Debug/netcoreapp2.0 `
-returntargetcode `
-register:user | Write-Host

if ($LastExitCode -ne 0)
{
exit 1
}

Write-Host "Generating HTML report"
& $reportGenerator `
-reports:coverage/coverage.xml `
-targetdir:coverage `
-verbosity:Error | Write-Host

Write-Host "Uploading coverage file"
& $codecov -f "coverage/coverage.xml" -t bda1c835-c4a2-4a1a-8d38-999b9a8ea80b
10 changes: 10 additions & 0 deletions test/GitLabApiClient.Test/GitLabApiClient.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\bin\Debug\</OutputPath>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\bin\Release\</OutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.19.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
Expand Down
7 changes: 5 additions & 2 deletions test/GitLabApiClient.Test/ProjectsClientTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
Expand Down Expand Up @@ -45,7 +46,7 @@ public async Task ProjectRetrievedByName()
[Fact]
public async Task ProjectCreated()
{
var createRequest = CreateProjectRequest.FromName("test-gitlabapiclient1");
var createRequest = CreateProjectRequest.FromName(GetRandomProjectName());
createRequest.Description = "description1";
createRequest.EnableContainerRegistry = true;
createRequest.EnableIssues = true;
Expand Down Expand Up @@ -78,7 +79,7 @@ public async Task ProjectCreated()
[Fact]
public async Task CreatedProjectCanBeUpdated()
{
var createRequest = CreateProjectRequest.FromName("test-gitlabapiclient1");
var createRequest = CreateProjectRequest.FromName(GetRandomProjectName());
createRequest.Description = "description1";
createRequest.EnableContainerRegistry = true;
createRequest.EnableIssues = true;
Expand Down Expand Up @@ -132,5 +133,7 @@ private async Task CleanupProjects()
foreach (int projectId in ProjectIdsToClean)
await _sut.DeleteAsync(projectId);
}

private static string GetRandomProjectName() => "test-gitlabapiclient" + Path.GetRandomFileName();
}
}

0 comments on commit d37182e

Please sign in to comment.