Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
"isRoot": true,
"tools": {
"fantomas": {
"version": "6.0.5",
"version": "7.0.3",
"commands": [
"fantomas"
]
},
"fsharp-analyzers": {
"version": "0.33.1",
"commands": [
"fsharp-analyzers"
]
}
}
}
23 changes: 23 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +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
29 changes: 0 additions & 29 deletions .github/workflows/dotnet-core.yaml

This file was deleted.

148 changes: 148 additions & 0 deletions .github/workflows/dotnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json
name: .NET

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
NUGET_XMLDOC_MODE: ''
DOTNET_MULTILEVEL_LOOKUP: 0

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # so that NerdBank.GitVersioning has access to history
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Restore dependencies
run: nix develop --command dotnet restore
- name: Build
run: nix develop --command dotnet build --no-restore --configuration Release
- name: Test
run: nix develop --command dotnet test

build-nix:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Build
run: nix build
- name: Reproducibility check
run: nix build --rebuild

check-dotnet-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Run Fantomas
run: nix run .#fantomas -- --check .

check-nix-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Run Alejandra
run: nix develop --command alejandra --check .

flake-check:
name: Check flake
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Flake check
run: nix flake check

linkcheck:
name: Check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Run link checker
run: nix develop --command markdown-link-check README.md

nuget-pack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # so that NerdBank.GitVersioning has access to history
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Restore dependencies
run: nix develop --command dotnet restore
- name: Build
run: nix develop --command dotnet build --no-restore --configuration Release
- name: Pack
run: nix develop --command dotnet pack --configuration Release
- name: Upload NuGet artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: FicroKanSharp/bin/Release/FicroKanSharp.*.nupkg

expected-pack:
needs: [nuget-pack]
runs-on: ubuntu-latest
steps:
- name: Download NuGet artifact
uses: actions/download-artifact@v4
with:
name: nuget-package
path: packed
- name: Check NuGet contents
# Verify that there is exactly one nupkg in the artifact that would be NuGet published
run: if [[ $(find packed -maxdepth 1 -name 'FicroKanSharp.*.nupkg' -printf c | wc -c) -ne "1" ]]; then exit 1; fi

all-required-checks-complete:
if: ${{ always() }}
needs: [check-dotnet-format, check-nix-format, build, build-nix, flake-check, nuget-pack, expected-pack]
runs-on: ubuntu-latest
steps:
- uses: G-Research/common-actions/check-required-lite@2b7dc49cb14f3344fbe6019c14a31165e258c059
with:
needs-context: ${{ toJSON(needs) }}

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ riderModule.iml
*.user
*.DotSettings
.DS_Store
.direnv/
result
7 changes: 4 additions & 3 deletions FicroKanSharp.Test/Arithmetic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ namespace FicroKanSharp.Test

open FicroKanSharp
open FsUnitTyped
open Xunit
open NUnit.Framework

[<TestFixture>]
module Arithmetic =

[<Fact>]
[<Test>]
let ``Arithmetic example, untyped`` () =
let zero : Term = Term.Symbol ("zero", [])

Expand Down Expand Up @@ -76,7 +77,7 @@ module Arithmetic =
| Zero
| Succ of TypedTerm<Nat>

[<Fact>]
[<Test>]
let ``Arithmetic example, typed`` () =
let rec ofInt (n : int) : TypedTerm<Nat> =
if n = 0 then
Expand Down
10 changes: 5 additions & 5 deletions FicroKanSharp.Test/FicroKanSharp.Test.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
Expand All @@ -14,10 +14,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="FsUnit" Version="4.1.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0" />
<PackageReference Include="FsUnit" Version="7.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions FicroKanSharp.Test/Geometry.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ namespace FicroKanSharp.Test

open FsUnitTyped
open FicroKanSharp
open Xunit
open NUnit.Framework

[<TestFixture>]
module Geometry =

type Point<'a> = Point of TypedTerm<'a> * TypedTerm<'a>
Expand Down Expand Up @@ -34,7 +35,7 @@ module Geometry =
|> TypedTerm.Goal.callFresh
|> TypedTerm.Goal.callFresh

[<Fact>]
[<Test>]
let ``Geometry example from Learn Prolog Now`` () =
Line (
TypedTerm.Literal (Point (TypedTerm.Literal 1, TypedTerm.Literal 1)),
Expand Down
7 changes: 4 additions & 3 deletions FicroKanSharp.Test/Recursive.fs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace FicroKanSharp.Test

open Xunit
open NUnit.Framework
open FsUnitTyped
open FicroKanSharp

[<TestFixture>]
module Recursive =

type Entity =
Expand All @@ -13,7 +14,7 @@ module Recursive =
| Blood of TypedTerm<Entity>
| Name of TypedTerm<string>

[<Fact>]
[<Test>]
let ``Recursive definitions, example 1`` () : unit =
let justAte (t1 : TypedTerm<Entity>) (t2 : TypedTerm<Entity>) : Goal =
Goal.disj
Expand Down Expand Up @@ -58,7 +59,7 @@ module Recursive =

type Human = Human of string

[<Fact>]
[<Test>]
let ``Recursive definitions, example 2`` () : unit =
let children =
[
Expand Down
7 changes: 4 additions & 3 deletions FicroKanSharp.Test/TestCustomUnification.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ namespace FicroKanSharp.Test

open FicroKanSharp
open FsUnitTyped
open Xunit
open NUnit.Framework

[<TestFixture>]
module TestCustomUnification =

[<RequireQualifiedAccess>]
Expand All @@ -27,7 +28,7 @@ module TestCustomUnification =
=
Some state

[<Fact>]
[<Test>]
let ``Type with custom unification`` () =
Goal.equiv (Term.Symbol (Int.Case1, [])) (Term.Symbol (Int.Case2, []))
|> Goal.evaluate
Expand Down Expand Up @@ -94,7 +95,7 @@ module TestCustomUnification =
else
Term.Symbol (Peano.Succ, [ toTerm (n - 1) ])

[<Fact>]
[<Test>]
let ``A custom augmented Peano naturals type`` () =
Goal.equiv (Term.Symbol (Peano.Pure 5, [])) (toTerm 5)
|> Goal.evaluate
Expand Down
Loading