Skip to content

Commit

Permalink
.github/workflows: adding sanity check step
Browse files Browse the repository at this point in the history
  • Loading branch information
Mersho committed Oct 18, 2023
1 parent a08d387 commit f493f69
Show file tree
Hide file tree
Showing 6 changed files with 581 additions and 13 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: dotnet fsi scripts/runUnitTests.fsx

Expand Down Expand Up @@ -118,6 +120,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx

Expand Down Expand Up @@ -149,6 +153,8 @@ jobs:
run: ./configure.sh && cat build.config
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: dotnet fsi scripts/runUnitTests.fsx

Expand Down Expand Up @@ -180,6 +186,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: dotnet fsi scripts/runUnitTests.fsx

Expand Down Expand Up @@ -222,6 +230,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx

- name: install
run: |
Expand Down Expand Up @@ -266,6 +276,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx

Expand Down Expand Up @@ -297,6 +309,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: dotnet fsi scripts/runUnitTests.fsx

Expand Down Expand Up @@ -328,6 +342,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: dotnet fsi scripts/runUnitTests.fsx

Expand Down Expand Up @@ -370,6 +386,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx

- name: install
run: |
Expand Down Expand Up @@ -414,6 +432,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: fsharpi --define:LEGACY_FRAMEWORK scripts/runUnitTests.fsx

Expand Down Expand Up @@ -452,6 +472,8 @@ jobs:
run: ./configure.sh
- name: build in DEBUG mode
run: make
- name: sanity check
run: dotnet fsi scripts/sanitycheck.fsx
- name: run unit tests
run: dotnet fsi scripts/runUnitTests.fsx

Expand All @@ -477,6 +499,8 @@ jobs:
run: del $(where.exe dotnet)
- name: build in DEBUG mode
run: .\make.bat
- name: sanity check
run: .\make.bat sanitycheck
- name: run unit tests
run: .\Tools\fsi.bat scripts\runUnitTests.fsx

Expand All @@ -503,6 +527,8 @@ jobs:
dotnet-version: '6.0.x'
- name: build in DEBUG mode
run: .\make.bat
- name: sanity check
run: .\make.bat sanitycheck
- name: run unit tests
run: dotnet fsi scripts/runUnitTests.fsx

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ reinstall:

check:
./scripts/runTests.fsx

sanitycheck:
@./scripts/build.sh sanitycheck
19 changes: 6 additions & 13 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
#!/usr/bin/env bash
set -e
set -exo pipefail

if [ ! -f ./build.config ]; then
echo "Please run ./configure.sh first" >&2
exit 1
BUILD_CONFIG="./build.config"
if [ ! -f "$BUILD_CONFIG" ]; then
echo "ERROR: configure hasn't been run yet, run ./configure.sh first" >&2 && exit 1
fi
source build.config

if [[ ! $BuildTool == dotnet* ]]; then
mkdir -p .nuget/
curl -o .nuget/NuGet.exe https://dist.nuget.org/win-x86-commandline/v5.4.0/nuget.exe
mono .nuget/NuGet.exe restore $Solution
fi

$BuildTool $Solution $1
source "$BUILD_CONFIG"
FsxRunnerBin=$FsxRunnerBin FsxRunnerArg=$FsxRunnerArg BuildTool=$BuildTool LegacyBuildTool=$LegacyBuildTool $FsxRunnerBin $FsxRunnerArg ./scripts/make.fsx "$@"
54 changes: 54 additions & 0 deletions scripts/fsxHelper.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
namespace GWallet.Scripting

open System
open System.IO

open Fsdk
open Fsdk.Process

module FsxHelper =

let ScriptsDir = __SOURCE_DIRECTORY__ |> DirectoryInfo
let RootDir = Path.Combine(ScriptsDir.FullName, "..") |> DirectoryInfo
let SourceDir = Path.Combine(ScriptsDir.FullName, "../src/") |> DirectoryInfo
let NugetDir = Path.Combine (RootDir.FullName, ".nuget") |> DirectoryInfo
let NugetExe = Path.Combine (NugetDir.FullName, "nuget.exe") |> FileInfo
let NugetSolutionPackagesDir = Path.Combine(RootDir.FullName, "packages") |> DirectoryInfo
let NugetScriptsPackagesDir() =
let dir = Path.Combine(NugetDir.FullName, "packages") |> DirectoryInfo
if not dir.Exists then
Directory.CreateDirectory dir.FullName
|> ignore
dir

let AreGtkLibsPresent echoMode =
if Misc.GuessPlatform() <> Misc.Platform.Linux then
failwith "Gtk is only supported in Linux"

let pkgConfigForGtkProc = Process.Execute({ Command = "pkg-config"; Arguments = "gtk-sharp-2.0" }, echoMode)
match pkgConfigForGtkProc.Result with
| Error _ -> false
| _ -> true

let FsxRunnerInfo() =
match Misc.GuessPlatform() with
| Misc.Platform.Windows ->
#if !LEGACY_FRAMEWORK
"dotnet", "fsi"
#else
Path.Combine(ScriptsDir.FullName, "fsx", "Tools", "fsi.bat"), String.Empty
#endif
| _ ->
let fsxRunnerBinEnvVar = Environment.GetEnvironmentVariable "FsxRunnerBin"
let fsxRunnerArgEnvVar = Environment.GetEnvironmentVariable "FsxRunnerArg"
if String.IsNullOrEmpty fsxRunnerBinEnvVar then
let msg = "FsxRunnerBin env var not found, it should have been sourced from build.config file"
let msgFull =
msg + Environment.NewLine +
(sprintf "(maybe you 1. %s, or 2. %s, or 3. %s)"
"called this from configure.fsx (which is not supported, just use this func from make.fsx or sanitycheck.fsx)"
"you meant to run a Makefile target rather than this script directly?"
"there is a .sh wrapper script for your .fsx script"
)
failwith msgFull
fsxRunnerBinEnvVar, fsxRunnerArgEnvVar
28 changes: 28 additions & 0 deletions scripts/make.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,34 @@ match maybeTarget with
| "0" -> ()
| _ -> failwith "Unexpected output from tests (error propagation)"

| Some "sanitycheck" ->

#if LEGACY_FRAMEWORK
if not FsxHelper.NugetExe.Exists then
MakeAll None |> ignore

let microsoftBuildLibVersion = "16.11.0"
let pkgOutputDir = FsxHelper.NugetScriptsPackagesDir()
Network.InstallNugetPackage
FsxHelper.NugetExe
pkgOutputDir
"Microsoft.Build"
(Some microsoftBuildLibVersion)
Echo.All
|> ignore

#endif

let sanityCheckScript = Path.Combine(FsxHelper.ScriptsDir.FullName, "sanitycheck.fsx")
let fsxRunnerBin,fsxRunnerArg = FsxHelper.FsxRunnerInfo()
Process.Execute(
{
Command = fsxRunnerBin
Arguments = sprintf "%s %s" fsxRunnerArg sanityCheckScript
},
Echo.All
).UnwrapDefault() |> ignore<string>

| Some someOtherTarget ->
Console.Error.WriteLine("Unrecognized target: " + someOtherTarget)
Environment.Exit 1
Loading

0 comments on commit f493f69

Please sign in to comment.