Skip to content

Commit

Permalink
Merge branch 'dev=main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Mar 12, 2024
2 parents f40483d + da57d7c commit f5155a2
Show file tree
Hide file tree
Showing 46 changed files with 1,513 additions and 345 deletions.
33 changes: 33 additions & 0 deletions .github/scripts/check_new_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
import os
from datetime import datetime, timedelta, timezone

current_utc_time = datetime.utcnow()
current_utc_time = current_utc_time.replace(tzinfo=timezone.utc)

print("Args list: ", sys.argv)

time_str = sys.argv[1]
days_deference = int(sys.argv[2])

datetime_obj = datetime.fromisoformat(time_str)
datetime_obj = datetime_obj.replace(tzinfo=timezone.utc)

time_difference = current_utc_time - datetime_obj

print("Time delta: ", time_difference)

has_new_commit = time_difference > timedelta(days=days_deference)
env_to_add = "HAS_NEW_COMMIT="

if time_difference > timedelta(days=days_deference):
print("No new commit found. Check in env var: [env.HAS_NEW_COMMIT].")
env_to_add = env_to_add + 'false'
else:
print("New commit found. Check in env var: [env.HAS_NEW_COMMIT].")
env_to_add = env_to_add + 'true'

command = "echo \"" + env_to_add + "\" >> $env:GITHUB_ENV"

with open('set_env.ps1', 'w', encoding='utf-8') as file:
file.write(command)
99 changes: 50 additions & 49 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
name: daily-build
name: Daily Build

on:
schedule:
- cron: '0 6 * * 0'
- cron: "0 6 * * 0"

jobs:
build:

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
include-prerelease: false

- name: Build
shell: pwsh
run: |
cd Common.BasicHelper
dotnet build -c Release
cd bin/Release
$out = ls
if ("$out" -match 'Common.BasicHelper.(\d*).(\d*).(\d*).(\d*).nupkg') {
$v1 = $Matches.1
$v2 = $Matches.2
$v3 = $Matches.3
$v4 = $Matches.4
$version = "$v1.$v2.$v3.$v4"
echo "version=$version"
echo "version=$version" >> $env:GITHUB_ENV
echo "canRelease=true" >> $env:GITHUB_ENV
} else {
echo "canRelease=false" >> $env:GITHUB_ENV
}
cd ../../..
- name: Create Release and Upload Release Asset
if: ${{ env.canRelease == 'true' }}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.version }}
name: Weekly Release v${{ env.version }}
body: Auto release by Actions.
draft: false
prerelease: true
files: |
Common.BasicHelper/bin/Release/*.nupkg
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
- name: Build
working-directory: Common.BasicHelper
shell: pwsh
run: |
dotnet build -c Release
cd bin/Release
$out = ls
if ("$out" -match 'Common.BasicHelper.(\d*).(\d*).(\d*).(\d*).nupkg') {
$v1 = $Matches.1
$v2 = $Matches.2
$v3 = $Matches.3
$v4 = $Matches.4
$version = "$v1.$v2.$v3.$v4"
echo "version=$version"
echo "version=$version" >> $env:GITHUB_ENV
echo "CAN_RELEASE=true" >> $env:GITHUB_ENV
} else {
echo "CAN_RELEASE=false" >> $env:GITHUB_ENV
}
- name: Check New Commit
shell: pwsh
run: |
$latest_commit_date=((git show --pretty=format:"%cd" --date=iso) -split '\n')[0]
py ./.github/scripts/check_new_commit.py "$latest_commit_date" 7
./set_env.ps1
- name: Create Release and Upload Release Asset
uses: softprops/action-gh-release@v1
if: env.CAN_RELEASE == 'true' && env.HAS_NEW_COMMIT == 'true'
with:
tag_name: v${{ env.version }}
name: Auto Release v${{ env.version }} on ${{ env.date }}
body: Auto release by Actions.
draft: false
prerelease: true
files: |
Common.BasicHelper/bin/Release/*.nupkg
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
dotnet-version: |
6.0.x
7.0.x
include-prerelease: false
- name: Build
run: |
Expand Down
26 changes: 14 additions & 12 deletions Common.BasicHelper.Samples/Common.BasicHelper.Samples.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'http' " />
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Common.BasicHelper\Common.BasicHelper.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common.BasicHelper\Common.BasicHelper.csproj" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions Common.BasicHelper.Samples/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Common.BasicHelper.Core.Shell;
using System.Web;
using Common.BasicHelper.Core.Shell;
using Common.BasicHelper.Graphics.Screen;
using Common.BasicHelper.Utils.Extensions;
using System.Web;

var builder = WebApplication.CreateBuilder(args);

Expand Down
76 changes: 37 additions & 39 deletions Common.BasicHelper.Samples/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40529",
"sslPort": 44396
}
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40529",
"sslPort": 44396
}
},
"profiles": {
"http": {
"commandName": "Project",
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5077",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true
},
"https": {
"commandName": "Project",
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7219;http://localhost:5077",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5077",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7219;http://localhost:5077",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
7 changes: 0 additions & 7 deletions Common.BasicHelper.Samples/Utils/Extensions/StringHelper.cs

This file was deleted.

13 changes: 8 additions & 5 deletions Common.BasicHelper.Test/Common.BasicHelper.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0-preview-23424-02" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
namespace Common.BasicHelper.Core.DataStructure.LineBasedPropertyTable;

[TestClass]
public class LbptSerializer_Tests
{
public class TestClasses
{
public class Person
{
public int Id { get; set; }

public string? Name { get; set; }
}

public class PersonGroup
{
public int? PersonCount => Persons?.Count;

public List<Person>? Persons { get; set; } = [];

public string? GroupName { get; set; } = "Test Group";

public List<int> TestList { get; set; } = [1, 2, 3, 4, 5, 6];
}

internal static PersonGroup GetOneGroup()
{
var group = new PersonGroup();
group.Persons?.Add(new()
{
Id = 0,
Name = "张三"
});
group.Persons?.Add(new()
{
Id = 1,
Name = "李四"
});
return group;
}
}

[TestMethod]
public void Test_Serialize()
{
var group = TestClasses.GetOneGroup();

var result = LbptSerializer.Serialize(group, out var text);

Console.WriteLine(text);

Assert.AreEqual(result.SerializedText, text);
}

[TestMethod]
public void Test_Deserialize()
{
var group = TestClasses.GetOneGroup();

var result = LbptSerializer.Serialize(group, out _).SerializedText;

var des = LbptSerializer.Deserialize<TestClasses.PersonGroup>(result);

Console.WriteLine(LbptSerializer.Serialize(des, out _).SerializedText);
}
}
Loading

0 comments on commit f5155a2

Please sign in to comment.