Skip to content
Merged
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
109 changes: 109 additions & 0 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Publish NuGet

on:
push:
branches:
- release

concurrency:
group: publish-nuget-release
cancel-in-progress: false

permissions:
contents: read

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true

jobs:
core-validation:
uses: ./.github/workflows/validate-dotnet.yml
permissions:
contents: read

browser-validation:
uses: ./.github/workflows/validate-browsers.yml
permissions:
contents: read

publish:
name: Build and publish package
needs:
- core-validation
- browser-validation
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
id-token: write

steps:
- name: Check out release commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false

- name: Set up .NET 10
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6
with:
dotnet-version: 10.0.x

- name: Calculate package version
id: version
shell: bash
run: |
current_version="$(sed -nE 's:.*<Version>([^<]+)</Version>.*:\1:p' Magic.IndexedDb/Magic.IndexedDb.csproj)"

if [[ ! "${current_version}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "Expected a stable major.minor.patch Version in Magic.IndexedDb.csproj, found '${current_version}'." >&2
exit 1
fi

major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
next_patch="$((10#${patch} + GITHUB_RUN_NUMBER))"
package_version="${major}.${minor}.${next_patch}"

echo "package_version=${package_version}" >> "${GITHUB_OUTPUT}"
echo "Publishing Magic.IndexedDb ${package_version} from ${GITHUB_SHA}."

- name: Restore package project
run: dotnet restore Magic.IndexedDb/Magic.IndexedDb.csproj

- name: Pack
run: >-
dotnet pack Magic.IndexedDb/Magic.IndexedDb.csproj
--configuration Release
--no-restore
--output artifacts
-p:Version=${{ steps.version.outputs.package_version }}
-p:PackageVersion=${{ steps.version.outputs.package_version }}
-p:ContinuousIntegrationBuild=true

- name: Upload package artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: Magic.IndexedDb-${{ steps.version.outputs.package_version }}
path: artifacts/*.nupkg
if-no-files-found: error
overwrite: true

- name: Request temporary NuGet API key
id: login
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1
with:
user: ${{ secrets.NUGET_USER }}

- name: Publish to NuGet.org
run: >-
dotnet nuget push artifacts/*.nupkg
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}"
--source https://api.nuget.org/v3/index.json
--skip-duplicate

- name: Write release summary
run: |
echo "## Published Magic.IndexedDb ${{ steps.version.outputs.package_version }}" >> "${GITHUB_STEP_SUMMARY}"
echo "Source commit: \`${GITHUB_SHA}\`" >> "${GITHUB_STEP_SUMMARY}"
147 changes: 147 additions & 0 deletions .github/workflows/validate-browsers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Browser validation

on:
workflow_call:
pull_request:
push:
branches:
- master
workflow_dispatch:

concurrency:
group: browser-validation-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true

jobs:
browser-validation:
name: ${{ matrix.name }}
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
include:
- name: Chrome integration
os: ubuntu-latest
browser: chromium
- name: Firefox integration
os: ubuntu-latest
browser: firefox
- name: Linux WebKit integration
os: ubuntu-latest
browser: webkit
- name: macOS WebKit integration
os: macos-15
browser: webkit
runs-on: ${{ matrix.os }}

steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false

- name: Set up .NET 10
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6
with:
dotnet-version: 10.0.x

- name: Restore browser tests
run: dotnet restore E2eTest/E2eTest.csproj

- name: Build browser tests
run: dotnet build E2eTest/E2eTest.csproj --configuration Release --no-restore

- name: Install browser and Linux dependencies
if: ${{ runner.os == 'Linux' }}
shell: pwsh
run: E2eTest/bin/Release/net10.0/playwright.ps1 install --with-deps ${{ matrix.browser }}

- name: Install browser on macOS
if: ${{ runner.os == 'macOS' }}
shell: pwsh
run: E2eTest/bin/Release/net10.0/playwright.ps1 install ${{ matrix.browser }}

- name: Run browser integration tests
if: ${{ runner.os == 'Linux' }}
run: >-
dotnet test E2eTest/E2eTest.csproj
--configuration Release
--no-build
--no-restore
--logger "trx;LogFileName=${{ matrix.browser }}-${{ runner.os }}.trx"
--results-directory artifacts/test-results
--
Playwright.BrowserName=${{ matrix.browser }}
Playwright.LaunchOptions.Headless=true

- name: Run macOS WebKit open and registration tests
if: ${{ runner.os == 'macOS' }}
run: >-
dotnet test E2eTest/E2eTest.csproj
--configuration Release
--no-build
--no-restore
--filter "FullyQualifiedName~E2eTest.OpenTest"
--logger "trx;LogFileName=webkit-macOS-open.trx"
--results-directory artifacts/test-results
--
Playwright.BrowserName=webkit
Playwright.LaunchOptions.Headless=true

- name: Run macOS WebKit CRUD and streaming tests
if: ${{ runner.os == 'macOS' }}
run: >-
dotnet test E2eTest/E2eTest.csproj
--configuration Release
--no-build
--no-restore
--filter "FullyQualifiedName~E2eTest.SingleRecordBasicTest"
--logger "trx;LogFileName=webkit-macOS-crud-streaming.trx"
--results-directory artifacts/test-results
--
Playwright.BrowserName=webkit
Playwright.LaunchOptions.Headless=true

- name: Run macOS WebKit query tests
if: ${{ runner.os == 'macOS' }}
run: >-
dotnet test E2eTest/E2eTest.csproj
--configuration Release
--no-build
--no-restore
--filter "FullyQualifiedName~E2eTest.WhereTest"
--logger "trx;LogFileName=webkit-macOS-query.trx"
--results-directory artifacts/test-results
--
Playwright.BrowserName=webkit
Playwright.LaunchOptions.Headless=true

- name: Run macOS WebKit cursor tests
if: ${{ runner.os == 'macOS' }}
run: >-
dotnet test E2eTest/E2eTest.csproj
--configuration Release
--no-build
--no-restore
--filter "FullyQualifiedName~E2eTest.CursorTest"
--logger "trx;LogFileName=webkit-macOS-cursor.trx"
--results-directory artifacts/test-results
--
Playwright.BrowserName=webkit
Playwright.LaunchOptions.Headless=true

- name: Upload browser test results
if: ${{ always() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: browser-${{ matrix.browser }}-${{ runner.os }}-${{ github.run_attempt }}
path: artifacts/test-results/*.trx
if-no-files-found: warn
overwrite: true
78 changes: 78 additions & 0 deletions .github/workflows/validate-dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Core validation

on:
workflow_call:
pull_request:
push:
branches:
- master
workflow_dispatch:

concurrency:
group: core-validation-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true

jobs:
core-validation:
name: Core validation
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false

- name: Set up .NET 10
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6
with:
dotnet-version: 10.0.x

- name: Restore unit tests
run: dotnet restore Magic.IndexedDb.UnitTests/Magic.IndexedDb.UnitTests.csproj

- name: Run unit and contract tests
run: >-
dotnet test Magic.IndexedDb.UnitTests/Magic.IndexedDb.UnitTests.csproj
--configuration Release
--no-restore
--logger "trx;LogFileName=core-validation.trx"
--results-directory artifacts/test-results

- name: Pack the NuGet artifact
run: >-
dotnet pack Magic.IndexedDb/Magic.IndexedDb.csproj
--configuration Release
--no-restore
--output artifacts/package
-p:ContinuousIntegrationBuild=true
-p:GeneratePackageOnBuild=false

- name: Verify package contents
shell: bash
run: |
package="$(find artifacts/package -maxdepth 1 -name '*.nupkg' -print -quit)"
test -n "${package}"
unzip -Z1 "${package}" | grep -Fx README.md
unzip -Z1 "${package}" | grep -Fx LICENSE.txt
unzip -Z1 "${package}" | grep -Fx wizardHatIcon.png
unzip -Z1 "${package}" | grep -F 'staticwebassets/'

- name: Upload test results and package
if: ${{ always() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: core-validation-${{ github.run_attempt }}
path: |
artifacts/test-results/*.trx
artifacts/package/*.nupkg
if-no-files-found: warn
overwrite: true
5 changes: 1 addition & 4 deletions E2eTest/Extensions/PageExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using E2eTest.Entities;
using Microsoft.Playwright;
using Microsoft.Playwright;

namespace E2eTest.Extensions;
internal static class PageExtensions
Expand All @@ -14,7 +13,5 @@ public static async ValueTask DeleteDatabaseAsync(this IPage page, string databa
request.onblocked = () => reject(new Error(`Deletion of ${database} was blocked.`));
})
""", database);
var databases = await page.EvaluateAsync<DatabaseInfo[]>("indexedDB.databases()");
Assert.IsFalse(databases!.Any(x => x.Name == database));
}
}
18 changes: 14 additions & 4 deletions E2eTest/OpenTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using E2eTest.Entities;
using E2eTest.Extensions;
using E2eTest.Extensions;
using TestBase.Models;
using E2eTestWebApp.TestPages;
using Magic.IndexedDb;
Expand All @@ -19,10 +18,21 @@ public async Task DirectOpenTest()
var result = await this.RunTestPageMethodAsync(p => p.DirectOpen);
Assert.AreEqual("OK", result);

var databases = await page.EvaluateAsync<DatabaseInfo[]>("indexedDB.databases()");
var version = await page.EvaluateAsync<int>("""
database => new Promise((resolve, reject) => {
const request = indexedDB.open(database);
request.onsuccess = () => {
const version = request.result.version;
request.result.close();
resolve(version);
};
request.onerror = () => reject(request.error);
request.onblocked = () => reject(new Error(`Opening ${database} was blocked.`));
})
""", "Employee");
// The actual version will be 10:
// https://dexie.org/docs/Dexie/Dexie.version()
Assert.IsTrue(databases!.Any(x => x.Name == "Employee" && x.Version == 10));
Assert.AreEqual(10, version);
}


Expand Down
Loading
Loading