Skip to content

Commit

Permalink
Code coverage and workflows to build nng and nupkg
Browse files Browse the repository at this point in the history
  • Loading branch information
jeikabu committed Feb 4, 2021
1 parent c8a0a23 commit 9938005
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 29 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

Expand All @@ -16,18 +15,30 @@ jobs:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- uses: actions/checkout@v2
- name: Setup .NET 5.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Setup .NET 3.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 5.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Checkout
uses: actions/checkout@v2
- name: Install coverlet
if: matrix.os == 'ubuntu-18.04'
run: |
dotnet add tests/tests.csproj package coverlet.msbuild
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --verbosity normal
run: dotnet test --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=lcov
- name: Code coverage
if: matrix.os == 'ubuntu-18.04'
uses: codecov/codecov-action@v1
with:
files: ./tests/coverage.info
flags: unittests

29 changes: 29 additions & 0 deletions .github/workflows/nng.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: nng

on:
workflow_dispatch:
inputs:
nng_tag:
description: 'NNG version'
required: true

jobs:
build:
strategy:
matrix:
os: [windows-2019, ubuntu-18.04, macos-10.15]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout nng.NET
uses: actions/checkout@v2
- name: Checkout NNG
if: matrix.os != 'ubuntu-18.04'
uses: actions/checkout@v2
with:
repository: nanomsg/nng
ref: ${{ github.event.inputs.nng_tag }}
path: nng
- name: Build
run: |
./scripts/build_nng.ps1 -nng_source ./nng -git_branch nng_update
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: publish

on:
release:
types: [published]

jobs:
build:
runs-on: windows-2019
steps:
- name: Checkout nng.NET
uses: actions/checkout@v2
- name: Package
run: |
./scripts/nupkg.ps1 -Version ${{ github.event.release.tag_name }} -NugetApiKey ${{ secrets.NUGET_API_KEY }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Using latest [NNG release](https://github.com/nanomsg/nng/releases).

[![NuGet](https://img.shields.io/nuget/vpre/Subor.nng.NETCore.svg?colorB=brightgreen)](https://www.nuget.org/packages/Subor.nng.NETCore)
![](https://github.com/jeikabu/nng.NETCore/workflows/build/badge.svg)
[![codecov](https://codecov.io/gh/subor/nng.NETCore/branch/master/graph/badge.svg)](https://codecov.io/gh/subor/nng.NETCore)
[![codecov](https://codecov.io/gh/jeikabu/nng.NETCore/branch/master/graph/badge.svg?token=KZMer5zeMv)](https://codecov.io/gh/jeikabu/nng.NETCore)

For list of missing APIs/features see [`is:issue is:open label:enhancement`](https://github.com/jeikabu/nng.NETCore/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement).

Expand Down
2 changes: 2 additions & 0 deletions common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</PropertyGroup>

<PropertyGroup>
<VersionPrefix>1.3.2</VersionPrefix>
<VersionSuffix>rc2</VersionSuffix>
<Authors>Subor</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Owners>Subor</Owners>
Expand Down
2 changes: 0 additions & 2 deletions nng.NETCore/nng.NETCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<!-- Including assembly as part of runtimes/ so don't want it placed in lib/ -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageId>Subor.nng.NETCore</PackageId>
<PackageVersion>1.3.1-rc0</PackageVersion>
<Version>1.3.1.0</Version>
<!-- Needed to avoid `error NU5128` when running `dotnet pack`.
Assemblies for targetted frameworks are in runtimes/ instead of lib/ or ref/
See: https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128#scenario-2
Expand Down
3 changes: 0 additions & 3 deletions nng.Shared/nng.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

<PropertyGroup>
<PackageId>Subor.nng.NETCore.Shared</PackageId>
<PackageVersion>1.3.1-rc0</PackageVersion>
<Version>1.3.1.0</Version>

<PackageOutputPath>../bin/$(Configuration)</PackageOutputPath>
</PropertyGroup>

Expand Down
21 changes: 20 additions & 1 deletion scripts/build_nng.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

param([string]$nng_source = "../nng/",
[switch]$clean,
[string]$git_branch,
[string]$runtimes = "$PSScriptRoot/../nng.NETCore/runtimes"
)

Expand Down Expand Up @@ -64,7 +65,25 @@ try {
Pop-Location
}
}

} finally {
Set-Location $current_dir
}

if ($git_branch) {
if (!$(git config user.email) -or !(git config user.name)) {
git config user.email "[email protected]"
git config user.name "jeikabu"
}

git checkout -b $git_branch
git add $runtimes
git commit -m "Update native NNG libs"
git push --set-upstream origin $git_branch
if (!$?) {
Write-Output "$? ExitCode: $LASTEXITCODE"
git pull origin $git_branch
Write-Output "$? ExitCode: $LASTEXITCODE"
git push --set-upstream origin $git_branch
Write-Output "$? ExitCode: $LASTEXITCODE"
}
}
38 changes: 23 additions & 15 deletions scripts/nupkg.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
param(
[string]$Version,
[string]$NugetApiKey,
[string]$Nuget,
[string]$Pfx
[string]$NugetApiKey = "",
[string]$Nuget = "",
[string]$Pfx = ""
)

$ErrorActionPreference = "Stop"

if (-not $(Test-Path $Pfx -PathType Leaf)) {
throw "Need pfx"
}
# Strip the leading "v". E.g. "v1.3.2-rc0" => "1.3.2-rc0"
$Version = $Version -replace "^v",""

if (-not $(Test-Path $Nuget -PathType Leaf) -and -not $(Get-Command nuget -ErrorAction Ignore)) {
throw "Nuget executable not found"
}
$nupkgs = "./bin/Release/*.nupkg"
Remove-Item $nupkgs -Force -ErrorAction Ignore

dotnet pack -c Release
dotnet pack --configuration Release -p:Version=$Version

$packages = "./bin/Release/Subor.nng.NETCore.$Version.nupkg", "./bin/Release/Subor.nng.NETCore.Shared.$Version.nupkg"
$packages = Get-ChildItem $nupkgs

foreach ($pkg in $packages) {
& $Nuget sign $pkg -Timestamper http://sha256timestamp.ws.symantec.com/sha256/timestamp -CertificatePath $Pfx
if ($Pfx) {
if (-not $(Test-Path $Pfx -PathType Leaf)) {
throw "Need pfx"
}
if (-not $(Test-Path $Nuget -PathType Leaf) -and -not $(Get-Command nuget -ErrorAction Ignore)) {
throw "Nuget executable not found"
}
foreach ($pkg in $packages) {
& $Nuget sign $pkg -Timestamper http://sha256timestamp.ws.symantec.com/sha256/timestamp -CertificatePath $Pfx
}
}

foreach ($pkg in $packages) {
dotnet nuget push $pkg -k $NugetApiKey -s https://api.nuget.org/v3/index.json
if ($NugetApiKey) {
foreach ($pkg in $packages) {
dotnet nuget push $pkg -k $NugetApiKey -s https://api.nuget.org/v3/index.json
}
}
4 changes: 4 additions & 0 deletions tests/tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
Expand Down

0 comments on commit 9938005

Please sign in to comment.