-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- updated all projects to .NET 8 - updated all other dependencies to latest - switch to shared docker build workflow - fix and improve event interceptor - added signalR stateful reconnect from .NET 8 https://learn.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-8.0&tabs=dotnet#configure-stateful-reconnect - added SignalR appsettings section with 2 settings - EnableStatefulReconnect defaults to true - StatefulReconnectBufferSizeBytes defaults to the .NET default of 100000
- Loading branch information
1 parent
593f6b2
commit 2d71d9d
Showing
28 changed files
with
804 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,20 @@ | ||
name: Publish Docker Images | ||
name: Build and Publish Image | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- development | ||
push: | ||
branches: [ development, staging ] | ||
branches: [development, staging] | ||
release: | ||
types: [ "published" ] | ||
workflow_dispatch: | ||
inputs: | ||
tagName: | ||
description: 'Tag of the image you want to build and push' | ||
required: true | ||
types: ["published"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prepare | ||
id: prep | ||
run: | | ||
DOCKER_IMAGE=cmusei/player-api | ||
VERSION=development | ||
if [[ ! -z "${{ github.event.inputs.tagName }}" ]]; then | ||
VERSION=${{ github.event.inputs.tagName }} | ||
TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
elif [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
MAJORMINORVERSION=$(echo $VERSION | grep -oP '(\d+)\.(\d+)') | ||
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${MAJORMINORVERSION}" | ||
elif [[ $GITHUB_REF == refs/heads/* ]]; then | ||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | ||
TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
fi | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
echo ::set-output name=push::false | ||
echo "event is pull_request, not pushing image" | ||
else | ||
echo ::set-output name=push::true | ||
echo "event is not pull_request, pushing image" | ||
fi | ||
echo ::set-output name=version::${VERSION} | ||
echo ::set-output name=tags::${TAGS} | ||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: ${{ steps.prep.outputs.push }} | ||
pull: true | ||
tags: ${{ steps.prep.outputs.tags }} | ||
labels: | | ||
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | ||
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
build-and-publish: | ||
name: Build and Publish | ||
uses: cmu-sei/Crucible-Github-Actions/.github/workflows/[email protected] | ||
with: | ||
imageName: cmusei/player-api | ||
secrets: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2024 Carnegie Mellon University. All Rights Reserved. | ||
// Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.ChangeTracking; | ||
|
||
namespace Player.Api.Data; | ||
|
||
public class Entry | ||
{ | ||
public object Entity { get; set; } | ||
public EntityState State { get; set; } | ||
public IEnumerable<PropertyEntry> Properties { get; set; } | ||
private Dictionary<string, bool> IsPropertyModified { get; set; } = new(); | ||
|
||
public Entry(EntityEntry entry, Entry oldEntry = null) | ||
{ | ||
Entity = entry.Entity; | ||
State = entry.State; | ||
Properties = entry.Properties; | ||
|
||
ProcessOldEntry(oldEntry); | ||
|
||
foreach (var prop in Properties) | ||
{ | ||
IsPropertyModified[prop.Metadata.Name] = prop.IsModified; | ||
} | ||
} | ||
|
||
private void ProcessOldEntry(Entry oldEntry) | ||
{ | ||
if (oldEntry == null) return; | ||
|
||
if (oldEntry.State != EntityState.Unchanged && oldEntry.State != EntityState.Detached) | ||
{ | ||
State = oldEntry.State; | ||
} | ||
|
||
var modifiedProperties = oldEntry.GetModifiedProperties(); | ||
|
||
foreach (var property in Properties) | ||
{ | ||
if (modifiedProperties.Contains(property.Metadata.Name)) | ||
{ | ||
property.IsModified = true; | ||
} | ||
} | ||
} | ||
|
||
public string[] GetModifiedProperties() | ||
{ | ||
return IsPropertyModified | ||
.Where(x => x.Value) | ||
.Select(x => x.Key) | ||
.ToArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2024 Carnegie Mellon University. All Rights Reserved. | ||
// Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Player.Api.Data.Data; | ||
|
||
public class PlayerContextFactory : IDbContextFactory<PlayerContext> | ||
{ | ||
private readonly IDbContextFactory<PlayerContext> _pooledFactory; | ||
private readonly IServiceProvider _serviceProvider; | ||
|
||
public PlayerContextFactory( | ||
IDbContextFactory<PlayerContext> pooledFactory, | ||
IServiceProvider serviceProvider) | ||
{ | ||
_pooledFactory = pooledFactory; | ||
_serviceProvider = serviceProvider; | ||
} | ||
|
||
public PlayerContext CreateDbContext() | ||
{ | ||
var context = _pooledFactory.CreateDbContext(); | ||
|
||
// Inject the current scope's ServiceProvider | ||
context.ServiceProvider = _serviceProvider; | ||
return context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.1" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</Project> |
2 changes: 1 addition & 1 deletion
2
Player.Api.Migrations.PostgreSQL/Migrations/20180425120959_notifications.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Player.Api.Migrations.PostgreSQL/Migrations/20201203194327_file-table.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Player.Api.Migrations.PostgreSQL/Migrations/20201208170359_add-team-ids.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.