Skip to content

Commit

Permalink
simplifying AppVeyor config and test coverage execution
Browse files Browse the repository at this point in the history
  • Loading branch information
salaros committed Oct 11, 2018
1 parent d2adc2d commit 46e3919
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ build/
# Other stuff
package/
tools/
coverage/
src/bin
src/obj
test/bin
test/obj
\.vs/
tests/coverage\.xml
2 changes: 1 addition & 1 deletion IsBizMail.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IsBizMail", "src\IsBizMail.csproj", "{F8722C5D-2464-2454-5C38-51BD6511CD90}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IsBizMail.Test", "tests\IsBizMail.Test.csproj", "{8A4D33FB-4592-4EC2-894F-B773BEAE305C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IsBizMail.Tests", "tests\IsBizMail.Tests.csproj", "{8A4D33FB-4592-4EC2-894F-B773BEAE305C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{B848CBFD-3FF8-444D-B64E-972917F0852F}"
ProjectSection(SolutionItems) = preProject
Expand Down
112 changes: 54 additions & 58 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ branches:
configuration: Debug

environment:
VERSION_SIMPLE: '{version}'
VERSION_INFORMATIONAL: '{version}'
VERSION_UNSTABLE_SUFFIX: 'preview'
VERSION_SIMPLE: "{version}"
VERSION_INFORMATIONAL: "{version}"
VERSION_UNSTABLE_SUFFIX: "preview"
COVERALLS_REPO_TOKEN:
secure: odGiKZUnpY4yFHVXwHGp3Tk1dXKQRPS1JVSftdfIK/rMc17ttK6q2T2jwfZme5pB
APPVEYOR_TOKEN:
Expand All @@ -35,30 +35,30 @@ install:
- dotnet restore

init:
- ps: |
$env:VERSION_SIMPLE = $env:APPVEYOR_BUILD_VERSION.TrimStart("v")
$env:VERSION_INFORMATIONAL = "$env:VERSION_SIMPLE"
$env:GITHUB_REPO_API = "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/tags"
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
### CHECK IF A IT'S A TAGGED BUILD
$env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
Write-Host "Building a tagged Git commit: $git_current_tag";
if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
$env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $tag_ver.Major, $tag_ver.Minor, $tag_ver.Build
$env:VERSION_SIMPLE = "$env:VERSION_INFORMATIONAL.$env:APPVEYOR_BUILD_NUMBER"
}
} elseif ($env:VERSION_INFORMATIONAL -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$current_ver = [version]$env:VERSION_INFORMATIONAL
$env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $current_ver.Major, $current_ver.Minor, $current_ver.Build
$env:VERSION_INFORMATIONAL = "{0}-{1}{2}" -f $env:VERSION_INFORMATIONAL, $env:VERSION_UNSTABLE_SUFFIX, $env:APPVEYOR_BUILD_NUMBER
}
### MAKE CALCULATED INFORMATIONAL VERSION THE ACTUAL BUILD VERSION
Update-AppveyorBuild -Version $env:VERSION_INFORMATIONAL
Write-Host "Using build version: $env:VERSION_SIMPLE"
Write-Host "Using (informational) build version: $env:VERSION_INFORMATIONAL"
- ps: |
$env:VERSION_SIMPLE = $env:APPVEYOR_BUILD_VERSION.TrimStart("v")
$env:VERSION_INFORMATIONAL = "$env:VERSION_SIMPLE"
$env:GITHUB_REPO_API = "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/tags"
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
### CHECK IF A IT'S A TAGGED BUILD
$env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
Write-Host "Building a tagged Git commit: $git_current_tag";
if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
$env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $tag_ver.Major, $tag_ver.Minor, $tag_ver.Build
$env:VERSION_SIMPLE = "$env:VERSION_INFORMATIONAL.$env:APPVEYOR_BUILD_NUMBER"
}
} elseif ($env:VERSION_INFORMATIONAL -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$current_ver = [version]$env:VERSION_INFORMATIONAL
$env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $current_ver.Major, $current_ver.Minor, $current_ver.Build
$env:VERSION_INFORMATIONAL = "{0}-{1}{2}" -f $env:VERSION_INFORMATIONAL, $env:VERSION_UNSTABLE_SUFFIX, $env:APPVEYOR_BUILD_NUMBER
}
### MAKE CALCULATED INFORMATIONAL VERSION THE ACTUAL BUILD VERSION
Update-AppveyorBuild -Version $env:VERSION_INFORMATIONAL
Write-Host "Using build version: $env:VERSION_SIMPLE"
Write-Host "Using (informational) build version: $env:VERSION_INFORMATIONAL"
dotnet_csproj:
patch: true
Expand All @@ -85,8 +85,7 @@ artifacts:

# Deploy to GitHub releases
deploy:
-
provider: GitHub
- provider: GitHub
auth_token:
secure: 2+d0KgCbWQpUR8TZfzvUEzbi4NQP6F/Tt0PUwLn6jXZCyO8FnrFVFJPsFa0QBQFl
artifact: NuGet_Files
Expand All @@ -98,56 +97,53 @@ deploy:
on:
appveyor_repo_tag: true

-
provider: NuGet
- provider: NuGet
api_key:
secure: TrtChQUTQ9rD8pffK1A9bjMYyN/8eQUjV+7IKVjS/C37TgXMae46Bzd527bZUVSb
artifact: NuGet_Files
server: # remove to push to NuGet.org
server: # remove to push to NuGet.org
skip_symbols: false
symbol_server: # remove to push symbols to SymbolSource.org
symbol_server: # remove to push symbols to SymbolSource.org

-
provider: NuGet
- provider: NuGet
server: https://ci.appveyor.com/nuget/salaros/api/v2/package
symbol_server: https://ci.appveyor.com/nuget/salaros/api/v2/package
api_key:
secure: 3zmnmVBweTgdk4SBM/rWHdC9JOM9s0pxm1bw1d+WHDo=
artifact: NuGet_Files

after_deploy:
- ps: |
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
$apiUrl = 'https://ci.appveyor.com/api'
$headers = @{
"Authorization" = "Bearer $env:APPVEYOR_TOKEN"
"Content-type" = "application/json"
}
Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/build-number" -Body '{"nextBuildNumber": 1 }' -Headers $headers
$env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
$ver_format = "version: {0}.{1}.{2}.{3}" -f $tag_ver.Major, $tag_ver.Minor, ($tag_ver.Build + 1), '{build}'
$headers."Content-type" = "text/plain";
Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/yaml" -Body $ver_format -Headers $headers
}
}
- ps: |
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
$apiUrl = 'https://ci.appveyor.com/api'
$headers = @{
"Authorization" = "Bearer $env:APPVEYOR_TOKEN"
"Content-type" = "application/json"
}
Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/build-number" -Body '{"nextBuildNumber": 1 }' -Headers $headers
$env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
$ver_format = "version: {0}.{1}.{2}.{3}" -f $tag_ver.Major, $tag_ver.Minor, ($tag_ver.Build + 1), '{build}'
$headers."Content-type" = "text/plain";
Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/yaml" -Body $ver_format -Headers $headers
}
}
# Start builds on tags only (GitHub and BitBucket)
skip_non_tags: false

# Tests shall stay off for now
test_script:
- cmd: dotnet test .\tests
- dotnet test .\tests

# Test coverage: OpenCover + Coveralls
after_test:
- ps: |
# Install NuGet packages and tools
nuget install OpenCover -Version 4.6.519 -OutputDirectory packages
dotnet tool install coveralls.net --tool-path tools
dotnet tool install -g coveralls.net
dotnet tool install -g dotnet-testx
# Set variables
.\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:dotnet.exe -targetargs:"test .\tests" -register:user -filter:"+[*]* -[xunit*]* -[*Tests]*" -excludedirs:".\src\obj" -output:".\tests\coverage.xml" -oldStyle
.\tools\csmacnz.Coveralls.exe --opencover --input .\tests\coverage.xml --repoToken $env:COVERALLS_REPO_TOKEN --commitId $env:APPVEYOR_REPO_COMMIT --commitBranch $env:APPVEYOR_REPO_BRANCH --commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR --commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL --commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE --jobId $env:APPVEYOR_JOB_ID
dotnet testx --project=all --html=true --opencover-filters="+[Salaros*]* -[xunit*]* -[*Tests]*" --opencover-options="-oldStyle"
csmacnz.Coveralls --opencover --input .\coverage\results.xml --repoToken $env:COVERALLS_REPO_TOKEN
2 changes: 1 addition & 1 deletion tests/EmailSamples.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Salaros.Email.Test
namespace Salaros.Email.Tests
{
internal class EmailSamples
{
Expand Down
29 changes: 19 additions & 10 deletions tests/IsBizMail.Test.csproj → tests/IsBizMail.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>Salaros.Email.Test</RootNamespace>
<RootNamespace>Salaros.Email.Tests</RootNamespace>
<IsPackable>false</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<StartupObject />
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\build\dotnet\bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>..\..\build\dotnet\bin\Release\</OutputPath>
<PropertyGroup>
<OutputPath>..\build\bin\$(Configuration)\</OutputPath>
<AssemblyName>IsBizMail.Tests</AssemblyName>
</PropertyGroup>

<ItemGroup>
<Compile Remove="TestResults\**" />
<EmbeddedResource Remove="TestResults\**" />
<None Remove="TestResults\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="OpenCover" Version="4.6.519" />
<PackageReference Include="ReportGenerator" Version="3.1.2" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -30,7 +36,10 @@
<ProjectReference Include="..\src\IsBizMail.csproj" />
</ItemGroup>

<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
<Copy SourceFiles="..\assets\email-test-samples.json" DestinationFolder="$(OutDir)" />
</Target>
<ItemGroup>
<Content Include="..\assets\email-test-samples.json" Link="email-test-samples.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion tests/IsBizMailTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Linq;

namespace Salaros.Email.Test
namespace Salaros.Email.Tests
{
public class IsBizMailTest
{
Expand Down

0 comments on commit 46e3919

Please sign in to comment.