Skip to content

Commit

Permalink
pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
aloneguid committed Nov 6, 2024
1 parent a904fbb commit 4cd48b9
Show file tree
Hide file tree
Showing 22 changed files with 430 additions and 1,124 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@ jobs:
8.0.x
- name: Build
run: dotnet build src/Config.Net.sln --configuration Release /p:Version=${{ env.VERSION }} /p:FileVersion=${{ env.VERSION }} /p:AssemblyVersion=${{ env.ASM_VERSION }}
- name: Upload a Build Artifact
- name: collect artifacts
run: |
mkdir -p artifacts
cp src/Config.Net/bin/Release/*.nupkg artifacts/
echo "${{ env.VERSION }}" >> artifacts/version.txt
cp docs/release-history.md artifacts/
grep -m 2 -B 1000 '^## ' artifacts/release-history.md | tail -n +3 | head -n -2 > artifacts/release-notes.md
cat artifacts/release-notes.md
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget
path: src/**/*.nupkg
name: bin
path: artifacts/*

# publish:
# needs:
Expand Down
25 changes: 2 additions & 23 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -745,35 +745,14 @@ Azure function [configuration](https://docs.microsoft.com/en-us/azure/azure-func

## Sponsorship

This framework is free and can be used for free, open source and commercial applications. Config.Net (all code, NuGets and binaries) are under the [MIT License (MIT)](https://github.com/aloneguid/config/blob/master/LICENSE). It's battle-tested and used by many awesome people and organisations. So hit the magic ⭐️ button, we appreciate it!!! 🙏 Thx!
This framework is free and can be used for free, open source and commercial applications. Config.Net (all code, NuGets and binaries) are under the [MIT License (MIT)](https://github.com/aloneguid/config/blob/master/LICENSE). It's battle-tested and used by many awesome people and organisations. So hit the magic ⭐️ button, I appreciate it!!! 🙏 Thx!

The core team members, Config.Net contributors and contributors in the ecosystem do this open source work in their free time. If you use Config.Net, and you'd like us to invest more time on it, please donate. This project increases your income/productivity/usabilty too.

### Why charge/sponsor for open source?

* [Open-Source Maintainers are Jerks! | Nick Randolph & Geoffrey Huntley](https://vimeo.com/296579853)
* [FOSS is free as in toilet | Geoffroy Couprie](http://unhandledexpression.com/general/2018/11/27/foss-is-free-as-in-toilet.html)
* [How to Charge for your Open Source | Mike Perham](https://www.mikeperham.com/2015/11/23/how-to-charge-for-your-open-source/)
* [Sustain OSS: The Report](https://sustainoss.org/assets/pdf/SustainOSS-west-2017-report.pdf)
* [Open Source Maintainers Owe You Nothing | Mike McQuaid](https://mikemcquaid.com/2018/03/19/open-source-maintainers-owe-you-nothing/)
* [Who should fund open source projects? | Jane Elizabeth](https://jaxenter.com/who-funds-open-source-projects-133222.html)
* [Apply at OSS Inc today| Ryan Chenkie](https://twitter.com/ryanchenkie/status/1067801413974032385)
* [The Ethics of Unpaid Labor and the OSS Community | Ashe Dryden](https://www.ashedryden.com/blog/the-ethics-of-unpaid-labor-and-the-oss-community)

### Backers

Become a backer and show your support to our open source project.

[![](https://opencollective.com/config/backers.svg)](https://opencollective.com/config#support)

### Sponsors

Does your company use Config.Net? Ask your manager or marketing team if your company would be interested in supporting our project. Support will allow the maintainers to dedicate more time for maintenance and new features for everyone. Also, your company's logo will show here - who doesn't want a little extra exposure?

[![](https://opencollective.com/config/sponsors.svg)](https://opencollective.com/config#sponsor)


## Special Thanks

Thanks to [JetBrains](https://www.jetbrains.com) for kindly providing an open-source license to their amazing [Rider IDE](https://www.jetbrains.com/rider/) for Open Source Development.
![Rider logo](https://resources.jetbrains.com/storage/products/company/brand/logos/Rider_icon.svg)
This project would not be possible without [Castle DynamicProxy project](https://www.castleproject.org/projects/dynamicproxy/) - a lightweight .NET proxy generator.
5 changes: 5 additions & 0 deletions docs/release-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 5.3.0

### Improvements

- Upgraded dependent libraries.
2 changes: 0 additions & 2 deletions docs/release-notes.md

This file was deleted.

45 changes: 0 additions & 45 deletions src/Config.Net.Tests/AssemblyConfigStoreTest.cs

This file was deleted.

11 changes: 4 additions & 7 deletions src/Config.Net.Tests/Config.Net.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>3.0.0</VersionPrefix>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>


<ItemGroup>
<None Update="TestData\.env">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand All @@ -24,17 +22,16 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Config.Net.Yaml\Config.Net.Yaml.csproj" />
<ProjectReference Include="..\Config.Net\Config.Net.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Storage.Net" Version="9.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="netbox" Version="2.5.3" />
</ItemGroup>
<ItemGroup>
Expand Down
202 changes: 92 additions & 110 deletions src/Config.Net.Tests/Stores/JsonFileCOnfigStoreTest.cs
Original file line number Diff line number Diff line change
@@ -1,117 +1,99 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Config.Net.Stores;
using Xunit;
using YamlDotNet.Core.Tokens;

namespace Config.Net.Tests.Stores
{
public class JsonFileConfigStoreTest : AbstractTestFixture, IDisposable
{
private string _path;
private JsonConfigStore _store;

public JsonFileConfigStoreTest()
{
_path = Path.Combine(BuildDir.FullName, "TestData", "sample.json");
_store = new JsonConfigStore(_path, true);
}

[Fact]
public void Read_inline_property()
{
string key = _store.Read("ApplicationInsights.InstrumentationKey");

Assert.NotNull(key);
}

[Fact]
public void Write_inline_property_reads_back()
{
if (!_store.CanWrite) return;

string key = "ApplicationInsights.InstrumentationKey";

_store.Write(key, "123");

Assert.Equal("123", _store.Read(key));
}

[Fact]
public void Write_new_value_hierarchically()
{
if (!_store.CanWrite) return;

string key = "One.Two.Three";

_store.Write(key, "111");

Assert.Equal("111", _store.Read(key));
}

[Fact]
public void AliasesOnCollections()
{
IMyConfigUsingAliases myConfig = new ConfigurationBuilder<IMyConfigUsingAliases>()
.UseConfigStore(_store)
.Build();

Assert.NotNull(myConfig.Credentials);
foreach (ICredsWithAlias c in myConfig.Credentials)
{
if (c.Name == "user1")
{
Assert.Equal("pass1", c.Pass);
}
else if (c.Name == "user2")
{
Assert.Equal("pass2", c.Pass);

namespace Config.Net.Tests.Stores {
public class JsonFileConfigStoreTest : AbstractTestFixture, IDisposable {
private string _path;
private JsonConfigStore _store;

public JsonFileConfigStoreTest() {
_path = Path.Combine(BuildDir.FullName, "TestData", "sample.json");
_store = new JsonConfigStore(_path, true);
}

[Fact]
public void Read_inline_property() {
string key = _store.Read("ApplicationInsights.InstrumentationKey");

Assert.NotNull(key);
}

[Fact]
public void Write_inline_property_reads_back() {
if(!_store.CanWrite)
return;

string key = "ApplicationInsights.InstrumentationKey";

_store.Write(key, "123");

Assert.Equal("123", _store.Read(key));
}

[Fact]
public void Write_new_value_hierarchically() {
if(!_store.CanWrite)
return;

string key = "One.Two.Three";

_store.Write(key, "111");

Assert.Equal("111", _store.Read(key));
}

[Fact]
public void AliasesOnCollections() {
IMyConfigUsingAliases myConfig = new ConfigurationBuilder<IMyConfigUsingAliases>()
.UseConfigStore(_store)
.Build();

Assert.NotNull(myConfig.Credentials);
foreach(ICredsWithAlias c in myConfig.Credentials) {
if(c.Name == "user1") {
Assert.Equal("pass1", c.Pass);
} else if(c.Name == "user2") {
Assert.Equal("pass2", c.Pass);
} else {
Assert.Equal("user1", c.Name);
}
}
else
{
Assert.Equal("user1", c.Name);
}

[Fact]
public void TestCreatingFileInMissingFolder() {
_path = Path.Combine("C:\\temp", "TestData", "sample.json");

if(Directory.Exists(_path)) {
Directory.Delete(_path);
}
}
}

[Fact]
public void TestCreatingFileInMissingFolder()
{
_path = Path.Combine("C:\\temp", "TestData", "sample.json");

if (Directory.Exists(_path))
{
Directory.Delete(_path);
}

string key = "One.Two.Three";

_store = new JsonConfigStore(_path, true);
_store.Write(key, "111");

Assert.Equal("111", _store.Read(key));

Assert.True(File.Exists(_path));
}

public void Dispose()
{
_store.Dispose();
}
}
public interface ICredsWithAlias
{
[Option(Alias = "Username")]
string Name { get; set; }
[Option(Alias = "Password")]
string Pass { get; set; }
}

public interface IMyConfigUsingAliases
{
[Option(Alias = "Creds")]
IEnumerable<ICredsWithAlias> Credentials { get; }
}
}

string key = "One.Two.Three";

_store = new JsonConfigStore(_path, true);
_store.Write(key, "111");

Assert.Equal("111", _store.Read(key));

Assert.True(File.Exists(_path));
}

public void Dispose() {
_store.Dispose();
}
}
public interface ICredsWithAlias {
[Option(Alias = "Username")]
string Name { get; set; }
[Option(Alias = "Password")]
string Pass { get; set; }
}

public interface IMyConfigUsingAliases {
[Option(Alias = "Creds")]
IEnumerable<ICredsWithAlias> Credentials { get; }
}
}
37 changes: 0 additions & 37 deletions src/Config.Net.Tests/Stores/YamlFileConfigStoreTest.cs

This file was deleted.

Loading

0 comments on commit 4cd48b9

Please sign in to comment.