Modernise CI (#5)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful

Co-authored-by: Smaug123 <3138005+Smaug123@users.noreply.github.com>
Reviewed-on: #5
This commit is contained in:
2025-09-09 08:18:41 +00:00
parent 1046be36a3
commit f46557926e
12 changed files with 60 additions and 45 deletions

View File

@@ -3,19 +3,19 @@
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"fantomas": { "fantomas": {
"version": "6.1.2", "version": "7.0.3",
"commands": [ "commands": [
"fantomas" "fantomas"
] ]
}, },
"fable": { "fable": {
"version": "3.2.9", "version": "4.25.0",
"commands": [ "commands": [
"fable" "fable"
] ]
}, },
"femto": { "femto": {
"version": "0.12.0", "version": "0.21.0",
"commands": [ "commands": [
"femto" "femto"
] ]

22
.envrc
View File

@@ -1 +1,23 @@
use flake use flake
DOTNET_PATH=$(readlink "$(which dotnet)")
SETTINGS_FILE=$(find . -maxdepth 1 -type f -name '*.sln.DotSettings.user')
MSBUILD=$(realpath "$(find "$(dirname "$DOTNET_PATH")/../share/dotnet/sdk" -maxdepth 2 -type f -name MSBuild.dll)")
if [ -f "$SETTINGS_FILE" ] ; then
xmlstarlet ed --inplace \
-N wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" \
-N x="http://schemas.microsoft.com/winfx/2006/xaml" \
-N s="clr-namespace:System;assembly=mscorlib" \
-N ss="urn:shemas-jetbrains-com:settings-storage-xaml" \
--update "//s:String[@x:Key='/Default/Environment/Hierarchy/Build/BuildTool/DotNetCliExePath/@EntryValue']" \
--value "$(realpath "$(dirname "$DOTNET_PATH")/../share/dotnet/dotnet")" \
"$SETTINGS_FILE"
xmlstarlet ed --inplace \
-N wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" \
-N x="http://schemas.microsoft.com/winfx/2006/xaml" \
-N s="clr-namespace:System;assembly=mscorlib" \
-N ss="urn:shemas-jetbrains-com:settings-storage-xaml" \
--update "//s:String[@x:Key='/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue']" \
--value "$MSBUILD" \
"$SETTINGS_FILE"
fi

View File

@@ -6,11 +6,11 @@ steps:
# Lint # Lint
- "nix develop --command bash -c 'dotnet tool restore && ./hooks/pre-push'" - "nix develop --command bash -c 'dotnet tool restore && ./hooks/pre-push'"
# Test # Test
- nix develop --command dotnet -- test - nix develop --command dotnet test
- nix develop --command dotnet -- test --configuration Release - nix develop --command dotnet test --configuration Release
# Perform build # Perform build
- "pushd RaftFable && nix develop --command npm -- install && popd" - "pushd RaftFable && nix develop --command npm install && popd"
- "pushd RaftFable && nix develop --command npm -- run-script build && popd" - "pushd RaftFable && nix develop --command npm run-script build && popd"
when: when:
- event: "push" - event: "push"

View File

@@ -1,6 +1,7 @@
namespace Raft.Test namespace Raft.Test
open FsCheck open FsCheck
open FsCheck.FSharp
open Raft open Raft
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
@@ -8,7 +9,7 @@ module NetworkAction =
let generate<'a> (clusterSize : int) : Gen<NetworkAction<'a>> = let generate<'a> (clusterSize : int) : Gen<NetworkAction<'a>> =
gen { gen {
let! choice = Arb.generate<NetworkAction<'a>> let! choice = ArbMap.defaults |> ArbMap.generate<NetworkAction<'a>>
let! server = Gen.choose (0, clusterSize - 1) let! server = Gen.choose (0, clusterSize - 1)
let server = server * 1<ServerId> let server = server * 1<ServerId>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -19,13 +19,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FsCheck" Version="2.16.5" /> <PackageReference Include="FsCheck" Version="3.3.1" />
<PackageReference Include="FsUnit" Version="5.0.5" /> <PackageReference Include="FsUnit" Version="7.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="NUnit" Version="3.13.3" /> <PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" /> <PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,6 +1,7 @@
namespace Raft.Test namespace Raft.Test
open System.Threading open System.Threading
open FsCheck.FSharp
open Raft open Raft
open NUnit.Framework open NUnit.Framework
open FsUnitTyped open FsUnitTyped
@@ -10,10 +11,7 @@ open FsCheck
module TestInMemoryServer = module TestInMemoryServer =
let check<'T> (prop : 'T) = let check<'T> (prop : 'T) =
let config = let config = Config.QuickThrowOnFailure.WithMaxTest(1000).WithQuietOnSuccess (true)
{ Config.QuickThrowOnFailure with
MaxTest = 1000
}
Check.One (config, prop) Check.One (config, prop)
@@ -194,7 +192,7 @@ module TestInMemoryServer =
let networkMessageSelectionGen (clusterSize : int) : Gen<NetworkMessageSelection> = let networkMessageSelectionGen (clusterSize : int) : Gen<NetworkMessageSelection> =
gen { gen {
let! pile = Gen.choose (0, clusterSize - 1) let! pile = Gen.choose (0, clusterSize - 1)
let! entry = Arb.generate<int> let! entry = ArbMap.defaults |> ArbMap.generate<int>
return (pile * 1<ServerId>, abs entry) return (pile * 1<ServerId>, abs entry)
} }
|> Gen.listOf |> Gen.listOf
@@ -425,7 +423,7 @@ module TestInMemoryServer =
firstTime = secondTime firstTime = secondTime
property property
|> Prop.forAll (ValidHistory.arb (Arb.Default.Byte().Generator) clusterSize) |> Prop.forAll (ValidHistory.arb (ArbMap.defaults |> ArbMap.generate<byte>) clusterSize)
|> check |> check
@@ -448,7 +446,7 @@ module TestInMemoryServer =
List.distinct leaders = leaders List.distinct leaders = leaders
property property
|> Prop.forAll (ValidHistory.arb (Arb.Default.Byte().Generator) clusterSize) |> Prop.forAll (ValidHistory.arb (ArbMap.defaults |> ArbMap.generate<byte>) clusterSize)
|> check |> check
let duplicationProperty<'a when 'a : equality> let duplicationProperty<'a when 'a : equality>

View File

@@ -1,5 +1,6 @@
namespace Raft.Test namespace Raft.Test
open FsCheck.FSharp
open Raft open Raft
open System.Collections.Generic open System.Collections.Generic
open NUnit.Framework open NUnit.Framework

View File

@@ -2,6 +2,7 @@ namespace Raft.Test
open Raft open Raft
open FsCheck open FsCheck
open FsCheck.FSharp
type ValidHistory<'a> = | ValidHistory of NetworkAction<'a> list type ValidHistory<'a> = | ValidHistory of NetworkAction<'a> list

View File

@@ -1,9 +1,4 @@
// Note this only includes basic configuration for development mode.
// For a more comprehensive configuration check:
// https://github.com/fable-compiler/webpack-config-template
var path = require("path"); var path = require("path");
module.exports = { module.exports = {
mode: "development", mode: "development",
entry: "./src/App.fs.js", entry: "./src/App.fs.js",
@@ -12,8 +7,12 @@ module.exports = {
filename: "bundle.js", filename: "bundle.js",
}, },
devServer: { devServer: {
publicPath: "/", static: {
contentBase: "./public", directory: path.join(__dirname, "./public"),
},
devMiddleware: {
publicPath: "/",
},
port: 8080, port: 8080,
}, },
module: { module: {

13
flake.lock generated
View File

@@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1689068808, "lastModified": 1731533236,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -20,15 +20,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1691179010, "lastModified": 1757034884,
"narHash": "sha256-83NO4I6eKStD0VPJWTt9lymaqhCeUmHQ/0MOUo7fQPM=", "narHash": "sha256-PgLSZDBEWUHpfTRfFyklmiiLBE1i1aGCtz4eRA3POao=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f9e7c7f7e5deba3339e5cc45ab3e4e17414ee78e", "rev": "ca77296380960cd497a765102eeb1356eb80fed0",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

View File

@@ -1,13 +1,12 @@
{ {
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils = { flake-utils = {
url = "github:numtide/flake-utils"; url = "github:numtide/flake-utils";
}; };
}; };
outputs = inputs @ { outputs = {
self,
nixpkgs, nixpkgs,
flake-utils, flake-utils,
... ...
@@ -17,12 +16,7 @@
in { in {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = buildInputs =
[pkgs.alejandra pkgs.nodejs pkgs.dotnet-sdk_6 pkgs.python3] [pkgs.alejandra pkgs.nodejs pkgs.dotnet-sdk_9 pkgs.python3 pkgs.xmlstarlet];
++ (
if pkgs.stdenv.isDarwin
then [pkgs.darwin.apple_sdk.frameworks.CoreServices]
else []
);
}; };
}); });
} }