From 85f007a2024eb3fb078813589654f768cb70c621 Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Mon, 8 Jan 2024 09:27:46 +0000 Subject: [PATCH] upgrade to .net 8 and upgrade all packages --- .github/workflows/ci.yml | 8 +++---- .github/workflows/codeql-analysis.yml | 2 +- TeslaMateAgile.Tests/IntegrationTests.cs | 12 +++++----- TeslaMateAgile.Tests/PriceHelperTests.cs | 10 ++++----- .../Services/FixedPriceServiceTests.cs | 10 ++++----- .../TeslaMateAgile.Tests.csproj | 13 ++++------- TeslaMateAgile/Dockerfile | 17 ++++++++------ TeslaMateAgile/TeslaMateAgile.csproj | 22 +++++++++---------- charts/teslamateagile/Chart.yaml | 2 +- charts/teslamateagile/values.yaml | 2 +- 10 files changed, 48 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa698e3..e0a29c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index bb8bec4..1249726 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/TeslaMateAgile.Tests/IntegrationTests.cs b/TeslaMateAgile.Tests/IntegrationTests.cs index 0c2567d..feac9c0 100644 --- a/TeslaMateAgile.Tests/IntegrationTests.cs +++ b/TeslaMateAgile.Tests/IntegrationTests.cs @@ -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)] @@ -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)] @@ -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)); } } diff --git a/TeslaMateAgile.Tests/PriceHelperTests.cs b/TeslaMateAgile.Tests/PriceHelperTests.cs index e73d6fc..694aa45 100644 --- a/TeslaMateAgile.Tests/PriceHelperTests.cs +++ b/TeslaMateAgile.Tests/PriceHelperTests.cs @@ -85,8 +85,8 @@ public async Task PriceHelper_CalculateChargeCost(string testName, List 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[][] { @@ -107,7 +107,7 @@ public void PriceHelper_CalculateEnergyUsed(string testName, List 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] @@ -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)); } } diff --git a/TeslaMateAgile.Tests/Services/FixedPriceServiceTests.cs b/TeslaMateAgile.Tests/Services/FixedPriceServiceTests.cs index b6b3f21..0c14f22 100644 --- a/TeslaMateAgile.Tests/Services/FixedPriceServiceTests.cs +++ b/TeslaMateAgile.Tests/Services/FixedPriceServiceTests.cs @@ -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)); } } @@ -413,6 +413,6 @@ public void FixedPriceService_GetPriceData_InfiniteLoopProtection() }; var fixedPriceService = Setup("Europe/London", fixedPrices); var exception = Assert.ThrowsAsync(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")); } } diff --git a/TeslaMateAgile.Tests/TeslaMateAgile.Tests.csproj b/TeslaMateAgile.Tests/TeslaMateAgile.Tests.csproj index ceabc20..d1fcc5d 100644 --- a/TeslaMateAgile.Tests/TeslaMateAgile.Tests.csproj +++ b/TeslaMateAgile.Tests/TeslaMateAgile.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 false @@ -15,19 +15,14 @@ - - - - - - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/TeslaMateAgile/Dockerfile b/TeslaMateAgile/Dockerfile index 3b67e21..4960354 100644 --- a/TeslaMateAgile/Dockerfile +++ b/TeslaMateAgile/Dockerfile @@ -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"] \ No newline at end of file diff --git a/TeslaMateAgile/TeslaMateAgile.csproj b/TeslaMateAgile/TeslaMateAgile.csproj index 7916976..76cae26 100644 --- a/TeslaMateAgile/TeslaMateAgile.csproj +++ b/TeslaMateAgile/TeslaMateAgile.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 3017e2b5-95b2-4dba-ab30-ac3546e8c9e4 Linux @@ -18,16 +18,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/charts/teslamateagile/Chart.yaml b/charts/teslamateagile/Chart.yaml index d1a659e..74ae055 100644 --- a/charts/teslamateagile/Chart.yaml +++ b/charts/teslamateagile/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v2 name: teslamateagile version: 1.0.0 -appVersion: v1.12.1 \ No newline at end of file +appVersion: v1.13.0 \ No newline at end of file diff --git a/charts/teslamateagile/values.yaml b/charts/teslamateagile/values.yaml index efc61de..d80b9de 100644 --- a/charts/teslamateagile/values.yaml +++ b/charts/teslamateagile/values.yaml @@ -1,6 +1,6 @@ image: repository: mattjeanes/teslamateagile - tag: v1.12.1 + tag: v1.13.0 pullPolicy: IfNotPresent resources: requests: