diff options
Diffstat (limited to 'Omni/Agent.hs')
| -rw-r--r-- | Omni/Agent.hs | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/Omni/Agent.hs b/Omni/Agent.hs index bf499af..bad2737 100644 --- a/Omni/Agent.hs +++ b/Omni/Agent.hs @@ -9,19 +9,20 @@ module Omni.Agent where import Alpha import qualified Data.Text as Text +import qualified Data.Text.IO as TIO import qualified Omni.Agent.Core as Core import qualified Omni.Agent.Git as Git +import qualified Omni.Agent.Log as Log import qualified Omni.Agent.Worker as Worker import qualified Omni.Cli as Cli import qualified Omni.Task.Core as TaskCore import qualified Omni.Test as Test import qualified System.Console.Docopt as Docopt import qualified System.Directory as Directory +import qualified System.Environment as Env import qualified System.Exit as Exit import System.FilePath ((</>)) import qualified System.IO.Temp as Temp -import qualified System.Environment as Env -import qualified Data.Text.IO as TIO import qualified System.Process as Process main :: IO () @@ -81,7 +82,7 @@ harvest :: Cli.Arguments -> IO () harvest args = do let path = Cli.getArgWithDefault args "." (Cli.longOption "path") putText "Harvesting task updates from workers..." - + branches <- Git.listBranches path "omni-worker-*" if null branches then putText "No worker branches found." @@ -91,7 +92,7 @@ harvest args = do -- Consolidate Directory.setCurrentDirectory path TaskCore.exportTasks - + -- Commit if changed Git.commit path "task: harvest updates from workers" putText "Success: Task database updated and committed." @@ -120,7 +121,7 @@ mergeDriver :: Cli.Arguments -> IO () mergeDriver args = do ours <- Cli.getArgOrExit args (Cli.argument "ours") theirs <- Cli.getArgOrExit args (Cli.argument "theirs") - + -- Set TASK_DB_PATH to ours (the file git provided as the current version) Env.setEnv "TASK_DB_PATH" ours TaskCore.importTasks theirs @@ -132,27 +133,37 @@ setup args = do let name = Text.pack nameStr root <- Git.getRepoRoot "." let worktreePath = root <> "/../" <> nameStr - + putText <| "Creating worktree '" <> Text.pack worktreePath <> "' on branch '" <> name <> "' (from live)..." - + -- git worktree add -b <name> <path> live Git.runGit root ["worktree", "add", "-b", nameStr, worktreePath, "live"] - + -- Copy .envrc.local if exists let envrc = root </> ".envrc.local" exists <- Directory.doesFileExist envrc when exists <| do putText "Copying .envrc.local..." Directory.copyFile envrc (worktreePath </> ".envrc.local") - + -- Config git Git.runGit worktreePath ["config", "user.name", "Omni Worker"] Git.runGit worktreePath ["config", "user.email", "bot@omni.agent"] - + putText <| "Worker setup complete at " <> Text.pack worktreePath test :: Test.Tree -test = Test.group "Omni.Agent" [unitTests] +test = Test.group "Omni.Agent" [unitTests, logTests] + +logTests :: Test.Tree +logTests = + Test.group + "Log tests" + [ Test.unit "Log.emptyStatus" <| do + let s = Log.emptyStatus "worker-1" + Log.statusWorker s Test.@?= "worker-1" + Log.statusFiles s Test.@?= 0 + ] unitTests :: Test.Tree unitTests = |
