Skip to content

Commit

Permalink
[ACL-228] Add Net9/Net8 support (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
tl-Roberto-Mancinelli authored Nov 25, 2024
1 parent efbf3aa commit ffe1832
Show file tree
Hide file tree
Showing 59 changed files with 193 additions and 370 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "1.3.0",
"version": "5.0.0",
"commands": [
"dotnet-cake"
]
Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,17 @@ on:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v2
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 11.0.x
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 2.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.x.x
dotnet-version: 9.0.x
- name: Restore tools
run: dotnet tool restore
- name: Run the build script
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@v2
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -47,7 +33,7 @@ jobs:
TrueLayer__ClientSecret: ${{ secrets.TRUELAYER__CLIENTSECRET }}
TrueLayer__Payments__SigningKey__KeyId: ${{ secrets.TRUELAYER__PAYMENTS__SIGNINGKEY__KEYID }}
with:
cake-version: 1.3.0
cake-version: 5.0.0
target: CI
verbosity: ${{ github.event.inputs.verbosity }}
- name: Upload pre-release packages
Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,17 @@ on:
default: 'false'
jobs:
publish:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v2
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 11.0.x
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 2.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.x.x
dotnet-version: 9.0.x
- name: Restore tools
run: dotnet tool restore
- name: Run the build script
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@v2
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
Expand All @@ -58,7 +44,7 @@ jobs:
TrueLayer__ClientSecret: ${{ secrets.TRUELAYER__CLIENTSECRET }}
TrueLayer__Payments__SigningKey__KeyId: ${{ secrets.TRUELAYER__PAYMENTS__SIGNINGKEY__KEYID }}
with:
cake-version: 1.3.0
cake-version: 5.0.0
target: ${{ github.event.inputs.target || 'Publish' }}
verbosity: ${{ github.event.inputs.verbosity || 'Normal' }}
arguments: |
Expand Down
106 changes: 17 additions & 89 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Install .NET Core Global tools.
#tool "dotnet:?package=dotnet-reportgenerator-globaltool&version=5.0.0"
#tool "dotnet:?package=coveralls.net&version=3.0.0"
#tool "dotnet:?package=dotnet-sonarscanner&version=5.4.0"
#tool nuget:?package=docfx.console&version=2.58.9
#tool nuget:?package=KuduSync.NET&version=1.5.3
#tool "dotnet:?package=dotnet-reportgenerator-globaltool&version=5.4.1"
#tool "dotnet:?package=coveralls.net&version=4.0.1"
#tool "dotnet:?package=dotnet-sonarscanner&version=9.0.2"
#tool nuget:?package=KuduSync.NET&version=1.5.4

// Install addins
#addin nuget:?package=Cake.Coverlet&version=2.5.4
#addin nuget:?package=Cake.Sonar&version=1.1.26
#addin nuget:?package=Cake.DocFx&version=1.0.0
#addin nuget:?package=Cake.Git&version=1.1.0
#addin nuget:?package=Cake.Kudu&version=1.3.0
#addin nuget:?package=Cake.Coverlet&version=4.0.1
#addin nuget:?package=Cake.Sonar&version=1.1.33
#addin nuget:?package=Cake.Git&version=4.0.0
#addin nuget:?package=Cake.Kudu&version=3.0.0

#r "System.Text.Json"
#r "System.IO"
Expand Down Expand Up @@ -83,15 +81,15 @@ Task("SonarBegin")
Url = "https://sonarcloud.io",
Exclusions = "test/**,examples/**",
OpenCoverReportsPath = $"{coveragePath}/*.xml",
Login = sonarToken,
Token = sonarToken,
VsTestReportsPath = $"{artifactsPath}/*.TestResults.xml",
});
});

Task("Build")
.Does(() =>
{
DotNetCoreBuild("TrueLayer.sln", new DotNetCoreBuildSettings
DotNetBuild("TrueLayer.sln", new DotNetBuildSettings
{
Configuration = configuration
});
Expand All @@ -104,7 +102,7 @@ Task("Test")
{
var projectName = project.GetFilenameWithoutExtension();

var testSettings = new DotNetCoreTestSettings
var testSettings = new DotNetTestSettings
{
NoBuild = true,
Configuration = configuration,
Expand All @@ -122,15 +120,15 @@ Task("Test")
//Threshold = coverageThreshold
};

DotNetCoreTest(project.ToString(), testSettings, coverletSettings);
DotNetTest(project.ToString(), testSettings, coverletSettings);
}
});


Task("Pack")
.Does(() =>
{
var settings = new DotNetCorePackSettings
var settings = new DotNetPackSettings
{
Configuration = configuration,
OutputDirectory = artifactsPath,
Expand All @@ -139,7 +137,7 @@ Task("Pack")

foreach (var file in GetFiles(packFiles))
{
DotNetCorePack(file.ToString(), settings);
DotNetPack(file.ToString(), settings);
}
});

Expand Down Expand Up @@ -202,7 +200,7 @@ Task("PublishPackages")
{
foreach(var package in GetFiles(packages))
{
DotNetCoreNuGetPush(package.ToString(), new DotNetCoreNuGetPushSettings {
DotNetNuGetPush(package.ToString(), new DotNetNuGetPushSettings {
ApiKey = BuildContext.NugetApiKey,
Source = BuildContext.NugetApiUrl,
SkipDuplicate = true
Expand All @@ -216,86 +214,18 @@ Task("SonarEnd")
{
SonarEnd(new SonarEndSettings
{
Login = sonarToken
Token = sonarToken
});
});

Task("BuildDocs")
.Does(() =>
{
Information("Extracting API Metadata");
DocFxMetadata(docFxConfig);

Information("Building Docs");
DocFxBuild(docFxConfig);
});

Task("ServeDocs")
.IsDependentOn("BuildDocs")
.Does(() =>
{
using (var process = DocFxServeStart(sitePath))
{
// Launch browser or other action based on the site
process.WaitForExit();
}
});

Task("PublishDocs")
.IsDependentOn("BuildDocs")
.WithCriteria(!string.IsNullOrEmpty(gitHubPagesToken))// && currentBranch.FriendlyName == "main")
.Does(() =>
{
// Get the current commit
var sourceCommit = currentBranch.Tip;
var publishFolder = $"./artifacts/docs-publish-{DateTime.Now.ToString("yyyyMMdd_HHmmss")}";
Information("Publishing Folder: {0}", publishFolder);
Information("Getting publish branch...");
GitClone("https://github.com/TrueLayer/truelayer-dotnet.git",
publishFolder,
gitHubUser,
gitHubPagesToken,
new GitCloneSettings { BranchName = "gh-pages" }
);

Information("Sync output files...");

Kudu.Sync(sitePath, publishFolder, new KuduSyncSettings {
ArgumentCustomization = args => args.Append("--ignore").AppendQuoted(".git;CNAME")
});

if (GitHasUncommitedChanges(publishFolder))
{
GitAddAll(publishFolder);
Information("Stage all changes...");

// Only considers modified files - https://github.com/cake-contrib/Cake_Git/issues/77
if (BuildContext.ForcePushDocs || GitHasStagedChanges(publishFolder))
{
Information("Commit all changes...");
GitCommit(
publishFolder,
sourceCommit.Committer.Name,
sourceCommit.Committer.Email,
string.Format("Continuous Integration Publish: {0}\r\n{1}", sourceCommit.Sha, sourceCommit.Message)
);

Information("Pushing all changes...");

GitPush(publishFolder, gitHubUser, gitHubPagesToken, "gh-pages");
}
}
});

Task("Dump").Does(() => BuildContext.PrintParameters(Context));

Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Pack")
.IsDependentOn("GenerateReports")
.IsDependentOn("BuildDocs");
.IsDependentOn("GenerateReports");

Task("CI")
//.IsDependentOn("SonarBegin")
Expand All @@ -306,11 +236,9 @@ Task("CI")
Task("Publish")
.IsDependentOn("CI")
.IsDependentOn("PublishPackages");
//.IsDependentOn("PublishDocs");

RunTarget(target);


public static class BuildContext
{
public static bool IsTag { get; private set; }
Expand Down
14 changes: 7 additions & 7 deletions examples/MvcExample/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public async Task<IActionResult> Donate(DonateModel donateModel)
return View("Index");
}

OneOf<Provider.UserSelected, Provider.Preselected> filter = donateModel.UserPreSelectedFilter
? new Provider.Preselected("mock-payments-gb-redirect", "faster_payments_service")
OneOf<Provider.UserSelected, Provider.Preselected> providerSelection = donateModel.UserPreSelectedFilter
? new Provider.Preselected(providerId: "mock-payments-gb-redirect", schemeSelection: new SchemeSelection.Preselected { SchemeId = "faster_payments_service"})
: new Provider.UserSelected();

var paymentRequest = new CreatePaymentRequest(
donateModel.AmountInMajor.ToMinorCurrencyUnit(2),
Currencies.GBP,
new PaymentMethod.BankTransfer(
filter,
providerSelection,
new Beneficiary.ExternalAccount(
"TrueLayer",
"truelayer-dotnet",
Expand Down Expand Up @@ -142,10 +142,10 @@ void SetProviderAndSchemeId(OneOf<PaymentMethod.BankTransfer, PaymentMethod.Mand

return apiResponse.Data.Match(
authRequired => Failed(authRequired.Status, authRequired.PaymentMethod),
authorizing => SuccessOrPending(authorizing),
authorized => SuccessOrPending(authorized),
success => SuccessOrPending(success),
settled => SuccessOrPending(settled),
SuccessOrPending,
SuccessOrPending,
SuccessOrPending,
SuccessOrPending,
failed => Failed(failed.Status, failed.PaymentMethod),
attemptFailed => Failed(attemptFailed.Status, attemptFailed.PaymentMethod)
);
Expand Down
2 changes: 0 additions & 2 deletions examples/MvcExample/Models/ErrorViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace MvcExample.Models
{
public class ErrorViewModel
Expand Down
2 changes: 1 addition & 1 deletion examples/MvcExample/MvcExample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "9.0.100",
"rollForward": "latestMinor"
}
}
3 changes: 1 addition & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<WarningsAsErrors>nullable;</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.0.0" PrivateAssets="all" />
<PackageReference Include="MinVer" Version="2.4.0" PrivateAssets="All" />
<PackageReference Include="MinVer" Version="6.0.0" PrivateAssets="All" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion src/TrueLayer/ApiResponseOfT.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Net;

Expand Down
5 changes: 0 additions & 5 deletions src/TrueLayer/Mandates/Model/Beneficiary.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OneOf;
using TrueLayer.Serialization;
using static TrueLayer.Payments.Model.AccountIdentifier;
Expand Down
6 changes: 0 additions & 6 deletions src/TrueLayer/Mandates/Model/Constraints.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TrueLayer.Mandates.Model
{
/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions src/TrueLayer/Mandates/Model/CreateMandateRequest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OneOf;
using TrueLayer.Payments.Model;
using static TrueLayer.Mandates.Model.Mandate;
Expand Down
5 changes: 0 additions & 5 deletions src/TrueLayer/Mandates/Model/CreateMandateResponse.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TrueLayer.Payments.Model;

namespace TrueLayer.Mandates.Model
Expand Down
Loading

0 comments on commit ffe1832

Please sign in to comment.