Skip to content

Feature/consolesink fixes - #34

Closed
OlegZee wants to merge 32 commits into
FakeBuild:devfrom
OlegZee:feature/consolesink-fixes
Closed

Feature/consolesink fixes#34
OlegZee wants to merge 32 commits into
FakeBuild:devfrom
OlegZee:feature/consolesink-fixes

Conversation

@OlegZee

Copy link
Copy Markdown
Collaborator

No description provided.

OlegZeeand others added 30 commits November 8, 2019 13:29
…rencing nuget), fixed console garbling in VS, added support for substitutions in phony rules, closing database on Ctrl-C, support for Tasks in recipes
- Added new build and publish workflows for .NET projects.
- Updated .NET SDK version from 7.0 to 9.0 in global.json and project files.
#2)
* Enhance documentation and improve Shell command options in Xake scripts, new dependsOn function, updates sample code in features.fsx
* Update samples/features.fsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/core/ScriptFuncs.fs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: olegz <oleg.zaimkin@developertools.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Refactor version retrieval in build script to simplify logic and improve clarity
new feature: --resetdb flag that clears database before running build.
fix: all targets requested become lowercase while parsing CLI args.
Add stdout and stderr handlers to ShellOptions and update tests
* feature: NoPersist and Teardown options in ExecOptions
feature: new "engine" mode for library mode
* refactor: enhance file reading functions and improve XakeEngine demand handling
* Deep refactoring of exec types and engine classes
* few fixes based on code review
* Update src/core/WorkerPool.fs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* following up review notes + more doc comments
---------
Co-authored-by: olegz <oleg.zaimkin@developertools.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* feature: NoPersist and Teardown options in ExecOptions
feature: new "engine" mode for library mode
* refactor: enhance file reading functions and improve XakeEngine demand handling
* Deep refactoring of exec types and engine classes
* few fixes based on code review
* Update src/core/WorkerPool.fs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* following up review notes + more doc comments
* follow up more issues
* Refactor error logging and improve demand handling in the engine:
- fixed noPersist behavior
- demand waits for prior runs of same target to complete before start
- more tests to verify behavior
---------
Co-authored-by: olegz <oleg.zaimkin@developertools.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add RuleBuilder implementing new rules definition syntax using "target" and "command" keywords
* new command rules are now imperative: always executed
* Update src/core/RuleBuilder.fs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fix XML doc comment misassociation for `<==` operator and `needSequentially` (#8)
* Initial plan
* Fix XML doc comment placement: move needSequentially above the &lt;== doc block
Co-authored-by: OlegZee <513301+OlegZee@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: OlegZee <513301+OlegZee@users.noreply.github.com>
* Moving new command, target(s) syntax to Xake namespace (from Experimental)
---------
Co-authored-by: olegz <oleg.zaimkin@developertools.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: OlegZee <513301+OlegZee@users.noreply.github.com>
* implement typed variable system with support for CLI and environment variable resolution
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…#11)
Adds consistent teardown execution for CLI script runs so teardown targets run after both successful builds and build failures (including when ThrowOnError is enabled), aligning CLI behavior with the long-lived engine teardown flow.
Changes:
Introduces ScriptRunner.runTeardownAsync and uses it from both CLI execution and XakeEngine.StopAsync.
Updates CLI runScript to always run teardown after build completion/failure, and to preserve the original build error when teardown also fails.
Adds CLI-focused tests covering teardown on success, failure, teardown-failure reporting, and skipping teardown for --dryrun/--dump.
… improve progress reporting.
improved: turning progress off for engine mode, cleaned output in tests

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes Xake’s core execution model and scripting surface by introducing a long-lived engine API, typed variable/schema support with --help integration, and updated build/test infrastructure targeting newer .NET tooling.

Changes:

  • Refactors script execution into a new ScriptRunner pipeline and adds a long-lived XakeEngine (start / Demand / StopAsync) for watch/LSP-style usage.
  • Introduces typed variables (Var.*) and varschema for CLI/env resolution + --help output.
  • Updates build scripts, samples, docs, CI workflows, and test target frameworks/tooling (notably net9.0 for tests and .NET 9 global.json).

Reviewed changes

Copilot reviewed 66 out of 68 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
xake.slnRemoves Paket solution items from the solution structure.
src/tests/XakeScriptTests.fsUpdates tests for new options semantics (e.g., ResetDb) and minor refactors.
src/tests/XakeEngineTests.fsAdds new tests for long-lived engine Demand/StopAsync behavior and concurrency.
src/tests/VarsTests.fsAdds comprehensive tests for typed variables, env/CLI precedence, and varschema behavior.
src/tests/tests.fsprojMoves tests to net9.0 and updates test packages; adds new test files.
src/tests/SystemTaskTests.fsExpands shell task tests (Unix-focused) and adjusts options (ThrowOnError, ResetDb).
src/tests/StorageTests.fsAdds test coverage for Storage.cleanupDb.
src/tests/ScriptErrorTests.fsSwitches to ThrowOnError and adjusts logger filter and want usage.
src/tests/RecipeTests.fsSwitches to ThrowOnError in test options.
src/tests/CommandTests.fsAdds tests for new command rule behavior across runs and engine demands.
src/tests/CommandLineTests.fsRefactors CLI assertions; adds teardown/resetdb/case-preservation tests.
src/core/XakeScriptBuilder.fsIntroduces new script builder + long-lived XakeEngine implementation.
src/core/XakeScript.fsMoves/defines ExecOptions here; adds new operators and options (ResetDb/NoPersist/Teardown/VarSchema).
src/core/Xake.fsprojAdjusts target frameworks, compile order, and adds new core modules.
src/core/WorkerPool.fsRefactors worker pool; adds scheduler helper for yielded slots.
src/core/Vars.fsAdds typed variable API (Var.*), required/default helpers, and varschema reflection-based schema capture.
src/core/Types.fsAdds/updates domain type documentation and comments.
src/core/Tasks/Shell.fsExtends shell CE API (stdout/stderr hooks, output capture, result composition) and improves docs.
src/core/Tasks/Rm.fsAdds/updates inline documentation for rm task and aliases.
src/core/Tasks/misc.fsAdds read helpers and reorganizes write helpers (writeTargetText, bytes).
src/core/Tasks/Cp.fsAdds/updates inline documentation for copy task and alias.
src/core/ScriptRunner.fsNew centralized runner converting ExecOptionsEngineOptions, handling Ctrl+C, teardown, resetdb, etc.
src/core/ScriptFuncs.fsRefactors recipe helpers; getVar now reads from ctx.Vars; adds helpers like dependsOn.
src/core/RuleBuilder.fsAdds command/target/targets builder-style rule definitions.
src/core/RecipeFunctions.fsMoves to module Xake.Recipe and streamlines helpers.
src/core/RecipeBuilder.fsExtends recipe CE to bind Task<'T> and improves inline docs.
src/core/Progress.fsTweaks progress loop timing and console reporting (active tasks count).
src/core/Program.fsMakes ParseArgs public; adds --resetdb; changes help flow to ShowHelp; adds xakeEngine builder.
src/core/ProcessExec.fsConverts to module internal Xake.ProcessExec and adds docs for pexec.
src/core/Prelude.fsAdds small helper docs for operators/active patterns.
src/core/Pickler.fsRefactors pickler module layout and definitions into Xake.Pickler.
src/core/PathExt.fsAdds auto-open path operators module.
src/core/Path.fsRefactors into module Xake.Path and removes embedded PathExt operators (now in PathExt.fs).
src/core/FileTasksImpl.fsAdds doc comment for ensureDirCreated.
src/core/Fileset.fsRefactors into module Xake.Fileset with clearer types/docs; keeps existing behavior.
src/core/File.fsAdds documentation; modifies name comparison/hash logic.
src/core/ExecTypes.fsSplits engine-level types (EngineOptions/EngineState) vs exec context; adds var/schema types.
src/core/DependencyAnalysis.fsUpdates to use ctx.Vars for var deps; signature cleanup.
src/core/Database.fsAdds noopDb, cleanupDb, backup helper, docstrings, and minor logging changes.
src/core/CommonLib.fsRefactors module declaration and documentation comments.
src/core/inner-examples.fsxRemoves internal example script.
samples/rmdir.fsxUpdates script header to #r "nuget: ..." reference style/version.
samples/gettingstarted.fsxUpdates script references to NuGet-style #r and newer package versions.
samples/features.fsxUpdates sample to dotnet fsi flow and demonstrates new command/target/dependsOn/sh features.
samples/catch_errors.fsxUpdates script reference to NuGet-style #r.
samples/book/intro.fsxUpdates script references to NuGet-style #r (currently with a syntax issue).
readme.mdUpdates badges, usage instructions, and links; shifts from FAKE to dotnet fsi.
LICENSEUpdates copyright year range.
global.jsonPins/requires .NET SDK 9 with major roll-forward.
build.shUpdates build invocation to dotnet fsi.
build.cmdUpdates build invocation to dotnet fsi.
build.projRemoves legacy FAKE tool restore project.
build.fsx.lockRemoves old paket lock for build script.
build.fsxUpdates build script to new APIs (varschema, typed vars, command/targets, sh).
.vscode/settings.jsonRemoves repo-level VS Code settings.
.travis.ymlUpdates Travis script to dotnet fsi (SDK version currently mismatched with global.json).
.gitignoreAdds Ionide/VS Code/Claude local settings ignores.
.github/workflows/publish.ymlAdds GitHub Actions workflow for tagged publish.
.github/workflows/build.ymlAdds GitHub Actions workflow for PR/branch build and test.
docs/todo.mdRemoves outdated TODO document.
docs/tasks.mdRewrites tasks documentation around new APIs (sh/cp/rm, output capture).
docs/overview.mdReplaces long overview with concise modern baseline and examples.
docs/implnotes.mdReplaces legacy internals notes with updated high-level implementation notes.
docs/devprocess.mdUpdates dev workflow to .NET 9 / dotnet fsi commands and current release process.
docs/cheatsheet.mdAdds new concise cheatsheet for current API and CLI usage.
CLAUDE.mdAdds repository guidance for Claude Code (commands, architecture, conventions).
Comments suppressed due to low confidence (1)

src/core/File.fs:13

  • File path comparison is currently case-insensitive on Unix (ignoreCase = Env.isUnix), which is the opposite of typical filesystem semantics and also inconsistent with DomainTypes.Target (which uses ordinal compare on Unix and ignore-case on Windows). This can cause incorrect equality/hashing for File on Unix and break dependency tracking/caching. ignoreCase should likely be not Env.isUnix (and getFileHash should follow the same rule).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 17 to +20
let create (logger:ILogger) maxThreads =
// controls how many threads are running in parallel
let throttler = new SemaphoreSlim (maxThreads)
let log = logger.Log

let mapKey (artifact:Target) = artifact.FullName

throttler, MailboxProcessor.Start(fun mbox ->
let rec loop(map) = async {
let! msg = mbox.Receive()

match msg with
| Run(artifact, targets, action, chnl) ->
let mkey = artifact |> mapKey

match map |> Map.tryFind mkey with
| Some (task:Task<'a>) ->
log Never "Task found for '%s'. Status %A" artifact.ShortName task.Status
chnl.Reply <| Async.AwaitTask task
return! loop(map)

| None ->
do log Info "Task queued '%s'" artifact.ShortName
do! throttler.WaitAsync(-1) |> Async.AwaitTask |> Async.Ignore

let task = Async.StartAsTask (async {
try
let! buildResult = action
do log Info "Task done '%s'" artifact.ShortName
return buildResult
finally
throttler.Release() |> ignore
})
chnl.Reply <| Async.AwaitTask task
let newMap = targets |> List.fold (fun m t -> m |> Map.add (mapKey t) task) map
return! loop newMap
}
loop(Map.empty) )
// controls how many threads are running in parallel
let throttler = new SemaphoreSlim (maxThreads)
let log = logger.Log
Comment on lines +124 to +128
let makeCtx extraVars = {
Engine = engine
Vars = vars @ defaultArg extraVars []
Progress = Progress.emptyProgress()
NeedRebuild = fun _ -> false
Comment on lines +158 to +163
let details = exceptions |> Seq.last |> fun e -> e.ToString()
let errorText = errors |> String.concat "\r\n"

do ctx.Logger.Log Error "Error '%s'. See build.log for more details" errorText
do ctx.Logger.Log Verbose "Error details are:\n%A\n\n" details
do ctx.Logger.Log Message "\n\n\tBuild failed after running for %A\n" (System.DateTime.Now - start)
Comment on lines 54 to +62
let! ctx = getCtx()
let log = ctx.Logger.Log

do! trace Level.Debug "[shell] settings: '%A'" opts
do! trace Level.Debug "[shell] settings: '%A'" opts // dangerous to log all options, but we need it for debugging purposes. Consider redacting sensitive info in the future.

let handleErr s = log (opts.ErrOutLevel s) "%s %s" opts.LogPrefix s
let handleStd s = log (opts.StdOutLevel s) "%s %s" opts.LogPrefix s
let handleStd s =
log (opts.StdOutLevel s) "%s %s" opts.LogPrefix s
extraStd s
Comment on lines +50 to +55
/// Reset database before build
ResetDb: bool

/// Skip build database; every target always rebuilds.
NoPersist: bool

Comment threadbuild.sh
#!/bin/bash
dotnet restore build.proj
dotnet fake run build.fsx -- build No newline at end of file
dotnet fsi build.fsx -- -- No newline at end of file
Comment thread.travis.yml
Comment on lines 1 to 6
language: csharp
mono: latest
dotnet: 2.1.300
dotnet: 7.0.202
env: VER=$(if [[ "${TRAVIS_TAG:0:1}" == "v" ]]; then echo ${TRAVIS_TAG:1}.${TRAVIS_BUILD_NUMBER}; else echo 1.0.0.${TRAVIS_BUILD_NUMBER}; fi;)
install:
- dotnet restore build.proj
script:
- export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5-api/
- dotnet fake run build.fsx -- build test -ll Diag
- dotnet fsi build.fsx -- -- build test -ll Diag
deploy:
Comment on lines 31 to 37
<ItemGroup>
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>
nuget Xake ~> 1.1 prerelease
nuget Xake.Dotnet ~> 1.1 prerelease //" // (1)
#r "nuget: Xake, 1.1.4.427-beta"
#r "nuget: Xake.Dotnet, 1.1.4.7-beta" (1)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@OlegZee@oleg-zaimkin