Skip to content

Commit

Permalink
upgrade to .net 8 and upgrade all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
MattJeanes committed Jan 8, 2024
1 parent 1ebe629 commit 85f007a
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 50 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Set variables
id: variables
Expand All @@ -41,11 +41,11 @@ jobs:
for appname in TeslaMateAgile; do
app=`echo $appname | tr '[:upper:]' '[:lower:]'`
echo "Building $appname docker amd64"
docker build -t $app:amd64 -f "$appname/Dockerfile" . --build-arg arch=bullseye-slim-amd64
docker build -t $app:amd64 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-amd64
echo "Building $appname docker arm32v7"
docker build -t $app:arm32v7 -f "$appname/Dockerfile" . --build-arg arch=bullseye-slim-arm32v7
docker build -t $app:arm32v7 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-arm32v7
echo "Building $appname docker arm64v8"
docker build -t $app:arm64v8 -f "$appname/Dockerfile" . --build-arg arch=bullseye-slim-arm64v8
docker build -t $app:arm64v8 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-arm64v8
done
- name: Upload a Build Artifact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
12 changes: 6 additions & 6 deletions TeslaMateAgile.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public async Task IntegrationTests_Tibber()

var priceData = await priceDataService.GetPriceData(from, to);

Assert.LessOrEqual(priceData.Min(x => x.ValidFrom), from);
Assert.GreaterOrEqual(priceData.Max(x => x.ValidTo), to);
Assert.That(priceData.Min(x => x.ValidFrom), Is.LessThanOrEqualTo(from));
Assert.That(priceData.Max(x => x.ValidTo), Is.GreaterThanOrEqualTo(to));
}

[Ignore(IntegrationTest)]
Expand Down Expand Up @@ -75,8 +75,8 @@ public async Task IntegrationTests_Awattar()

var priceData = await priceDataService.GetPriceData(from, to);

Assert.LessOrEqual(priceData.Min(x => x.ValidFrom), from);
Assert.GreaterOrEqual(priceData.Max(x => x.ValidTo), to);
Assert.That(priceData.Min(x => x.ValidFrom), Is.LessThanOrEqualTo(from));
Assert.That(priceData.Max(x => x.ValidTo), Is.GreaterThanOrEqualTo(to));
}

[Ignore(IntegrationTest)]
Expand Down Expand Up @@ -121,7 +121,7 @@ public async Task IntegrationTests_Energinet()
Console.WriteLine($"{price.ValidFrom} - {price.ValidTo} - {price.Value}");
}

Assert.LessOrEqual(priceData.Min(x => x.ValidFrom), from);
Assert.GreaterOrEqual(priceData.Max(x => x.ValidTo), to);
Assert.That(priceData.Min(x => x.ValidFrom), Is.LessThanOrEqualTo(from));
Assert.That(priceData.Max(x => x.ValidTo), Is.GreaterThanOrEqualTo(to));
}
}
10 changes: 5 additions & 5 deletions TeslaMateAgile.Tests/PriceHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public async Task PriceHelper_CalculateChargeCost(string testName, List<Price> p
Console.WriteLine($"Running calculate charge cost test '{testName}'");
var priceHelper = Setup(prices);
var (price, energy) = await priceHelper.CalculateChargeCost(charges);
Assert.AreEqual(expectedPrice, price);
Assert.AreEqual(expectedEnergy, energy);
Assert.That(expectedPrice, Is.EqualTo(price));
Assert.That(expectedEnergy, Is.EqualTo(energy));
}

private static readonly object[][] PriceHelper_CalculateEnergyUsed_Cases = new object[][] {
Expand All @@ -107,7 +107,7 @@ public void PriceHelper_CalculateEnergyUsed(string testName, List<Charge> charge
var phases = priceHelper.DeterminePhases(charges);
if (!phases.HasValue) { throw new Exception("Phases has no value"); }
var energy = priceHelper.CalculateEnergyUsed(charges, phases.Value);
Assert.AreEqual(expectedEnergy, Math.Round(energy, 2));
Assert.That(expectedEnergy, Is.EqualTo(Math.Round(energy, 2)));
}

[Test]
Expand All @@ -116,7 +116,7 @@ public async Task PriceHelper_NoPhaseData()
var charges = TestHelpers.ImportCharges("nophasedata_test.csv");
var priceHelper = Setup();
var (price, energy) = await priceHelper.CalculateChargeCost(charges);
Assert.AreEqual(0, price);
Assert.AreEqual(0, energy);
Assert.That(0, Is.EqualTo(price));
Assert.That(0, Is.EqualTo(energy));
}
}
10 changes: 5 additions & 5 deletions TeslaMateAgile.Tests/Services/FixedPriceServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,15 @@ public async Task FixedPriceService_GetPriceData(string testName, string timeZon
var fixedPriceService = Setup(timeZone, fixedPrices);
var result = await fixedPriceService.GetPriceData(from, to);
var actualPrices = result.OrderBy(x => x.ValidFrom).ToList();
Assert.AreEqual(expectedPrices.Count, actualPrices.Count());
Assert.That(expectedPrices.Count, Is.EqualTo(actualPrices.Count()));
for (var i = 0; i < actualPrices.Count(); i++)
{
var actualPrice = actualPrices[i];
var expectedPrice = expectedPrices[i];

Assert.AreEqual(expectedPrice.ValidFrom, actualPrice.ValidFrom);
Assert.AreEqual(expectedPrice.ValidTo, actualPrice.ValidTo);
Assert.AreEqual(expectedPrice.Value, actualPrice.Value);
Assert.That(expectedPrice.ValidFrom, Is.EqualTo(actualPrice.ValidFrom));
Assert.That(expectedPrice.ValidTo, Is.EqualTo(actualPrice.ValidTo));
Assert.That(expectedPrice.Value, Is.EqualTo(actualPrice.Value));
}
}

Expand All @@ -413,6 +413,6 @@ public void FixedPriceService_GetPriceData_InfiniteLoopProtection()
};
var fixedPriceService = Setup("Europe/London", fixedPrices);
var exception = Assert.ThrowsAsync<Exception>(async () => { await fixedPriceService.GetPriceData(from, to); });
Assert.AreEqual(exception?.Message, "Infinite loop detected within FixedPrice provider");
Assert.That(exception?.Message, Is.EqualTo("Infinite loop detected within FixedPrice provider"));
}
}
13 changes: 4 additions & 9 deletions TeslaMateAgile.Tests/TeslaMateAgile.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -15,19 +15,14 @@
</ItemGroup>

<ItemGroup>
<None Remove="Charges\exactmillisecond_test.csv" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="Moq.Contrib.HttpClient" Version="1.4.0" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="nunit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="CsvHelper" Version="30.0.1" />
</ItemGroup>

Expand Down
17 changes: 10 additions & 7 deletions TeslaMateAgile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
ARG arch=bullseye-slim
ARG arch=bookworm-slim

FROM mcr.microsoft.com/dotnet/runtime:7.0-${arch} AS base
FROM mcr.microsoft.com/dotnet/runtime:8.0-${arch} AS base
USER app
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:7.0-bullseye-slim AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["TeslaMateAgile/TeslaMateAgile.csproj", "TeslaMateAgile/"]
RUN dotnet restore "TeslaMateAgile/TeslaMateAgile.csproj"
RUN dotnet restore "./TeslaMateAgile/TeslaMateAgile.csproj"
COPY . .
WORKDIR "/src/TeslaMateAgile"
RUN dotnet build "TeslaMateAgile.csproj" -c Release -o /app/build
RUN dotnet build "./TeslaMateAgile.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
RUN dotnet publish "TeslaMateAgile.csproj" -c Release -o /app/publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./TeslaMateAgile.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TeslaMateAgile.dll"]
ENTRYPOINT ["dotnet", "TeslaMateAgile.dll"]
22 changes: 11 additions & 11 deletions TeslaMateAgile/TeslaMateAgile.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<UserSecretsId>3017e2b5-95b2-4dba-ab30-ac3546e8c9e4</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
Expand All @@ -18,16 +18,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="GraphQL.Client" Version="6.0.0" />
<PackageReference Include="GraphQL.Client.Serializer.SystemTextJson" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="GraphQL.Client" Version="6.0.2" />
<PackageReference Include="GraphQL.Client.Serializer.SystemTextJson" Version="6.0.2" />
<PackageReference Include="TimeZoneConverter" Version="6.1.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion charts/teslamateagile/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v2
name: teslamateagile
version: 1.0.0
appVersion: v1.12.1
appVersion: v1.13.0
2 changes: 1 addition & 1 deletion charts/teslamateagile/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
image:
repository: mattjeanes/teslamateagile
tag: v1.12.1
tag: v1.13.0
pullPolicy: IfNotPresent
resources:
requests:
Expand Down

0 comments on commit 85f007a

Please sign in to comment.