Skip to content

feat: improves doc, unit tests, ci/cd #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,29 @@ name: Publish NuGet Package
on:
push:
branches:
- release/* # Default release branch
- master
workflow_run:
workflows: [ build-and-test ]
types:
- completed

jobs:
release-please:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- uses: googleapis/release-please-action@v4
with:
target-branch: ${{ github.ref_name }}
manifest-file: .release-please-manifest.json
config-file: release-please-config.json

publish:
needs: release-please
if: ${{ github.repository_owner == 'supabase-community' && startsWith(github.event.head_commit.message, 'chore(master)') && github.ref == 'refs/heads/master' && github.event_name == 'push' }}
name: build, pack & publish
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "4.1.0"
}
4 changes: 3 additions & 1 deletion Postgrest/Postgrest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
</Description>
<PackageIconUrl>https://avatars.githubusercontent.com/u/54469796?s=200&amp;v=4</PackageIconUrl>
<PackageTags>supabase,postgrest</PackageTags>
<!-- x-release-please-start-version -->
<ReleaseVersion>4.1.0</ReleaseVersion>
<PackageVersion>4.1.0</PackageVersion>
<!-- x-release-please-end -->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand All @@ -35,7 +37,7 @@
</PropertyGroup>

<PropertyGroup Condition=" '$(Version)' == '' ">
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">4.1.0</VersionPrefix>
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">4.1.0</VersionPrefix> <!-- x-release-please-version -->
<VersionSuffix Condition=" '$(VersionSuffix)' == '' "></VersionSuffix>
<Version Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version>
<Version Condition=" '$(Version)' == '' ">$(VersionPrefix)</Version>
Expand Down
2 changes: 1 addition & 1 deletion PostgrestTests/ClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace PostgrestTests
[TestClass]
public class ClientTests
{
private const string BaseUrl = "http://localhost:3000";
private const string BaseUrl = "http://localhost:54321/rest/v1";

[TestMethod("Initializes")]
public void TestInitialization()
Expand Down
2 changes: 1 addition & 1 deletion PostgrestTests/CoercionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace PostgrestTests;
[TestClass]
public class CoercionTests
{
private const string BaseUrl = "http://localhost:3000";
private const string BaseUrl = "http://localhost:54321/rest/v1";

[TestMethod("Coercion: Can coerce primitive types")]
public async Task CanCoercePrimitiveTypes()
Expand Down
4 changes: 2 additions & 2 deletions PostgrestTests/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ internal static Client GetHostedClient()
internal static Client GetLocalClient()
{
var url = Environment.GetEnvironmentVariable("SUPABASE_URL");
if (url == null) url = "http://localhost:3000";
if (url == null) url = "http://localhost:54321";
var publicKey = Environment.GetEnvironmentVariable("SUPABASE_PUBLIC_KEY");
if (publicKey == null) publicKey = "reallyreallyreallyreallyverysafe";
if (publicKey == null) publicKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0";

var client = new Client($"{url}/rest/v1", new ClientOptions
{
Expand Down
5 changes: 4 additions & 1 deletion PostgrestTests/LinqTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace PostgrestTests
[TestClass]
public class LinqTests
{
private const string BaseUrl = "http://localhost:3000";
private const string BaseUrl = "http://localhost:54321/rest/v1";

[TestMethod("Linq: Select")]
public async Task TestLinqSelect()
Expand Down Expand Up @@ -123,14 +123,17 @@ await client.Table<KitchenSink>()
.Get();

await client.Table<KitchenSink>()
.Where(x => x.DateTimeValue == null)
.Set(x => x.BooleanValue!, true)
.Update();

await client.Table<KitchenSink>()
.Where(x => x.DateTimeValue == null)
.Set(x => x.BooleanValue, true)
.Update();

await client.Table<KitchenSink>()
.Where(x => x.DateTimeValue == null)
.Set(x => x.StringValue!, null)
.Update();
}
Expand Down
15 changes: 15 additions & 0 deletions PostgrestTests/Models/Category.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using Supabase.Postgrest.Attributes;
using Supabase.Postgrest.Models;

namespace PostgrestTests.Models;

[Table("category")]
public class Category : BaseModel
{
[PrimaryKey("id")]
public Guid Id { get; set; }

[Column("name")]
public string? Name { get; set; }
}
19 changes: 19 additions & 0 deletions PostgrestTests/Models/Product.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using Supabase.Postgrest.Attributes;
using Supabase.Postgrest.Models;

namespace PostgrestTests.Models;

[Table("product")]
public class Product : BaseModel
{

[PrimaryKey("id")]
public Guid Id { get; set; }

[Column("name")]
public string? Name { get; set; }

[Reference(typeof(Category))]
public Category? Category { get; set; }
}
23 changes: 22 additions & 1 deletion PostgrestTests/ReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace PostgrestTests
[TestClass]
public class ReferenceTests
{
private const string BaseUrl = "http://localhost:3000";
private const string BaseUrl = "http://localhost:54321/rest/v1";

[TestMethod("Reference: Returns linked models on a root model.")]
public async Task TestReferenceReturnsLinkedModels()
Expand All @@ -36,13 +36,34 @@ public async Task TestReferenceReturnsLinkedModels()
.Single();

Assert.IsNotNull(person2?.Profile);
Assert.IsTrue(person2.Profile.Email!.Contains("bob"));

var byEmail = await client.Table<Person>()
.Order(x => x.CreatedAt, Ordering.Ascending)
.Filter("profile.email", Operator.Equals, "[email protected]")
.Single();

Assert.IsNotNull(byEmail);

var product = await client.Table<Product>()
.Filter("id", Operator.Equals, "8b8e89a0-63c7-4917-8dc1-7797dc0285f1")
.Single();

Assert.IsNotNull(product);
Assert.AreEqual("product 1", product.Name);

Assert.IsNotNull(product.Category);
Assert.AreEqual("999e4b26-91a8-4ea4-af2c-77a3540f7843", product.Category.Id.ToString());
Assert.AreEqual("category 1", product.Category.Name);

var products = await client.Table<Product>()
.Get();
Assert.IsNotNull(products.Models);
Assert.IsTrue(products.Models.Count == 3);

var productFiltered = products.Models.Find(x => x.Id.ToString() == "8b8e89a0-63c7-4917-8dc1-7797dc0285f1");
Assert.AreEqual("999e4b26-91a8-4ea4-af2c-77a3540f7843", productFiltered?.Category?.Id.ToString());
Assert.AreEqual("category 1", productFiltered?.Category?.Name);
}

[TestMethod("Reference: Can create linked records.")]
Expand Down
2 changes: 1 addition & 1 deletion PostgrestTests/TableWithCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Task Empty()
[TestClass]
public class TableWithCacheTests
{
private const string BaseUrl = "http://localhost:3000";
private const string BaseUrl = "http://localhost:54321/rest/v1";

[TestMethod("Table: Can construct with Caching Provider and raise events.")]
public async Task TestCacheWorksWithGetRequests()
Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
<p align="center">
<img width="300" src=".github/logo.png"/>
</p>
# Supabase.Postgrest

<p align="center">
<img src="https://github.com/supabase/postgrest-csharp/workflows/Build%20And%20Test/badge.svg"/>
<a href="https://www.nuget.org/packages/Supabase.Postgrest/">
<img src="https://img.shields.io/nuget/vpre/Supabase.Postgrest"/>
</a>
</p>
[![Build and Test](https://github.com/supabase-community/postgrest-csharp/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/supabase-community/postgrest-csharp/acionts/workflows/build-and-test.yml)
[![NuGet](https://img.shields.io/nuget/vpre/Supabase.Postgrest)](https://www.nuget.org/packages/Supabase.Postgrest/)

---

Expand All @@ -32,7 +26,7 @@ await client.Table<Movie>()

---

Documentation can be found [here](https://supabase-community.github.io/postgrest-csharp/api/Postgrest.html).
Documentation can be found [here](https://supabase-community.github.io/postgrest-csharp/api/Supabase.Postgrest.html).

Postgrest-csharp is written primarily as a helper library
for [supabase/supabase-csharp](https://github.com/supabase/supabase-csharp), however, it should be easy enough to use
Expand Down
16 changes: 16 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"packages": {
".": {
"changelog-path": "CHANGELOG.md",
"bump-minor-pre-major": false,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"prerelease": false,
"release-type": "simple",
"extra-files": [
"Postgrest/Postgrest.csproj"
]
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
8 changes: 8 additions & 0 deletions supabase/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Supabase
.branches
.temp

# dotenvx
.env.keys
.env.local
.env.*.local
Loading
Loading