From f46557926e3eef1759684726bdb083318f615b1f Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 9 Sep 2025 08:18:41 +0000 Subject: [PATCH] Modernise CI (#5) Co-authored-by: Smaug123 <3138005+Smaug123@users.noreply.github.com> Reviewed-on: https://gitea.patrickstevens.co.uk/patrick/raft-fable/pulls/5 --- .../dotnet-tools.json | 6 ++--- .envrc | 22 +++++++++++++++++++ ...-complete.yml => all-checks-complete.yaml} | 0 .woodpecker/{.build.yml => build.yaml} | 8 +++---- Raft.Test/NetworkAction.fs | 3 ++- Raft.Test/Raft.Test.fsproj | 14 +++++------- Raft.Test/TestInMemoryServer.fs | 12 +++++----- Raft.Test/TestNetworkAction.fs | 1 + Raft.Test/ValidHistory.fs | 1 + RaftFable/webpack.config.js | 13 +++++------ flake.lock | 13 ++++++----- flake.nix | 12 +++------- 12 files changed, 60 insertions(+), 45 deletions(-) rename dotnet-tools.json => .config/dotnet-tools.json (75%) rename .woodpecker/{.all-checks-complete.yml => all-checks-complete.yaml} (100%) rename .woodpecker/{.build.yml => build.yaml} (58%) diff --git a/dotnet-tools.json b/.config/dotnet-tools.json similarity index 75% rename from dotnet-tools.json rename to .config/dotnet-tools.json index 809ba48..e52a8bb 100644 --- a/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,19 +3,19 @@ "isRoot": true, "tools": { "fantomas": { - "version": "6.1.2", + "version": "7.0.3", "commands": [ "fantomas" ] }, "fable": { - "version": "3.2.9", + "version": "4.25.0", "commands": [ "fable" ] }, "femto": { - "version": "0.12.0", + "version": "0.21.0", "commands": [ "femto" ] diff --git a/.envrc b/.envrc index 3550a30..e75d028 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,23 @@ 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 diff --git a/.woodpecker/.all-checks-complete.yml b/.woodpecker/all-checks-complete.yaml similarity index 100% rename from .woodpecker/.all-checks-complete.yml rename to .woodpecker/all-checks-complete.yaml diff --git a/.woodpecker/.build.yml b/.woodpecker/build.yaml similarity index 58% rename from .woodpecker/.build.yml rename to .woodpecker/build.yaml index 7cc894c..175db3c 100644 --- a/.woodpecker/.build.yml +++ b/.woodpecker/build.yaml @@ -6,11 +6,11 @@ steps: # Lint - "nix develop --command bash -c 'dotnet tool restore && ./hooks/pre-push'" # Test - - nix develop --command dotnet -- test - - nix develop --command dotnet -- test --configuration Release + - nix develop --command dotnet test + - nix develop --command dotnet test --configuration Release # Perform build - - "pushd RaftFable && nix develop --command npm -- install && popd" - - "pushd RaftFable && nix develop --command npm -- run-script build && popd" + - "pushd RaftFable && nix develop --command npm install && popd" + - "pushd RaftFable && nix develop --command npm run-script build && popd" when: - event: "push" diff --git a/Raft.Test/NetworkAction.fs b/Raft.Test/NetworkAction.fs index abb97f4..32c6f25 100644 --- a/Raft.Test/NetworkAction.fs +++ b/Raft.Test/NetworkAction.fs @@ -1,6 +1,7 @@ namespace Raft.Test open FsCheck +open FsCheck.FSharp open Raft [] @@ -8,7 +9,7 @@ module NetworkAction = let generate<'a> (clusterSize : int) : Gen> = gen { - let! choice = Arb.generate> + let! choice = ArbMap.defaults |> ArbMap.generate> let! server = Gen.choose (0, clusterSize - 1) let server = server * 1 diff --git a/Raft.Test/Raft.Test.fsproj b/Raft.Test/Raft.Test.fsproj index d81f07c..8b56c59 100644 --- a/Raft.Test/Raft.Test.fsproj +++ b/Raft.Test/Raft.Test.fsproj @@ -1,7 +1,7 @@ - net6.0 + net9.0 false true @@ -19,13 +19,11 @@ - - - - - - - + + + + + diff --git a/Raft.Test/TestInMemoryServer.fs b/Raft.Test/TestInMemoryServer.fs index a5f174c..80e6a64 100644 --- a/Raft.Test/TestInMemoryServer.fs +++ b/Raft.Test/TestInMemoryServer.fs @@ -1,6 +1,7 @@ namespace Raft.Test open System.Threading +open FsCheck.FSharp open Raft open NUnit.Framework open FsUnitTyped @@ -10,10 +11,7 @@ open FsCheck module TestInMemoryServer = let check<'T> (prop : 'T) = - let config = - { Config.QuickThrowOnFailure with - MaxTest = 1000 - } + let config = Config.QuickThrowOnFailure.WithMaxTest(1000).WithQuietOnSuccess (true) Check.One (config, prop) @@ -194,7 +192,7 @@ module TestInMemoryServer = let networkMessageSelectionGen (clusterSize : int) : Gen = gen { let! pile = Gen.choose (0, clusterSize - 1) - let! entry = Arb.generate + let! entry = ArbMap.defaults |> ArbMap.generate return (pile * 1, abs entry) } |> Gen.listOf @@ -425,7 +423,7 @@ module TestInMemoryServer = firstTime = secondTime property - |> Prop.forAll (ValidHistory.arb (Arb.Default.Byte().Generator) clusterSize) + |> Prop.forAll (ValidHistory.arb (ArbMap.defaults |> ArbMap.generate) clusterSize) |> check @@ -448,7 +446,7 @@ module TestInMemoryServer = List.distinct leaders = leaders property - |> Prop.forAll (ValidHistory.arb (Arb.Default.Byte().Generator) clusterSize) + |> Prop.forAll (ValidHistory.arb (ArbMap.defaults |> ArbMap.generate) clusterSize) |> check let duplicationProperty<'a when 'a : equality> diff --git a/Raft.Test/TestNetworkAction.fs b/Raft.Test/TestNetworkAction.fs index a472016..540d603 100644 --- a/Raft.Test/TestNetworkAction.fs +++ b/Raft.Test/TestNetworkAction.fs @@ -1,5 +1,6 @@ namespace Raft.Test +open FsCheck.FSharp open Raft open System.Collections.Generic open NUnit.Framework diff --git a/Raft.Test/ValidHistory.fs b/Raft.Test/ValidHistory.fs index 00366ed..dce9f2e 100644 --- a/Raft.Test/ValidHistory.fs +++ b/Raft.Test/ValidHistory.fs @@ -2,6 +2,7 @@ namespace Raft.Test open Raft open FsCheck +open FsCheck.FSharp type ValidHistory<'a> = | ValidHistory of NetworkAction<'a> list diff --git a/RaftFable/webpack.config.js b/RaftFable/webpack.config.js index 00890a1..63adc5b 100644 --- a/RaftFable/webpack.config.js +++ b/RaftFable/webpack.config.js @@ -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"); - module.exports = { mode: "development", entry: "./src/App.fs.js", @@ -12,8 +7,12 @@ module.exports = { filename: "bundle.js", }, devServer: { - publicPath: "/", - contentBase: "./public", + static: { + directory: path.join(__dirname, "./public"), + }, + devMiddleware: { + publicPath: "/", + }, port: 8080, }, module: { diff --git a/flake.lock b/flake.lock index 7125225..302ca36 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -20,15 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1691179010, - "narHash": "sha256-83NO4I6eKStD0VPJWTt9lymaqhCeUmHQ/0MOUo7fQPM=", + "lastModified": 1757034884, + "narHash": "sha256-PgLSZDBEWUHpfTRfFyklmiiLBE1i1aGCtz4eRA3POao=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f9e7c7f7e5deba3339e5cc45ab3e4e17414ee78e", + "rev": "ca77296380960cd497a765102eeb1356eb80fed0", "type": "github" }, "original": { "owner": "nixos", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index cba753f..d615d11 100644 --- a/flake.nix +++ b/flake.nix @@ -1,13 +1,12 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; flake-utils = { url = "github:numtide/flake-utils"; }; }; - outputs = inputs @ { - self, + outputs = { nixpkgs, flake-utils, ... @@ -17,12 +16,7 @@ in { devShells.default = pkgs.mkShell { buildInputs = - [pkgs.alejandra pkgs.nodejs pkgs.dotnet-sdk_6 pkgs.python3] - ++ ( - if pkgs.stdenv.isDarwin - then [pkgs.darwin.apple_sdk.frameworks.CoreServices] - else [] - ); + [pkgs.alejandra pkgs.nodejs pkgs.dotnet-sdk_9 pkgs.python3 pkgs.xmlstarlet]; }; }); }