Skip to content

Commit

Permalink
Merge pull request #310 from SapiensAnatis/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SapiensAnatis authored Jul 16, 2023
2 parents c217049 + e37f333 commit a1386a3
Show file tree
Hide file tree
Showing 201 changed files with 1,134,306 additions and 2,791 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]
},
"csharpier": {
"version": "0.24.2",
"version": "0.25.0",
"commands": [
"dotnet-csharpier"
]
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ name: deploy
on:
workflow_call:
inputs:
deployment:
github-environment:
type: string
required: true
description: "Kubernetes deployment name"
namespace:
type: string
required: true
description: "Kubernetes namespace"
description: "GitHub environment name"

jobs:
deploy:
runs-on: ubuntu-latest

environment:
name: ${{ inputs.github-environment }}
url: https://dawnshard.co.uk
steps:
- name: ssh and restart pods
uses: appleboy/[email protected]
Expand All @@ -25,5 +23,5 @@ jobs:
key: ${{ secrets.SSH_KEY }}
script_stop: true
script: |
kubectl rollout restart deployment/${{ inputs.deployment }} -n ${{ inputs.namespace }}
kubectl rollout status deployment/${{ inputs.deployment }} -n ${{ inputs.namespace }}
kubectl rollout restart deployment/${{ vars.K8S_DEPLOYMENT }} -n ${{ vars.K8S_NAMESPACE }}
kubectl rollout status deployment/${{ vars.K8S_DEPLOYMENT }} -n ${{ vars.K8S_NAMESPACE }}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ jobs:
uses: ./.github/workflows/publish.yaml
with:
ref: ${{ github.ref_name }}
image-tag: ${{ github.ref_name }}
dockerfile: "DragaliaAPI/Dockerfile"
image-name: "dragalia-api"
secrets: inherit
23 changes: 19 additions & 4 deletions .github/workflows/publish-manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@ name: publish-tag-manual
on:
workflow_dispatch:
inputs:
tag:
ref:
required: true
type: string
description: ref to checkout
dockerfile:
required: true
type: string
description: path to Dockerfile
image-name:
required: true
description: "Tag to publish"
type: string
description: Docker image name
image-tag:
required: false
default: "undefined"
type: string
description: Docker image tag

env:
HUSKY: 0
Expand All @@ -15,6 +28,8 @@ jobs:
publish:
uses: ./.github/workflows/publish.yaml
with:
ref: ${{ inputs.tag }}
image-tag: ${{ inputs.tag }}
ref: ${{ inputs.ref }}
dockerfile: ${{ inputs.dockerfile }}
image-name: ${{ inputs.image-name }}
image-tag: ${{ inputs.image-tag }}
secrets: inherit
14 changes: 3 additions & 11 deletions .github/workflows/publish-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
[
{
dockerfile: "DragaliaAPI.Photon.StateManager/Dockerfile",
image: "dragalia-api-statemanager",
image: "photon-state-manager",
},
{ dockerfile: "DragaliaAPI/Dockerfile", image: "dragalia-api" },
]
Expand All @@ -31,17 +31,9 @@ jobs:
deploy:
strategy:
matrix:
args:
[
{
deployment: "photonstatemanager",
namespace: "photonstatemanager",
},
{ deployment: "dragalia-api-dawnshard", namespace: "dragalia-api" },
]
github-environment: ["PhotonStateManager", "Dawnshard"]
needs: publish
uses: ./.github/workflows/deploy.yaml
with:
deployment: ${{ matrix.args.deployment }}
namespace: ${{ matrix.args.namespace }}
github-environment: ${{ matrix.github-environment }}
secrets: inherit
18 changes: 18 additions & 0 deletions .github/workflows/publish-statemanager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: publish-tag

on:
push:
tags:
- "statemanager@*"

env:
HUSKY: 0

jobs:
publish:
uses: ./.github/workflows/publish.yaml
with:
ref: ${{ github.ref_name }}
dockerfile: "DragaliaAPI.Photon.StateManager/Dockerfile"
image-name: "photon-state-manager"
secrets: inherit
46 changes: 34 additions & 12 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ on:
type: string
description: Docker image name
image-tag:
required: true
required: false
default: "undefined"
type: string
description: Docker image tag

Expand All @@ -31,22 +32,43 @@ jobs:
dotnet-version: ["7.0.x"]

steps:
- name: derive tag
id: derive-tag
run: |
TAG_REGEX="[\w]+?@v(.*)"
echo "Ref: ${{ inputs.ref }}"
echo "Tag: ${{ inputs.image-tag }}"
if [ ${{ inputs.image-tag }} != "undefined" ]
then
echo "tag=${{ inputs.image-tag }}" >> "$GITHUB_OUTPUT"
exit 0;
fi
if [ ${{ inputs.ref }} = "develop" ]
then
echo "tag=latest" >> "$GITHUB_OUTPUT"
elif [[ ${{ inputs.ref }} =~ $TAG_REGEX ]]
then
echo "tag=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
else
echo "No image-tag provided and failed to derive image tag from ref"
exit 1;
fi
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ${{ inputs.dockerfile }}
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ inputs.image-name }}:${{ inputs.image-tag }}
run: |
IMAGE=ghcr.io/sapiensanatis/${{ inputs.image-name }}:${{ steps.derive-tag.outputs.tag }}
docker build . --file ${{ inputs.dockerfile }} --tag ${IMAGE}
docker push ${IMAGE}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Runtime.InteropServices;
using DragaliaAPI.Database.Entities;
using DragaliaAPI.Database.Repositories;
using DragaliaAPI.Features.Fort;
using DragaliaAPI.Services;
using DragaliaAPI.Shared.Definitions.Enums;
using DragaliaAPI.Shared.PlayerDetails;
Expand Down
153 changes: 2 additions & 151 deletions DragaliaAPI.Database.Test/Repositories/UnitRepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public async Task AddCharas_UpdatesDatabase()
List<Charas> idList = new() { Charas.Addis, Charas.Aeleen };

await this.unitRepository.AddCharas(idList);
await this.unitRepository.SaveChangesAsync();
await this.fixture.ApiContext.SaveChangesAsync();

(
await this.fixture.ApiContext.PlayerCharaData
Expand Down Expand Up @@ -198,7 +198,7 @@ await fixture.AddToDatabase(
List<Dragons> idList = new() { Dragons.KonohanaSakuya, Dragons.Michael, Dragons.Michael };

await this.unitRepository.AddDragons(idList);
await this.unitRepository.SaveChangesAsync();
await this.fixture.ApiContext.SaveChangesAsync();

(
await this.fixture.ApiContext.PlayerDragonData
Expand Down Expand Up @@ -226,153 +226,4 @@ await this.fixture.ApiContext.PlayerDragonReliability
.Should()
.Contain(new List<Dragons>() { Dragons.KonohanaSakuya, Dragons.Michael, });
}

[Fact]
public async Task BuildDetailedPartyUnit_ReturnsCorrectResult()
{
DbPlayerCharaData chara = new(DeviceAccountId, Charas.BondforgedPrince);

DbPlayerCharaData chara1 =
new(DeviceAccountId, Charas.GalaMym) { IsUnlockEditSkill = true, Skill1Level = 3 };

DbPlayerCharaData chara2 =
new(DeviceAccountId, Charas.SummerCleo) { IsUnlockEditSkill = true, Skill2Level = 2 };

DbPlayerDragonData dragon = DbPlayerDragonDataFactory.Create(
DeviceAccountId,
Dragons.MidgardsormrZero
);
dragon.DragonKeyId = 400;

DbPlayerDragonReliability reliability = DbPlayerDragonReliabilityFactory.Create(
DeviceAccountId,
Dragons.MidgardsormrZero
);
reliability.Level = 15;

DbWeaponBody weapon =
new() { DeviceAccountId = DeviceAccountId, WeaponBodyId = WeaponBodies.Excalibur };

List<DbAbilityCrest> crests =
new()
{
new()
{
DeviceAccountId = DeviceAccountId,
AbilityCrestId = AbilityCrests.ADogsDay
},
new()
{
DeviceAccountId = DeviceAccountId,
AbilityCrestId = AbilityCrests.TheRedImpulse
},
new()
{
DeviceAccountId = DeviceAccountId,
AbilityCrestId = AbilityCrests.ThePrinceofDragonyule
},
new()
{
DeviceAccountId = DeviceAccountId,
AbilityCrestId = AbilityCrests.TaikoTandem
},
new()
{
DeviceAccountId = DeviceAccountId,
AbilityCrestId = AbilityCrests.AChoiceBlend
},
new()
{
DeviceAccountId = DeviceAccountId,
AbilityCrestId = AbilityCrests.CrownofLightSerpentsBoon
},
new()
{
DeviceAccountId = DeviceAccountId,
AbilityCrestId = AbilityCrests.AKingsPrideSwordsBoon
}
};

DbTalisman talisman =
new()
{
DeviceAccountId = DeviceAccountId,
TalismanId = Talismans.GalaNedrick,
TalismanKeyId = 44444
};

DbPartyUnit unit =
new()
{
DeviceAccountId = DeviceAccountId,
UnitNo = 1,
PartyNo = 1,
CharaId = Charas.BondforgedPrince,
EquipWeaponBodyId = WeaponBodies.Excalibur,
EquipWeaponSkinId = 1,
EquipDragonKeyId = 400,
EquipTalismanKeyId = 44444,
EquipCrestSlotType1CrestId1 = AbilityCrests.ADogsDay,
EquipCrestSlotType1CrestId2 = AbilityCrests.TheRedImpulse,
EquipCrestSlotType1CrestId3 = AbilityCrests.ThePrinceofDragonyule,
EquipCrestSlotType2CrestId1 = AbilityCrests.TaikoTandem,
EquipCrestSlotType2CrestId2 = AbilityCrests.AChoiceBlend,
EquipCrestSlotType3CrestId1 = AbilityCrests.CrownofLightSerpentsBoon,
EquipCrestSlotType3CrestId2 = AbilityCrests.AKingsPrideSwordsBoon,
EditSkill1CharaId = Charas.GalaMym,
EditSkill2CharaId = Charas.SummerCleo,
};

DbWeaponSkin skin = new() { DeviceAccountId = DeviceAccountId, WeaponSkinId = 1 };

await this.fixture.AddToDatabase(chara);
await this.fixture.AddToDatabase(chara1);
await this.fixture.AddToDatabase(chara2);
await this.fixture.AddToDatabase(dragon);
await this.fixture.AddToDatabase(reliability);
await this.fixture.AddToDatabase(weapon);
await this.fixture.AddRangeToDatabase(crests);
await this.fixture.AddToDatabase(talisman);
await this.fixture.AddToDatabase(skin);

// Set up party
DbParty party = await this.fixture.ApiContext.PlayerParties
.Where(x => x.DeviceAccountId == DeviceAccountId && x.PartyNo == 1)
.FirstAsync();

party.Units = new List<DbPartyUnit>() { unit };

await this.fixture.ApiContext.SaveChangesAsync();

var unitQuery = this.fixture.ApiContext.PlayerPartyUnits.Where(
x => x.DeviceAccountId == DeviceAccountId && x.PartyNo == 1
);

IQueryable<DbDetailedPartyUnit> buildQuery = this.unitRepository.BuildDetailedPartyUnit(
unitQuery
);

DbDetailedPartyUnit result = await buildQuery.FirstAsync();

result
.Should()
.BeEquivalentTo(
new DbDetailedPartyUnit()
{
DeviceAccountId = DeviceAccountId,
Position = 1,
CharaData = chara,
DragonData = dragon,
WeaponBodyData = weapon,
TalismanData = talisman,
WeaponSkinData = skin,
CrestSlotType1CrestList = crests.GetRange(0, 3),
CrestSlotType2CrestList = crests.GetRange(3, 2),
CrestSlotType3CrestList = crests.GetRange(5, 2),
DragonReliabilityLevel = 15,
EditSkill1CharaData = new() { CharaId = Charas.GalaMym, EditSkillLevel = 3, },
EditSkill2CharaData = new() { CharaId = Charas.SummerCleo, EditSkillLevel = 2, }
}
);
}
}
2 changes: 2 additions & 0 deletions DragaliaAPI.Database/ApiContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,6 @@ but EF Core doesn't like this and the client probably stops you anyway?
public DbSet<DbPlayerShopPurchase> PlayerPurchases { get; set; }

public DbSet<DbPlayerTrade> PlayerTrades { get; set; }

public DbSet<DbQuestClearPartyUnit> QuestClearPartyUnits { get; set; }
}
Loading

0 comments on commit a1386a3

Please sign in to comment.