Skip to content

Commit

Permalink
Merge pull request #41 from guitarrapc/feature/new_sample
Browse files Browse the repository at this point in the history
feat: add net6.0 test and samples. drop netcoreapp2.2
  • Loading branch information
guitarrapc authored Apr 25, 2022
2 parents db7f591 + b245787 commit 96d9eb4
Show file tree
Hide file tree
Showing 41 changed files with 364 additions and 149 deletions.
47 changes: 0 additions & 47 deletions .github/workflows/build.yaml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/dotnet-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: dotnet-build

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
NUGET_XMLDOC_MODE: skip

jobs:
build-dotnet:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v2
with:
dotnet-version: |
6.0.x
5.0.x
3.1.x
# build
- name: Build
run: dotnet build ./src/SkiaSharp.QrCode/SkiaSharp.QrCode.csproj -c Debug
- name: Build (ManualGenerate)
run: dotnet build ./samples/ManualGenerate/ManualGenerate.csproj -c Debug
- name: Build (SimpleGenerate)
run: dotnet build ./samples/SimpleGenerate/SimpleGenerate.csproj -c Debug
# tests
- name: Test (net3.1)
run: dotnet test ./tests/SkiaSharp.QrCode.Tests.net31/ -c Debug
- name: Test (net5.0)
run: dotnet test ./tests/SkiaSharp.QrCode.Tests.net50/ -c Debug
- name: Test (net6.0)
run: dotnet test ./tests/SkiaSharp.QrCode.Tests.net60/ -c Debug -p:CollectCoverage=true -p:CoverletOutputFormat=opencover
- uses: codecov/codecov-action@v1
with:
file: ./tests/SkiaSharp.QrCode.Tests.net60/coverage.opencover.xml
flags: unittests
fail_ci_if_error: true
verbose: true

run-linux:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v2
with:
dotnet-version: |
6.0.x
5.0.x
3.1.x
# run
- name: ManualGenerate (net3.1)
run: dotnet run --project ./samples/ManualGenerate/ManualGenerate.csproj -c Debug -f netcoreapp3.1
- name: SimpleGenerate (net3.1)
run: dotnet run --project ./samples/SimpleGenerate/SimpleGenerate.csproj -c Debug -f netcoreapp3.1
- name: ManualGenerate (net5.0)
run: dotnet run --project ./samples/ManualGenerate/ManualGenerate.csproj -c Debug -f net5.0
- name: SimpleGenerate (net5.0)
run: dotnet run --project ./samples/SimpleGenerate/SimpleGenerate.csproj -c Debug -f net5.0
- name: ManualGenerate (net6.0)
run: dotnet run --project ./samples/ManualGenerate/ManualGenerate.csproj -c Debug -f net6.0
- name: SimpleGenerate (net6.0)
run: dotnet run --project ./samples/SimpleGenerate/SimpleGenerate.csproj -c Debug -f net6.0
- name: Linux Docker Compose Run
run: docker-compose -f ./samples/LinuxRunSamples/compose.yaml up
11 changes: 7 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ jobs:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
NUGET_XMLDOC_MODE: skip
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v2
with:
dotnet-version: 5.0.x
dotnet-version: |
6.0.x
5.0.x
3.1.x
# tag
- run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# build
Expand All @@ -39,7 +42,7 @@ jobs:
steps:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
dotnet-version: 6.0.x
- run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# Create Release
- uses: actions/create-release@v1
Expand Down
39 changes: 23 additions & 16 deletions SkiaSharp.QrCode.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.QrCode", "src\SkiaSharp.QrCode\SkiaSharp.QrCode.csproj", "{0850349B-4894-4190-B04C-EB6986529185}"
EndProject
Expand All @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManualGenerate", "samples\M
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleGenerate", "samples\SimpleGenerate\SimpleGenerate.csproj", "{096520D5-85EC-4AC5-BDE4-7F11B5874EDA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NanoServerGenerate.2.2", "samples\NanoServerGenerate.2.2\NanoServerGenerate.2.2.csproj", "{BB6B4CE2-A9AA-4CBA-A0EA-CA9EEC6024D9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NanoServerGenerate.3.1", "samples\NanoServerGenerate.3.1\NanoServerGenerate.3.1.csproj", "{2FCFFF3C-FBA0-42A2-942C-8CB6E5835CE3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D411A8A1-96FC-495F-9583-4C154DF25240}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AF981C34-65A3-48DB-BBFB-52EFE0F824AB}"
Expand All @@ -28,6 +24,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.QrCode.Tests.net5
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.QrCode.Tests.net31", "tests\SkiaSharp.QrCode.Tests.net31\SkiaSharp.QrCode.Tests.net31.csproj", "{4960D7EB-2B2B-4B27-ADA1-923AB06DBC72}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NanoServerGenerate31", "samples\NanoServerGenerate31\NanoServerGenerate31.csproj", "{B721726D-4F32-4695-8860-F6922C577F38}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NanoServerGenerate60", "samples\NanoServerGenerate60\NanoServerGenerate60.csproj", "{DE7C59CA-B61E-4D96-9EE5-E4526DB7AC68}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.QrCode.Tests.net60", "tests\SkiaSharp.QrCode.Tests.net60\SkiaSharp.QrCode.Tests.net60.csproj", "{C921D5DC-9121-463F-8665-7AC184E68DD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -46,14 +48,6 @@ Global
{096520D5-85EC-4AC5-BDE4-7F11B5874EDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{096520D5-85EC-4AC5-BDE4-7F11B5874EDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{096520D5-85EC-4AC5-BDE4-7F11B5874EDA}.Release|Any CPU.Build.0 = Release|Any CPU
{BB6B4CE2-A9AA-4CBA-A0EA-CA9EEC6024D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB6B4CE2-A9AA-4CBA-A0EA-CA9EEC6024D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB6B4CE2-A9AA-4CBA-A0EA-CA9EEC6024D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB6B4CE2-A9AA-4CBA-A0EA-CA9EEC6024D9}.Release|Any CPU.Build.0 = Release|Any CPU
{2FCFFF3C-FBA0-42A2-942C-8CB6E5835CE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FCFFF3C-FBA0-42A2-942C-8CB6E5835CE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FCFFF3C-FBA0-42A2-942C-8CB6E5835CE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FCFFF3C-FBA0-42A2-942C-8CB6E5835CE3}.Release|Any CPU.Build.0 = Release|Any CPU
{975C9157-6E43-44DE-9405-C2CF8C217AE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{975C9157-6E43-44DE-9405-C2CF8C217AE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{975C9157-6E43-44DE-9405-C2CF8C217AE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -62,6 +56,18 @@ Global
{4960D7EB-2B2B-4B27-ADA1-923AB06DBC72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4960D7EB-2B2B-4B27-ADA1-923AB06DBC72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4960D7EB-2B2B-4B27-ADA1-923AB06DBC72}.Release|Any CPU.Build.0 = Release|Any CPU
{B721726D-4F32-4695-8860-F6922C577F38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B721726D-4F32-4695-8860-F6922C577F38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B721726D-4F32-4695-8860-F6922C577F38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B721726D-4F32-4695-8860-F6922C577F38}.Release|Any CPU.Build.0 = Release|Any CPU
{DE7C59CA-B61E-4D96-9EE5-E4526DB7AC68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE7C59CA-B61E-4D96-9EE5-E4526DB7AC68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE7C59CA-B61E-4D96-9EE5-E4526DB7AC68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE7C59CA-B61E-4D96-9EE5-E4526DB7AC68}.Release|Any CPU.Build.0 = Release|Any CPU
{C921D5DC-9121-463F-8665-7AC184E68DD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C921D5DC-9121-463F-8665-7AC184E68DD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C921D5DC-9121-463F-8665-7AC184E68DD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C921D5DC-9121-463F-8665-7AC184E68DD9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -70,10 +76,11 @@ Global
{0850349B-4894-4190-B04C-EB6986529185} = {8C639322-95F9-438F-8B71-1890FB797E25}
{72A72621-F8FA-4A0F-845C-06F2BA2DB114} = {C4DBE18B-7128-4E6E-B5C6-F18E4DA5D616}
{096520D5-85EC-4AC5-BDE4-7F11B5874EDA} = {C4DBE18B-7128-4E6E-B5C6-F18E4DA5D616}
{BB6B4CE2-A9AA-4CBA-A0EA-CA9EEC6024D9} = {C4DBE18B-7128-4E6E-B5C6-F18E4DA5D616}
{2FCFFF3C-FBA0-42A2-942C-8CB6E5835CE3} = {C4DBE18B-7128-4E6E-B5C6-F18E4DA5D616}
{975C9157-6E43-44DE-9405-C2CF8C217AE6} = {D411A8A1-96FC-495F-9583-4C154DF25240}
{4960D7EB-2B2B-4B27-ADA1-923AB06DBC72} = {D411A8A1-96FC-495F-9583-4C154DF25240}
{B721726D-4F32-4695-8860-F6922C577F38} = {C4DBE18B-7128-4E6E-B5C6-F18E4DA5D616}
{DE7C59CA-B61E-4D96-9EE5-E4526DB7AC68} = {C4DBE18B-7128-4E6E-B5C6-F18E4DA5D616}
{C921D5DC-9121-463F-8665-7AC184E68DD9} = {D411A8A1-96FC-495F-9583-4C154DF25240}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D0A3AD8D-B614-4A6D-AB7E-6A6993495E0F}
Expand Down
2 changes: 1 addition & 1 deletion samples/LinuxRunSamples/3.1/BuildTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/LinuxRunSamples/3.1_nodep/BuildTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/LinuxRunSamples/5.0/BuildTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/LinuxRunSamples/5.0_nodep/BuildTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions samples/LinuxRunSamples/6.0/BuildTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SkiaSharp.QrCode" Version="0.4.1" />
<!-- require libfontconfig1 https://github.com/mono/SkiaSharp/issues/964#issuecomment-549385484 -->
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.80.2" />
</ItemGroup>

<ItemGroup>
<None Update="samples\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
39 changes: 39 additions & 0 deletions samples/LinuxRunSamples/6.0/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using SkiaSharp;
using System;
using System.IO;
using SkiaSharp.QrCode;
using SkiaSharp.QrCode.Models;

Directory.CreateDirectory("output");

var content = "testtesttest";
using var generator = new QRCodeGenerator();
// Generate QrCode
var qr = generator.CreateQrCode(content, ECCLevel.L);

// Render to canvas
var info = new SKImageInfo(512, 512);
using var surface = SKSurface.Create(info);
var canvas = surface.Canvas;
canvas.Render(qr, info.Width, info.Height);

// gen color
// yellow https://rgb.to/yellow
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(60,100,50));
// red https://rgb.to/red
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(0, 100, 50));

// gen icon
var logo = File.ReadAllBytes("samples/test.png");
var icon = new IconData
{
Icon = SKBitmap.Decode(logo),
IconSizePercent = 10,
};
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.Parse("000000"), icon);

// Output to Stream -> File
using var image = surface.Snapshot();
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
using var stream = File.OpenWrite(@"output/hoge.png");
data.SaveTo(stream);
13 changes: 13 additions & 0 deletions samples/LinuxRunSamples/6.0/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash -ex

FRAMEWORK=netcoreapp3.1
while [ $# -gt 0 ]; do
case $1 in
-f) FRAMEWORK=$2; shift 2; ;;
*) shift ;;
esac
done

apt update && apt install -y libfontconfig1

dotnet run --csproj BuildTest.csproj -f "${FRAMEWORK}"
Binary file added samples/LinuxRunSamples/6.0/samples/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions samples/LinuxRunSamples/6.0_nodep/BuildTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SkiaSharp.QrCode" Version="0.4.1" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.2" />
</ItemGroup>

<ItemGroup>
<None Update="samples\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
39 changes: 39 additions & 0 deletions samples/LinuxRunSamples/6.0_nodep/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using SkiaSharp;
using System;
using System.IO;
using SkiaSharp.QrCode;
using SkiaSharp.QrCode.Models;

Directory.CreateDirectory("output");

var content = "testtesttest";
using var generator = new QRCodeGenerator();
// Generate QrCode
var qr = generator.CreateQrCode(content, ECCLevel.L);

// Render to canvas
var info = new SKImageInfo(512, 512);
using var surface = SKSurface.Create(info);
var canvas = surface.Canvas;
canvas.Render(qr, info.Width, info.Height);

// gen color
// yellow https://rgb.to/yellow
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(60,100,50));
// red https://rgb.to/red
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(0, 100, 50));

// gen icon
var logo = File.ReadAllBytes("samples/test.png");
var icon = new IconData
{
Icon = SKBitmap.Decode(logo),
IconSizePercent = 10,
};
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.Parse("000000"), icon);

// Output to Stream -> File
using var image = surface.Snapshot();
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
using var stream = File.OpenWrite(@"output/hoge.png");
data.SaveTo(stream);
Loading

0 comments on commit 96d9eb4

Please sign in to comment.