Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc045d021c | |||
| aa14333604 | |||
| 72c11f77e5 | |||
| caf34e707c | |||
| b96775f1ed | |||
| 91e84a5059 | |||
| 8b1c56d310 | |||
| 6a2b52475f | |||
| ddc7429dc5 | |||
| 3c80c46c91 |
@@ -6,6 +6,9 @@ on:
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
env:
|
||||
BBDOX__PG__PORT: 8301
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
|
||||
@@ -13,12 +16,13 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
dotnet-version: [ "6.0", "7.0", "8.0" ]
|
||||
postgres-version: [ "12", "13", "14", "15", "latest" ]
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:${{ matrix.postgres-version }}
|
||||
networks:
|
||||
- runner_overlay
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
options: >-
|
||||
@@ -27,20 +31,32 @@ jobs:
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
- "8301:5432"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET ${{ matrix.dotnet-version }}.x
|
||||
- name: Setup .NET 6
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: ${{ matrix.dotnet-version }}.x
|
||||
dotnet-version: "6.0.x"
|
||||
- name: Setup .NET 7
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: "7.0.x"
|
||||
- name: Setup .NET 8
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: "8.0.x"
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore src/BitBadger.Documents.sln
|
||||
- name: Build
|
||||
run: dotnet build src/BitBadger.Documents.sln --no-restore -f net${{ matrix.dotnet-version }}
|
||||
- name: Test ${{ matrix.dotnet-version }} against PostgreSQL ${{ matrix.postgres-version }}
|
||||
run: dotnet run --project src/Tests/BitBadger.Documents.Tests.fsproj -f net${{ matrix.dotnet-version }}
|
||||
run: dotnet build src/BitBadger.Documents.sln --no-restore
|
||||
- name: Test .NET 6 against PostgreSQL ${{ matrix.postgres-version }}
|
||||
run: dotnet run --project src/Tests/BitBadger.Documents.Tests.fsproj -f net6.0
|
||||
- name: Test .NET 7 against PostgreSQL ${{ matrix.postgres-version }}
|
||||
run: dotnet run --project src/Tests/BitBadger.Documents.Tests.fsproj -f net7.0
|
||||
- name: Test .NET 8 against PostgreSQL ${{ matrix.postgres-version }}
|
||||
run: dotnet run --project src/Tests/BitBadger.Documents.Tests.fsproj -f net8.0
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-test
|
||||
@@ -1,7 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageReleaseNotes>Added Field type for by-field operations</PackageReleaseNotes>
|
||||
<Description>Common files for PostgreSQL and SQLite document database libraries</Description>
|
||||
<PackageReleaseNotes>v3 release</PackageReleaseNotes>
|
||||
<PackageTags>JSON Document SQL</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
||||
<FileVersion>3.0.0.0</FileVersion>
|
||||
<VersionPrefix>3.0.0</VersionPrefix>
|
||||
<VersionSuffix>rc-2</VersionSuffix>
|
||||
<Authors>danieljsummers</Authors>
|
||||
<Company>Bit Badger Solutions</Company>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<PackageProjectUrl>https://bitbadger.solutions/open-source/relational-documents/</PackageProjectUrl>
|
||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||
<RepositoryUrl>https://github.com/bit-badger/BitBadger.Documents</RepositoryUrl>
|
||||
<RepositoryUrl>https://git.bitbadger.solutions/bit-badger/BitBadger.Documents</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<Copyright>MIT License</Copyright>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageReleaseNotes>Adds Field type for by-field operations (BREAKING from rc-1); adds RemoveFields* functions</PackageReleaseNotes>
|
||||
<Description>Use PostgreSQL as a document database</Description>
|
||||
<PackageReleaseNotes>v3 release; official replacement for BitBadger.Npgsql.Documents</PackageReleaseNotes>
|
||||
<PackageTags>JSON Document PostgreSQL Npgsql</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ Retrieve all customers:
|
||||
```csharp
|
||||
// C#; parameter is table name
|
||||
// Find.All type signature is Func<string, Task<List<TDoc>>>
|
||||
var customers = await Find.All("customer");
|
||||
var customers = await Find.All<Customer>("customer");
|
||||
```
|
||||
|
||||
```fsharp
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageReleaseNotes>Adds Field type for by-field operations (BREAKING from rc-1); adds RemoveFields* functions</PackageReleaseNotes>
|
||||
<Description>Use SQLite as a document database</Description>
|
||||
<PackageReleaseNotes>Overall v3 release; initial release supporting SQLite</PackageReleaseNotes>
|
||||
<PackageTags>JSON Document SQLite</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ Retrieve all customers:
|
||||
```csharp
|
||||
// C#; parameter is table name
|
||||
// Find.All type signature is Func<string, Task<List<TDoc>>>
|
||||
var customers = await Find.All("customer");
|
||||
var customers = await Find.All<Customer>("customer");
|
||||
```
|
||||
|
||||
```fsharp
|
||||
@@ -72,28 +72,28 @@ Count customers in Atlanta:
|
||||
|
||||
```csharp
|
||||
// C#; parameters are table name, field, operator, and value
|
||||
// Count.ByField type signature is Func<string, string, Op, object, Task<long>>
|
||||
var customerCount = await Count.ByField("customer", "City", Op.EQ, "Atlanta");
|
||||
// Count.ByField type signature is Func<string, Field, Task<long>>
|
||||
var customerCount = await Count.ByField("customer", Field.EQ("City", "Atlanta"));
|
||||
```
|
||||
|
||||
```fsharp
|
||||
// F#
|
||||
// Count.byField type signature is string -> string -> Op -> obj -> Task<int64>
|
||||
let! customerCount = Count.byField "customer" "City" EQ "Atlanta"
|
||||
// Count.byField type signature is string -> Field -> Task<int64>
|
||||
let! customerCount = Count.byField "customer" (Field.EQ "City" "Atlanta")
|
||||
```
|
||||
|
||||
Delete customers in Chicago: _(no offense, Second City; just an example...)_
|
||||
|
||||
```csharp
|
||||
// C#; parameters are same as above, except return is void
|
||||
// Delete.ByField type signature is Func<string, string, Op, object, Task>
|
||||
await Delete.ByField("customer", "City", Op.EQ, "Chicago");
|
||||
// Delete.ByField type signature is Func<string, Field, Task>
|
||||
await Delete.ByField("customer", Field.EQ("City", "Chicago"));
|
||||
```
|
||||
|
||||
```fsharp
|
||||
// F#
|
||||
// Delete.byField type signature is string -> string -> Op -> obj -> Task<unit>
|
||||
do! Delete.byField "customer" "City" EQ "Chicago"
|
||||
do! Delete.byField "customer" (Field.EQ "City" "Chicago")
|
||||
```
|
||||
|
||||
## More Information
|
||||
|
||||
@@ -53,65 +53,55 @@ public static class PostgresDb
|
||||
/// The host for the database
|
||||
/// </summary>
|
||||
private static readonly Lazy<string> DbHost = new(() =>
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postgres.DbHost") switch
|
||||
Environment.GetEnvironmentVariable("BBDOX_PG_HOST") switch
|
||||
{
|
||||
null => "localhost",
|
||||
var host when host.Trim() == "" => "localhost",
|
||||
var host => host
|
||||
};
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// The port for the database
|
||||
/// </summary>
|
||||
private static readonly Lazy<int> DbPort = new(() =>
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postgres.DbPort") switch
|
||||
Environment.GetEnvironmentVariable("BBDOX_PG_PORT") switch
|
||||
{
|
||||
null => 5432,
|
||||
var port when port.Trim() == "" => 5432,
|
||||
var port => int.Parse(port)
|
||||
};
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// The database itself
|
||||
/// </summary>
|
||||
private static readonly Lazy<string> DbDatabase = new(() =>
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postres.DbDatabase") switch
|
||||
Environment.GetEnvironmentVariable("BBDOX_PG_DATABASE") switch
|
||||
{
|
||||
null => "postgres",
|
||||
var db when db.Trim() == "" => "postgres",
|
||||
var db => db
|
||||
};
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// The user to use in connecting to the database
|
||||
/// </summary>
|
||||
private static readonly Lazy<string> DbUser = new(() =>
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postgres.DbUser") switch
|
||||
Environment.GetEnvironmentVariable("BBDOX_PG_USER") switch
|
||||
{
|
||||
null => "postgres",
|
||||
var user when user.Trim() == "" => "postgres",
|
||||
var user => user
|
||||
};
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// The password to use for the database
|
||||
/// </summary>
|
||||
private static readonly Lazy<string> DbPassword = new(() =>
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postrgres.DbPwd") switch
|
||||
Environment.GetEnvironmentVariable("BBDOX_PG_PWD") switch
|
||||
{
|
||||
null => "postgres",
|
||||
var pwd when pwd.Trim() == "" => "postgres",
|
||||
var pwd => pwd
|
||||
};
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
open Expecto
|
||||
open BitBadger.Documents.Tests.CSharp
|
||||
|
||||
let postgresOnly =
|
||||
match System.Environment.GetEnvironmentVariable "BBDOX_PG_ONLY" with
|
||||
| null -> false
|
||||
| "true" -> true
|
||||
| _ -> false
|
||||
|
||||
let allTests =
|
||||
testList
|
||||
"BitBadger.Documents"
|
||||
[ CommonTests.all
|
||||
testList "BitBadger.Documents" [
|
||||
if not postgresOnly then
|
||||
CommonTests.all
|
||||
CommonCSharpTests.Unit
|
||||
PostgresTests.all
|
||||
PostgresCSharpTests.All
|
||||
PostgresExtensionTests.integrationTests
|
||||
testSequenced PostgresCSharpExtensionTests.Integration
|
||||
if not postgresOnly then
|
||||
SqliteTests.all
|
||||
SqliteCSharpTests.All
|
||||
SqliteExtensionTests.integrationTests
|
||||
testSequenced SqliteCSharpExtensionTests.Integration ]
|
||||
testSequenced SqliteCSharpExtensionTests.Integration
|
||||
]
|
||||
|
||||
[<EntryPoint>]
|
||||
let main args = runTestsWithCLIArgs [] args allTests
|
||||
|
||||
13
src/package.sh
Executable file
13
src/package.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo --- Package Common library
|
||||
dotnet pack Common/BitBadger.Documents.Common.fsproj -c Release
|
||||
cp Common/bin/Release/BitBadger.Documents.Common.*.nupkg .
|
||||
|
||||
echo --- Package PostgreSQL library
|
||||
dotnet pack Postgres/BitBadger.Documents.Postgres.fsproj -c Release
|
||||
cp Postgres/bin/Release/BitBadger.Documents.Postgres.*.nupkg .
|
||||
|
||||
echo --- Package SQLite library
|
||||
dotnet pack Sqlite/BitBadger.Documents.Sqlite.fsproj -c Release
|
||||
cp Sqlite/bin/Release/BitBadger.Documents.Sqlite.*.nupkg .
|
||||
33
src/test_all.sh
Executable file
33
src/test_all.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
dotnet clean BitBadger.Documents.sln
|
||||
dotnet restore BitBadger.Documents.sln
|
||||
dotnet build BitBadger.Documents.sln --no-restore
|
||||
|
||||
cd ./Tests || exit
|
||||
|
||||
export BBDOX_PG_PORT=8301
|
||||
PG_VERSIONS=('12' '13' '14' '15' 'latest')
|
||||
NET_VERSIONS=('6.0' '7.0' '8.0')
|
||||
|
||||
for PG_VERSION in "${PG_VERSIONS[@]}"
|
||||
do
|
||||
echo Starting PostgreSQL:$PG_VERSION
|
||||
docker run -d -p $BBDOX_PG_PORT:5432 --name pg_test -e POSTGRES_PASSWORD=postgres postgres:$PG_VERSION
|
||||
sleep 4
|
||||
for NET_VERSION in "${NET_VERSIONS[@]}"
|
||||
do
|
||||
if [ "$PG_VERSION" = "latest" ]; then
|
||||
echo Testing SQLite and PostgreSQL under .NET $NET_VERSION...
|
||||
dotnet run -f net$NET_VERSION
|
||||
else
|
||||
echo Testing PostgreSQL v$PG_VERSION under .NET $NET_VERSION...
|
||||
BBDOX_PG_ONLY="true" dotnet run -f net$NET_VERSION
|
||||
fi
|
||||
done
|
||||
docker stop pg_test
|
||||
sleep 2
|
||||
docker rm pg_test
|
||||
done
|
||||
|
||||
cd .. || exit
|
||||
Reference in New Issue
Block a user