Skip to content
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

Add GitHub Actions run to build and test changes #2

Open
wants to merge 4 commits into
base: emclient
Choose a base branch
from
Open
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
47 changes: 47 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: .NET

on:
push:
branches: [ emclient ]
pull_request:
branches: [ emclient ]

jobs:
build:

strategy:
matrix:
os: [windows-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
path: "SQLitePCL.raw"
- uses: actions/checkout@v2
with:
repository: ericsink/cb
path: "cb"
- name: Setup .NET 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 2.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.x
- name: Add msbuild to PATH
if: startsWith(matrix.os, 'windows')
uses: microsoft/[email protected]
- name: Install T4
run: dotnet tool install --global dotnet-t4
- name: Build
run: |
cd SQLitePCL.raw/build
dotnet run
28 changes: 17 additions & 11 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
open System
open System.Diagnostics
open System.IO
open System.Runtime.InteropServices
open System.Xml.Linq
open System.Linq

Expand Down Expand Up @@ -165,25 +166,30 @@ let main argv =

//exec "dotnet" (sprintf "run --framework=%s" "net5.0") (Path.Combine(top, "test_nupkgs", "cil", "fake_xunit"))

exec "dotnet" "test" (Path.Combine(top, "test_nupkgs", "e_sqlite3", "real_xunit"))
exec "dotnet" "test" (Path.Combine(top, "test_nupkgs", "winsqlite3", "real_xunit"))
exec "dotnet" "test" (Path.Combine(top, "test_nupkgs", "e_sqlcipher", "real_xunit"))
// TODO do bundle_sqlite3 real_xunit here?
let real_xunit_dirs = [
yield "e_sqlite3"
yield "e_sqlcipher"
// TODO do bundle_sqlite3 real_xunit here?
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then yield "winsqlite3"
]

let fake_xunit_tfms = [
"netcoreapp2.1"
"netcoreapp3.1"
//"net461"
yield "netcoreapp2.1"
yield "netcoreapp3.1"
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then yield "net461"
]

let fake_xunit_dirs = [
"e_sqlite3"
"e_sqlcipher"
"winsqlite3"
"sqlite3"
yield "e_sqlite3"
yield "e_sqlcipher"
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then yield "winsqlite3"
yield "sqlite3"
]

for tfm in fake_xunit_tfms do
for dir in real_xunit_dirs do
let args = sprintf "test --framework=%s" tfm
exec "dotnet" args (Path.Combine(top, "test_nupkgs", dir, "real_xunit"))
for dir in fake_xunit_dirs do
let args = sprintf "run --framework=%s" tfm
exec "dotnet" args (Path.Combine(top, "test_nupkgs", dir, "fake_xunit"))
Expand Down
14 changes: 9 additions & 5 deletions gen_nuspecs/gen_nuspecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,13 @@ string cpu
}

static string make_cb_path_mac(
WhichLib lib
WhichLib lib,
string cpu
)
{
var dir_name = lib.AsString_basename_in_cb();
var lib_name = lib.AsString_libname_in_cb(LibSuffix.DYLIB);
return Path.Combine("$cb_bin_path$", dir_name, "mac", lib_name);
return Path.Combine("$cb_bin_path$", dir_name, "mac", cpu, lib_name);
}

static void write_nuspec_file_entry_native_linux(
Expand All @@ -344,13 +345,15 @@ XmlWriter f

static void write_nuspec_file_entry_native_mac(
WhichLib lib,
string cpu_in_cb,
string rid,
XmlWriter f
)
{
var filename = lib.AsString_libname_in_nupkg(LibSuffix.DYLIB);
write_nuspec_file_entry_native(
make_cb_path_mac(lib),
"osx-x64",
make_cb_path_mac(lib, cpu_in_cb),
rid,
filename,
f
);
Expand Down Expand Up @@ -408,7 +411,8 @@ XmlWriter f
write_nuspec_file_entry_native_uwp(lib, win_toolset, "appcontainer", "x64", "win10-x64", f);
write_nuspec_file_entry_native_uwp(lib, win_toolset, "appcontainer", "x86", "win10-x86", f);

write_nuspec_file_entry_native_mac(lib, f);
write_nuspec_file_entry_native_mac(lib, "x86_64", "osx-x64", f);
write_nuspec_file_entry_native_mac(lib, "arm64", "osx-arm64", f);

write_nuspec_file_entry_native_linux(lib, "x64", "linux-x64", f);
write_nuspec_file_entry_native_linux(lib, "x86", "linux-x86", f);
Expand Down
50 changes: 41 additions & 9 deletions src/common/tests_xunit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using SQLitePCL;
using SQLitePCL.Ugly;
Expand Down Expand Up @@ -67,10 +68,13 @@ public void test_GetZeroTerminatedUTF8Bytes()
[Fact]
public void test_call_sqlite3_enable_load_extension()
{
using (sqlite3 db = ugly.open(":memory:"))
if (0 == raw.sqlite3_compileoption_used("SQLITE_OMIT_LOAD_EXTENSION"))
{
var rc = raw.sqlite3_enable_load_extension(db, 0);
Assert.Equal(raw.SQLITE_OK, rc);
using (sqlite3 db = ugly.open(":memory:"))
{
var rc = raw.sqlite3_enable_load_extension(db, 0);
Assert.Equal(raw.SQLITE_OK, rc);
}
}
}

Expand Down Expand Up @@ -676,6 +680,10 @@ public void test_last_insert_rowid()
[Fact]
public void test_keywords()
{
var version = raw.sqlite3_libversion_number();

if (version < 3024000) return; // Added in 3.24.0: https://sqlite.org/releaselog/3_24_0.html

var n = SQLitePCL.raw.sqlite3_keyword_count();
Assert.True(n > 0);
for (var i=0; i<n; i++)
Expand Down Expand Up @@ -777,10 +785,17 @@ public void test_threadsafe()
public void test_enable_shared_cache()
{
int result = raw.sqlite3_enable_shared_cache(1);
Assert.Equal(raw.SQLITE_OK, result);
// https://www.sqlite.org/c3ref/enable_shared_cache.html
// Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 and will always
// return SQLITE_MISUSE. On those systems, shared cache mode should be enabled
// per-database connection via sqlite3_open_v2() with SQLITE_OPEN_SHAREDCACHE.
if (result != raw.SQLITE_MISUSE)
{
Assert.Equal(raw.SQLITE_OK, result);

result = raw.sqlite3_enable_shared_cache(0);
Assert.Equal(raw.SQLITE_OK, result);
result = raw.sqlite3_enable_shared_cache(0);
Assert.Equal(raw.SQLITE_OK, result);
}
}

[Fact]
Expand Down Expand Up @@ -811,12 +826,15 @@ public void test_sqlite3_soft_heap_limit64()
}

[Fact]
public void sqlite3_hard_heap_limit64()
public void test_sqlite3_hard_heap_limit64()
{
var version = raw.sqlite3_libversion_number();

if (version < 3031001) return; // Added in 3.31.1: https://sqlite.org/releaselog/3_31_1.html

// Skip failing test on macOS system provided libsqlite3.dylib
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && raw.GetNativeLibraryName() == "sqlite3")
return;

var query = raw.sqlite3_hard_heap_limit64(-1);
Assert.True(query >= 0);

Expand All @@ -831,11 +849,17 @@ public void sqlite3_hard_heap_limit64()
[Fact]
public void test_sqlite3_status()
{
// Skip failing test on macOS system provided libsqlite3.dylib
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && raw.GetNativeLibraryName() == "sqlite3")
return;

using (sqlite3 db = ugly.open(":memory:"))
{
int current;
int highwater;
ugly.sqlite3_status(raw.SQLITE_STATUS_MEMORY_USED, out current, out highwater, 0);

var rc = raw.sqlite3_status(raw.SQLITE_STATUS_MEMORY_USED, out current, out highwater, 0);
Assert.Equal(raw.SQLITE_OK, rc);

Assert.True(current > 0);
Assert.True(highwater > 0);
Expand Down Expand Up @@ -1524,6 +1548,10 @@ public void test_stmt_busy()
[Fact]
public void test_stmt_isexplain()
{
var version = raw.sqlite3_libversion_number();

if (version < 3028000) return; // Added in 3.28.0: https://sqlite.org/releaselog/3_28_0.html

using (sqlite3 db = ugly.open(":memory:"))
{
db.exec("CREATE TABLE foo (x int);");
Expand Down Expand Up @@ -2817,6 +2845,10 @@ public class class_test_sqlite3_config
[Order(0)]
public void test_log()
{
// Skip failing test on macOS system provided libsqlite3.dylib
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && raw.GetNativeLibraryName() == "sqlite3")
return;

var msgs = new List<string>();
var rc = raw.sqlite3_config_log(
(v, errcode, msg) => msgs.Add(msg),
Expand Down