From 460ca626bd5a1694eea776500b7e852f34c64384 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 22 Jan 2020 13:44:14 +1100 Subject: [PATCH] Update codecov calc and use inbuild ref source/targets --- .github/workflows/build-and-test.yml | 51 +++++++++++++++++-- .gitignore | 2 +- Directory.Build.props | 3 +- ImageSharp.sln | 4 +- ci-build.ps1 | 15 ++---- ci-pack.ps1 | 11 ++++ tests/Directory.Build.targets | 10 ++-- .../ImageSharp.Tests/ImageSharp.Tests.csproj | 2 +- tests/NuGet.config | 11 ---- 9 files changed, 73 insertions(+), 36 deletions(-) create mode 100644 ci-pack.ps1 delete mode 100644 tests/NuGet.config diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4cb40d36a..28e109dac 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -82,7 +82,7 @@ jobs: shell: pwsh run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}" env: - CI : True + CI: True XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit - name: Update Codecov @@ -93,13 +93,54 @@ jobs: file: "coverage.${{matrix.options.framework}}.xml" flags: unittests - - name: Pack # We can use this filter as we know it happens only once and takes the most time to complete. - if: (github.event_name == 'push') && (matrix.options.codecov == true) + Publish: + needs: [Build] + + runs-on: windows-latest + + if: (github.event_name == 'push') + + steps: + - uses: actions/checkout@v2 + + - name: Install NuGet + uses: NuGet/setup-nuget@v1 + + - name: Setup Git + shell: bash + run: | + git config --global core.autocrlf false + git config --global core.longpaths true + git fetch --prune --unshallow + git submodule -q update --init --recursive + + - name: Fetch Tags for GitVersion + run: | + git fetch --tags + + - name: Fetch master for GitVersion + if: github.ref != 'refs/heads/master' + run: git branch --create-reflog master origin/master + + - name: Install GitVersion + uses: gittools/actions/setup-gitversion@v0.3 + with: + versionSpec: "5.1.x" + + - name: Use GitVersion + id: gitversion # step id used as reference for output values + uses: gittools/actions/execute-gitversion@v0.3 + + - name: Setup DotNet SDK + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "3.1.101" + + - name: Pack shell: pwsh - run: ./ci-build.ps1 "${{steps.gitversion.outputs.nuGetVersion}}" + run: ./ci-pack.ps1 "${{steps.gitversion.outputs.nuGetVersion}}" - name: Publish to MyGet - if: (github.event_name == 'push') && (matrix.options.codecov == true) shell: pwsh run: nuget.exe push .\artifacts\*.nupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v2/package # TODO: If github.ref starts with 'refs/tags' then it was tag push and we can optionally push out package to nuget.org diff --git a/.gitignore b/.gitignore index 8fcb5ef40..a89cfcf10 100644 --- a/.gitignore +++ b/.gitignore @@ -216,7 +216,7 @@ artifacts/ *.csproj.bak #CodeCoverage -/ImageSharp.Coverage.xml +*.lcov # Tests **/Images/ActualOutput diff --git a/Directory.Build.props b/Directory.Build.props index 346da14be..604153f97 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -91,8 +91,9 @@ git https://www.myget.org/F/sixlabors/api/v3/index.json; - https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; https://api.nuget.org/v3/index.json; + + https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json; 002400000c8000009400000006020000002400005253413100040000010001000147e6fe6766715eec6cfed61f1e7dcdbf69748a3e355c67e9d8dfd953acab1d5e012ba34b23308166fdc61ee1d0390d5f36d814a6091dd4b5ed9eda5a26afced924c683b4bfb4b3d64b0586a57eff9f02b1f84e3cb0ddd518bd1697f2c84dcbb97eb8bb5c7801be12112ed0ec86db934b0e9a5171e6bb1384b6d2f7d54dfa97 true diff --git a/ImageSharp.sln b/ImageSharp.sln index 5d74f7332..40878c575 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .gitignore = .gitignore .gitmodules = .gitmodules ci-build.ps1 = ci-build.ps1 + ci-pack.ps1 = ci-pack.ps1 ci-test.ps1 = ci-test.ps1 Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets @@ -44,7 +45,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{56801022 ProjectSection(SolutionItems) = preProject tests\Directory.Build.props = tests\Directory.Build.props tests\Directory.Build.targets = tests\Directory.Build.targets - tests\NuGet.config = tests\NuGet.config EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{FA55F5DE-11A6-487D-ABA4-BC93A02717DD}" @@ -330,7 +330,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedInfrastructure", "shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.shproj", "{68A8CC40-6AED-4E96-B524-31B1158FDEEA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Tests.ProfilingSandbox", "tests\ImageSharp.Tests.ProfilingSandbox\ImageSharp.Tests.ProfilingSandbox.csproj", "{FC527290-2F22-432C-B77B-6E815726B02C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Tests.ProfilingSandbox", "tests\ImageSharp.Tests.ProfilingSandbox\ImageSharp.Tests.ProfilingSandbox.csproj", "{FC527290-2F22-432C-B77B-6E815726B02C}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution diff --git a/ci-build.ps1 b/ci-build.ps1 index ad757dc9e..17c6e6603 100644 --- a/ci-build.ps1 +++ b/ci-build.ps1 @@ -1,20 +1,13 @@ param( [Parameter(Mandatory, Position = 0)] [string]$version, - [Parameter(Mandatory = $false, Position = 1)] - [string]$targetFramework = 'ALL' + [Parameter(Mandatory = $true, Position = 1)] + [string]$targetFramework ) dotnet clean -c Release $repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY" -if ($targetFramework -ne 'ALL') { - # Building for a specific framework. - dotnet build -c Release -f $targetFramework /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl -} -else { - - # Building for packing and publishing. - dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl -} +# Building for a specific framework. +dotnet build -c Release -f $targetFramework /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl diff --git a/ci-pack.ps1 b/ci-pack.ps1 new file mode 100644 index 000000000..a4e846db9 --- /dev/null +++ b/ci-pack.ps1 @@ -0,0 +1,11 @@ +param( + [Parameter(Mandatory, Position = 0)] + [string]$version +) + +dotnet clean -c Release + +$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY" + +# Building for packing and publishing. +dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index da21cbb75..22c70d8ca 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -28,10 +28,12 @@ true true - opencover + [SixLabors.*]* + lcov - $(MSBuildThisFileDirectory)..\coverage.xml - + $(MSBuildThisFileDirectory)..\ + $(CoverletOutputPath)$(AssemblyName).$(TargetFramework).lcov + true @@ -43,11 +45,11 @@ + - diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 59534c2a4..34cdca49a 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -18,9 +18,9 @@ + - diff --git a/tests/NuGet.config b/tests/NuGet.config deleted file mode 100644 index 1bb9a0fc2..000000000 --- a/tests/NuGet.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - -