From 0540351ff72e5be0cf62a3c345e41f91ee8f2c82 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Tue, 16 Jan 2024 15:24:46 -0500 Subject: [PATCH 001/181] Further work on compilation to standalone executables Switch compile.native to using the native Runtime Tweak the call for compilation to use `racket runner.rkt`, since it seems like _compiling_ runner.rkt precludes the use of create-embedding-executable, at least until something further is figured out. runner and other racket infrastructure additions for producing the right input for racket executable creation --- .../src/Unison/Runtime/Interface.hs | 15 ++++-- scheme-libs/racket/runner.rkt | 52 +++++++++++++++---- .../racket/unison/primops-generated.rkt | 30 +++++++++++ .../src/Unison/Codebase/Editor/HandleInput.hs | 38 +++++++------- 4 files changed, 102 insertions(+), 33 deletions(-) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 657b6616a3..6798dbffc4 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -476,8 +476,9 @@ nativeCompile :: nativeCompile _version ctxVar cl ppe base path = tryM $ do ctx <- readIORef ctxVar (tyrs, tmrs) <- collectRefDeps cl base - (_, codes) <- loadDeps cl ppe ctx tyrs tmrs - nativeCompileCodes codes base path + (ctx, codes) <- loadDeps cl ppe ctx tyrs tmrs + Just ibase <- pure $ baseToIntermed ctx base + nativeCompileCodes codes ibase path interpCompile :: Text -> @@ -655,6 +656,14 @@ schemeProc args = std_err = Inherit } +racketProc :: [String] -> CreateProcess +racketProc args = + (proc "racket" ("scheme-libs/racket/runner.rkt":args)) + { std_in = CreatePipe, + std_out = Inherit, + std_err = Inherit + } + -- Note: this currently does not support yielding values; instead it -- just produces a result appropriate for unitary `run` commands. The -- reason is that the executed code can cause output to occur, which @@ -712,7 +721,7 @@ nativeCompileCodes codes base path = do waitForProcess ph pure () callout _ _ _ _ = fail "withCreateProcess didn't provide handles" - withCreateProcess (schemeProc ["-o", path]) callout + withCreateProcess (racketProc ["-o", path]) callout evalInContext :: PrettyPrintEnv -> diff --git a/scheme-libs/racket/runner.rkt b/scheme-libs/racket/runner.rkt index 37406b55ba..af6226c200 100644 --- a/scheme-libs/racket/runner.rkt +++ b/scheme-libs/racket/runner.rkt @@ -1,6 +1,7 @@ -#!racket/base +#lang racket/base (require + racket/pretty (except-in racket false true unit any) compiler/embed unison/boot @@ -29,9 +30,7 @@ (define (build-main-module main-def) `(module unison-main racket/base - (require - unison/boot) - + (require unison/boot) (provide main) (define (main) @@ -45,13 +44,44 @@ ((termlink->proc main-ref)) (data 'unit 0)))) -; stub implementation -(define (do-compile output) (void)) - ; (let-values ([(code main-ref) (decode-input)]) - ; (create-embedding-executable - ; output - ; #:modules '((#f unison-main)) - ; #:literal-expression '(begin (require unison-main) (main))))) +(define (write-module srcf main-ref icode) + (call-with-output-file + srcf + (lambda (port) + (parameterize ([print-as-expression #t]) + (display "#lang racket/base\n\n" port) + + (for ([expr (build-intermediate-expressions main-ref icode)]) + (pretty-print expr port 1) + (newline port)) + (newline port))) + #:exists 'replace)) + +(define (do-compile output) + (define-values (icode main-ref) (decode-input)) + + (define srcf (path->string (path-replace-extension output ".rkt"))) + (define dstf (embedding-executable-add-suffix output #f)) + (define chop (path->string (path-replace-extension output ""))) + (define mod-sym (string->symbol (string-append "#%unison:" chop))) + + (define primary + (parameterize ([current-namespace (make-base-namespace)]) + (compile + `(begin + (namespace-require '',mod-sym) + (when (module-declared? '',mod-sym) + ((dynamic-require '',mod-sym 'main))))))) + + (write-module srcf main-ref icode) + + (create-embedding-executable + dstf + #:modules `((#%unison: (file ,srcf))) + #:variant 'cs + ; #:cmdline '("-U" "--") + #:configure-via-first-module? #t + #:literal-expressions (list primary))) (define runtime-namespace (let ([ns (variable-reference->namespace (#%variable-reference))]) diff --git a/scheme-libs/racket/unison/primops-generated.rkt b/scheme-libs/racket/unison/primops-generated.rkt index 03f49e776d..f84384937a 100644 --- a/scheme-libs/racket/unison/primops-generated.rkt +++ b/scheme-libs/racket/unison/primops-generated.rkt @@ -49,6 +49,7 @@ termlink->name add-runtime-code + build-intermediate-expressions build-runtime-module termlink->proc) @@ -558,6 +559,35 @@ (parameterize ([current-namespace runtime-namespace]) (dynamic-require `(quote ,mname) sym)))])) +; Straight-line module builder given intermediate definitions. +; This expects to receive a list of termlink, code pairs, and +; generates a scheme module that contains the corresponding +; definitions. +(define (build-intermediate-expressions primary dfns0) + (let* ([udefs (chunked-list->list dfns0)] + [pname (termlink->name primary)] + [tmlinks (map ufst udefs)] + [codes (map usnd udefs)] + [tylinks (gen-typelinks codes)] + [sdefs (flatten (map gen-code udefs))]) + `((require unison/boot + unison/data-info + unison/primops + unison/primops-generated + unison/builtin-generated + unison/simple-wrappers + unison/compound-wrappers) + + (provide main) + + ,@tylinks + + ,@sdefs + + (define (main) + (handle ['ref-4n0fgs00] top-exn-handler + (,pname #f)))))) + (define (build-runtime-module mname tylinks tmlinks defs) (let ([names (map termlink->name tmlinks)]) `(module ,mname racket/base diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs index 60bbb94454..0bbaaef2d0 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs @@ -971,7 +971,7 @@ loop e = do when (not updated) (Cli.respond $ NothingToPatch patchPath scopePath') ExecuteI main args -> handleRun False main args MakeStandaloneI output main -> doCompile False output main - CompileSchemeI output main -> doCompileScheme output main + CompileSchemeI output main -> doCompile True output main ExecuteSchemeI main args -> doRunAsScheme main args GenSchemeLibsI mdir -> doGenerateSchemeBoot True Nothing mdir @@ -2071,21 +2071,21 @@ runScheme file args = do unless success $ Cli.returnEarly (PrintMessage "Scheme evaluation failed.") -buildScheme :: String -> String -> Cli () -buildScheme main file = do - ensureSchemeExists - statDir <- getSchemeStaticLibDir - genDir <- getSchemeGenLibDir - buildRacket genDir statDir main file - -buildRacket :: String -> String -> String -> String -> Cli () -buildRacket genDir statDir main file = - let args = ["-l", "raco", "--", "exe", "-o", main, file] - opts = racketOpts genDir statDir args - in void . liftIO $ - catch - (True <$ callProcess "racket" opts) - (\(_ :: IOException) -> pure False) +-- buildScheme :: String -> String -> Cli () +-- buildScheme main file = do +-- ensureSchemeExists +-- statDir <- getSchemeStaticLibDir +-- genDir <- getSchemeGenLibDir +-- buildRacket genDir statDir main file + +-- buildRacket :: String -> String -> String -> String -> Cli () +-- buildRacket genDir statDir main file = +-- let args = ["-l", "raco", "--", "exe", "-o", main, file] +-- opts = racketOpts genDir statDir args +-- in void . liftIO $ +-- catch +-- (True <$ callProcess "racket" opts) +-- (\(_ :: IOException) -> pure False) doCompile :: Bool -> String -> HQ.HashQualified Name -> Cli () doCompile native output main = do @@ -2111,9 +2111,9 @@ doRunAsScheme main0 args = case HQ.fromString main0 of runScheme fullpath args Nothing -> Cli.respond $ BadName main0 -doCompileScheme :: String -> HQ.HashQualified Name -> Cli () -doCompileScheme out main = - generateSchemeFile True out main >>= buildScheme out +-- doCompileScheme :: String -> HQ.HashQualified Name -> Cli () +-- doCompileScheme out main = +-- generateSchemeFile True out main >>= buildScheme out generateSchemeFile :: Bool -> String -> HQ.HashQualified Name -> Cli String generateSchemeFile exec out main = do From f78c119fdc43936b3ea8da05588246ebb4fdcd2e Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Mon, 5 Feb 2024 13:32:01 -0500 Subject: [PATCH 002/181] Revise how native compilation works There are, for the moment, multiple problems with producing executables. One is that the API doesn't work when certain math libraries are imported. The other is that the API doesn't work in a generated executable. So, I've turned the 'compile mode' of the standalone runtime program just generate a module to be compiled. Then we can use an installed `raco` to build that module into a standalone program. I don't think there's any advantage currently to not using raco, since the best we can do is write our own separate exe builder that still requires racket to be installed. In any case, the exe builder must apparently be a separate program so that it doesn't need to import the offending math library. --- .../src/Unison/Runtime/Interface.hs | 27 +++++++------ scheme-libs/racket/runner.rkt | 40 +++++-------------- .../racket/unison/primops-generated.rkt | 11 ++--- 3 files changed, 28 insertions(+), 50 deletions(-) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 6798dbffc4..97c6e967a0 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -44,9 +44,16 @@ import Data.Set as Set ) import Data.Set qualified as Set import Data.Text (isPrefixOf, unpack) +import System.Directory + ( XdgDirectory(XdgCache), + createDirectoryIfMissing, + getXdgDirectory + ) +import System.FilePath ((<.>), ()) import System.Process ( CreateProcess (..), StdStream (..), + callProcess, proc, waitForProcess, withCreateProcess, @@ -648,22 +655,14 @@ backReferenceTm ws frs irs dcm c i = do bs <- Map.lookup r dcm Map.lookup i bs -schemeProc :: [String] -> CreateProcess -schemeProc args = +ucrProc :: [String] -> CreateProcess +ucrProc args = (proc "native-compiler/bin/runner" args) { std_in = CreatePipe, std_out = Inherit, std_err = Inherit } -racketProc :: [String] -> CreateProcess -racketProc args = - (proc "racket" ("scheme-libs/racket/runner.rkt":args)) - { std_in = CreatePipe, - std_out = Inherit, - std_err = Inherit - } - -- Note: this currently does not support yielding values; instead it -- just produces a result appropriate for unitary `run` commands. The -- reason is that the executed code can cause output to occur, which @@ -705,7 +704,7 @@ nativeEvalInContext _ ctx codes base = do -- decodeResult . deserializeValue =<< BS.hGetContents pout callout _ _ _ _ = pure . Left $ "withCreateProcess didn't provide handles" - withCreateProcess (schemeProc []) callout + withCreateProcess (ucrProc []) callout nativeCompileCodes :: [(Reference, SuperGroup Symbol)] -> @@ -713,7 +712,10 @@ nativeCompileCodes :: FilePath -> IO () nativeCompileCodes codes base path = do + genDir <- getXdgDirectory XdgCache "unisonlanguage/racket-tmp" + createDirectoryIfMissing True genDir let bytes = serializeValue . compileValue base $ codes + srcPath = genDir path <.> "rkt" callout (Just pin) _ _ ph = do BS.hPut pin . runPutS . putWord32be . fromIntegral $ BS.length bytes BS.hPut pin bytes @@ -721,7 +723,8 @@ nativeCompileCodes codes base path = do waitForProcess ph pure () callout _ _ _ _ = fail "withCreateProcess didn't provide handles" - withCreateProcess (racketProc ["-o", path]) callout + withCreateProcess (ucrProc ["-G", srcPath]) callout + callProcess "raco" ["exe", "-o", path, srcPath] evalInContext :: PrettyPrintEnv -> diff --git a/scheme-libs/racket/runner.rkt b/scheme-libs/racket/runner.rkt index af6226c200..ef3b42eddb 100644 --- a/scheme-libs/racket/runner.rkt +++ b/scheme-libs/racket/runner.rkt @@ -51,37 +51,15 @@ (parameterize ([print-as-expression #t]) (display "#lang racket/base\n\n" port) - (for ([expr (build-intermediate-expressions main-ref icode)]) + (for ([expr (build-intermediate-module main-ref icode)]) (pretty-print expr port 1) (newline port)) (newline port))) #:exists 'replace)) -(define (do-compile output) +(define (do-generate srcf) (define-values (icode main-ref) (decode-input)) - - (define srcf (path->string (path-replace-extension output ".rkt"))) - (define dstf (embedding-executable-add-suffix output #f)) - (define chop (path->string (path-replace-extension output ""))) - (define mod-sym (string->symbol (string-append "#%unison:" chop))) - - (define primary - (parameterize ([current-namespace (make-base-namespace)]) - (compile - `(begin - (namespace-require '',mod-sym) - (when (module-declared? '',mod-sym) - ((dynamic-require '',mod-sym 'main))))))) - - (write-module srcf main-ref icode) - - (create-embedding-executable - dstf - #:modules `((#%unison: (file ,srcf))) - #:variant 'cs - ; #:cmdline '("-U" "--") - #:configure-via-first-module? #t - #:literal-expressions (list primary))) + (write-module srcf main-ref icode)) (define runtime-namespace (let ([ns (variable-reference->namespace (#%variable-reference))]) @@ -99,20 +77,20 @@ [(null? ls) '()] [else (append (car ls) (join (cdr ls)))])) -(define compile (make-parameter #f)) +(define generate-to (make-parameter #f)) (define (handle-command-line) (command-line #:program "runner" #:once-any - [("-o" "--output") + [("-G" "--generate-file") file - "compile to " - (compile file)] + "generate code to " + (generate-to file)] #:args () - (compile))) + (generate-to))) (let ([out (handle-command-line)]) (if out - (do-compile out) + (do-generate out) (do-evaluate))) diff --git a/scheme-libs/racket/unison/primops-generated.rkt b/scheme-libs/racket/unison/primops-generated.rkt index f84384937a..e59ce25666 100644 --- a/scheme-libs/racket/unison/primops-generated.rkt +++ b/scheme-libs/racket/unison/primops-generated.rkt @@ -49,7 +49,7 @@ termlink->name add-runtime-code - build-intermediate-expressions + build-intermediate-module build-runtime-module termlink->proc) @@ -563,7 +563,7 @@ ; This expects to receive a list of termlink, code pairs, and ; generates a scheme module that contains the corresponding ; definitions. -(define (build-intermediate-expressions primary dfns0) +(define (build-intermediate-module primary dfns0) (let* ([udefs (chunked-list->list dfns0)] [pname (termlink->name primary)] [tmlinks (map ufst udefs)] @@ -578,15 +578,12 @@ unison/simple-wrappers unison/compound-wrappers) - (provide main) - ,@tylinks ,@sdefs - (define (main) - (handle ['ref-4n0fgs00] top-exn-handler - (,pname #f)))))) + (handle ['ref-4n0fgs00] top-exn-handler + (,pname #f))))) (define (build-runtime-module mname tylinks tmlinks defs) (let ([names (map termlink->name tmlinks)]) From 958b8b958a5353f8657131e423b07456c2dc27d0 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Mon, 5 Feb 2024 16:37:29 -0500 Subject: [PATCH 003/181] Rename runner, add docs, delete dead code --- scheme-libs/racket/runner.rkt | 96 ----------------------------- scheme-libs/racket/ucr.rkt | 111 ++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 96 deletions(-) delete mode 100644 scheme-libs/racket/runner.rkt create mode 100644 scheme-libs/racket/ucr.rkt diff --git a/scheme-libs/racket/runner.rkt b/scheme-libs/racket/runner.rkt deleted file mode 100644 index ef3b42eddb..0000000000 --- a/scheme-libs/racket/runner.rkt +++ /dev/null @@ -1,96 +0,0 @@ -#lang racket/base - -(require - racket/pretty - (except-in racket false true unit any) - compiler/embed - unison/boot - unison/data - unison/data-info - unison/chunked-seq - unison/primops - unison/primops-generated - unison/builtin-generated) - -(define (grab-bytes) - (let* ([size-bytes (read-bytes 4)] - [size (integer-bytes->integer size-bytes #f #t 0 4)]) - (read-bytes size))) - -(define (decode-input) - (let ([bs (grab-bytes)]) - (match (builtin-Value.deserialize (bytes->chunked-bytes bs)) - [(unison-data _ t (list q)) - (= t unison-either-right:tag) - (apply - values - (unison-tuple->list (reify-value (unison-quote-val q))))] - [else - (raise "unexpected input")]))) - -(define (build-main-module main-def) - `(module unison-main racket/base - (require unison/boot) - (provide main) - - (define (main) - (handle ['ref-4n0fgs00] top-exn-handler - (,(termlink->name main-def)))))) - -(define (do-evaluate) - (let-values ([(code main-ref) (decode-input)]) - (add-runtime-code 'unison-main code) - (handle ['ref-4n0fgs00] top-exn-handler - ((termlink->proc main-ref)) - (data 'unit 0)))) - -(define (write-module srcf main-ref icode) - (call-with-output-file - srcf - (lambda (port) - (parameterize ([print-as-expression #t]) - (display "#lang racket/base\n\n" port) - - (for ([expr (build-intermediate-module main-ref icode)]) - (pretty-print expr port 1) - (newline port)) - (newline port))) - #:exists 'replace)) - -(define (do-generate srcf) - (define-values (icode main-ref) (decode-input)) - (write-module srcf main-ref icode)) - -(define runtime-namespace - (let ([ns (variable-reference->namespace (#%variable-reference))]) - (namespace-require ''#%kernel ns) - ns)) - -(define (chunked-list->list cl) - (vector->list (chunked-list->vector cl))) - -(define (list->chunked-list l) - (vector->chunked-list (list->vector l))) - -(define (join ls) - (cond - [(null? ls) '()] - [else (append (car ls) (join (cdr ls)))])) - -(define generate-to (make-parameter #f)) - -(define (handle-command-line) - (command-line - #:program "runner" - #:once-any - [("-G" "--generate-file") - file - "generate code to " - (generate-to file)] - #:args () - (generate-to))) - -(let ([out (handle-command-line)]) - (if out - (do-generate out) - (do-evaluate))) diff --git a/scheme-libs/racket/ucr.rkt b/scheme-libs/racket/ucr.rkt new file mode 100644 index 0000000000..6f4217b416 --- /dev/null +++ b/scheme-libs/racket/ucr.rkt @@ -0,0 +1,111 @@ +#lang racket/base + +; This implements a standalone unison runtime, with options for +; generating compilable racket modules. +; +; For runtime, it relies on the support for unison dynamic code +; loading. It expects to be provided with a serialized list of term +; links and associated code. It then loads the code in the same manner +; as dynamic runtime execution, and evaluates a main definition. +; +; Since this is intended to be an implementation of evaluation for +; e.g. ucm, the input is expected to be complete. No protocol is +; implemented for negotiating with a host for additional needed +; definitions. The program has all the built in definitions, and +; everything else is expected to be provided in the initial input. +; +; In addition to this mode, it is possible to supply a command line +; argument `-G` with a file name. This will instead produce a racket +; file with the supplied definitions. This file should be suitable for +; compilation and distribution with the `raco` tool, so long as the +; supporting unison-on-racket libraries are known to the racket +; install. + +(require + racket/pretty + (except-in racket false true unit any) + compiler/embed + unison/boot + unison/data + unison/data-info + unison/chunked-seq + unison/primops + unison/primops-generated + unison/builtin-generated) + +; Gets bytes using the expected input format. The format is simple: +; +; - 4 bytes indicating how many bytes follow +; - the actual payload, with size matching the above +(define (grab-bytes) + (let* ([size-bytes (read-bytes 4)] + [size (integer-bytes->integer size-bytes #f #t 0 4)]) + (read-bytes size))) + +; Reads and decodes the input. First uses `grab-bytes` to read the +; payload, then uses unison functions to deserialize the `Value` that +; is expected. +; +; The `Value` is expected to be a pair of loadable code and which +; definition should be executed. In unison types, it is: +; +; ([(Link.Term, Code)], Link.Term) +(define (decode-input) + (let ([bs (grab-bytes)]) + (match (builtin-Value.deserialize (bytes->chunked-bytes bs)) + [(unison-data _ t (list q)) + (= t unison-either-right:tag) + (apply + values + (unison-tuple->list (reify-value (unison-quote-val q))))] + [else + (raise "unexpected input")]))) + +; Implements the evaluation mode of operation. First decodes the +; input. Then uses the dynamic loading machinery to add the code to +; the runtime. Finally executes a specified main reference. +(define (do-evaluate) + (let-values ([(code main-ref) (decode-input)]) + (add-runtime-code 'unison-main code) + (handle ['ref-4n0fgs00] top-exn-handler + ((termlink->proc main-ref)) + (data 'unit 0)))) + +; Uses racket pretty printing machinery to instead generate a file +; containing the given code, and which executes the main definition on +; loading. This file can then be built with `raco exe`. +(define (write-module srcf main-ref icode) + (call-with-output-file + srcf + (lambda (port) + (parameterize ([print-as-expression #t]) + (display "#lang racket/base\n\n" port) + + (for ([expr (build-intermediate-module main-ref icode)]) + (pretty-print expr port 1) + (newline port)) + (newline port))) + #:exists 'replace)) + +; Decodes input and writes a module to the specified file. +(define (do-generate srcf) + (define-values (icode main-ref) (decode-input)) + (write-module srcf main-ref icode)) + +(define generate-to (make-parameter #f)) + +(define (handle-command-line) + (command-line + #:program "ucr" + #:once-any + [("-G" "--generate-file") + file + "generate code to " + (generate-to file)] + #:args () + (generate-to))) + +(let ([out (handle-command-line)]) + (if out + (do-generate out) + (do-evaluate))) From 2e98e1a7c2f3de9e00ce4cc081dc67fa46d9c177 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Tue, 6 Feb 2024 14:04:43 -0500 Subject: [PATCH 004/181] Add a transcript to create generated racket libs --- unison-src/transcripts-manual/gen-racket-libs.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 unison-src/transcripts-manual/gen-racket-libs.md diff --git a/unison-src/transcripts-manual/gen-racket-libs.md b/unison-src/transcripts-manual/gen-racket-libs.md new file mode 100644 index 0000000000..3f64517732 --- /dev/null +++ b/unison-src/transcripts-manual/gen-racket-libs.md @@ -0,0 +1,9 @@ + +Fetch base, then fetch the compiler, then build the generated +libraries in the racket directory. + +```ucm +.> pull @unison/base/releases/2.5.0 .base +.> compile.native.fetch +.> compile.native.genlibs scheme-libs/racket +``` From c3c62c4d453a66eb5ab133c93cef969e5a63be18 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Tue, 6 Feb 2024 16:28:24 -0500 Subject: [PATCH 005/181] Give a nicer looking error for ucr/raco problems --- parser-typechecker/src/Unison/Runtime/Interface.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 97c6e967a0..584bbff3e4 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -723,8 +723,19 @@ nativeCompileCodes codes base path = do waitForProcess ph pure () callout _ _ _ _ = fail "withCreateProcess didn't provide handles" + ucrError (_ :: IOException) = + die + "I had trouble calling the unison runtime exectuable.\n\n\ + \Please check that the `ucr` executable is properly\ + \ installed." + racoError (_ :: IOException) = + die + "I had trouble calling the `raco` executable.\n\n\ + \Please verify that you have racket installed." withCreateProcess (ucrProc ["-G", srcPath]) callout + `UnliftIO.catch` ucrError callProcess "raco" ["exe", "-o", path, srcPath] + `UnliftIO.catch` racoError evalInContext :: PrettyPrintEnv -> From 72743c5d30e027d1b46e1e6ca447eccb2651d034 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Tue, 6 Feb 2024 16:29:43 -0500 Subject: [PATCH 006/181] Eliminate commented dead code --- .../src/Unison/Codebase/Editor/HandleInput.hs | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs index 0bbaaef2d0..8973e0c78b 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs @@ -2071,22 +2071,6 @@ runScheme file args = do unless success $ Cli.returnEarly (PrintMessage "Scheme evaluation failed.") --- buildScheme :: String -> String -> Cli () --- buildScheme main file = do --- ensureSchemeExists --- statDir <- getSchemeStaticLibDir --- genDir <- getSchemeGenLibDir --- buildRacket genDir statDir main file - --- buildRacket :: String -> String -> String -> String -> Cli () --- buildRacket genDir statDir main file = --- let args = ["-l", "raco", "--", "exe", "-o", main, file] --- opts = racketOpts genDir statDir args --- in void . liftIO $ --- catch --- (True <$ callProcess "racket" opts) --- (\(_ :: IOException) -> pure False) - doCompile :: Bool -> String -> HQ.HashQualified Name -> Cli () doCompile native output main = do Cli.Env {codebase, runtime, nativeRuntime} <- ask @@ -2111,10 +2095,6 @@ doRunAsScheme main0 args = case HQ.fromString main0 of runScheme fullpath args Nothing -> Cli.respond $ BadName main0 --- doCompileScheme :: String -> HQ.HashQualified Name -> Cli () --- doCompileScheme out main = --- generateSchemeFile True out main >>= buildScheme out - generateSchemeFile :: Bool -> String -> HQ.HashQualified Name -> Cli String generateSchemeFile exec out main = do (comp, ppe) <- resolveMainRef main From 788e082ac7d7ba411b2ec6fed2b03065f8a7e39e Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 7 Feb 2024 12:00:14 -0500 Subject: [PATCH 007/181] Add an improved error message for unison native runtime failure --- parser-typechecker/src/Unison/Runtime/Interface.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 584bbff3e4..0cf631fadb 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -704,7 +704,12 @@ nativeEvalInContext _ ctx codes base = do -- decodeResult . deserializeValue =<< BS.hGetContents pout callout _ _ _ _ = pure . Left $ "withCreateProcess didn't provide handles" - withCreateProcess (ucrProc []) callout + ucrError (_ :: IOException) = + die + "I had trouble calling the unison runtime exectuable.\n\n\ + \Please check that the `ucr` executable is properly\ + \ installed." + withCreateProcess (ucrProc []) callout `UnliftIO.catch` ucrError nativeCompileCodes :: [(Reference, SuperGroup Symbol)] -> From 7ce4ad224d09008da85569b5f6cb0f3ea5182a38 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 7 Feb 2024 12:00:42 -0500 Subject: [PATCH 008/181] Add information on further building to gen-racket-libs.md --- .../transcripts-manual/gen-racket-libs.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/unison-src/transcripts-manual/gen-racket-libs.md b/unison-src/transcripts-manual/gen-racket-libs.md index 3f64517732..51c425ad74 100644 --- a/unison-src/transcripts-manual/gen-racket-libs.md +++ b/unison-src/transcripts-manual/gen-racket-libs.md @@ -7,3 +7,24 @@ libraries in the racket directory. .> compile.native.fetch .> compile.native.genlibs scheme-libs/racket ``` + +After executing this, `scheme-libs/racket` will contain the full +complement of unison libraries for a given combination of ucm version +and @unison/internal version. + +To set up racket to use these files, we need to create a package with +them. This is accomplished by running. + + raco pkg install -t dir unison + +in the directory where the `unison` directory is located. Then the +runtime executable can be built with + + raco exe scheme-libs/racket/ucr.rkt + +and a distributable directory can be produced with: + + raco distribute scheme-libs/racket/ucr + +At that point, should contain the executable and all +dependencies necessary to run it. From a678f55e10aa80f4ea747e6ae094c410c2ad239d Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 7 Feb 2024 16:10:33 -0500 Subject: [PATCH 009/181] Actually make run.native use the standalone runner All the infrastructure was there already, just needed to enable it. This should break the jit tests in CI until we can get the runner building as a prior step, and coordinate the location the native runtime looks for the build files. --- .../src/Unison/Runtime/Interface.hs | 2 +- .../src/Unison/Codebase/Editor/HandleInput.hs | 99 +------------------ unison-src/builtin-tests/jit-tests.output.md | 4 + 3 files changed, 7 insertions(+), 98 deletions(-) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 0cf631fadb..cab7aa791a 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -657,7 +657,7 @@ backReferenceTm ws frs irs dcm c i = do ucrProc :: [String] -> CreateProcess ucrProc args = - (proc "native-compiler/bin/runner" args) + (proc "native-compiler/bin/ucr" args) { std_in = CreatePipe, std_out = Inherit, std_err = Inherit diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs index 8973e0c78b..15966c1a46 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs @@ -9,7 +9,6 @@ where -- TODO: Don't import backend import Control.Error.Util qualified as ErrorUtil -import Control.Exception (catch) import Control.Lens import Control.Monad.Reader (ask) import Control.Monad.State (StateT) @@ -29,9 +28,7 @@ import Data.These (These (..)) import Data.Time (UTCTime) import Data.Tuple.Extra (uncurry3) import System.Directory (XdgDirectory (..), createDirectoryIfMissing, doesFileExist, getXdgDirectory) -import System.Exit (ExitCode (..)) import System.FilePath (()) -import System.Process (callProcess, readCreateProcessWithExitCode, shell) import U.Codebase.Branch.Diff qualified as V2Branch.Diff import U.Codebase.Causal qualified as V2Causal import U.Codebase.HashTags (CausalHash (..)) @@ -88,7 +85,7 @@ import Unison.Codebase.Editor.HandleInput.Push (handleGist, handlePushRemoteBran import Unison.Codebase.Editor.HandleInput.ReleaseDraft (handleReleaseDraft) import Unison.Codebase.Editor.HandleInput.Run (handleRun) import Unison.Codebase.Editor.HandleInput.RuntimeUtils qualified as RuntimeUtils -import Unison.Codebase.Editor.HandleInput.TermResolution (resolveCon, resolveMainRef, resolveTermRef) +import Unison.Codebase.Editor.HandleInput.TermResolution (resolveMainRef, resolveTermRef) import Unison.Codebase.Editor.HandleInput.Tests qualified as Tests import Unison.Codebase.Editor.HandleInput.UI (openUI) import Unison.Codebase.Editor.HandleInput.Update (doSlurpAdds, handleUpdate) @@ -133,7 +130,6 @@ import Unison.Hash qualified as Hash import Unison.HashQualified qualified as HQ import Unison.HashQualified' qualified as HQ' import Unison.HashQualified' qualified as HashQualified -import Unison.JitInfo qualified as JitInfo import Unison.LabeledDependency (LabeledDependency) import Unison.LabeledDependency qualified as LD import Unison.LabeledDependency qualified as LabeledDependency @@ -972,7 +968,7 @@ loop e = do ExecuteI main args -> handleRun False main args MakeStandaloneI output main -> doCompile False output main CompileSchemeI output main -> doCompile True output main - ExecuteSchemeI main args -> doRunAsScheme main args + ExecuteSchemeI main args -> handleRun True main args GenSchemeLibsI mdir -> doGenerateSchemeBoot True Nothing mdir FetchSchemeCompilerI name branch -> @@ -1945,11 +1941,6 @@ doFetchCompiler username branch = (ReadShare'ProjectBranch prj) (This compilerPath) -ensureCompilerExists :: Cli () -ensureCompilerExists = - Cli.branchExistsAtPath' compilerPath - >>= flip unless (doFetchCompiler "unison" JitInfo.currentRelease) - getCacheDir :: Cli String getCacheDir = liftIO $ getXdgDirectory XdgCache "unisonlanguage" @@ -1959,14 +1950,6 @@ getSchemeGenLibDir = Just dir -> pure dir Nothing -> ( "scheme-libs") <$> getCacheDir -getSchemeStaticLibDir :: Cli String -getSchemeStaticLibDir = - Cli.getConfig "SchemeLibs.Static" >>= \case - Just dir -> pure dir - Nothing -> - liftIO $ - getXdgDirectory XdgData ("unisonlanguage" "scheme-libs") - doGenerateSchemeBoot :: Bool -> Maybe PPE.PrettyPrintEnv -> Maybe String -> Cli () doGenerateSchemeBoot force mppe mdir = do @@ -2029,48 +2012,6 @@ typecheckAndEval ppe tm = do a = External rendered = P.toPlainUnbroken $ TP.pretty ppe tm -ensureSchemeExists :: Cli () -ensureSchemeExists = - liftIO callScheme >>= \case - True -> pure () - False -> Cli.returnEarly (PrintMessage msg) - where - msg = - P.lines - [ "I can't seem to call racket. See", - "", - P.indentN - 2 - "https://download.racket-lang.org/", - "", - "for how to install Racket." - ] - cmd = "racket -l- raco help" - callScheme = - readCreateProcessWithExitCode (shell cmd) "" >>= \case - (ExitSuccess, _, _) -> pure True - (ExitFailure _, _, _) -> pure False - -racketOpts :: FilePath -> FilePath -> [String] -> [String] -racketOpts gendir statdir args = "-y" : libs ++ args - where - includes = [gendir, statdir "racket"] - libs = concatMap (\dir -> ["-S", dir]) includes - -runScheme :: String -> [String] -> Cli () -runScheme file args = do - ensureSchemeExists - gendir <- getSchemeGenLibDir - statdir <- getSchemeStaticLibDir - let cmd = "racket" - opts = racketOpts gendir statdir (file : args) - success <- - liftIO $ - (True <$ callProcess cmd opts) - `catch` \(_ :: IOException) -> pure False - unless success $ - Cli.returnEarly (PrintMessage "Scheme evaluation failed.") - doCompile :: Bool -> String -> HQ.HashQualified Name -> Cli () doCompile native output main = do Cli.Env {codebase, runtime, nativeRuntime} <- ask @@ -2088,42 +2029,6 @@ doCompile native output main = do ) (Cli.returnEarly . EvaluationFailure) -doRunAsScheme :: String -> [String] -> Cli () -doRunAsScheme main0 args = case HQ.fromString main0 of - Just main -> do - fullpath <- generateSchemeFile True main0 main - runScheme fullpath args - Nothing -> Cli.respond $ BadName main0 - -generateSchemeFile :: Bool -> String -> HQ.HashQualified Name -> Cli String -generateSchemeFile exec out main = do - (comp, ppe) <- resolveMainRef main - ensureCompilerExists - doGenerateSchemeBoot False (Just ppe) Nothing - cacheDir <- getCacheDir - liftIO $ createDirectoryIfMissing True (cacheDir "scheme-tmp") - let scratch = out ++ ".scm" - fullpath = cacheDir "scheme-tmp" scratch - output = Text.pack fullpath - sscm <- Term.ref a <$> resolveTermRef saveNm - fprf <- resolveCon filePathNm - let toCmp = Term.termLink a (Referent.Ref comp) - outTm = Term.text a output - fpc = Term.constructor a fprf - fp = Term.app a fpc outTm - tm :: Term Symbol Ann - tm = Term.apps' sscm [Term.boolean a exec, toCmp, fp] - typecheckAndEval ppe tm - pure fullpath - where - a = External - hq nm - | Just hqn <- HQ.fromString nm = hqn - | otherwise = error $ "internal error: cannot hash qualify: " ++ nm - - saveNm = hq ".unison.internal.compiler.saveScheme" - filePathNm = hq "FilePath.FilePath" - delete :: Input -> DeleteOutput -> diff --git a/unison-src/builtin-tests/jit-tests.output.md b/unison-src/builtin-tests/jit-tests.output.md index f43952ca6f..70e7e86caf 100644 --- a/unison-src/builtin-tests/jit-tests.output.md +++ b/unison-src/builtin-tests/jit-tests.output.md @@ -8,8 +8,12 @@ to `Tests.check` and `Tests.checkEqual`). ```ucm .> run.native tests + () + ``` ```ucm .> run.native tests.jit.only + () + ``` From 6703193069dc5e9e119208c2534d4651033eebab Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Thu, 8 Feb 2024 11:49:10 -0500 Subject: [PATCH 010/181] Rename ucr to unison-runtime --- parser-typechecker/src/Unison/Runtime/Interface.hs | 10 +++++----- scheme-libs/racket/{ucr.rkt => unison-runtime.rkt} | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) rename scheme-libs/racket/{ucr.rkt => unison-runtime.rkt} (99%) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index cab7aa791a..72513a47bf 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -657,7 +657,7 @@ backReferenceTm ws frs irs dcm c i = do ucrProc :: [String] -> CreateProcess ucrProc args = - (proc "native-compiler/bin/ucr" args) + (proc "native-compiler/bin/unison-runtime" args) { std_in = CreatePipe, std_out = Inherit, std_err = Inherit @@ -707,8 +707,8 @@ nativeEvalInContext _ ctx codes base = do ucrError (_ :: IOException) = die "I had trouble calling the unison runtime exectuable.\n\n\ - \Please check that the `ucr` executable is properly\ - \ installed." + \Please check that the `unison-runtime` executable is\ + \properly installed." withCreateProcess (ucrProc []) callout `UnliftIO.catch` ucrError nativeCompileCodes :: @@ -731,8 +731,8 @@ nativeCompileCodes codes base path = do ucrError (_ :: IOException) = die "I had trouble calling the unison runtime exectuable.\n\n\ - \Please check that the `ucr` executable is properly\ - \ installed." + \Please check that the `unison-runtime` executable is\ + \properly installed." racoError (_ :: IOException) = die "I had trouble calling the `raco` executable.\n\n\ diff --git a/scheme-libs/racket/ucr.rkt b/scheme-libs/racket/unison-runtime.rkt similarity index 99% rename from scheme-libs/racket/ucr.rkt rename to scheme-libs/racket/unison-runtime.rkt index 6f4217b416..34e511e3bb 100644 --- a/scheme-libs/racket/ucr.rkt +++ b/scheme-libs/racket/unison-runtime.rkt @@ -96,7 +96,7 @@ (define (handle-command-line) (command-line - #:program "ucr" + #:program "unison-runtime" #:once-any [("-G" "--generate-file") file From 9a253e8eb8664f9af12b4bdd5f47e3691940eb9d Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Thu, 8 Feb 2024 15:05:06 -0500 Subject: [PATCH 011/181] Add info file for unison racket package --- scheme-libs/racket/unison/info.rkt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 scheme-libs/racket/unison/info.rkt diff --git a/scheme-libs/racket/unison/info.rkt b/scheme-libs/racket/unison/info.rkt new file mode 100644 index 0000000000..23f0c7bc89 --- /dev/null +++ b/scheme-libs/racket/unison/info.rkt @@ -0,0 +1,5 @@ +#lang info + +(define collection "unison") + +(define deps (list)) From 038550ced3211670327c69d079346b4b1ee33bac Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Fri, 9 Feb 2024 16:52:59 -0500 Subject: [PATCH 012/181] Native runtime location argument, and an improved error msg --- .../src/Unison/Runtime/Exception.hs | 3 + .../src/Unison/Runtime/Interface.hs | 141 ++++++++++++++---- .../src/Unison/Codebase/TranscriptParser.hs | 11 +- unison-cli/unison/ArgParse.hs | 15 +- unison-cli/unison/Main.hs | 39 +++-- 5 files changed, 156 insertions(+), 53 deletions(-) diff --git a/parser-typechecker/src/Unison/Runtime/Exception.hs b/parser-typechecker/src/Unison/Runtime/Exception.hs index 11f5fdbc1c..dff4a627b7 100644 --- a/parser-typechecker/src/Unison/Runtime/Exception.hs +++ b/parser-typechecker/src/Unison/Runtime/Exception.hs @@ -18,5 +18,8 @@ instance Exception RuntimeExn die :: (HasCallStack) => String -> IO a die = throwIO . PE callStack . P.lit . fromString +dieP :: HasCallStack => P.Pretty P.ColorText -> IO a +dieP = throwIO . PE callStack + exn :: (HasCallStack) => String -> a exn = throw . PE callStack . P.lit . fromString diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 72513a47bf..056c8a3b48 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -21,6 +21,7 @@ module Unison.Runtime.Interface where import Control.Concurrent.STM as STM +import Control.Exception (throwIO) import Control.Monad import Data.Binary.Get (runGetOrFail) -- import Data.Bits (shiftL) @@ -44,17 +45,21 @@ import Data.Set as Set ) import Data.Set qualified as Set import Data.Text (isPrefixOf, unpack) +import GHC.Stack (callStack) import System.Directory ( XdgDirectory(XdgCache), createDirectoryIfMissing, getXdgDirectory ) +import System.Exit (ExitCode(..)) import System.FilePath ((<.>), ()) import System.Process ( CreateProcess (..), StdStream (..), callProcess, proc, + readCreateProcessWithExitCode, + shell, waitForProcess, withCreateProcess, ) @@ -440,18 +445,19 @@ decompileCtx crs ctx = decompile ib $ backReferenceTm crs fr ir dt dt = decompTm ctx nativeEval :: + FilePath -> IORef EvalCtx -> CodeLookup Symbol IO () -> PrettyPrintEnv -> Term Symbol -> IO (Either Error ([Error], Term Symbol)) -nativeEval ctxVar cl ppe tm = catchInternalErrors $ do +nativeEval execDir ctxVar cl ppe tm = catchInternalErrors $ do ctx <- readIORef ctxVar (tyrs, tmrs) <- collectDeps cl tm (ctx, codes) <- loadDeps cl ppe ctx tyrs tmrs (ctx, tcodes, base) <- prepareEvaluation ppe tm ctx writeIORef ctxVar ctx - nativeEvalInContext ppe ctx (codes ++ tcodes) base + nativeEvalInContext execDir ppe ctx (codes ++ tcodes) base interpEval :: ActiveThreads -> @@ -472,20 +478,82 @@ interpEval activeThreads cleanupThreads ctxVar cl ppe tm = evalInContext ppe ctx activeThreads initw `UnliftIO.finally` cleanupThreads +ensureExists :: HasCallStack => CreateProcess -> Pretty ColorText -> IO () +ensureExists cmd err = + ccall >>= \case + True -> pure () + False -> dieP err + where + call = readCreateProcessWithExitCode cmd "" >>= \case + (ExitSuccess, _, _) -> pure True + (ExitFailure _, _, _) -> pure False + ccall = call `UnliftIO.catch` \(_ :: IOException) -> pure False + +ensureRuntimeExists :: HasCallStack => FilePath -> IO () +ensureRuntimeExists execDir = ensureExists cmd (runtimeErrMsg execDir) + where + cmd = proc (ucrFile execDir) ["--help"] + +ensureRacoExists :: HasCallStack => IO () +ensureRacoExists = ensureExists (shell "raco help") racoErrMsg + +runtimeErrMsg :: String -> Pretty ColorText +runtimeErrMsg execDir = + P.lines + [ P.wrap + "I can't seem to call `unison-runtime`. I was looking for\ + \ it at:", + "", + P.indentN + 2 + (fromString $ ucrFile execDir), + "", + "See", + "", + P.indentN + 2 + "TODO", + "", + P.wrap + "for detailed instructions on how to install unison with this\ + \ feature available.", + "", + P.wrap + "If you have the executable installed somewhere else, you can\ + \ use the `--runtime-path` command line argument to specify\ + \ where it is." + ] + +racoErrMsg :: Pretty ColorText +racoErrMsg = + P.lines + [ P.wrap + "I can't seem to call `raco`. Please ensure Racket \ + \is installed.", + "", + "See", + "", + P.indentN + 2 + "https://download.racket-lang.org/", + "", + "for how to install Racket manually." + ] + nativeCompile :: - Text -> + FilePath -> IORef EvalCtx -> CodeLookup Symbol IO () -> PrettyPrintEnv -> Reference -> FilePath -> IO (Maybe Error) -nativeCompile _version ctxVar cl ppe base path = tryM $ do +nativeCompile execDir ctxVar cl ppe base path = tryM $ do ctx <- readIORef ctxVar (tyrs, tmrs) <- collectRefDeps cl base (ctx, codes) <- loadDeps cl ppe ctx tyrs tmrs Just ibase <- pure $ baseToIntermed ctx base - nativeCompileCodes codes ibase path + nativeCompileCodes execDir codes ibase path interpCompile :: Text -> @@ -655,9 +723,12 @@ backReferenceTm ws frs irs dcm c i = do bs <- Map.lookup r dcm Map.lookup i bs -ucrProc :: [String] -> CreateProcess -ucrProc args = - (proc "native-compiler/bin/unison-runtime" args) +ucrFile :: FilePath -> FilePath +ucrFile execDir = execDir "unison-runtime" + +ucrProc :: FilePath -> [String] -> CreateProcess +ucrProc execDir args = + (proc (ucrFile execDir) args) { std_in = CreatePipe, std_out = Inherit, std_err = Inherit @@ -675,12 +746,14 @@ ucrProc args = -- taken over the input. This could probably be without a side -- channel, but a side channel is probably better. nativeEvalInContext :: + FilePath -> PrettyPrintEnv -> EvalCtx -> [(Reference, SuperGroup Symbol)] -> Reference -> IO (Either Error ([Error], Term Symbol)) -nativeEvalInContext _ ctx codes base = do +nativeEvalInContext execDir _ ctx codes base = do + ensureRuntimeExists execDir let cc = ccache ctx crs <- readTVarIO $ combRefs cc let bytes = serializeValue . compileValue base $ codes @@ -704,19 +777,19 @@ nativeEvalInContext _ ctx codes base = do -- decodeResult . deserializeValue =<< BS.hGetContents pout callout _ _ _ _ = pure . Left $ "withCreateProcess didn't provide handles" - ucrError (_ :: IOException) = - die - "I had trouble calling the unison runtime exectuable.\n\n\ - \Please check that the `unison-runtime` executable is\ - \properly installed." - withCreateProcess (ucrProc []) callout `UnliftIO.catch` ucrError + ucrError (_ :: IOException) = pure $ Left (runtimeErrMsg execDir) + withCreateProcess (ucrProc execDir []) callout + `UnliftIO.catch` ucrError nativeCompileCodes :: + FilePath -> [(Reference, SuperGroup Symbol)] -> Reference -> FilePath -> IO () -nativeCompileCodes codes base path = do +nativeCompileCodes execDir codes base path = do + ensureRuntimeExists execDir + ensureRacoExists genDir <- getXdgDirectory XdgCache "unisonlanguage/racket-tmp" createDirectoryIfMissing True genDir let bytes = serializeValue . compileValue base $ codes @@ -729,15 +802,9 @@ nativeCompileCodes codes base path = do pure () callout _ _ _ _ = fail "withCreateProcess didn't provide handles" ucrError (_ :: IOException) = - die - "I had trouble calling the unison runtime exectuable.\n\n\ - \Please check that the `unison-runtime` executable is\ - \properly installed." - racoError (_ :: IOException) = - die - "I had trouble calling the `raco` executable.\n\n\ - \Please verify that you have racket installed." - withCreateProcess (ucrProc ["-G", srcPath]) callout + throwIO $ PE callStack (runtimeErrMsg execDir) + racoError (_ :: IOException) = throwIO $ PE callStack racoErrMsg + withCreateProcess (ucrProc execDir ["-G", srcPath]) callout `UnliftIO.catch` ucrError callProcess "raco" ["exe", "-o", path, srcPath] `UnliftIO.catch` racoError @@ -900,7 +967,11 @@ icon = "💔💥" catchInternalErrors :: IO (Either Error a) -> IO (Either Error a) -catchInternalErrors sub = sub `UnliftIO.catch` \(CE _ e) -> pure $ Left e +catchInternalErrors sub = sub `UnliftIO.catch` hCE `UnliftIO.catch` hRE + where + hCE (CE _ e) = pure $ Left e + hRE (PE _ e) = pure $ Left e + hRE (BU _ _ _) = pure $ Left "impossible" decodeStandalone :: BL.ByteString -> @@ -945,14 +1016,14 @@ startRuntime sandboxed runtimeHost version = do ioTestTypes = builtinIOTestTypes External } -startNativeRuntime :: Text -> IO (Runtime Symbol) -startNativeRuntime version = do +startNativeRuntime :: Text -> FilePath -> IO (Runtime Symbol) +startNativeRuntime _version execDir = do ctxVar <- newIORef =<< baseContext False pure $ Runtime { terminate = pure (), - evaluate = nativeEval ctxVar, - compileTo = nativeCompile version ctxVar, + evaluate = nativeEval execDir ctxVar, + compileTo = nativeCompile execDir ctxVar, mainType = builtinMain External, ioTestTypes = builtinIOTestTypes External } @@ -962,10 +1033,14 @@ withRuntime sandboxed runtimeHost version action = UnliftIO.bracket (liftIO $ startRuntime sandboxed runtimeHost version) (liftIO . terminate) action tryM :: IO () -> IO (Maybe Error) -tryM = fmap (either (Just . extract) (const Nothing)) . try +tryM = + flip UnliftIO.catch hRE . + flip UnliftIO.catch hCE . + fmap (const Nothing) where - extract (PE _ e) = e - extract (BU _ _ _) = "impossible" + hCE (CE _ e) = pure $ Just e + hRE (PE _ e) = pure $ Just e + hRE (BU _ _ _) = pure $ Just "impossible" runStandalone :: StoredCache -> Word64 -> IO (Either (Pretty ColorText) ()) runStandalone sc init = diff --git a/unison-cli/src/Unison/Codebase/TranscriptParser.hs b/unison-cli/src/Unison/Codebase/TranscriptParser.hs index f49bea960c..9fe6cae89a 100644 --- a/unison-cli/src/Unison/Codebase/TranscriptParser.hs +++ b/unison-cli/src/Unison/Codebase/TranscriptParser.hs @@ -196,11 +196,12 @@ withTranscriptRunner :: (UnliftIO.MonadUnliftIO m) => Verbosity -> UCMVersion -> + FilePath -> Maybe FilePath -> (TranscriptRunner -> m r) -> m r -withTranscriptRunner verbosity ucmVersion configFile action = do - withRuntimes \runtime sbRuntime nRuntime -> withConfig \config -> do +withTranscriptRunner verbosity ucmVersion nrtp configFile action = do + withRuntimes nrtp \runtime sbRuntime nRuntime -> withConfig \config -> do action \transcriptName transcriptSrc (codebaseDir, codebase) -> do Server.startServer (Backend.BackendEnv {Backend.useNamesIndex = False}) Server.defaultCodebaseServerOpts runtime codebase \baseUrl -> do let parsed = parse transcriptName transcriptSrc @@ -209,12 +210,12 @@ withTranscriptRunner verbosity ucmVersion configFile action = do pure $ join @(Either TranscriptError) result where withRuntimes :: - (Runtime.Runtime Symbol -> Runtime.Runtime Symbol -> Runtime.Runtime Symbol -> m a) -> m a - withRuntimes action = + FilePath -> (Runtime.Runtime Symbol -> Runtime.Runtime Symbol -> Runtime.Runtime Symbol -> m a) -> m a + withRuntimes nrtp action = RTI.withRuntime False RTI.Persistent ucmVersion \runtime -> do RTI.withRuntime True RTI.Persistent ucmVersion \sbRuntime -> do action runtime sbRuntime - =<< liftIO (RTI.startNativeRuntime ucmVersion) + =<< liftIO (RTI.startNativeRuntime ucmVersion nrtp) withConfig :: forall a. ((Maybe Config -> m a) -> m a) withConfig action = do case configFile of diff --git a/unison-cli/unison/ArgParse.hs b/unison-cli/unison/ArgParse.hs index 971e289ec5..9e0a596b15 100644 --- a/unison-cli/unison/ArgParse.hs +++ b/unison-cli/unison/ArgParse.hs @@ -117,7 +117,8 @@ data Command -- | Options shared by sufficiently many subcommands. data GlobalOptions = GlobalOptions { codebasePathOption :: Maybe CodebasePathOption, - exitOption :: ShouldExit + exitOption :: ShouldExit, + nativeRuntimePath :: Maybe FilePath } deriving (Show, Eq) @@ -259,11 +260,13 @@ globalOptionsParser = do -- ApplicativeDo codebasePathOption <- codebasePathParser <|> codebaseCreateParser exitOption <- exitParser + nativeRuntimePath <- nativeRuntimePathFlag pure GlobalOptions { codebasePathOption = codebasePathOption, - exitOption = exitOption + exitOption = exitOption, + nativeRuntimePath = nativeRuntimePath } codebasePathParser :: Parser (Maybe CodebasePathOption) @@ -446,6 +449,14 @@ readAbsolutePath = do <> show rel <> " was relative. Try adding a `.` prefix, e.g. `.path.to.project`" +nativeRuntimePathFlag :: Parser (Maybe FilePath) +nativeRuntimePathFlag = + optional . strOption $ + long "runtime-path" + <> metavar "DIR" + <> help "Path to native runtime files" + <> noGlobal + readPath' :: ReadM Path.Path' readPath' = do strPath <- OptParse.str diff --git a/unison-cli/unison/Main.hs b/unison-cli/unison/Main.hs index 42664ec3f8..98fb5cec71 100644 --- a/unison-cli/unison/Main.hs +++ b/unison-cli/unison/Main.hs @@ -15,7 +15,12 @@ where import ArgParse ( CodebasePathOption (..), Command (Init, Launch, PrintVersion, Run, Transcript), - GlobalOptions (GlobalOptions, codebasePathOption, exitOption), + GlobalOptions + ( GlobalOptions, + codebasePathOption, + exitOption, + nativeRuntimePath + ), IsHeadless (Headless, WithCLI), RunSource (..), ShouldExit (DoNotExit, Exit), @@ -41,7 +46,7 @@ import Ki qualified import Network.HTTP.Client qualified as HTTP import Network.HTTP.Client.TLS qualified as HTTP import Stats (recordRtsStats) -import System.Directory (canonicalizePath, getCurrentDirectory, removeDirectoryRecursive) +import System.Directory (canonicalizePath, getCurrentDirectory, removeDirectoryRecursive, getXdgDirectory, XdgDirectory(..)) import System.Environment (getProgName, withArgs) import System.Exit qualified as Exit import System.FilePath qualified as FP @@ -87,6 +92,11 @@ import Version qualified type Runtimes = (RTI.Runtime Symbol, RTI.Runtime Symbol, RTI.Runtime Symbol) +fixNativeRuntimePath :: Maybe FilePath -> IO FilePath +fixNativeRuntimePath = maybe dflt pure + where + dflt = getXdgDirectory XdgData ("unisonlanguage" FP. "libexec") + main :: IO () main = do -- Replace the default exception handler with one complains loudly, because we shouldn't have any uncaught exceptions. @@ -120,6 +130,7 @@ main = do progName <- getProgName -- hSetBuffering stdout NoBuffering -- cool (renderUsageInfo, globalOptions, command) <- parseCLIArgs progName (Text.unpack Version.gitDescribeWithDate) + nrtp <- fixNativeRuntimePath (nativeRuntimePath globalOptions) let GlobalOptions {codebasePathOption = mCodePathOption, exitOption = exitOption} = globalOptions withConfig mCodePathOption \config -> do currentDir <- getCurrentDirectory @@ -152,7 +163,7 @@ main = do Left _ -> exitError "I couldn't find that file or it is for some reason unreadable." Right contents -> do getCodebaseOrExit mCodePathOption (SC.MigrateAutomatically SC.Backup SC.Vacuum) \(initRes, _, theCodebase) -> do - withRuntimes RTI.OneOff \(rt, sbrt, nrt) -> do + withRuntimes nrtp RTI.OneOff \(rt, sbrt, nrt) -> do let fileEvent = Input.UnisonFileChanged (Text.pack file) contents let noOpRootNotifier _ = pure () let noOpPathNotifier _ = pure () @@ -178,7 +189,7 @@ main = do Left _ -> exitError "I had trouble reading this input." Right contents -> do getCodebaseOrExit mCodePathOption (SC.MigrateAutomatically SC.Backup SC.Vacuum) \(initRes, _, theCodebase) -> do - withRuntimes RTI.OneOff \(rt, sbrt, nrt) -> do + withRuntimes nrtp RTI.OneOff \(rt, sbrt, nrt) -> do let fileEvent = Input.UnisonFileChanged (Text.pack "") contents let noOpRootNotifier _ = pure () let noOpPathNotifier _ = pure () @@ -263,13 +274,13 @@ main = do \that matches your version of Unison." ] Transcript shouldFork shouldSaveCodebase mrtsStatsFp transcriptFiles -> do - let action = runTranscripts Verbosity.Verbose renderUsageInfo shouldFork shouldSaveCodebase mCodePathOption transcriptFiles + let action = runTranscripts Verbosity.Verbose renderUsageInfo shouldFork shouldSaveCodebase mCodePathOption nrtp transcriptFiles case mrtsStatsFp of Nothing -> action Just fp -> recordRtsStats fp action Launch isHeadless codebaseServerOpts mayStartingPath shouldWatchFiles -> do getCodebaseOrExit mCodePathOption (SC.MigrateAfterPrompt SC.Backup SC.Vacuum) \(initRes, _, theCodebase) -> do - withRuntimes RTI.Persistent \(runtime, sbRuntime, nRuntime) -> do + withRuntimes nrtp RTI.Persistent \(runtime, sbRuntime, nRuntime) -> do startingPath <- case isHeadless of WithCLI -> do -- If the user didn't provide a starting path on the command line, put them in the most recent @@ -334,12 +345,12 @@ main = do Exit -> do Exit.exitSuccess where -- (runtime, sandboxed runtime) - withRuntimes :: RTI.RuntimeHost -> (Runtimes -> IO a) -> IO a - withRuntimes mode action = + withRuntimes :: FilePath -> RTI.RuntimeHost -> (Runtimes -> IO a) -> IO a + withRuntimes nrtp mode action = RTI.withRuntime False mode Version.gitDescribeWithDate \runtime -> do RTI.withRuntime True mode Version.gitDescribeWithDate \sbRuntime -> action . (runtime,sbRuntime,) - =<< RTI.startNativeRuntime Version.gitDescribeWithDate + =<< RTI.startNativeRuntime Version.gitDescribeWithDate nrtp withConfig :: Maybe CodebasePathOption -> (Config -> IO a) -> IO a withConfig mCodePathOption action = do UnliftIO.bracket @@ -391,14 +402,15 @@ runTranscripts' :: String -> Maybe FilePath -> FilePath -> + FilePath -> NonEmpty MarkdownFile -> IO Bool -runTranscripts' progName mcodepath transcriptDir markdownFiles = do +runTranscripts' progName mcodepath nativeRtp transcriptDir markdownFiles = do currentDir <- getCurrentDirectory configFilePath <- getConfigFilePath mcodepath -- We don't need to create a codebase through `getCodebaseOrExit` as we've already done so previously. and <$> getCodebaseOrExit (Just (DontCreateCodebaseWhenMissing transcriptDir)) (SC.MigrateAutomatically SC.Backup SC.Vacuum) \(_, codebasePath, theCodebase) -> do - TR.withTranscriptRunner Verbosity.Verbose Version.gitDescribeWithDate (Just configFilePath) $ \runTranscript -> do + TR.withTranscriptRunner Verbosity.Verbose Version.gitDescribeWithDate nativeRtp (Just configFilePath) $ \runTranscript -> do for markdownFiles $ \(MarkdownFile fileName) -> do transcriptSrc <- readUtf8 fileName result <- runTranscript fileName transcriptSrc (codebasePath, theCodebase) @@ -446,9 +458,10 @@ runTranscripts :: ShouldForkCodebase -> ShouldSaveCodebase -> Maybe CodebasePathOption -> + FilePath -> NonEmpty String -> IO () -runTranscripts verbosity renderUsageInfo shouldFork shouldSaveTempCodebase mCodePathOption args = do +runTranscripts verbosity renderUsageInfo shouldFork shouldSaveTempCodebase mCodePathOption nativeRtp args = do markdownFiles <- case traverse (first (pure @[]) . markdownFile) args of Failure invalidArgs -> do PT.putPrettyLn $ @@ -466,7 +479,7 @@ runTranscripts verbosity renderUsageInfo shouldFork shouldSaveTempCodebase mCode progName <- getProgName transcriptDir <- prepareTranscriptDir verbosity shouldFork mCodePathOption shouldSaveTempCodebase completed <- - runTranscripts' progName (Just transcriptDir) transcriptDir markdownFiles + runTranscripts' progName (Just transcriptDir) nativeRtp transcriptDir markdownFiles case shouldSaveTempCodebase of DontSaveCodebase -> removeDirectoryRecursive transcriptDir SaveCodebase _ -> From b3cad2ce2ad6bb34d8e6f297f2b5a060b637a895 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:02:04 -0500 Subject: [PATCH 013/181] refactor ci.yaml with jit setup steps (attempt 1) recommend moving support scheme files to another repo if they aren't deeply related to ucm; but maybe they are. --- .github/workflows/ci.yaml | 230 ++++++++++++------ unison-src/builtin-tests/jit-tests.md | 2 - .../transcripts-manual/gen-racket-libs.md | 29 ++- .../gen-racket-libs.output.md | 45 ++++ 4 files changed, 228 insertions(+), 78 deletions(-) create mode 100644 unison-src/transcripts-manual/gen-racket-libs.output.md diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 52aabb3287..2d56af94d4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,9 +17,25 @@ on: - release/* workflow_dispatch: +env: + ormolu_version: "0.5.0.1" + racket_version: "8.7" + jit_version: "@unison/internal/releases/0.0.10" + jit_src_scheme: "${{$HOME}}/unison-jit-src/scheme-libs/racket" + jit_bin: "${{$HOME}}/unison-jit-bin" + jit_generator_os: ubuntu-20.04 + jit_codebase: "${{$HOME}}/unison-jit-codebase" + -jobs: +matrix: + os: + # While iterating on this file, you can disable one or more of these to speed things up + - ubuntu-20.04 + - macOS-12 + - windows-2019 + +jobs: ormolu: runs-on: ubuntu-20.04 # Only run formatting on trunk commits @@ -39,7 +55,7 @@ jobs: separator: "\n" - uses: haskell-actions/run-ormolu@v14 with: - version: "0.5.0.1" + version: ${{ env.ormolu_version }} mode: inplace pattern: ${{ steps.changed-files.outputs.all_changed_files }} - name: apply formatting changes @@ -47,33 +63,20 @@ jobs: if: ${{ always() }} with: commit_message: automatically run ormolu - - build: - name: ${{ matrix.os }} + build-ucm: + name: Build UCM ${{ matrix.os }} runs-on: ${{ matrix.os }} - # The 'always()' causes this to build even if the ormolu job is skipped. if: ${{ always() }} needs: ormolu - defaults: - run: - shell: bash strategy: # Run each build to completion, regardless of if any have failed fail-fast: false - matrix: - os: - # While iterating on this file, you can disable one or more of these to speed things up - - ubuntu-20.04 - - macOS-12 - - windows-2019 + steps: - uses: actions/checkout@v2 - # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. # GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to # purge one manually. - - - id: stackage-resolver name: record stackage resolver # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files @@ -172,19 +175,6 @@ jobs: if: runner.os == 'macOS' run: rm -rf ~/.stack/setup-exe-cache - - name: install stack-clean-old (to scan or clean up old stackage caches) - run: | - if ! stack exec -- which stack-clean-old; then - stack install stack-clean-old - fi - - - name: check initial stackage cache size - run: | - echo global .stack - stack exec -- stack-clean-old list -G || true - echo project .stack-work - stack exec -- stack-clean-old list -P || true - # Build deps, then build local code. Splitting it into two steps just allows us to see how much time each step # takes. - name: build dependencies @@ -249,51 +239,164 @@ jobs: git diff --cached --ignore-cr-at-eol --exit-code - name: cli-integration-tests run: stack --no-terminal exec cli-integration-tests - - name: Cache Racket dependencies - uses: actions/cache@v2 + + - name: verify stack ghci startup + if: runner.os == 'macOS' + run: echo | stack ghci + + - name: save ucm artifact + uses: actions/upload-artifact@v4 + with: + name: unison-${{ matrix.os }} + path: $(stack exec -- which unison) + + generate-jit-source: + name: Generate JIT source + needs: build-ucm + runs-on: ${{ env.jit_generator_os }} + steps: + - uses: actions/cache@v3 + name: cache jit source if: runner.os == 'Linux' + with: + path: ${{ env.jit_src_scheme }} + key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{jit_src}}.${{github.sha}} + restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{jit_src}}. + + - name: check source exists + id: jit_src_exists + uses: thebinaryfelix/check-file-existence-action@v1 + with: + files: "${{ env.jit_src_scheme }}/unison/{data-info,boot-generated,simple-wrappers,builtin-generated,compound-wrappers}.ss" + + - name: create transcript + if: steps.jit_src_exists.outputs.exists == 'false' + uses: 1arp/create-a-file-action@0.3 + with: + file: 'setup-jit.md' + content: | + ```ucm + .> project.create-empty jit-setup + jit-setup/main> pull ${{ env.jit_version }} lib.jit + ``` + ```unison + generateSchemeBoot dir = do + saveDataInfoFile dir dataInfos + saveBaseFile dir bootSpec + saveWrapperFile dir simpleWrapperSpec + saveBaseFile dir builtinSpec + saveWrapperFile dir compoundWrapperSpec + + go = generateSchemeBoot "${{ env.jit_src_scheme }}" + ``` + ```ucm + jit-setup/main> run go + ``` + + - name: download ucm artifact + if: steps.jit_src_exists.outputs.exists == 'false' + uses: actions/download-artifact@v4 + with: + name: unison-${{ env.jit_generator_os }} + path: ./ + + - name: generate source + if: steps.jit_src_exists.outputs.exists == 'false' + run: | + cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} + chmod +x unison-${{ env.jit_generator_os }} + unison-${{ env.jit_generator_os }} transcript setup-jit.md + + - name: save jit source + if: steps.jit_src_exists.outputs.exists == 'false' + uses: actions/upload-artifact@v4 + with: + name: jit-source + path: ${{ env.jit_src_scheme }}/** + + + build-jit-binary: + name: Build JIT binary ${{ matrix.os }} + needs: [build-ucm, generate-jit-source] + runs-on: ${{ matrix.os }} + env: + ucm: ${{ runner.temp }}/unison-${{ matrix.os }} + steps: + - name: cache jit binaries + uses: actions/cache@v3 + with: + path: ${{ env.jit_bin }} + key: jit_bin.racket_${{env.racket_version}}.jit_${{jit_src}}.${{github.sha}} + restore-keys: jit_bin.racket_${{env.racket_version}}.jit_${{jit_src}}. + + - name: check binary exists + id: jit_bin_exists + uses: thebinaryfelix/check-file-existence-action@v1 + with: + files: "${{ env.jit_bin }}/unison-runtime" + + - name: Cache Racket dependencies + if: steps.jit_bin_exists.outputs.exists == 'false' + uses: actions/cache@v3 with: path: | ~/.cache/racket ~/.local/share/racket - key: ${{ runner.os }}-racket-8.7 - - - uses: Bogdanp/setup-racket@v1.10 - if: runner.os == 'Linux' + key: ${{ runner.os }}-racket-${{env.racket_version}} + - uses: Bogdanp/setup-racket@v1.11 + # if: steps.jit_bin_exists.outputs.exists == 'false' with: architecture: 'x64' distribution: 'full' variant: 'CS' - version: '8.7' # match with cache key above - - run: raco pkg install --auto --skip-installed --batch x509-lib - if: runner.os == 'Linux' + version: ${{env.racket_version}} - uses: awalsh128/cache-apt-pkgs-action@latest # read this if a package isn't installing correctly # https://github.com/awalsh128/cache-apt-pkgs-action#caveats - if: runner.os == 'Linux' with: packages: libb2-dev version: 1.0 # cache key version afaik + - name: download jit source + # if: steps.jit_src_exists.outputs.exists == 'false' + uses: actions/download-artifact@v4 + with: + name: jit-source + path: ${{ env.jit_src_scheme }} - - uses: actions/cache@v3 - name: cache base.md codebase (unix) - if: runner.os == 'Linux' + - uses: actions/checkout@v2 # checkout scheme-libs from unison repo + # if: steps.jit_src_exists.outputs.exists == 'false' + + - name: download ucm + # if: steps.jit_bin_exists.outputs.exists == 'false' + uses: actions/download-artifact@v4 with: - path: ~/.cache/unisonlanguage/base.unison - key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md','**/unison-cli/src/Unison/JitInfo.hs')}}-${{github.sha}} - restore-keys: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md','**/unison-cli/src/Unison/JitInfo.hs')}}- + name: unison-${{ matrix.os }} + path: ${{ runner.temp }} + - run: | + chmod +x ${{ env.ucm }} + ${{ env.ucm }} transcript setup-jit.md - - name: set up `base` codebase - if: runner.os == 'Linux' + + - name: build jit binary + # if: steps.jit_bin_exists.outputs.exists == 'false' run: | - ./unison-src/builtin-tests/setup-base-codebase.sh + cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} + raco pkg install --auto ${{ env.jit_src_scheme }}/unison + raco exe ${{ env.jit_src_scheme }}/unison-runtime.rkt + raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }} - - name: jit tests - # if: false # temporarily disabled - if: runner.os == 'Linux' + -name: save jit binary + # if: steps.jit_bin_exists.outputs.exists == 'false' + uses: actions/upload-artifact@v4 + with: + name: jit-binary-${{ matrix.os }} + path: ${{ env.jit_bin }}/** + + - name: jit tests ${{ matrix.os }} + # if: steps.jit_bin_exists.outputs.exists == 'false' run: | - ./unison-src/builtin-tests/jit-tests.sh - cat ./unison-src/builtin-tests/jit-tests.output.md + time ${{ env.ucm }} transcript unison-src/builtin-tests/jit-tests.md + cat unison-src/builtin-tests/jit-tests.output.md CHANGE=$(git diff unison-src/builtin-tests/jit-tests.output.md) if [ -n "$CHANGE" ]; then echo "The jit-tests output has changed" @@ -301,23 +404,12 @@ jobs: fi - name: interpreter tests - # if: false # temporarily disabled - if: runner.os == 'Linux' + # if: steps.jit_bin_exists.outputs.exists == 'false' run: | - ./unison-src/builtin-tests/interpreter-tests.sh - cat ./unison-src/builtin-tests/interpreter-tests.output.md + time ${{ env.ucm }} transcript unison-src/builtin-tests/interpreter-tests.md + cat unison-src/builtin-tests/interpreter-tests.output.md CHANGE=$(git diff unison-src/builtin-tests/interpreter-tests.output.md) if [ -n "$CHANGE" ]; then echo "The interpreter-tests output has changed" exit 1 fi - - - name: verify stack ghci startup - if: runner.os == 'macOS' - run: echo | stack ghci - - name: check final stackage cache size - run: | - echo global .stack - stack exec -- stack-clean-old list -G || true - echo project .stack-work - stack exec -- stack-clean-old list -P || true diff --git a/unison-src/builtin-tests/jit-tests.md b/unison-src/builtin-tests/jit-tests.md index 71b60982d2..a5212c99f9 100644 --- a/unison-src/builtin-tests/jit-tests.md +++ b/unison-src/builtin-tests/jit-tests.md @@ -2,8 +2,6 @@ Note: This should be forked off of the codebase created by base.md ```ucm:hide -.> compile.native.fetch -.> compile.native.genlibs .> load unison-src/builtin-tests/testlib.u .> add ``` diff --git a/unison-src/transcripts-manual/gen-racket-libs.md b/unison-src/transcripts-manual/gen-racket-libs.md index 51c425ad74..31a118d4d6 100644 --- a/unison-src/transcripts-manual/gen-racket-libs.md +++ b/unison-src/transcripts-manual/gen-racket-libs.md @@ -1,11 +1,26 @@ -Fetch base, then fetch the compiler, then build the generated -libraries in the racket directory. +When we start out, `./scheme-libs/racket` contains a bunch of library files that we'll need. They define the Unison builtins for Racket. + +Next, we'll download the jit project and generate a few Racket files from it. + +```ucm +.> project.create-empty jit-setup +jit-setup/main> pull @unison/internal/releases/0.0.10 lib.jit +``` + +```unison +generateSchemeBoot dir = do + saveDataInfoFile dir dataInfos + saveBaseFile dir bootSpec + saveWrapperFile dir simpleWrapperSpec + saveBaseFile dir builtinSpec + saveWrapperFile dir compoundWrapperSpec + +go = generateSchemeBoot "scheme-libs/racket" +``` ```ucm -.> pull @unison/base/releases/2.5.0 .base -.> compile.native.fetch -.> compile.native.genlibs scheme-libs/racket +jit-setup/main> run go ``` After executing this, `scheme-libs/racket` will contain the full @@ -20,11 +35,11 @@ them. This is accomplished by running. in the directory where the `unison` directory is located. Then the runtime executable can be built with - raco exe scheme-libs/racket/ucr.rkt + raco exe scheme-libs/racket/unison-runtime.rkt and a distributable directory can be produced with: - raco distribute scheme-libs/racket/ucr + raco distribute scheme-libs/racket/unison-runtime At that point, should contain the executable and all dependencies necessary to run it. diff --git a/unison-src/transcripts-manual/gen-racket-libs.output.md b/unison-src/transcripts-manual/gen-racket-libs.output.md new file mode 100644 index 0000000000..01c8efdd5e --- /dev/null +++ b/unison-src/transcripts-manual/gen-racket-libs.output.md @@ -0,0 +1,45 @@ + +Fetch base, then fetch the compiler, then build the generated +libraries in the racket directory. + +```ucm +.> pull @unison/base/releases/2.5.0 .base + + Downloaded 12426 entities. + + ✅ + + Successfully pulled into .base, which was empty. + +.> compile.native.fetch + + Downloaded 1465 entities. + + ✅ + + Successfully updated .unison.internal from + @unison/internal/releases/0.0.10. + +.> compile.native.genlibs scheme-libs/racket + +``` +After executing this, `scheme-libs/racket` will contain the full +complement of unison libraries for a given combination of ucm version +and @unison/internal version. + +To set up racket to use these files, we need to create a package with +them. This is accomplished by running. + + raco pkg install -t dir unison + +in the directory where the `unison directory is located. Then the +runtime executable can be built with + + raco exe scheme-libs/racket/ucr.rkt + +and a distributable directory can be produced with: + + raco distribute scheme-libs/racket/ucr + +At that point, should contain the executable and all +dependencies necessary to run it. From 61d63a6a8df44d6ac3cdc9cd2e7e67ebe31cd220 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:04:42 -0500 Subject: [PATCH 014/181] yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2d56af94d4..f2c45b77a9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -320,7 +320,7 @@ jobs: needs: [build-ucm, generate-jit-source] runs-on: ${{ matrix.os }} env: - ucm: ${{ runner.temp }}/unison-${{ matrix.os }} + ucm: "${{ runner.temp }}/unison-${{ matrix.os }}" steps: - name: cache jit binaries uses: actions/cache@v3 From 221ebb8ee9e16700946ce662c855e83281953214 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:12:07 -0500 Subject: [PATCH 015/181] unyaml --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f2c45b77a9..aa0c4493e2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -320,7 +320,7 @@ jobs: needs: [build-ucm, generate-jit-source] runs-on: ${{ matrix.os }} env: - ucm: "${{ runner.temp }}/unison-${{ matrix.os }}" + ucm: ${{ runner.temp }}/unison-${{ matrix.os }} steps: - name: cache jit binaries uses: actions/cache@v3 @@ -385,7 +385,7 @@ jobs: raco exe ${{ env.jit_src_scheme }}/unison-runtime.rkt raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }} - -name: save jit binary + - name: save jit binary # if: steps.jit_bin_exists.outputs.exists == 'false' uses: actions/upload-artifact@v4 with: From eb845f132e35dee7c4feabc8686bdeaf1596c608 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:18:44 -0500 Subject: [PATCH 016/181] yaml home --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index aa0c4493e2..b1e6ddc776 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,10 +21,10 @@ env: ormolu_version: "0.5.0.1" racket_version: "8.7" jit_version: "@unison/internal/releases/0.0.10" - jit_src_scheme: "${{$HOME}}/unison-jit-src/scheme-libs/racket" - jit_bin: "${{$HOME}}/unison-jit-bin" + jit_src_scheme: "${{ env.home }}/unison-jit-src/scheme-libs/racket" + jit_bin: "${{ env.home }}/unison-jit-bin" jit_generator_os: ubuntu-20.04 - jit_codebase: "${{$HOME}}/unison-jit-codebase" + jit_codebase: "${{ env.home }}/unison-jit-codebase" From 296333d9db0cae85d2b5d9d630668203cf75e13d Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:27:39 -0500 Subject: [PATCH 017/181] yaml unhome --- .github/workflows/ci.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b1e6ddc776..5d975fd8be 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,10 +21,9 @@ env: ormolu_version: "0.5.0.1" racket_version: "8.7" jit_version: "@unison/internal/releases/0.0.10" - jit_src_scheme: "${{ env.home }}/unison-jit-src/scheme-libs/racket" - jit_bin: "${{ env.home }}/unison-jit-bin" + jit_src_scheme: "${{ runner.temp }}/unison-jit-src/scheme-libs/racket" + jit_bin: "${{ runner.temp }}/unison-jit-bin" jit_generator_os: ubuntu-20.04 - jit_codebase: "${{ env.home }}/unison-jit-codebase" @@ -254,6 +253,8 @@ jobs: name: Generate JIT source needs: build-ucm runs-on: ${{ env.jit_generator_os }} + env: + ucm: ${{ runner.temp }}/unison-${{ env.jit_generator_os }} steps: - uses: actions/cache@v3 name: cache jit source @@ -298,14 +299,14 @@ jobs: uses: actions/download-artifact@v4 with: name: unison-${{ env.jit_generator_os }} - path: ./ + path: ${{ runner.temp }} - name: generate source if: steps.jit_src_exists.outputs.exists == 'false' run: | cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} - chmod +x unison-${{ env.jit_generator_os }} - unison-${{ env.jit_generator_os }} transcript setup-jit.md + chmod +x ${{ env.ucm }} + ${{ env.ucm }} transcript setup-jit.md - name: save jit source if: steps.jit_src_exists.outputs.exists == 'false' From f96d8cedbe386aea631234476398c5b6b8e77b9f Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:34:04 -0500 Subject: [PATCH 018/181] yaml move env --- .github/workflows/ci.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5d975fd8be..65205df431 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,8 +21,8 @@ env: ormolu_version: "0.5.0.1" racket_version: "8.7" jit_version: "@unison/internal/releases/0.0.10" - jit_src_scheme: "${{ runner.temp }}/unison-jit-src/scheme-libs/racket" - jit_bin: "${{ runner.temp }}/unison-jit-bin" + jit_src_scheme: "unison-jit-src/scheme-libs/racket" + jit_bin: "unison-jit-bin" jit_generator_os: ubuntu-20.04 @@ -254,6 +254,7 @@ jobs: needs: build-ucm runs-on: ${{ env.jit_generator_os }} env: + jit_src_scheme: ${{ runner.temp}}/${{ env.jit_src_scheme }} ucm: ${{ runner.temp }}/unison-${{ env.jit_generator_os }} steps: - uses: actions/cache@v3 @@ -321,6 +322,8 @@ jobs: needs: [build-ucm, generate-jit-source] runs-on: ${{ matrix.os }} env: + jit_src_scheme: ${{ runner.temp}}/${{ env.jit_src_scheme }} + jit_bin: ${{ runner.temp}}/${{ env.jit_bin }} ucm: ${{ runner.temp }}/unison-${{ matrix.os }} steps: - name: cache jit binaries @@ -377,7 +380,6 @@ jobs: chmod +x ${{ env.ucm }} ${{ env.ucm }} transcript setup-jit.md - - name: build jit binary # if: steps.jit_bin_exists.outputs.exists == 'false' run: | From cf91e87bbdafe7f8c2130098ef552f8c6a072d47 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:36:08 -0500 Subject: [PATCH 019/181] yaml matrix --- .github/workflows/ci.yaml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 65205df431..71fc1a52dd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,15 +25,6 @@ env: jit_bin: "unison-jit-bin" jit_generator_os: ubuntu-20.04 - - -matrix: - os: - # While iterating on this file, you can disable one or more of these to speed things up - - ubuntu-20.04 - - macOS-12 - - windows-2019 - jobs: ormolu: runs-on: ubuntu-20.04 @@ -70,6 +61,12 @@ jobs: strategy: # Run each build to completion, regardless of if any have failed fail-fast: false + matrix: + os: + # While iterating on this file, you can disable one or more of these to speed things up + - ubuntu-20.04 + - macOS-12 + - windows-2019 steps: - uses: actions/checkout@v2 @@ -321,6 +318,15 @@ jobs: name: Build JIT binary ${{ matrix.os }} needs: [build-ucm, generate-jit-source] runs-on: ${{ matrix.os }} + strategy: + # Run each build to completion, regardless of if any have failed + fail-fast: false + matrix: + os: + # While iterating on this file, you can disable one or more of these to speed things up + - ubuntu-20.04 + - macOS-12 + - windows-2019 env: jit_src_scheme: ${{ runner.temp}}/${{ env.jit_src_scheme }} jit_bin: ${{ runner.temp}}/${{ env.jit_bin }} From 5dde584f9a0eb039da9b58ffbc4c1599a46855f9 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:41:54 -0500 Subject: [PATCH 020/181] yaml can't define vars in terms of vars but bash tricks can maybe? --- .github/workflows/ci.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 71fc1a52dd..527b1d2379 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -250,10 +250,11 @@ jobs: name: Generate JIT source needs: build-ucm runs-on: ${{ env.jit_generator_os }} - env: - jit_src_scheme: ${{ runner.temp}}/${{ env.jit_src_scheme }} - ucm: ${{ runner.temp }}/unison-${{ env.jit_generator_os }} steps: + - name: set up environment + run: | + echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV + echo "ucm=${{ runner.temp }}/unison-${{ matrix.os }}" >> $GITHUB_ENV - uses: actions/cache@v3 name: cache jit source if: runner.os == 'Linux' @@ -327,11 +328,12 @@ jobs: - ubuntu-20.04 - macOS-12 - windows-2019 - env: - jit_src_scheme: ${{ runner.temp}}/${{ env.jit_src_scheme }} - jit_bin: ${{ runner.temp}}/${{ env.jit_bin }} - ucm: ${{ runner.temp }}/unison-${{ matrix.os }} steps: + - name: set up environment + run: | + echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV + echo "jit_bin=${{ runner.temp }}/${{ env.jit_bin }}" >> $GITHUB_ENV + echo "ucm=${{ runner.temp }}/unison-${{ matrix.os }}" >> $GITHUB_ENV - name: cache jit binaries uses: actions/cache@v3 with: From 9ff8d76b6ac2ae4ae0c96c2ebbb2ae1decb61d9a Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:44:24 -0500 Subject: [PATCH 021/181] yaml quotes sometimes --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 527b1d2379..3b987f8fb2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -249,7 +249,7 @@ jobs: generate-jit-source: name: Generate JIT source needs: build-ucm - runs-on: ${{ env.jit_generator_os }} + runs-on: "${{ env.jit_generator_os }}" steps: - name: set up environment run: | From 7e0bdafc2a81820a3d797ee971ca56dce0bd1539 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:45:45 -0500 Subject: [PATCH 022/181] yaml renamed var --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3b987f8fb2..8718e4cbf8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -260,8 +260,8 @@ jobs: if: runner.os == 'Linux' with: path: ${{ env.jit_src_scheme }} - key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{jit_src}}.${{github.sha}} - restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{jit_src}}. + key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{jit_src_scheme}}.${{github.sha}} + restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{jit_src_scheme}}. - name: check source exists id: jit_src_exists @@ -338,8 +338,8 @@ jobs: uses: actions/cache@v3 with: path: ${{ env.jit_bin }} - key: jit_bin.racket_${{env.racket_version}}.jit_${{jit_src}}.${{github.sha}} - restore-keys: jit_bin.racket_${{env.racket_version}}.jit_${{jit_src}}. + key: jit_bin.racket_${{env.racket_version}}.jit_${{jit_src_scheme}}.${{github.sha}} + restore-keys: jit_bin.racket_${{env.racket_version}}.jit_${{jit_src_scheme}}. - name: check binary exists id: jit_bin_exists From 27acbd4d8e84f3ee8593ddf187b05958d966b2cf Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:46:58 -0500 Subject: [PATCH 023/181] yaml need env namespace --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8718e4cbf8..85b950b0d6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -260,8 +260,8 @@ jobs: if: runner.os == 'Linux' with: path: ${{ env.jit_src_scheme }} - key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{jit_src_scheme}}.${{github.sha}} - restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{jit_src_scheme}}. + key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_src_scheme}}.${{github.sha}} + restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_src_scheme}}. - name: check source exists id: jit_src_exists @@ -338,8 +338,8 @@ jobs: uses: actions/cache@v3 with: path: ${{ env.jit_bin }} - key: jit_bin.racket_${{env.racket_version}}.jit_${{jit_src_scheme}}.${{github.sha}} - restore-keys: jit_bin.racket_${{env.racket_version}}.jit_${{jit_src_scheme}}. + key: jit_bin.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}.${{ github.sha }} + restore-keys: jit_bin.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}. - name: check binary exists id: jit_bin_exists From d46159ca62f2a574e6be978d32f32bfaea4ee596 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:54:02 -0500 Subject: [PATCH 024/181] yaml broken variables hack --- .github/workflows/ci.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 85b950b0d6..4bbcd57b59 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -246,10 +246,15 @@ jobs: name: unison-${{ matrix.os }} path: $(stack exec -- which unison) + jit_generator_os-hack: + name: Generate JIT source hacky prereq + outputs: + runner: ${{ env.jit_generator_os }} + generate-jit-source: name: Generate JIT source - needs: build-ucm - runs-on: "${{ env.jit_generator_os }}" + needs: [build-ucm, jit_generator_os-hack] + runs-on: ${{needs.jit_generator_os-hack.outputs.runner}} steps: - name: set up environment run: | From 5d4ab9f1a02fc6cc70c637dabe95b1ff7615b4dd Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:56:19 -0500 Subject: [PATCH 025/181] yaml hack documentation --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4bbcd57b59..edc9ccca0d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -246,8 +246,11 @@ jobs: name: unison-${{ matrix.os }} path: $(stack exec -- which unison) + # we can't use an env variable for generate-jit-source's runs-on + # but we can use a step output, which can use an env variable jit_generator_os-hack: name: Generate JIT source hacky prereq + run: echo "fingers crossed!" # every step requires an action outputs: runner: ${{ env.jit_generator_os }} From 771191520e6bb8e58e98b15d55dcbd2bfbb2e8a4 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:57:29 -0500 Subject: [PATCH 026/181] yaml job steps --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index edc9ccca0d..59a9cae4bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -250,7 +250,8 @@ jobs: # but we can use a step output, which can use an env variable jit_generator_os-hack: name: Generate JIT source hacky prereq - run: echo "fingers crossed!" # every step requires an action + steps: + - run: echo "fingers crossed!" # every step requires an action outputs: runner: ${{ env.jit_generator_os }} From 3aa7fd9314ed762f1476e72adcf11b7a4a673fb5 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 21:58:24 -0500 Subject: [PATCH 027/181] yaml tweak identifier? --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 59a9cae4bd..4f45aad43e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -248,7 +248,7 @@ jobs: # we can't use an env variable for generate-jit-source's runs-on # but we can use a step output, which can use an env variable - jit_generator_os-hack: + jit_generator_os_hack: name: Generate JIT source hacky prereq steps: - run: echo "fingers crossed!" # every step requires an action @@ -257,8 +257,8 @@ jobs: generate-jit-source: name: Generate JIT source - needs: [build-ucm, jit_generator_os-hack] - runs-on: ${{needs.jit_generator_os-hack.outputs.runner}} + needs: [build-ucm, jit_generator_os_hack] + runs-on: ${{needs.jit_generator_os_hack.outputs.runner}} steps: - name: set up environment run: | From 18bfab6c0eb5f3448a429e376c9b61c89c180656 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 11 Feb 2024 22:01:29 -0500 Subject: [PATCH 028/181] yaml that didn't work --- .github/workflows/ci.yaml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4f45aad43e..9949b14ffc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -246,19 +246,10 @@ jobs: name: unison-${{ matrix.os }} path: $(stack exec -- which unison) - # we can't use an env variable for generate-jit-source's runs-on - # but we can use a step output, which can use an env variable - jit_generator_os_hack: - name: Generate JIT source hacky prereq - steps: - - run: echo "fingers crossed!" # every step requires an action - outputs: - runner: ${{ env.jit_generator_os }} - generate-jit-source: name: Generate JIT source - needs: [build-ucm, jit_generator_os_hack] - runs-on: ${{needs.jit_generator_os_hack.outputs.runner}} + needs: build-ucm + runs-on: ubuntu-20.04 steps: - name: set up environment run: | From 62cd7349f01207ddf54dd4e289320ec0021b5b2a Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 00:18:44 -0500 Subject: [PATCH 029/181] yaml bump plugins to node 20 --- .github/workflows/ci.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9949b14ffc..39111ed054 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: # contributor forks on contributor PRs. if: github.ref_name == 'trunk' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v41 @@ -69,7 +69,7 @@ jobs: - windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. # GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to # purge one manually. @@ -84,7 +84,7 @@ jobs: grep resolver stack.yaml | awk '{ x="resolver_short="; if (split($2,a,"-") > 2) print x a[1]; else {split($2,b,"."); print x b[1]}}' >> "$GITHUB_OUTPUT" grep resolver stack.yaml | awk '{print "resolver_long="$2}' >> "$GITHUB_OUTPUT" # Cache ~/.stack, keyed by the contents of 'stack.yaml'. - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: cache ~/.stack (unix) if: runner.os != 'Windows' with: @@ -99,10 +99,11 @@ jobs: stack-1_${{matrix.os}}- # Cache ~/.stack, keyed by the contents of 'stack.yaml'. - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: cache ~/.stack (Windows) if: runner.os == 'Windows' with: + save-always: true path: | C:\Users\runneradmin\AppData\Roaming\stack C:\Users\runneradmin\AppData\Local\Programs\stack @@ -116,9 +117,10 @@ jobs: stack-1_${{matrix.os}}- # Cache each local package's ~/.stack-work for fast incremental builds in CI. - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: cache .stack-work with: + save-always: true path: | **/.stack-work # Main cache key: commit hash. This should always result in a cache miss... @@ -255,7 +257,7 @@ jobs: run: | echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV echo "ucm=${{ runner.temp }}/unison-${{ matrix.os }}" >> $GITHUB_ENV - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: cache jit source if: runner.os == 'Linux' with: @@ -335,7 +337,7 @@ jobs: echo "jit_bin=${{ runner.temp }}/${{ env.jit_bin }}" >> $GITHUB_ENV echo "ucm=${{ runner.temp }}/unison-${{ matrix.os }}" >> $GITHUB_ENV - name: cache jit binaries - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.jit_bin }} key: jit_bin.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}.${{ github.sha }} @@ -349,7 +351,7 @@ jobs: - name: Cache Racket dependencies if: steps.jit_bin_exists.outputs.exists == 'false' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cache/racket @@ -375,7 +377,7 @@ jobs: name: jit-source path: ${{ env.jit_src_scheme }} - - uses: actions/checkout@v2 # checkout scheme-libs from unison repo + - uses: actions/checkout@v4 # checkout scheme-libs from unison repo # if: steps.jit_src_exists.outputs.exists == 'false' - name: download ucm From 7b53c51a39cb1da074b292e28756c2cb1d198fda Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Mon, 12 Feb 2024 10:53:34 -0500 Subject: [PATCH 030/181] Modify transcript runner to allow runtime path Fixes problems with it building, since it hadn't been updated to call other modified functions in the right way. --- unison-cli/transcripts/Transcripts.hs | 44 +++++++++++++++++---------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/unison-cli/transcripts/Transcripts.hs b/unison-cli/transcripts/Transcripts.hs index a1bc843f91..ae61176405 100644 --- a/unison-cli/transcripts/Transcripts.hs +++ b/unison-cli/transcripts/Transcripts.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE OverloadedStrings, RecordWildCards #-} {- This module kicks off the Transcript Tests. It doesn't do the transcript parsing itself. @@ -27,17 +27,24 @@ import Unison.Prelude import UnliftIO.STM qualified as STM data TestConfig = TestConfig - { matchPrefix :: Maybe String + { matchPrefix :: Maybe String, + runtimePath :: FilePath } deriving (Show) -type TestBuilder = FilePath -> [String] -> String -> Test () +type TestBuilder = FilePath -> FilePath -> [String] -> String -> Test () testBuilder :: - Bool -> ((FilePath, Text) -> IO ()) -> FilePath -> [String] -> String -> Test () -testBuilder expectFailure recordFailure dir prelude transcript = scope transcript $ do + Bool -> + ((FilePath, Text) -> IO ()) -> + FilePath -> + FilePath -> + [String] -> + String -> + Test () +testBuilder expectFailure recordFailure runtimePath dir prelude transcript = scope transcript $ do outputs <- io . withTemporaryUcmCodebase SC.init Verbosity.Silent "transcript" SC.DoLock $ \(codebasePath, codebase) -> do - withTranscriptRunner Verbosity.Silent "TODO: pass version here" Nothing \runTranscript -> do + withTranscriptRunner Verbosity.Silent "TODO: pass version here" runtimePath Nothing \runTranscript -> do for files \filePath -> do transcriptSrc <- readUtf8 filePath out <- silence $ runTranscript filePath transcriptSrc (codebasePath, codebase) @@ -73,7 +80,7 @@ outputFileForTranscript filePath = replaceExtension filePath ".output.md" buildTests :: TestConfig -> TestBuilder -> FilePath -> Test () -buildTests config testBuilder dir = do +buildTests TestConfig{ .. } testBuilder dir = do io . putStrLn . unlines @@ -88,7 +95,7 @@ buildTests config testBuilder dir = do & filter (\f -> takeExtensions f == ".md") & partition ((isPrefixOf "_") . snd . splitFileName) -- if there is a matchPrefix set, filter non-prelude files by that prefix - or return True - & second (filter (\f -> maybe True (`isPrefixOf` f) (matchPrefix config))) + & second (filter (\f -> maybe True (`isPrefixOf` f) matchPrefix)) case length transcripts of 0 -> pure () @@ -96,7 +103,7 @@ buildTests config testBuilder dir = do -- if you don't give it any tests, this keeps it going -- till the end so we can search all transcripts for -- prefix matches. - _ -> tests (testBuilder dir prelude <$> transcripts) + _ -> tests (testBuilder runtimePath dir prelude <$> transcripts) -- Transcripts that exit successfully get cleaned-up by the transcript parser. -- Any remaining folders matching "transcript-.*" are output directories @@ -139,14 +146,19 @@ test config = do Text.putStrLn msg cleanup -handleArgs :: [String] -> TestConfig -handleArgs args = - let matchPrefix = case args of - [prefix] -> Just prefix - _ -> Nothing - in TestConfig matchPrefix +handleArgs :: TestConfig -> [String] -> TestConfig +handleArgs acc ("--runtime-path":p:rest) = + handleArgs (acc { runtimePath = p }) rest +handleArgs acc [prefix] = acc { matchPrefix = Just prefix } +handleArgs acc _ = acc + +defaultConfig :: IO TestConfig +defaultConfig = + TestConfig Nothing <$> + getXdgDirectory XdgData "unisonlanguage/libexec" main :: IO () main = withCP65001 do - testConfig <- handleArgs <$> getArgs + dcfg <- defaultConfig + testConfig <- handleArgs dcfg <$> getArgs run (test testConfig) From 9905eb829f32cc1e151735c8d9b761dd15aee86e Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Mon, 12 Feb 2024 11:28:20 -0500 Subject: [PATCH 031/181] Fix ucm tests w/r/t/ previous additions --- unison-cli/tests/Unison/Test/Ucm.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unison-cli/tests/Unison/Test/Ucm.hs b/unison-cli/tests/Unison/Test/Ucm.hs index fc0682fe9a..54655cfe29 100644 --- a/unison-cli/tests/Unison/Test/Ucm.hs +++ b/unison-cli/tests/Unison/Test/Ucm.hs @@ -66,7 +66,7 @@ runTranscript :: Codebase -> Transcript -> IO TranscriptOutput runTranscript (Codebase codebasePath fmt) transcript = do let err e = fail $ "Parse error: \n" <> show e cbInit = case fmt of CodebaseFormat2 -> SC.init - TR.withTranscriptRunner Verbosity.Silent "Unison.Test.Ucm.runTranscript Invalid Version String" configFile $ \runner -> do + TR.withTranscriptRunner Verbosity.Silent "Unison.Test.Ucm.runTranscript Invalid Version String" rtp configFile $ \runner -> do result <- Codebase.Init.withOpenCodebase cbInit "transcript" codebasePath SC.DoLock SC.DontMigrate \codebase -> do Codebase.runTransaction codebase (Codebase.installUcmDependencies codebase) let transcriptSrc = stripMargin . Text.pack $ unTranscript transcript @@ -78,6 +78,9 @@ runTranscript (Codebase codebasePath fmt) transcript = do Right x -> pure x where configFile = Nothing + -- Note: this needs to be properly configured if these tests ever + -- need to do native compiles. But I suspect they won't. + rtp = "native-compiler/bin" lowLevel :: Codebase -> (Codebase.Codebase IO Symbol Ann -> IO a) -> IO a lowLevel (Codebase root fmt) action = do From 0cf6222f3ef752de5291543e57c865eecabcaa54 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 12:46:04 -0500 Subject: [PATCH 032/181] yaml can't evaluate shell expression as value --- .github/workflows/ci.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 39111ed054..d0be3f9edc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -194,6 +194,8 @@ jobs: done - name: build run: stack --no-terminal build --fast --no-run-tests --test + - name: output ucm path + run: echo "::set-output name=ucm-path::$(stack exec -- which unison)" # Run each test suite (tests and transcripts) - name: check disk space before @@ -246,7 +248,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: unison-${{ matrix.os }} - path: $(stack exec -- which unison) + path: ${{ steps.build.outputs.ucm-path }} generate-jit-source: name: Generate JIT source From 79356fd797fb284f8bb63b6db18bce86f6f1615a Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 12:58:46 -0500 Subject: [PATCH 033/181] yaml step id --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d0be3f9edc..10bf7bab28 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -195,6 +195,7 @@ jobs: - name: build run: stack --no-terminal build --fast --no-run-tests --test - name: output ucm path + id: ucm-path run: echo "::set-output name=ucm-path::$(stack exec -- which unison)" # Run each test suite (tests and transcripts) @@ -248,7 +249,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: unison-${{ matrix.os }} - path: ${{ steps.build.outputs.ucm-path }} + path: ${{ steps.ucm-path.outputs.ucm-path }} generate-jit-source: name: Generate JIT source From 03c2d6328e2a8631271365f299009dc404fd10fb Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 13:17:24 -0500 Subject: [PATCH 034/181] yaml update deprecated output convention --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 10bf7bab28..431733fc6e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -196,7 +196,7 @@ jobs: run: stack --no-terminal build --fast --no-run-tests --test - name: output ucm path id: ucm-path - run: echo "::set-output name=ucm-path::$(stack exec -- which unison)" + run: echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT # Run each test suite (tests and transcripts) - name: check disk space before From 23f5b1e0f81a09ccc5bf96b3fc2493b8980fa120 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 13:18:29 -0500 Subject: [PATCH 035/181] yaml debug windows artifact failure --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 431733fc6e..38d5aa4db9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -250,6 +250,10 @@ jobs: with: name: unison-${{ matrix.os }} path: ${{ steps.ucm-path.outputs.ucm-path }} + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ failure() }} + generate-jit-source: name: Generate JIT source From c3cbd23f7ec3a630b9c8e24a4a0af3aa0e8f94e3 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 13:21:46 -0500 Subject: [PATCH 036/181] yaml temporarily disable tests --- .github/workflows/ci.yaml | 82 +++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 38d5aa4db9..5d6d3e19a7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -199,47 +199,47 @@ jobs: run: echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT # Run each test suite (tests and transcripts) - - name: check disk space before - if: ${{ always() }} - run: df -h - - name: unison-cli test - run: stack --no-terminal build --fast --test unison-cli - - name: check disk space after - if: ${{ always() }} - run: df -h - - name: unison-core tests - run: stack --no-terminal build --fast --test unison-core - - name: unison-parser-typechecker tests - run: stack --no-terminal build --fast --test unison-parser-typechecker - - name: unison-sqlite tests - run: stack --no-terminal build --fast --test unison-sqlite - - name: unison-syntax tests - run: stack --no-terminal build --fast --test unison-syntax - - name: unison-util-bytes tests - run: stack --no-terminal build --fast --test unison-util-bytes - - name: unison-util-cache tests - run: stack --no-terminal build --fast --test unison-util-cache - - name: unison-util-relation tests - run: stack --no-terminal build --fast --test unison-util-relation - - name: round-trip-tests - run: | - stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md - git add unison-src/transcripts-round-trip/main.output.md - # Fail if any transcripts cause git diffs. - git diff --cached --ignore-cr-at-eol --exit-code - stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md - git add unison-src/transcripts-manual/rewrites.output.md - # Fail if any transcripts cause git diffs. - git diff --cached --ignore-cr-at-eol --exit-code - - name: transcripts - run: | - stack --no-terminal exec transcripts - # Add all changes to the index for when we diff. - git add --all - # Fail if any transcripts cause git diffs. - git diff --cached --ignore-cr-at-eol --exit-code - - name: cli-integration-tests - run: stack --no-terminal exec cli-integration-tests + # - name: check disk space before + # if: ${{ always() }} + # run: df -h + # - name: unison-cli test + # run: stack --no-terminal build --fast --test unison-cli + # - name: check disk space after + # if: ${{ always() }} + # run: df -h + # - name: unison-core tests + # run: stack --no-terminal build --fast --test unison-core + # - name: unison-parser-typechecker tests + # run: stack --no-terminal build --fast --test unison-parser-typechecker + # - name: unison-sqlite tests + # run: stack --no-terminal build --fast --test unison-sqlite + # - name: unison-syntax tests + # run: stack --no-terminal build --fast --test unison-syntax + # - name: unison-util-bytes tests + # run: stack --no-terminal build --fast --test unison-util-bytes + # - name: unison-util-cache tests + # run: stack --no-terminal build --fast --test unison-util-cache + # - name: unison-util-relation tests + # run: stack --no-terminal build --fast --test unison-util-relation + # - name: round-trip-tests + # run: | + # stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md + # git add unison-src/transcripts-round-trip/main.output.md + # # Fail if any transcripts cause git diffs. + # git diff --cached --ignore-cr-at-eol --exit-code + # stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md + # git add unison-src/transcripts-manual/rewrites.output.md + # # Fail if any transcripts cause git diffs. + # git diff --cached --ignore-cr-at-eol --exit-code + # - name: transcripts + # run: | + # stack --no-terminal exec transcripts + # # Add all changes to the index for when we diff. + # git add --all + # # Fail if any transcripts cause git diffs. + # git diff --cached --ignore-cr-at-eol --exit-code + # - name: cli-integration-tests + # run: stack --no-terminal exec cli-integration-tests - name: verify stack ghci startup if: runner.os == 'macOS' From 6561343635b457e14ded082d7258f4e08957534b Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 13:34:54 -0500 Subject: [PATCH 037/181] yaml failing to uploading files is still success --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5d6d3e19a7..12ddf3dd44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -252,7 +252,7 @@ jobs: path: ${{ steps.ucm-path.outputs.ucm-path }} - name: Setup tmate session uses: mxschmitt/action-tmate@v3 - if: ${{ failure() }} + if: ${{ always() }} generate-jit-source: From b8a3435fa3ab8a64f1933d212581cc51f312c495 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 14:50:42 -0500 Subject: [PATCH 038/181] yaml swearing --- .github/workflows/ci.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 12ddf3dd44..dc264a7b90 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -196,7 +196,9 @@ jobs: run: stack --no-terminal build --fast --no-run-tests --test - name: output ucm path id: ucm-path - run: echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT + run: | + echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT + cp "$(stack exec -- which unison)" . # Run each test suite (tests and transcripts) # - name: check disk space before @@ -245,14 +247,20 @@ jobs: if: runner.os == 'macOS' run: echo | stack ghci + - name: debug check ucm artifact + uses: actions/upload-artifact@v4 + run: ls -l ${{ steps.ucm-path.outputs.ucm-path }} + - name: save ucm artifact uses: actions/upload-artifact@v4 with: name: unison-${{ matrix.os }} path: ${{ steps.ucm-path.outputs.ucm-path }} - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} + if-no-files-found: error + + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} generate-jit-source: From 709f4a37e6713aba117fc0bfa01ae86e3d3aec0f Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 14:59:17 -0500 Subject: [PATCH 039/181] yaml whoops --- .github/workflows/ci.yaml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dc264a7b90..8b44409b87 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -242,14 +242,9 @@ jobs: # git diff --cached --ignore-cr-at-eol --exit-code # - name: cli-integration-tests # run: stack --no-terminal exec cli-integration-tests - - - name: verify stack ghci startup - if: runner.os == 'macOS' - run: echo | stack ghci - - - name: debug check ucm artifact - uses: actions/upload-artifact@v4 - run: ls -l ${{ steps.ucm-path.outputs.ucm-path }} + # - name: verify stack ghci startup + # if: runner.os == 'macOS' + # run: echo | stack ghci - name: save ucm artifact uses: actions/upload-artifact@v4 From e1e579820d64b06138f9539d064a11f2105ae2c8 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 15:04:07 -0500 Subject: [PATCH 040/181] yaml swearing+1 --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8b44409b87..1dca346a8e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -246,6 +246,9 @@ jobs: # if: runner.os == 'macOS' # run: echo | stack ghci + - name: debug check ucm artifact + run: ls -l ${{ steps.ucm-path.outputs.ucm-path }} + - name: save ucm artifact uses: actions/upload-artifact@v4 with: From 2d906cd53d8b8b48a110dc3f6936125ff5be9935 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 15:39:26 -0500 Subject: [PATCH 041/181] yaml maybe move bins somewhere nicer --- .github/workflows/ci.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1dca346a8e..1dc7a1de0f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,6 +20,7 @@ on: env: ormolu_version: "0.5.0.1" racket_version: "8.7" + ucm_local_bin: "ucm-local-bin" jit_version: "@unison/internal/releases/0.0.10" jit_src_scheme: "unison-jit-src/scheme-libs/racket" jit_bin: "unison-jit-bin" @@ -193,7 +194,15 @@ jobs: stack --no-terminal build --fast --only-dependencies && break; done - name: build - run: stack --no-terminal build --fast --no-run-tests --test + run: | + stack build \ + --fast \ + --test \ + --no-run-tests \ + --no-terminal \ + --local-bin-path ${{env.ucm_local_bin}} \ + --copy-bins + - name: output ucm path id: ucm-path run: | From 6e37a5ef3cf098549cc5689aec43f62b83575d43 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 17:40:14 -0500 Subject: [PATCH 042/181] yaml getting desperate --- .github/workflows/ci.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1dc7a1de0f..fdb0e7a4af 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -256,7 +256,9 @@ jobs: # run: echo | stack ghci - name: debug check ucm artifact - run: ls -l ${{ steps.ucm-path.outputs.ucm-path }} + run: | + ls -l ${{ env.ucm_local_bin }} + ls -l ${{ steps.ucm-path.outputs.ucm-path }} - name: save ucm artifact uses: actions/upload-artifact@v4 @@ -265,9 +267,9 @@ jobs: path: ${{ steps.ucm-path.outputs.ucm-path }} if-no-files-found: error - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ always() }} generate-jit-source: From 004f79759b12567c0acaff8a35c6c46ff283513d Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 18:08:04 -0500 Subject: [PATCH 043/181] yaml loving magical filenames --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fdb0e7a4af..d0cd3379ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -264,7 +264,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: unison-${{ matrix.os }} - path: ${{ steps.ucm-path.outputs.ucm-path }} + path: ${{ steps.ucm-path.outputs.ucm-path }}{,.exe} if-no-files-found: error - name: Setup tmate session From bacf978cde51f1373a029cd25d72f0d2b15c3f73 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Mon, 12 Feb 2024 18:24:06 -0500 Subject: [PATCH 044/181] yaml unmagic filenames. are duplicate ids ok? --- .github/workflows/ci.yaml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d0cd3379ea..07bbdb524a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -203,11 +203,15 @@ jobs: --local-bin-path ${{env.ucm_local_bin}} \ --copy-bins - - name: output ucm path + - name: output ucm path (Windows only) id: ucm-path - run: | - echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT - cp "$(stack exec -- which unison)" . + if: runner.os == 'Windows' + run: echo "ucm-path=$(stack exec -- where unison)" >> $GITHUB_OUTPUT + + - name: output ucm path (non-Windows) + id: ucm-path + if: runner.os != 'Windows' + run: echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT # Run each test suite (tests and transcripts) # - name: check disk space before @@ -264,7 +268,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: unison-${{ matrix.os }} - path: ${{ steps.ucm-path.outputs.ucm-path }}{,.exe} + path: ${{ steps.ucm-path.outputs.ucm-path }} if-no-files-found: error - name: Setup tmate session From 8100d1f121c3c6bc3684850b5b4c8ddfeb07ba1e Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 10:49:24 -0500 Subject: [PATCH 045/181] yaml no good, does globbing work for upload-artifact? --- .github/workflows/ci.yaml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 07bbdb524a..d0cd3379ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -203,15 +203,11 @@ jobs: --local-bin-path ${{env.ucm_local_bin}} \ --copy-bins - - name: output ucm path (Windows only) + - name: output ucm path id: ucm-path - if: runner.os == 'Windows' - run: echo "ucm-path=$(stack exec -- where unison)" >> $GITHUB_OUTPUT - - - name: output ucm path (non-Windows) - id: ucm-path - if: runner.os != 'Windows' - run: echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT + run: | + echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT + cp "$(stack exec -- which unison)" . # Run each test suite (tests and transcripts) # - name: check disk space before @@ -268,7 +264,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: unison-${{ matrix.os }} - path: ${{ steps.ucm-path.outputs.ucm-path }} + path: ${{ steps.ucm-path.outputs.ucm-path }}{,.exe} if-no-files-found: error - name: Setup tmate session From e08a59330cac0740f865a6708ce83b0e471cdbd3 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 10:54:20 -0500 Subject: [PATCH 046/181] yaml test linux only, for a change --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d0cd3379ea..d45ea794cd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -66,8 +66,8 @@ jobs: os: # While iterating on this file, you can disable one or more of these to speed things up - ubuntu-20.04 - - macOS-12 - - windows-2019 + # - macOS-12 + # - windows-2019 steps: - uses: actions/checkout@v4 From caf447169ae1fee19013a88961a0d0185ee23212 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 11:45:03 -0500 Subject: [PATCH 047/181] yaml globs don't work --- .github/workflows/ci.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d45ea794cd..53722e2437 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -206,8 +206,11 @@ jobs: - name: output ucm path id: ucm-path run: | - echo "ucm-path=$(stack exec -- which unison)" >> $GITHUB_OUTPUT - cp "$(stack exec -- which unison)" . + if [[ ${{runner.os}} = "Windows" ]]; then + echo "ucm-path=${env.ucm_local_bin}/unison.exe" >> $GITHUB_OUTPUT + else + echo "ucm-path=${env.ucm_local_bin}/unison" >> $GITHUB_OUTPUT + fi # Run each test suite (tests and transcripts) # - name: check disk space before @@ -264,7 +267,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: unison-${{ matrix.os }} - path: ${{ steps.ucm-path.outputs.ucm-path }}{,.exe} + path: ${{ steps.ucm-path.outputs.ucm-path }} if-no-files-found: error - name: Setup tmate session From 661c2863c83a5c0cdb894c85d5803cda07852ff2 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 15:04:55 -0500 Subject: [PATCH 048/181] yaml copilot whoops --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 53722e2437..62b1430584 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -207,9 +207,9 @@ jobs: id: ucm-path run: | if [[ ${{runner.os}} = "Windows" ]]; then - echo "ucm-path=${env.ucm_local_bin}/unison.exe" >> $GITHUB_OUTPUT + echo "ucm-path=${{env.ucm_local_bin}}/unison.exe" >> $GITHUB_OUTPUT else - echo "ucm-path=${env.ucm_local_bin}/unison" >> $GITHUB_OUTPUT + echo "ucm-path=${{env.ucm_local_bin}}/unison" >> $GITHUB_OUTPUT fi # Run each test suite (tests and transcripts) From b9536da70ce50f2a2f5192c4f12e5c6f4ddb1854 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 15:05:10 -0500 Subject: [PATCH 049/181] skip tmate for now --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 62b1430584..b54ecdbc7b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -270,9 +270,9 @@ jobs: path: ${{ steps.ucm-path.outputs.ucm-path }} if-no-files-found: error - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} generate-jit-source: From 65b13f4e7e85caea68a7e356770e8bf5ec7e3352 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 15:17:38 -0500 Subject: [PATCH 050/181] yaml blowing up because we skipped ormolu? --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b54ecdbc7b..cdaae40cb6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -276,6 +276,7 @@ jobs: generate-jit-source: + if: ${{ always() }} name: Generate JIT source needs: build-ucm runs-on: ubuntu-20.04 @@ -345,6 +346,7 @@ jobs: build-jit-binary: + if: ${{ always() }} name: Build JIT binary ${{ matrix.os }} needs: [build-ucm, generate-jit-source] runs-on: ${{ matrix.os }} From 1649abea1c43293af81f0f421bae29345c637a2d Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 15:19:57 -0500 Subject: [PATCH 051/181] yaml slightly better? --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cdaae40cb6..8cbaa401ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,7 +57,7 @@ jobs: build-ucm: name: Build UCM ${{ matrix.os }} runs-on: ${{ matrix.os }} - if: ${{ always() }} + if: always() needs: ormolu strategy: # Run each build to completion, regardless of if any have failed @@ -276,7 +276,7 @@ jobs: generate-jit-source: - if: ${{ always() }} + if: always() && needs.build-ucm.result == success name: Generate JIT source needs: build-ucm runs-on: ubuntu-20.04 @@ -346,9 +346,9 @@ jobs: build-jit-binary: - if: ${{ always() }} + if: always() && needs.generate-jit-source.result == success name: Build JIT binary ${{ matrix.os }} - needs: [build-ucm, generate-jit-source] + needs: generate-jit-source runs-on: ${{ matrix.os }} strategy: # Run each build to completion, regardless of if any have failed From c8773fb37c1e74e404d987054589643181a9baed Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 15:36:44 -0500 Subject: [PATCH 052/181] yaml can i get an `if` that makes any sense --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8cbaa401ea..1e9509cd7f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -276,7 +276,7 @@ jobs: generate-jit-source: - if: always() && needs.build-ucm.result == success + if: always() && needs.build-ucm.result == 'success' name: Generate JIT source needs: build-ucm runs-on: ubuntu-20.04 @@ -346,7 +346,7 @@ jobs: build-jit-binary: - if: always() && needs.generate-jit-source.result == success + if: always() && needs.generate-jit-source.result == 'success' name: Build JIT binary ${{ matrix.os }} needs: generate-jit-source runs-on: ${{ matrix.os }} From befb88bfbb63fd5afcffd4fd1d8cb9a0f9f00641 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 15:39:28 -0500 Subject: [PATCH 053/181] comma --- unison-cli/unison/ArgParse.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unison-cli/unison/ArgParse.hs b/unison-cli/unison/ArgParse.hs index b531aec3e2..c2ba0ffa66 100644 --- a/unison-cli/unison/ArgParse.hs +++ b/unison-cli/unison/ArgParse.hs @@ -119,7 +119,7 @@ data Command data GlobalOptions = GlobalOptions { codebasePathOption :: Maybe CodebasePathOption, exitOption :: ShouldExit, - nativeRuntimePath :: Maybe FilePath + nativeRuntimePath :: Maybe FilePath, lspFormattingConfig :: LspFormattingConfig } deriving (Show, Eq) From 6405ad08f6c937b9025d04039eca8b9b973e4cd7 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 15:53:36 -0500 Subject: [PATCH 054/181] yaml switch plugin --- .github/workflows/ci.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1e9509cd7f..82521da9e3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -374,12 +374,12 @@ jobs: - name: check binary exists id: jit_bin_exists - uses: thebinaryfelix/check-file-existence-action@v1 + uses: andstor/file-existence-action@v3 with: files: "${{ env.jit_bin }}/unison-runtime" - name: Cache Racket dependencies - if: steps.jit_bin_exists.outputs.exists == 'false' + if: steps.jit_bin_exists.outputs.files_exists == 'false' uses: actions/cache@v4 with: path: | @@ -387,7 +387,7 @@ jobs: ~/.local/share/racket key: ${{ runner.os }}-racket-${{env.racket_version}} - uses: Bogdanp/setup-racket@v1.11 - # if: steps.jit_bin_exists.outputs.exists == 'false' + # if: steps.jit_bin_exists.outputs.files_exists == 'false' with: architecture: 'x64' distribution: 'full' @@ -400,17 +400,17 @@ jobs: packages: libb2-dev version: 1.0 # cache key version afaik - name: download jit source - # if: steps.jit_src_exists.outputs.exists == 'false' + # if: steps.jit_src_exists.outputs.files_exists == 'false' uses: actions/download-artifact@v4 with: name: jit-source path: ${{ env.jit_src_scheme }} - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - # if: steps.jit_src_exists.outputs.exists == 'false' + # if: steps.jit_src_exists.outputs.files_exists == 'false' - name: download ucm - # if: steps.jit_bin_exists.outputs.exists == 'false' + # if: steps.jit_bin_exists.outputs.files_exists == 'false' uses: actions/download-artifact@v4 with: name: unison-${{ matrix.os }} @@ -420,7 +420,7 @@ jobs: ${{ env.ucm }} transcript setup-jit.md - name: build jit binary - # if: steps.jit_bin_exists.outputs.exists == 'false' + # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} raco pkg install --auto ${{ env.jit_src_scheme }}/unison @@ -428,14 +428,14 @@ jobs: raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }} - name: save jit binary - # if: steps.jit_bin_exists.outputs.exists == 'false' + # if: steps.jit_bin_exists.outputs.files_exists == 'false' uses: actions/upload-artifact@v4 with: name: jit-binary-${{ matrix.os }} path: ${{ env.jit_bin }}/** - name: jit tests ${{ matrix.os }} - # if: steps.jit_bin_exists.outputs.exists == 'false' + # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | time ${{ env.ucm }} transcript unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md @@ -446,7 +446,7 @@ jobs: fi - name: interpreter tests - # if: steps.jit_bin_exists.outputs.exists == 'false' + # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | time ${{ env.ucm }} transcript unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md From 16c9a7e892d39521d79415607b9dae44f84da13a Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 16:03:29 -0500 Subject: [PATCH 055/181] yaml x2 --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 82521da9e3..5f623027a5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -295,7 +295,7 @@ jobs: - name: check source exists id: jit_src_exists - uses: thebinaryfelix/check-file-existence-action@v1 + uses: andstor/file-existence-action@v3 with: files: "${{ env.jit_src_scheme }}/unison/{data-info,boot-generated,simple-wrappers,builtin-generated,compound-wrappers}.ss" @@ -324,21 +324,21 @@ jobs: ``` - name: download ucm artifact - if: steps.jit_src_exists.outputs.exists == 'false' + if: steps.jit_src_exists.outputs.files_exists == 'false' uses: actions/download-artifact@v4 with: name: unison-${{ env.jit_generator_os }} path: ${{ runner.temp }} - name: generate source - if: steps.jit_src_exists.outputs.exists == 'false' + if: steps.jit_src_exists.outputs.files_exists == 'false' run: | cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} chmod +x ${{ env.ucm }} ${{ env.ucm }} transcript setup-jit.md - name: save jit source - if: steps.jit_src_exists.outputs.exists == 'false' + if: steps.jit_src_exists.outputs.files_exists == 'false' uses: actions/upload-artifact@v4 with: name: jit-source From 248dca03c099041b15d3a1056cdc681ce8984dcd Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 16:17:03 -0500 Subject: [PATCH 056/181] yaml get scheme-libs/ --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5f623027a5..b15e3d35c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -330,6 +330,9 @@ jobs: name: unison-${{ env.jit_generator_os }} path: ${{ runner.temp }} + - name: download scheme-libs + uses: actions/checkout@v4 + - name: generate source if: steps.jit_src_exists.outputs.files_exists == 'false' run: | From c2c6de1f0570714860d59c5d6a21c6e3e554de35 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 16:19:05 -0500 Subject: [PATCH 057/181] yaml missed one variable name swap --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b15e3d35c1..5a14914673 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -300,7 +300,7 @@ jobs: files: "${{ env.jit_src_scheme }}/unison/{data-info,boot-generated,simple-wrappers,builtin-generated,compound-wrappers}.ss" - name: create transcript - if: steps.jit_src_exists.outputs.exists == 'false' + if: steps.jit_src_exists.outputs.files_exists == 'false' uses: 1arp/create-a-file-action@0.3 with: file: 'setup-jit.md' From d8e2c61eac093cfd452b7642157fa2cb3125015f Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 16:29:40 -0500 Subject: [PATCH 058/181] yaml where are my files? --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5a14914673..7b88831f5c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -332,6 +332,9 @@ jobs: - name: download scheme-libs uses: actions/checkout@v4 + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ always() }} - name: generate source if: steps.jit_src_exists.outputs.files_exists == 'false' From 4a8a42d77bd312ed8f68009388f3bed65a952fe4 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 16:43:49 -0500 Subject: [PATCH 059/181] yaml make temp scheme dir before --- .github/workflows/ci.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b88831f5c..0a2cd643c3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -284,7 +284,7 @@ jobs: - name: set up environment run: | echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV - echo "ucm=${{ runner.temp }}/unison-${{ matrix.os }}" >> $GITHUB_ENV + echo "ucm=${{ runner.temp }}/unison-${{ env.jit_generator_os }}" >> $GITHUB_ENV - uses: actions/cache@v4 name: cache jit source if: runner.os == 'Linux' @@ -332,13 +332,15 @@ jobs: - name: download scheme-libs uses: actions/checkout@v4 - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} + + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} - name: generate source if: steps.jit_src_exists.outputs.files_exists == 'false' run: | + mkdir -p ${{ env.jit_src_scheme }} cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} chmod +x ${{ env.ucm }} ${{ env.ucm }} transcript setup-jit.md From 57360bfa2073f3e067397f6d0e345f7c992651d7 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 16:44:31 -0500 Subject: [PATCH 060/181] yaml downloaded unison artifact filename is just called unison --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0a2cd643c3..c7007c8bc6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -284,7 +284,7 @@ jobs: - name: set up environment run: | echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV - echo "ucm=${{ runner.temp }}/unison-${{ env.jit_generator_os }}" >> $GITHUB_ENV + echo "ucm=${{ runner.temp }}/unison" >> $GITHUB_ENV - uses: actions/cache@v4 name: cache jit source if: runner.os == 'Linux' @@ -372,7 +372,7 @@ jobs: run: | echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV echo "jit_bin=${{ runner.temp }}/${{ env.jit_bin }}" >> $GITHUB_ENV - echo "ucm=${{ runner.temp }}/unison-${{ matrix.os }}" >> $GITHUB_ENV + echo "ucm=${{ runner.temp }}/unison" >> $GITHUB_ENV - name: cache jit binaries uses: actions/cache@v4 with: From 9ea88f3bb7287c7e3891228be1b1f6b66225c61d Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 20:30:12 -0500 Subject: [PATCH 061/181] yaml maybe transcript was being overwritten by checkout --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c7007c8bc6..3b19cdaa73 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -303,7 +303,7 @@ jobs: if: steps.jit_src_exists.outputs.files_exists == 'false' uses: 1arp/create-a-file-action@0.3 with: - file: 'setup-jit.md' + file: ${{ runner.temp }}/setup-jit.md content: | ```ucm .> project.create-empty jit-setup @@ -343,7 +343,7 @@ jobs: mkdir -p ${{ env.jit_src_scheme }} cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} chmod +x ${{ env.ucm }} - ${{ env.ucm }} transcript setup-jit.md + ${{ env.ucm }} transcript ${{ runner.temp }}/setup-jit.md - name: save jit source if: steps.jit_src_exists.outputs.files_exists == 'false' From 385625ce3bf7f365f32a7954f544b7738c2550b4 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 21:10:44 -0500 Subject: [PATCH 062/181] yaml create transcript with separate path and file --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3b19cdaa73..3840414594 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -303,7 +303,8 @@ jobs: if: steps.jit_src_exists.outputs.files_exists == 'false' uses: 1arp/create-a-file-action@0.3 with: - file: ${{ runner.temp }}/setup-jit.md + path: ${{ runner.temp }} + file: setup-jit.md content: | ```ucm .> project.create-empty jit-setup From 614f573c90475b4ff29427fd105572ba654e30dc Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 21:13:30 -0500 Subject: [PATCH 063/181] yaml try tmate again --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3840414594..bdd8aad8a9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -334,9 +334,9 @@ jobs: - name: download scheme-libs uses: actions/checkout@v4 - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ always() }} - name: generate source if: steps.jit_src_exists.outputs.files_exists == 'false' From b47102c43000c19d1925cb8b4f542e5c585749b0 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 21:19:06 -0500 Subject: [PATCH 064/181] yaml i hope quotes don't matter --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bdd8aad8a9..2d6240ffdf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -303,8 +303,8 @@ jobs: if: steps.jit_src_exists.outputs.files_exists == 'false' uses: 1arp/create-a-file-action@0.3 with: - path: ${{ runner.temp }} - file: setup-jit.md + path: "${{ runner.temp }}" + file: "setup-jit.md" content: | ```ucm .> project.create-empty jit-setup From a99b7636d216ce4383770487645eb9987f336f83 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 21:28:49 -0500 Subject: [PATCH 065/181] yaml try finnp/create-file-action@v2 instead? --- .github/workflows/ci.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2d6240ffdf..849a62d2d5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -301,11 +301,10 @@ jobs: - name: create transcript if: steps.jit_src_exists.outputs.files_exists == 'false' - uses: 1arp/create-a-file-action@0.3 - with: - path: "${{ runner.temp }}" - file: "setup-jit.md" - content: | + uses: finnp/create-file-action@v2 + env: + - FILE_NAME: ${{ runner.temp }}/setup-jit.md + - FILE_DATA: | ```ucm .> project.create-empty jit-setup jit-setup/main> pull ${{ env.jit_version }} lib.jit From 002013532302cc3024326a8bf4d9316b2c971e5f Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 21:31:19 -0500 Subject: [PATCH 066/181] try DamianReeves/write-file-action@v1.3 instead --- .github/workflows/ci.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 849a62d2d5..4b376b9af4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -301,10 +301,11 @@ jobs: - name: create transcript if: steps.jit_src_exists.outputs.files_exists == 'false' - uses: finnp/create-file-action@v2 - env: - - FILE_NAME: ${{ runner.temp }}/setup-jit.md - - FILE_DATA: | + uses: DamianReeves/write-file-action@v1.3 + with: + path: ${{ runner.temp }}/setup-jit.md + write-mode: overwrite + contents: | ```ucm .> project.create-empty jit-setup jit-setup/main> pull ${{ env.jit_version }} lib.jit From f8cae189bdec157c830e0cee5af91ddcc23ebe5e Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 21:49:37 -0500 Subject: [PATCH 067/181] yaml don't need to run transcript here --- .github/workflows/ci.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4b376b9af4..f85dc3ac43 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -424,9 +424,6 @@ jobs: with: name: unison-${{ matrix.os }} path: ${{ runner.temp }} - - run: | - chmod +x ${{ env.ucm }} - ${{ env.ucm }} transcript setup-jit.md - name: build jit binary # if: steps.jit_bin_exists.outputs.files_exists == 'false' @@ -446,6 +443,7 @@ jobs: - name: jit tests ${{ matrix.os }} # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | + chmod +x ${{ env.ucm }} time ${{ env.ucm }} transcript unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md CHANGE=$(git diff unison-src/builtin-tests/jit-tests.output.md) From 36b59b635eea9741d84fee6838b7bbc5c88b8635 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 21:50:36 -0500 Subject: [PATCH 068/181] yaml untmate --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f85dc3ac43..71691f55e5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -334,9 +334,9 @@ jobs: - name: download scheme-libs uses: actions/checkout@v4 - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} - name: generate source if: steps.jit_src_exists.outputs.files_exists == 'false' From aaa62d11ff6c0fd36de04a6b0d85eb7f258a9f57 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 22:04:21 -0500 Subject: [PATCH 069/181] commit racket deps list --- scheme-libs/racket/unison/info.rkt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scheme-libs/racket/unison/info.rkt b/scheme-libs/racket/unison/info.rkt index 23f0c7bc89..c09dd06912 100644 --- a/scheme-libs/racket/unison/info.rkt +++ b/scheme-libs/racket/unison/info.rkt @@ -2,4 +2,11 @@ (define collection "unison") -(define deps (list)) +(define deps + (list + "x509-lib" + "r6rs-lib" + "rackunit-lib" + "math-lib" + "srfi-lib" + )) From 7c4331792bd5c56ec42cdaee70dff6e7e528428f Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 22:18:19 -0500 Subject: [PATCH 070/181] yaml no apt on windows --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 71691f55e5..fe998f90e6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -403,6 +403,7 @@ jobs: variant: 'CS' version: ${{env.racket_version}} - uses: awalsh128/cache-apt-pkgs-action@latest + if: runner.os != 'Windows' # read this if a package isn't installing correctly # https://github.com/awalsh128/cache-apt-pkgs-action#caveats with: From 1d25ac7ab4bebe16fedd339167ff38952d0003ba Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 22:18:23 -0500 Subject: [PATCH 071/181] yaml tmate --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fe998f90e6..06c5f65f3d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -426,6 +426,10 @@ jobs: name: unison-${{ matrix.os }} path: ${{ runner.temp }} + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ always() }} + - name: build jit binary # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | From 9c664923b1e3ff977dc37ea258976d50c301cfdf Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 22:24:07 -0500 Subject: [PATCH 072/181] yaml forget broken files-exist action --- .github/workflows/ci.yaml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06c5f65f3d..d6796332c4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -295,9 +295,24 @@ jobs: - name: check source exists id: jit_src_exists - uses: andstor/file-existence-action@v3 - with: - files: "${{ env.jit_src_scheme }}/unison/{data-info,boot-generated,simple-wrappers,builtin-generated,compound-wrappers}.ss" + run: | + files=(data-info boot-generated simple-wrappers builtin-generated compound-wrappers) + all_exist=true + + for file in "${files[@]}"; do + if [[ ! -f "${{ env.jit_src_scheme }}/unison/$file.ss" ]]; then + echo "$file does not exist." + all_exist=false + # Uncomment the next line if you want to stop checking after the first missing file + # break + fi + done + + if $all_exist; then + echo "files_exists=true" >> $GITHUB_OUTPUT + else + echo "files_exists=false" >> $GITHUB_OUTPUT + fi - name: create transcript if: steps.jit_src_exists.outputs.files_exists == 'false' From db73426cf3f52c52b56b17f49f9b49ad9099af17 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 22:26:58 -0500 Subject: [PATCH 073/181] yaml skip clone if src not needed --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d6796332c4..528be38075 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -347,6 +347,7 @@ jobs: path: ${{ runner.temp }} - name: download scheme-libs + if: steps.jit_src_exists.outputs.files_exists == 'false' uses: actions/checkout@v4 # - name: Setup tmate session From 0162dff6249400d49357ede610aa59a93a2f466f Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 22:28:38 -0500 Subject: [PATCH 074/181] yaml always save jit source for next step (for now) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 528be38075..08371c7d26 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -363,7 +363,7 @@ jobs: ${{ env.ucm }} transcript ${{ runner.temp }}/setup-jit.md - name: save jit source - if: steps.jit_src_exists.outputs.files_exists == 'false' + if: ${{ always() }} uses: actions/upload-artifact@v4 with: name: jit-source From cc2113871986362bee1fae3d57c27a789504d8db Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 23:03:31 -0500 Subject: [PATCH 075/181] yaml more yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 08371c7d26..a900634920 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -452,7 +452,7 @@ jobs: cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} raco pkg install --auto ${{ env.jit_src_scheme }}/unison raco exe ${{ env.jit_src_scheme }}/unison-runtime.rkt - raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }} + raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }}/unison-runtime - name: save jit binary # if: steps.jit_bin_exists.outputs.files_exists == 'false' From 22dd1ff90cac459de98bbcd641fe23322a935a7a Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 13 Feb 2024 23:19:22 -0500 Subject: [PATCH 076/181] yaml all platforms without tmate --- .github/workflows/ci.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a900634920..7d31dd8dba 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -66,8 +66,8 @@ jobs: os: # While iterating on this file, you can disable one or more of these to speed things up - ubuntu-20.04 - # - macOS-12 - # - windows-2019 + - macOS-12 + - windows-2019 steps: - uses: actions/checkout@v4 @@ -442,9 +442,9 @@ jobs: name: unison-${{ matrix.os }} path: ${{ runner.temp }} - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} - name: build jit binary # if: steps.jit_bin_exists.outputs.files_exists == 'false' From 0ceea67c7ff4f1dfcf4bcbfc67a489a00c2031aa Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 08:14:32 -0500 Subject: [PATCH 077/181] yaml set up base codebase --- .github/workflows/ci.yaml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7d31dd8dba..46121ccfb1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,6 +25,7 @@ env: jit_src_scheme: "unison-jit-src/scheme-libs/racket" jit_bin: "unison-jit-bin" jit_generator_os: ubuntu-20.04 + base-codebase: "~/.cache/unisonlanguage/base.unison" jobs: ormolu: @@ -346,6 +347,10 @@ jobs: name: unison-${{ env.jit_generator_os }} path: ${{ runner.temp }} + - name: set ucm permissions + if: steps.jit_src_exists.outputs.files_exists == 'false' + run: chmod +x ${{ env.ucm }} + - name: download scheme-libs if: steps.jit_src_exists.outputs.files_exists == 'false' uses: actions/checkout@v4 @@ -359,7 +364,6 @@ jobs: run: | mkdir -p ${{ env.jit_src_scheme }} cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} - chmod +x ${{ env.ucm }} ${{ env.ucm }} transcript ${{ runner.temp }}/setup-jit.md - name: save jit source @@ -461,11 +465,25 @@ jobs: name: jit-binary-${{ matrix.os }} path: ${{ env.jit_bin }}/** + - name: cache base.md codebase + # if: steps.jit_bin_exists.outputs.files_exists == 'false' + uses: actions/cache@v4 + with: + path: ${{ env.base-codebase}} + key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md'}-${{github.sha}} + restore-keys: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}- + + - name: set ucm permissions + run: chmod +x ${{ env.ucm }} + + - name: create base.md codebase + # if: steps.jit_bin_exists.outputs.files_exists == 'false' + run: ${{env.ucm}} transcript -S ${{env.base-codebase}} unison-src/builtin-tests/base.md + - name: jit tests ${{ matrix.os }} # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | - chmod +x ${{ env.ucm }} - time ${{ env.ucm }} transcript unison-src/builtin-tests/jit-tests.md + time ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md CHANGE=$(git diff unison-src/builtin-tests/jit-tests.output.md) if [ -n "$CHANGE" ]; then @@ -476,7 +494,7 @@ jobs: - name: interpreter tests # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | - time ${{ env.ucm }} transcript unison-src/builtin-tests/interpreter-tests.md + time ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md CHANGE=$(git diff unison-src/builtin-tests/interpreter-tests.output.md) if [ -n "$CHANGE" ]; then From f56fb23f462d2f67cd4a6996d577cdfe6420349a Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 08:15:14 -0500 Subject: [PATCH 078/181] don't fetch internal --- unison-src/builtin-tests/base.md | 1 - 1 file changed, 1 deletion(-) diff --git a/unison-src/builtin-tests/base.md b/unison-src/builtin-tests/base.md index 493c1428c5..a3785e3210 100644 --- a/unison-src/builtin-tests/base.md +++ b/unison-src/builtin-tests/base.md @@ -6,5 +6,4 @@ Thus, make sure the contents of this file define the contents of the cache ```ucm .> pull @unison/base/releases/2.5.0 .base -.> compile.native.fetch ``` From d5c4466c3d6706c43883767cd8a8662ef7f32b0b Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 08:16:04 -0500 Subject: [PATCH 079/181] yaml typo --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 46121ccfb1..746371e442 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -470,7 +470,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.base-codebase}} - key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md'}-${{github.sha}} + key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}-${{github.sha}} restore-keys: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}- - name: set ucm permissions From 8cc6b870bcbb3d7dc269de4e4af364ec7673b018 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 10:20:14 -0500 Subject: [PATCH 080/181] yaml stop before jit tests --- .github/workflows/ci.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 746371e442..1683c4a66f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -480,10 +480,14 @@ jobs: # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: ${{env.ucm}} transcript -S ${{env.base-codebase}} unison-src/builtin-tests/base.md + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ always() }} + - name: jit tests ${{ matrix.os }} # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | - time ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md + time ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_bin }}/bin -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md CHANGE=$(git diff unison-src/builtin-tests/jit-tests.output.md) if [ -n "$CHANGE" ]; then From 2e8ca880538f58486039e587c6c27ea1467945d4 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 10:38:01 -0500 Subject: [PATCH 081/181] yaml mac doesn't have apt either --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1683c4a66f..3f7902352d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -423,7 +423,7 @@ jobs: variant: 'CS' version: ${{env.racket_version}} - uses: awalsh128/cache-apt-pkgs-action@latest - if: runner.os != 'Windows' + if: runner.os == 'Linux' # read this if a package isn't installing correctly # https://github.com/awalsh128/cache-apt-pkgs-action#caveats with: From 851cc9c85f25124f3aca69ce3d4f6b1691245f5a Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 10:38:17 -0500 Subject: [PATCH 082/181] yaml switch windows path separator --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3f7902352d..6362a10676 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -453,7 +453,7 @@ jobs: - name: build jit binary # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | - cp -R scheme-libs/racket/* ${{ env.jit_src_scheme }} + cp -R scheme-libs/racket/* ${jit_src_scheme//\\//} # replace \\ with / (on windows) raco pkg install --auto ${{ env.jit_src_scheme }}/unison raco exe ${{ env.jit_src_scheme }}/unison-runtime.rkt raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }}/unison-runtime From 9b933722fbc71a919642b762483c272f35221f45 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 10:52:37 -0500 Subject: [PATCH 083/181] yaml file existence plugins don't work --- .github/workflows/ci.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6362a10676..ddbb7ec218 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -403,9 +403,12 @@ jobs: - name: check binary exists id: jit_bin_exists - uses: andstor/file-existence-action@v3 - with: - files: "${{ env.jit_bin }}/unison-runtime" + run: | + if [[ -f "${{ env.jit_bin }}/bin/unison-runtime" ]]; then + echo "files_exists=true" >> $GITHUB_OUTPUT + else + echo "files_exists=false" >> $GITHUB_OUTPUT + fi - name: Cache Racket dependencies if: steps.jit_bin_exists.outputs.files_exists == 'false' From 85ded9040fef912f74c80b58ec655e580ce567ea Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 13:38:16 -0500 Subject: [PATCH 084/181] yaml the lack of proper flow control is astounding --- .github/workflows/ci.yaml | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ddbb7ec218..85d10f00ee 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -419,74 +419,64 @@ jobs: ~/.local/share/racket key: ${{ runner.os }}-racket-${{env.racket_version}} - uses: Bogdanp/setup-racket@v1.11 - # if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.jit_bin_exists.outputs.files_exists == 'false' with: architecture: 'x64' distribution: 'full' variant: 'CS' version: ${{env.racket_version}} - uses: awalsh128/cache-apt-pkgs-action@latest - if: runner.os == 'Linux' + if: runner.os == 'Linux' && steps.jit_bin_exists.outputs.files_exists == 'false' # read this if a package isn't installing correctly # https://github.com/awalsh128/cache-apt-pkgs-action#caveats with: packages: libb2-dev version: 1.0 # cache key version afaik - name: download jit source - # if: steps.jit_src_exists.outputs.files_exists == 'false' + if: steps.jit_src_exists.outputs.files_exists == 'false' uses: actions/download-artifact@v4 with: name: jit-source path: ${{ env.jit_src_scheme }} - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - # if: steps.jit_src_exists.outputs.files_exists == 'false' - - - name: download ucm - # if: steps.jit_bin_exists.outputs.files_exists == 'false' - uses: actions/download-artifact@v4 - with: - name: unison-${{ matrix.os }} - path: ${{ runner.temp }} - - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} + if: steps.jit_src_exists.outputs.files_exists == 'false' - name: build jit binary - # if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | cp -R scheme-libs/racket/* ${jit_src_scheme//\\//} # replace \\ with / (on windows) - raco pkg install --auto ${{ env.jit_src_scheme }}/unison + raco pkg install --auto --skip-installed ${{ env.jit_src_scheme }}/unison | raco exe ${{ env.jit_src_scheme }}/unison-runtime.rkt raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }}/unison-runtime - name: save jit binary - # if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.jit_bin_exists.outputs.files_exists == 'false' uses: actions/upload-artifact@v4 with: name: jit-binary-${{ matrix.os }} path: ${{ env.jit_bin }}/** - name: cache base.md codebase - # if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.jit_bin_exists.outputs.files_exists == 'false' uses: actions/cache@v4 with: path: ${{ env.base-codebase}} key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}-${{github.sha}} restore-keys: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}- + - name: download ucm + uses: actions/download-artifact@v4 + with: + name: unison-${{ matrix.os }} + path: ${{ runner.temp }} + - name: set ucm permissions run: chmod +x ${{ env.ucm }} - name: create base.md codebase - # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: ${{env.ucm}} transcript -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} - - name: jit tests ${{ matrix.os }} # if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | From 3e6aec4d0684839aae668c672f1ef034074e40c1 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 14 Feb 2024 13:52:09 -0500 Subject: [PATCH 085/181] yaml always checkout repo prior to running transcript from it --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 85d10f00ee..32c7de1fd6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -440,7 +440,6 @@ jobs: path: ${{ env.jit_src_scheme }} - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - if: steps.jit_src_exists.outputs.files_exists == 'false' - name: build jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' From bb66d4c8c259103a19835db8f1ebadcd70c2ebee Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 05:47:32 -0500 Subject: [PATCH 086/181] yaml whoops --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 32c7de1fd6..fde396f7af 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -433,7 +433,7 @@ jobs: packages: libb2-dev version: 1.0 # cache key version afaik - name: download jit source - if: steps.jit_src_exists.outputs.files_exists == 'false' + if: steps.jit_bin_exists.outputs.files_exists == 'false' uses: actions/download-artifact@v4 with: name: jit-source From 69f41b706eb866a8e92b54ebf08f26a7d12b8063 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 05:59:25 -0500 Subject: [PATCH 087/181] yaml no clue whats going on again --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fde396f7af..c62161d3b2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -355,10 +355,6 @@ jobs: if: steps.jit_src_exists.outputs.files_exists == 'false' uses: actions/checkout@v4 - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} - - name: generate source if: steps.jit_src_exists.outputs.files_exists == 'false' run: | @@ -441,6 +437,10 @@ jobs: - uses: actions/checkout@v4 # checkout scheme-libs from unison repo + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} + - name: build jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' run: | From 719bd7b1bb43c6aaeffc465fba4cc5e356936772 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 06:10:08 -0500 Subject: [PATCH 088/181] yaml remove caching condition --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c62161d3b2..596d0bb462 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -457,7 +457,6 @@ jobs: path: ${{ env.jit_bin }}/** - name: cache base.md codebase - if: steps.jit_bin_exists.outputs.files_exists == 'false' uses: actions/cache@v4 with: path: ${{ env.base-codebase}} From ae100d0e43cd60eb74c8aa7543cfe68818ddfab5 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 06:10:57 -0500 Subject: [PATCH 089/181] yaml works better when uncommented --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 596d0bb462..e5bdf13bdd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -437,9 +437,9 @@ jobs: - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ always() }} - name: build jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' From f747904fa4b86c4aa34519d43b930104d7f5ac3d Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 06:34:09 -0500 Subject: [PATCH 090/181] yaml does overriding the default with the default make it work better? --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e5bdf13bdd..db3909eb37 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -443,9 +443,10 @@ jobs: - name: build jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' + shell: bash run: | cp -R scheme-libs/racket/* ${jit_src_scheme//\\//} # replace \\ with / (on windows) - raco pkg install --auto --skip-installed ${{ env.jit_src_scheme }}/unison | + raco pkg install --auto --skip-installed ${{ env.jit_src_scheme }}/unison raco exe ${{ env.jit_src_scheme }}/unison-runtime.rkt raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }}/unison-runtime From a662a725c231d6a3fd73398685c52bd2d5d79e39 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 06:39:18 -0500 Subject: [PATCH 091/181] yaml lame that that worked --- .github/workflows/ci.yaml | 9 +++++---- docs/github-actions-help.md | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 docs/github-actions-help.md diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index db3909eb37..6c0dd9fdd3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -445,10 +445,11 @@ jobs: if: steps.jit_bin_exists.outputs.files_exists == 'false' shell: bash run: | - cp -R scheme-libs/racket/* ${jit_src_scheme//\\//} # replace \\ with / (on windows) - raco pkg install --auto --skip-installed ${{ env.jit_src_scheme }}/unison - raco exe ${{ env.jit_src_scheme }}/unison-runtime.rkt - raco distribute ${{ env.jit_bin }} ${{ env.jit_src_scheme }}/unison-runtime + jit_src_scheme_adjusted="${jit_src_scheme//\\//}" # replace \\ with / (on windows) + cp -R scheme-libs/racket/* "$jit_src_scheme_adjusted" + raco pkg install --auto --skip-installed "$jit_src_scheme_adjusted"/unison + raco exe "$jit_src_scheme_adjusted"/unison-runtime.rkt + raco distribute ${{ env.jit_bin }} "$jit_src_scheme_adjusted"/unison-runtime - name: save jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' diff --git a/docs/github-actions-help.md b/docs/github-actions-help.md new file mode 100644 index 0000000000..9688b96832 --- /dev/null +++ b/docs/github-actions-help.md @@ -0,0 +1,7 @@ +## Some things I wish I'd known about Github Actions + +You can't have an `env:` key defined in terms of another `env` key, but + +You can't define a `matrix` at the top level, it has to be defined within a `job`'s `strategy`. + +Windows doesn't seem to honor the `default: run: shell:` setting, so you need to set the `shell:` on `run:` manually? From 964cbe8d6709e97aa2f3ec6f3089d27995fc9e9d Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 08:14:01 -0500 Subject: [PATCH 092/181] yaml try not to blow up on the second run --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6c0dd9fdd3..35e08888e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -475,7 +475,7 @@ jobs: run: chmod +x ${{ env.ucm }} - name: create base.md codebase - run: ${{env.ucm}} transcript -S ${{env.base-codebase}} unison-src/builtin-tests/base.md + run: ${{env.ucm}} transcript -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: jit tests ${{ matrix.os }} # if: steps.jit_bin_exists.outputs.files_exists == 'false' From ddc303df5550e485991f5156332b6a0c9358a673 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 08:22:09 -0500 Subject: [PATCH 093/181] yaml argh --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 35e08888e7..572b0f2b46 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -475,7 +475,7 @@ jobs: run: chmod +x ${{ env.ucm }} - name: create base.md codebase - run: ${{env.ucm}} transcript -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md + run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: jit tests ${{ matrix.os }} # if: steps.jit_bin_exists.outputs.files_exists == 'false' From d64feb2ebe2a1b4f8eb195dc9b15bdda096f5f63 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 08:22:34 -0500 Subject: [PATCH 094/181] yaml disable pause again --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 572b0f2b46..009b2ebb0e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -437,9 +437,9 @@ jobs: - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} - name: build jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' From e4f1563100b32180dcd4dcb4c89da11e03d79663 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 10:19:27 -0500 Subject: [PATCH 095/181] yaml why did windows fail to build jit binary? --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 009b2ebb0e..31e9a2eb17 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -437,10 +437,6 @@ jobs: - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} - - name: build jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' shell: bash @@ -451,6 +447,10 @@ jobs: raco exe "$jit_src_scheme_adjusted"/unison-runtime.rkt raco distribute ${{ env.jit_bin }} "$jit_src_scheme_adjusted"/unison-runtime + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: runner.os == 'Windows' + - name: save jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' uses: actions/upload-artifact@v4 From 3421b619ff7b102279cd6f0d91dadbdd7bcb8841 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 10:31:20 -0500 Subject: [PATCH 096/181] yaml because of course you have to specify always --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 31e9a2eb17..bacc797f61 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -449,7 +449,7 @@ jobs: - name: Setup tmate session uses: mxschmitt/action-tmate@v3 - if: runner.os == 'Windows' + if: ${{ always() }} && runner.os == 'Windows' - name: save jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' From a42ccc682af02ac9cdf37197edb21fd5f73df327 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 10:53:45 -0500 Subject: [PATCH 097/181] yaml jump through some hoops re `.exe` on windows --- .github/workflows/ci.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bacc797f61..9e0f8d1639 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -442,14 +442,20 @@ jobs: shell: bash run: | jit_src_scheme_adjusted="${jit_src_scheme//\\//}" # replace \\ with / (on windows) + jit_bin_adjusted=${jit_bin//\\//} # replace \\ with / (on windows) cp -R scheme-libs/racket/* "$jit_src_scheme_adjusted" raco pkg install --auto --skip-installed "$jit_src_scheme_adjusted"/unison raco exe "$jit_src_scheme_adjusted"/unison-runtime.rkt - raco distribute ${{ env.jit_bin }} "$jit_src_scheme_adjusted"/unison-runtime + if [[ ${{runner.os}} = "Windows" ]]; then + unison_runtime_exe="$jit_src_scheme_adjusted/unison-runtime.exe" + else + unison_runtime_exe="$jit_src_scheme_adjusted/unison-runtime" + fi + raco distribute "$jit_bin_adjusted" "$unison_runtime_exe" - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} && runner.os == 'Windows' + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} && runner.os == 'Windows' - name: save jit binary if: steps.jit_bin_exists.outputs.files_exists == 'false' From 3b7c24bc929980f182afcb9294fec6a90df57fa2 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 14:15:20 -0500 Subject: [PATCH 098/181] yaml small refactor, hope I don't regret it --- .github/workflows/ci.yaml | 83 ++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9e0f8d1639..c692bd079d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ env: ucm_local_bin: "ucm-local-bin" jit_version: "@unison/internal/releases/0.0.10" jit_src_scheme: "unison-jit-src/scheme-libs/racket" - jit_bin: "unison-jit-bin" + jit_dist: "unison-jit-dist" jit_generator_os: ubuntu-20.04 base-codebase: "~/.cache/unisonlanguage/base.unison" @@ -386,28 +386,44 @@ jobs: - windows-2019 steps: - name: set up environment + id: checks run: | - echo "jit_src_scheme=${{ runner.temp }}/${{ env.jit_src_scheme }}" >> $GITHUB_ENV - echo "jit_bin=${{ runner.temp }}/${{ env.jit_bin }}" >> $GITHUB_ENV - echo "ucm=${{ runner.temp }}/unison" >> $GITHUB_ENV - - name: cache jit binaries - uses: actions/cache@v4 - with: - path: ${{ env.jit_bin }} - key: jit_bin.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}.${{ github.sha }} - restore-keys: jit_bin.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}. + jit_src_scheme="${{ runner.temp }}/${{ env.jit_src_scheme }}" # scheme source + jit_exe="${jit_src_scheme}/unison-runtime" # initially built jit + jit_dist="${{ runner.temp }}/${{ env.jit_dist }}" # jit binary with libraries destination + jit_dist_exe="${jit_dist}/bin/unison-runtime" # jit binary itself + ucm="${{ runner.temp }}/unison" - - name: check binary exists - id: jit_bin_exists - run: | - if [[ -f "${{ env.jit_bin }}/bin/unison-runtime" ]]; then - echo "files_exists=true" >> $GITHUB_OUTPUT + if [[ ${{runner.os}} = "Windows" ]]; then + jit_src_scheme="${jit_src_scheme//\\//}" + jit_dist="${jit_dist//\\//}" + + jit_exe="${jit_exe//\\//}.exe" + jit_dist_exe="${jit_dist_exe//\\//}.exe" + ucm="${ucm//\\//}.exe" + fi + + if [[ -f "$jit_dist_exe" ]]; then + echo "jit_dist_exists=true" >> $GITHUB_OUTPUT else - echo "files_exists=false" >> $GITHUB_OUTPUT + echo "jit_dist_exists=false" >> $GITHUB_OUTPUT fi + echo "jit_src_scheme=$jit_src_scheme" >> $GITHUB_ENV + echo "jit_exe=$jit_exe" >> $GITHUB_ENV + echo "jit_dist=$jit_dist" >> $GITHUB_ENV + echo "jit_dist_exe=$jit_dist_exe" >> $GITHUB_ENV + echo "ucm=$ucm" >> $GITHUB_ENV + + - name: cache jit binaries + uses: actions/cache@v4 + with: + path: ${{ env.jit_dist }} + key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}.${{ github.sha }} + restore-keys: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}. + - name: Cache Racket dependencies - if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.checks.outputs.jit_dist_exists == 'false' uses: actions/cache@v4 with: path: | @@ -415,21 +431,21 @@ jobs: ~/.local/share/racket key: ${{ runner.os }}-racket-${{env.racket_version}} - uses: Bogdanp/setup-racket@v1.11 - if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.checks.outputs.jit_dist_exists == 'false' with: architecture: 'x64' distribution: 'full' variant: 'CS' version: ${{env.racket_version}} - uses: awalsh128/cache-apt-pkgs-action@latest - if: runner.os == 'Linux' && steps.jit_bin_exists.outputs.files_exists == 'false' + if: runner.os == 'Linux' && steps.checks.outputs.jit_dist_exists == 'false' # read this if a package isn't installing correctly # https://github.com/awalsh128/cache-apt-pkgs-action#caveats with: packages: libb2-dev version: 1.0 # cache key version afaik - name: download jit source - if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.checks.outputs.jit_dist_exists == 'false' uses: actions/download-artifact@v4 with: name: jit-source @@ -438,31 +454,24 @@ jobs: - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - name: build jit binary - if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.checks.outputs.jit_dist_exists == 'false' shell: bash run: | - jit_src_scheme_adjusted="${jit_src_scheme//\\//}" # replace \\ with / (on windows) - jit_bin_adjusted=${jit_bin//\\//} # replace \\ with / (on windows) - cp -R scheme-libs/racket/* "$jit_src_scheme_adjusted" - raco pkg install --auto --skip-installed "$jit_src_scheme_adjusted"/unison - raco exe "$jit_src_scheme_adjusted"/unison-runtime.rkt - if [[ ${{runner.os}} = "Windows" ]]; then - unison_runtime_exe="$jit_src_scheme_adjusted/unison-runtime.exe" - else - unison_runtime_exe="$jit_src_scheme_adjusted/unison-runtime" - fi - raco distribute "$jit_bin_adjusted" "$unison_runtime_exe" + cp -R scheme-libs/racket/* "$jit_src_scheme" + raco pkg install --auto --skip-installed "$jit_src_scheme"/unison + raco exe "$jit_src_scheme"/unison-runtime.rkt + raco distribute "$jit_dist" "$jit_exe" # - name: Setup tmate session # uses: mxschmitt/action-tmate@v3 # if: ${{ always() }} && runner.os == 'Windows' - name: save jit binary - if: steps.jit_bin_exists.outputs.files_exists == 'false' + if: steps.checks.outputs.jit_dist_exists == 'false' uses: actions/upload-artifact@v4 with: name: jit-binary-${{ matrix.os }} - path: ${{ env.jit_bin }}/** + path: ${{ env.jit_dist }}/** - name: cache base.md codebase uses: actions/cache@v4 @@ -484,9 +493,9 @@ jobs: run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: jit tests ${{ matrix.os }} - # if: steps.jit_bin_exists.outputs.files_exists == 'false' + # if: steps.checks.outputs.jit_dist_exists == 'false' run: | - time ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_bin }}/bin -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md + time ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist }}/bin -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md CHANGE=$(git diff unison-src/builtin-tests/jit-tests.output.md) if [ -n "$CHANGE" ]; then @@ -495,7 +504,7 @@ jobs: fi - name: interpreter tests - # if: steps.jit_bin_exists.outputs.files_exists == 'false' + # if: steps.checks.outputs.jit_dist_exists == 'false' run: | time ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md From 02e5c3e8042c3bf6833d3a7f7f34c39886e885bc Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 16:15:59 -0500 Subject: [PATCH 099/181] yaml it never ends --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c692bd079d..8f4dee7e62 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -513,3 +513,7 @@ jobs: echo "The interpreter-tests output has changed" exit 1 fi + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ always() }} From b668fe3b96d67730a1e9f3dbe923ec9c9a64e210 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 16:53:04 -0500 Subject: [PATCH 100/181] jit tests reply on some types not in base at least ThreadKilledFailure, from https://github.com/unisonweb/unison/pull/3835 --- unison-src/builtin-tests/base.md | 1 + 1 file changed, 1 insertion(+) diff --git a/unison-src/builtin-tests/base.md b/unison-src/builtin-tests/base.md index a3785e3210..1a0b17f975 100644 --- a/unison-src/builtin-tests/base.md +++ b/unison-src/builtin-tests/base.md @@ -6,4 +6,5 @@ Thus, make sure the contents of this file define the contents of the cache ```ucm .> pull @unison/base/releases/2.5.0 .base +.> builtins.mergeio ``` From 3cc86fac62d858b1170385b99b551b500a444046 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 17:11:27 -0500 Subject: [PATCH 101/181] all the mergeio types we rely on should be in base I suppose? --- unison-src/builtin-tests/base.md | 1 + 1 file changed, 1 insertion(+) diff --git a/unison-src/builtin-tests/base.md b/unison-src/builtin-tests/base.md index 1a0b17f975..d4717fdcc1 100644 --- a/unison-src/builtin-tests/base.md +++ b/unison-src/builtin-tests/base.md @@ -7,4 +7,5 @@ Thus, make sure the contents of this file define the contents of the cache ```ucm .> pull @unison/base/releases/2.5.0 .base .> builtins.mergeio +.> undo ``` From 719933b5caa86f37ba3019affdb4200633bd6deb Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Thu, 15 Feb 2024 18:28:52 -0500 Subject: [PATCH 102/181] Make --runtime-path expect full executable path --- .../src/Unison/Runtime/Interface.hs | 46 +++++++++---------- unison-cli/transcripts/Transcripts.hs | 9 ++-- unison-cli/unison/Main.hs | 13 +++++- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 056c8a3b48..956a53466a 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -451,13 +451,13 @@ nativeEval :: PrettyPrintEnv -> Term Symbol -> IO (Either Error ([Error], Term Symbol)) -nativeEval execDir ctxVar cl ppe tm = catchInternalErrors $ do +nativeEval executable ctxVar cl ppe tm = catchInternalErrors $ do ctx <- readIORef ctxVar (tyrs, tmrs) <- collectDeps cl tm (ctx, codes) <- loadDeps cl ppe ctx tyrs tmrs (ctx, tcodes, base) <- prepareEvaluation ppe tm ctx writeIORef ctxVar ctx - nativeEvalInContext execDir ppe ctx (codes ++ tcodes) base + nativeEvalInContext executable ppe ctx (codes ++ tcodes) base interpEval :: ActiveThreads -> @@ -490,15 +490,16 @@ ensureExists cmd err = ccall = call `UnliftIO.catch` \(_ :: IOException) -> pure False ensureRuntimeExists :: HasCallStack => FilePath -> IO () -ensureRuntimeExists execDir = ensureExists cmd (runtimeErrMsg execDir) +ensureRuntimeExists executable = + ensureExists cmd (runtimeErrMsg executable) where - cmd = proc (ucrFile execDir) ["--help"] + cmd = proc executable ["--help"] ensureRacoExists :: HasCallStack => IO () ensureRacoExists = ensureExists (shell "raco help") racoErrMsg runtimeErrMsg :: String -> Pretty ColorText -runtimeErrMsg execDir = +runtimeErrMsg executable = P.lines [ P.wrap "I can't seem to call `unison-runtime`. I was looking for\ @@ -506,7 +507,7 @@ runtimeErrMsg execDir = "", P.indentN 2 - (fromString $ ucrFile execDir), + (fromString executable), "", "See", "", @@ -548,12 +549,12 @@ nativeCompile :: Reference -> FilePath -> IO (Maybe Error) -nativeCompile execDir ctxVar cl ppe base path = tryM $ do +nativeCompile executable ctxVar cl ppe base path = tryM $ do ctx <- readIORef ctxVar (tyrs, tmrs) <- collectRefDeps cl base (ctx, codes) <- loadDeps cl ppe ctx tyrs tmrs Just ibase <- pure $ baseToIntermed ctx base - nativeCompileCodes execDir codes ibase path + nativeCompileCodes executable codes ibase path interpCompile :: Text -> @@ -723,12 +724,9 @@ backReferenceTm ws frs irs dcm c i = do bs <- Map.lookup r dcm Map.lookup i bs -ucrFile :: FilePath -> FilePath -ucrFile execDir = execDir "unison-runtime" - ucrProc :: FilePath -> [String] -> CreateProcess -ucrProc execDir args = - (proc (ucrFile execDir) args) +ucrProc executable args = + (proc executable args) { std_in = CreatePipe, std_out = Inherit, std_err = Inherit @@ -752,8 +750,8 @@ nativeEvalInContext :: [(Reference, SuperGroup Symbol)] -> Reference -> IO (Either Error ([Error], Term Symbol)) -nativeEvalInContext execDir _ ctx codes base = do - ensureRuntimeExists execDir +nativeEvalInContext executable _ ctx codes base = do + ensureRuntimeExists executable let cc = ccache ctx crs <- readTVarIO $ combRefs cc let bytes = serializeValue . compileValue base $ codes @@ -777,8 +775,8 @@ nativeEvalInContext execDir _ ctx codes base = do -- decodeResult . deserializeValue =<< BS.hGetContents pout callout _ _ _ _ = pure . Left $ "withCreateProcess didn't provide handles" - ucrError (_ :: IOException) = pure $ Left (runtimeErrMsg execDir) - withCreateProcess (ucrProc execDir []) callout + ucrError (_ :: IOException) = pure $ Left (runtimeErrMsg executable) + withCreateProcess (ucrProc executable []) callout `UnliftIO.catch` ucrError nativeCompileCodes :: @@ -787,8 +785,8 @@ nativeCompileCodes :: Reference -> FilePath -> IO () -nativeCompileCodes execDir codes base path = do - ensureRuntimeExists execDir +nativeCompileCodes executable codes base path = do + ensureRuntimeExists executable ensureRacoExists genDir <- getXdgDirectory XdgCache "unisonlanguage/racket-tmp" createDirectoryIfMissing True genDir @@ -802,9 +800,9 @@ nativeCompileCodes execDir codes base path = do pure () callout _ _ _ _ = fail "withCreateProcess didn't provide handles" ucrError (_ :: IOException) = - throwIO $ PE callStack (runtimeErrMsg execDir) + throwIO $ PE callStack (runtimeErrMsg executable) racoError (_ :: IOException) = throwIO $ PE callStack racoErrMsg - withCreateProcess (ucrProc execDir ["-G", srcPath]) callout + withCreateProcess (ucrProc executable ["-G", srcPath]) callout `UnliftIO.catch` ucrError callProcess "raco" ["exe", "-o", path, srcPath] `UnliftIO.catch` racoError @@ -1017,13 +1015,13 @@ startRuntime sandboxed runtimeHost version = do } startNativeRuntime :: Text -> FilePath -> IO (Runtime Symbol) -startNativeRuntime _version execDir = do +startNativeRuntime _version executable = do ctxVar <- newIORef =<< baseContext False pure $ Runtime { terminate = pure (), - evaluate = nativeEval execDir ctxVar, - compileTo = nativeCompile execDir ctxVar, + evaluate = nativeEval executable ctxVar, + compileTo = nativeCompile executable ctxVar, mainType = builtinMain External, ioTestTypes = builtinIOTestTypes External } diff --git a/unison-cli/transcripts/Transcripts.hs b/unison-cli/transcripts/Transcripts.hs index ae61176405..5ca7a59e86 100644 --- a/unison-cli/transcripts/Transcripts.hs +++ b/unison-cli/transcripts/Transcripts.hs @@ -16,6 +16,7 @@ import System.FilePath splitFileName, takeExtensions, (), + (<.>), ) import System.IO.CodePage (withCP65001) import System.IO.Silently (silence) @@ -153,9 +154,11 @@ handleArgs acc [prefix] = acc { matchPrefix = Just prefix } handleArgs acc _ = acc defaultConfig :: IO TestConfig -defaultConfig = - TestConfig Nothing <$> - getXdgDirectory XdgData "unisonlanguage/libexec" +defaultConfig = TestConfig Nothing <$> defaultRTP + where + defaultRTP = do + dir <- getXdgDirectory XdgData ("unisonlanguage" "libexec") + pure (dir "unison-runtime" <.> exeExtension) main :: IO () main = withCP65001 do diff --git a/unison-cli/unison/Main.hs b/unison-cli/unison/Main.hs index f4f82570a5..1faad3be6c 100644 --- a/unison-cli/unison/Main.hs +++ b/unison-cli/unison/Main.hs @@ -41,7 +41,14 @@ import Ki qualified import Network.HTTP.Client qualified as HTTP import Network.HTTP.Client.TLS qualified as HTTP import Stats (recordRtsStats) -import System.Directory (canonicalizePath, getCurrentDirectory, removeDirectoryRecursive, getXdgDirectory, XdgDirectory(..)) +import System.Directory + ( canonicalizePath, + getCurrentDirectory, + removeDirectoryRecursive, + getXdgDirectory, + XdgDirectory(..), + exeExtension + ) import System.Environment (getProgName, withArgs) import System.Exit qualified as Exit import System.FilePath qualified as FP @@ -90,7 +97,9 @@ type Runtimes = fixNativeRuntimePath :: Maybe FilePath -> IO FilePath fixNativeRuntimePath = maybe dflt pure where - dflt = getXdgDirectory XdgData ("unisonlanguage" FP. "libexec") + exe = "unison-runtime" FP.<.> exeExtension + unisonDir = "unisonlanguage" FP. "libexec" + dflt = (FP. exe) <$> getXdgDirectory XdgData unisonDir main :: IO () main = do From 596a58c051d6a606a4e859839afd528d5a626bf9 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 19:08:41 -0500 Subject: [PATCH 103/181] yaml change semantics of --runtime-path --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8f4dee7e62..3c281092d8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -495,7 +495,7 @@ jobs: - name: jit tests ${{ matrix.os }} # if: steps.checks.outputs.jit_dist_exists == 'false' run: | - time ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist }}/bin -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md + time ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md CHANGE=$(git diff unison-src/builtin-tests/jit-tests.output.md) if [ -n "$CHANGE" ]; then @@ -514,6 +514,6 @@ jobs: exit 1 fi - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ always() }} + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ always() }} From 41c06a9ec71cc347bdc28d21ae9e16d62b9d0816 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 19:25:21 -0500 Subject: [PATCH 104/181] yaml definitely almost done --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3c281092d8..5fdfb9986a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -514,6 +514,6 @@ jobs: exit 1 fi - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ failure() }} From 759de6630242b88af4f27c14383003acddf3cefe Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 19:42:03 -0500 Subject: [PATCH 105/181] yaml fix jit source cache key --- .github/workflows/ci.yaml | 6 ++---- docs/github-actions-help.md | 13 +++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5fdfb9986a..21081134ce 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -274,8 +274,6 @@ jobs: # - name: Setup tmate session # uses: mxschmitt/action-tmate@v3 # if: ${{ always() }} - - generate-jit-source: if: always() && needs.build-ucm.result == 'success' name: Generate JIT source @@ -291,8 +289,8 @@ jobs: if: runner.os == 'Linux' with: path: ${{ env.jit_src_scheme }} - key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_src_scheme}}.${{github.sha}} - restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_src_scheme}}. + key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme)}}.${{github.sha}} + restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme)}}. - name: check source exists id: jit_src_exists diff --git a/docs/github-actions-help.md b/docs/github-actions-help.md index 9688b96832..f3cffbf98c 100644 --- a/docs/github-actions-help.md +++ b/docs/github-actions-help.md @@ -5,3 +5,16 @@ You can't have an `env:` key defined in terms of another `env` key, but You can't define a `matrix` at the top level, it has to be defined within a `job`'s `strategy`. Windows doesn't seem to honor the `default: run: shell:` setting, so you need to set the `shell:` on `run:` manually? + +Don't hesitate to do a lot with `run:` blocks aka bash scripts — at least bash is mature and well documented. + +e.g. + echo "bar=whatever" >> $GITHUB_OUTPUT + # access with `steps..outputs.bar` in yaml strings + + echo "foo=whatever" >> $GITHUB_ENV + # access with `env.foo` in yaml strings, or `$foo` in bash + + +Default Environment Variables: +https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables From 653da00269e2513193dd6f15c49d00682f425b57 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 19:50:20 -0500 Subject: [PATCH 106/181] raco distribute builds a different directory structure in windows than in mac/linux --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 21081134ce..7eb96b5da7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -397,7 +397,7 @@ jobs: jit_dist="${jit_dist//\\//}" jit_exe="${jit_exe//\\//}.exe" - jit_dist_exe="${jit_dist_exe//\\//}.exe" + jit_dist_exe="${jit_dist//\\//}/unison-runtime.exe" ucm="${ucm//\\//}.exe" fi From 06643c9b0f9264bb737529e49b0847aade76b126 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 19:52:05 -0500 Subject: [PATCH 107/181] yaml accidentally a ) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7eb96b5da7..2415ca1454 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -289,7 +289,7 @@ jobs: if: runner.os == 'Linux' with: path: ${{ env.jit_src_scheme }} - key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme)}}.${{github.sha}} + key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme))}}.${{github.sha}} restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme)}}. - name: check source exists From da994541b559dd9da66f442c769b60ac016c8d16 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 19:53:29 -0500 Subject: [PATCH 108/181] yaml accidentally the other ) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2415ca1454..74a6b7131a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -290,7 +290,7 @@ jobs: with: path: ${{ env.jit_src_scheme }} key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme))}}.${{github.sha}} - restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme)}}. + restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme))}}. - name: check source exists id: jit_src_exists From 1bd7aef9d946d894249bd0e443d1e26db6e21c26 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 20:03:49 -0500 Subject: [PATCH 109/181] yaml actually wanted jit version, not jit source hash which we don't know --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 74a6b7131a..5b5f6b68d0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -289,8 +289,8 @@ jobs: if: runner.os == 'Linux' with: path: ${{ env.jit_src_scheme }} - key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme))}}.${{github.sha}} - restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{hashFiles(format('{0}/**', env.jit_src_scheme))}}. + key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_version}}.${{github.sha}} + restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_version}}. - name: check source exists id: jit_src_exists From 61b3d68201dbc8ae61b22b25a781d44872e7ca13 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 20:07:39 -0500 Subject: [PATCH 110/181] yaml same here --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5b5f6b68d0..272feb89cc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -417,8 +417,8 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.jit_dist }} - key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}.${{ github.sha }} - restore-keys: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_src_scheme }}. + key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}.${{ github.sha }} + restore-keys: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}. - name: Cache Racket dependencies if: steps.checks.outputs.jit_dist_exists == 'false' From ce5f1b8472b162b220759eab908515ac6e572d62 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 15 Feb 2024 22:41:49 -0500 Subject: [PATCH 111/181] simplify but hopefully not break caching --- .github/workflows/ci.yaml | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 272feb89cc..860e9245f5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -91,14 +91,9 @@ jobs: if: runner.os != 'Windows' with: path: ~/.stack - key: stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-${{github.sha}} + key: stack-1_${{matrix.os}}-${{hashFiles('**/stack.yaml')}} # Fall-back to use the most recent cache for the stack.yaml, or failing that the OS - restore-keys: | - stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}- - stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}- - stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}- - stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}. - stack-1_${{matrix.os}}- + restore-keys: stack-1_${{matrix.os}}- # Cache ~/.stack, keyed by the contents of 'stack.yaml'. - uses: actions/cache@v4 @@ -109,14 +104,9 @@ jobs: path: | C:\Users\runneradmin\AppData\Roaming\stack C:\Users\runneradmin\AppData\Local\Programs\stack - key: stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-${{github.sha}} + key: stack-1_${{matrix.os}}-${{hashFiles('**/stack.yaml')}} # Fall-back to use the most recent cache for the stack.yaml, or failing that the OS - restore-keys: | - stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}- - stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}- - stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}- - stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}. - stack-1_${{matrix.os}}- + restore-keys: stack-1_${{matrix.os}}- # Cache each local package's ~/.stack-work for fast incremental builds in CI. - uses: actions/cache@v4 @@ -131,13 +121,8 @@ jobs: # recent branch cache. # Then it will save a new cache at this commit sha, which should be used by # the next build on this branch. - key: stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}-${{hashFiles('**/stack.yaml')}}-${{github.sha}} - restore-keys: | - stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}- - stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}- - stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}- - stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}. - stack-work-4_${{matrix.os}}- + key: stack-work-4_${{matrix.os}}-${{hashFiles('**/stack.yaml')}} + restore-keys: stack-work-4_${{matrix.os}}- # Install stack by downloading the binary from GitHub. # The installation process differs by OS. @@ -289,8 +274,7 @@ jobs: if: runner.os == 'Linux' with: path: ${{ env.jit_src_scheme }} - key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_version}}.${{github.sha}} - restore-keys: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_version}}. + key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_version}} - name: check source exists id: jit_src_exists @@ -417,8 +401,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.jit_dist }} - key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}.${{ github.sha }} - restore-keys: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}. + key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} - name: Cache Racket dependencies if: steps.checks.outputs.jit_dist_exists == 'false' @@ -475,8 +458,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.base-codebase}} - key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}-${{github.sha}} - restore-keys: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}- + key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. - name: download ucm uses: actions/download-artifact@v4 From b607e7accaeabba9c61c244aeb58082083c2a504 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 10:42:54 -0500 Subject: [PATCH 112/181] add ioexception message to ucr and raco failures. --- .../src/Unison/Runtime/Interface.hs | 74 ++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 956a53466a..c25ac7093b 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -47,11 +47,11 @@ import Data.Set qualified as Set import Data.Text (isPrefixOf, unpack) import GHC.Stack (callStack) import System.Directory - ( XdgDirectory(XdgCache), + ( XdgDirectory (XdgCache), createDirectoryIfMissing, - getXdgDirectory + getXdgDirectory, ) -import System.Exit (ExitCode(..)) +import System.Exit (ExitCode (..)) import System.FilePath ((<.>), ()) import System.Process ( CreateProcess (..), @@ -478,16 +478,17 @@ interpEval activeThreads cleanupThreads ctxVar cl ppe tm = evalInContext ppe ctx activeThreads initw `UnliftIO.finally` cleanupThreads -ensureExists :: HasCallStack => CreateProcess -> Pretty ColorText -> IO () +ensureExists :: HasCallStack => CreateProcess -> (Maybe String -> Pretty ColorText) -> IO () ensureExists cmd err = ccall >>= \case - True -> pure () - False -> dieP err + Nothing -> pure () + Just exception -> dieP $ err exception where - call = readCreateProcessWithExitCode cmd "" >>= \case - (ExitSuccess, _, _) -> pure True - (ExitFailure _, _, _) -> pure False - ccall = call `UnliftIO.catch` \(_ :: IOException) -> pure False + call = + readCreateProcessWithExitCode cmd "" >>= \case + (ExitSuccess, _, _) -> pure Nothing + (ExitFailure _, _, _) -> pure (Just Nothing) + ccall = call `UnliftIO.catch` \(e :: IOException) -> pure . Just . Just $ show e ensureRuntimeExists :: HasCallStack => FilePath -> IO () ensureRuntimeExists executable = @@ -498,40 +499,47 @@ ensureRuntimeExists executable = ensureRacoExists :: HasCallStack => IO () ensureRacoExists = ensureExists (shell "raco help") racoErrMsg -runtimeErrMsg :: String -> Pretty ColorText -runtimeErrMsg executable = +runtimeErrMsg :: String -> Maybe String -> Pretty ColorText +runtimeErrMsg executable error = P.lines [ P.wrap - "I can't seem to call `unison-runtime`. I was looking for\ - \ it at:", + "I can't seem to call the Unison native runtime at:", "", P.indentN 2 (fromString executable), "", - "See", - "", - P.indentN - 2 - "TODO", + case error of + Just msg -> + P.lines + [ P.wrap "The error message I received was:", + "", + P.indentN 2 (fromString msg) + ] + Nothing -> P.wrap "I'm sorry I don't know more specifically what went wrong.", "", P.wrap - "for detailed instructions on how to install unison with this\ - \ feature available.", - "", - P.wrap - "If you have the executable installed somewhere else, you can\ + "If you have the executable installed somewhere other than the above location, you can\ \ use the `--runtime-path` command line argument to specify\ \ where it is." ] -racoErrMsg :: Pretty ColorText -racoErrMsg = +racoErrMsg :: Maybe String -> Pretty ColorText +racoErrMsg error = P.lines [ P.wrap "I can't seem to call `raco`. Please ensure Racket \ \is installed.", "", + case error of + Just msg -> + P.lines + [ P.wrap "The error message I received was:", + "", + P.indentN 2 (fromString msg) + ] + Nothing -> P.wrap "I'm sorry I don't know more specifically what went wrong.", + "", "See", "", P.indentN @@ -775,7 +783,7 @@ nativeEvalInContext executable _ ctx codes base = do -- decodeResult . deserializeValue =<< BS.hGetContents pout callout _ _ _ _ = pure . Left $ "withCreateProcess didn't provide handles" - ucrError (_ :: IOException) = pure $ Left (runtimeErrMsg executable) + ucrError (e :: IOException) = pure $ Left (runtimeErrMsg executable (Just $ show e)) withCreateProcess (ucrProc executable []) callout `UnliftIO.catch` ucrError @@ -799,9 +807,9 @@ nativeCompileCodes executable codes base path = do waitForProcess ph pure () callout _ _ _ _ = fail "withCreateProcess didn't provide handles" - ucrError (_ :: IOException) = - throwIO $ PE callStack (runtimeErrMsg executable) - racoError (_ :: IOException) = throwIO $ PE callStack racoErrMsg + ucrError (e :: IOException) = + throwIO $ PE callStack (runtimeErrMsg executable (Just (show e))) + racoError (e :: IOException) = throwIO $ PE callStack (racoErrMsg (Just (show e))) withCreateProcess (ucrProc executable ["-G", srcPath]) callout `UnliftIO.catch` ucrError callProcess "raco" ["exe", "-o", path, srcPath] @@ -1032,9 +1040,9 @@ withRuntime sandboxed runtimeHost version action = tryM :: IO () -> IO (Maybe Error) tryM = - flip UnliftIO.catch hRE . - flip UnliftIO.catch hCE . - fmap (const Nothing) + flip UnliftIO.catch hRE + . flip UnliftIO.catch hCE + . fmap (const Nothing) where hCE (CE _ e) = pure $ Just e hRE (PE _ e) = pure $ Just e From 6857bf9a5007c064ea42914092516071cee824a5 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 13:50:01 -0500 Subject: [PATCH 113/181] yaml add windows-2022 os --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 860e9245f5..3f354459e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -69,6 +69,7 @@ jobs: - ubuntu-20.04 - macOS-12 - windows-2019 + - windows-2022 steps: - uses: actions/checkout@v4 @@ -366,6 +367,7 @@ jobs: - ubuntu-20.04 - macOS-12 - windows-2019 + - windows-2022 steps: - name: set up environment id: checks From ef3ff1955d127674c81e62f968be239ec8d75975 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 13:50:09 -0500 Subject: [PATCH 114/181] cache tips --- docs/github-actions-help.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/github-actions-help.md b/docs/github-actions-help.md index f3cffbf98c..33f127bbc8 100644 --- a/docs/github-actions-help.md +++ b/docs/github-actions-help.md @@ -18,3 +18,5 @@ e.g. Default Environment Variables: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables + +When using the `cache` action, getting a cache hit on the primary key means you won't update the cache with any changes. From 08f36fb12bd7d5e1b074b85f39712af3ab3eb396 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 13:52:50 -0500 Subject: [PATCH 115/181] yaml maybe less broken caching --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3f354459e7..81a73f8687 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -122,7 +122,7 @@ jobs: # recent branch cache. # Then it will save a new cache at this commit sha, which should be used by # the next build on this branch. - key: stack-work-4_${{matrix.os}}-${{hashFiles('**/stack.yaml')}} + key: stack-work-4_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/*.hs')}} restore-keys: stack-work-4_${{matrix.os}}- # Install stack by downloading the binary from GitHub. From 2d0deab8139e0937648aabeae3b4d43407c73f60 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 18:43:30 -0500 Subject: [PATCH 116/181] beef up the error messages around calling the native runtime --- .../src/Unison/Runtime/Interface.hs | 137 ++++++++++++------ 1 file changed, 90 insertions(+), 47 deletions(-) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index c25ac7093b..9b9c7499ea 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -45,6 +45,7 @@ import Data.Set as Set ) import Data.Set qualified as Set import Data.Text (isPrefixOf, unpack) +import GHC.IO.Exception (IOErrorType (NoSuchThing, PermissionDenied), IOException (ioe_description, ioe_type)) import GHC.Stack (callStack) import System.Directory ( XdgDirectory (XdgCache), @@ -54,7 +55,8 @@ import System.Directory import System.Exit (ExitCode (..)) import System.FilePath ((<.>), ()) import System.Process - ( CreateProcess (..), + ( CmdSpec (RawCommand, ShellCommand), + CreateProcess (..), StdStream (..), callProcess, proc, @@ -478,67 +480,106 @@ interpEval activeThreads cleanupThreads ctxVar cl ppe tm = evalInContext ppe ctx activeThreads initw `UnliftIO.finally` cleanupThreads -ensureExists :: HasCallStack => CreateProcess -> (Maybe String -> Pretty ColorText) -> IO () +ensureExists :: HasCallStack => CreateProcess -> (CreateProcess -> Either (Int, String, String) IOException -> Pretty ColorText) -> IO () ensureExists cmd err = ccall >>= \case Nothing -> pure () - Just exception -> dieP $ err exception + Just failure -> dieP $ err cmd failure where call = readCreateProcessWithExitCode cmd "" >>= \case - (ExitSuccess, _, _) -> pure Nothing - (ExitFailure _, _, _) -> pure (Just Nothing) - ccall = call `UnliftIO.catch` \(e :: IOException) -> pure . Just . Just $ show e + (ExitSuccess, _stdout, _stderr) -> pure Nothing + (ExitFailure exitCode, stdout, stderr) -> pure (Just (Left (exitCode, stdout, stderr))) + ccall = call `UnliftIO.catch` \(e :: IOException) -> pure . Just $ Right e ensureRuntimeExists :: HasCallStack => FilePath -> IO () ensureRuntimeExists executable = - ensureExists cmd (runtimeErrMsg executable) + ensureExists cmd runtimeErrMsg where cmd = proc executable ["--help"] ensureRacoExists :: HasCallStack => IO () -ensureRacoExists = ensureExists (shell "raco help") racoErrMsg - -runtimeErrMsg :: String -> Maybe String -> Pretty ColorText -runtimeErrMsg executable error = - P.lines - [ P.wrap - "I can't seem to call the Unison native runtime at:", - "", - P.indentN - 2 - (fromString executable), - "", - case error of - Just msg -> - P.lines - [ P.wrap "The error message I received was:", - "", - P.indentN 2 (fromString msg) - ] - Nothing -> P.wrap "I'm sorry I don't know more specifically what went wrong.", - "", - P.wrap - "If you have the executable installed somewhere other than the above location, you can\ - \ use the `--runtime-path` command line argument to specify\ - \ where it is." - ] +ensureRacoExists = ensureExists (shell "raco help") (const racoErrMsg) + +prettyCmdSpec :: CmdSpec -> Pretty ColorText +prettyCmdSpec = \case + ShellCommand string -> fromString string + System.Process.RawCommand filePath args -> + P.sep " " (fromString filePath : Prelude.map fromString args) + +prettyCallError :: Either (Int, String, String) IOException -> Pretty ColorText +prettyCallError = \case + Right ex -> + P.lines + [ P.wrap . fromString $ "The error type was: '" ++ show (ioe_type ex) ++ "', and the message is:", + "", + P.indentN 2 (fromString (ioe_description ex)) + ] + Left (errCode, stdout, stderr) -> + let prettyExitCode = "The exit code was" <> fromString (show errCode) + in if null stdout && null stderr + then P.wrap $ prettyExitCode <> " but there was no output." + else + P.lines + [ P.wrap $ prettyExitCode <> "and the output was:", + "", + P.indentN + 2 + if null stdout + then fromString stderr + else + if null stderr + then fromString stdout + else P.lines $ [fromString stdout, "", "---", "", fromString stderr] + ] + +runtimeErrMsg :: CreateProcess -> Either (Int, String, String) IOException -> Pretty ColorText +runtimeErrMsg cp error = + case error of + Right (ioe_type -> NoSuchThing) -> + P.lines + [ P.wrap "I couldn't find the Unison native runtime. I tried to start it with:", + "", + P.indentN 2 $ prettyCmdSpec (cmdspec cp), + "", + P.wrap + "If that doesn't look right, you can use the `--runtime-path` command line \ + \argument to specify the correct path for the executable." + ] + Right (ioe_type -> PermissionDenied) -> + P.lines + [ P.wrap + "I got a 'Permission Denied' error when trying to start the \ + \Unison native runtime with:", + "", + P.indentN 2 $ prettyCmdSpec (cmdspec cp), + "", + P.wrap + "Please check the permisssions (e.g. check that the directory is accessible, \ + \and that the program is marked executable).", + "", + P.wrap + "If it looks like I'm calling the wrong executable altogether, you can use the \ + \`--runtime-path` command line argument to specify the correct one." + ] + _ -> + P.lines + [ P.wrap + "I got an error when starting the Unison native runtime using:", + "", + P.indentN 2 (prettyCmdSpec (System.Process.cmdspec cp)), + "", + prettyCallError error + ] -racoErrMsg :: Maybe String -> Pretty ColorText +racoErrMsg :: Either (Int, String, String) IOException -> Pretty ColorText racoErrMsg error = P.lines [ P.wrap "I can't seem to call `raco`. Please ensure Racket \ \is installed.", "", - case error of - Just msg -> - P.lines - [ P.wrap "The error message I received was:", - "", - P.indentN 2 (fromString msg) - ] - Nothing -> P.wrap "I'm sorry I don't know more specifically what went wrong.", + prettyCallError error, "", "See", "", @@ -783,8 +824,9 @@ nativeEvalInContext executable _ ctx codes base = do -- decodeResult . deserializeValue =<< BS.hGetContents pout callout _ _ _ _ = pure . Left $ "withCreateProcess didn't provide handles" - ucrError (e :: IOException) = pure $ Left (runtimeErrMsg executable (Just $ show e)) - withCreateProcess (ucrProc executable []) callout + p = ucrProc executable [] + ucrError (e :: IOException) = pure $ Left (runtimeErrMsg p (Right e)) + withCreateProcess p callout `UnliftIO.catch` ucrError nativeCompileCodes :: @@ -808,9 +850,10 @@ nativeCompileCodes executable codes base path = do pure () callout _ _ _ _ = fail "withCreateProcess didn't provide handles" ucrError (e :: IOException) = - throwIO $ PE callStack (runtimeErrMsg executable (Just (show e))) - racoError (e :: IOException) = throwIO $ PE callStack (racoErrMsg (Just (show e))) - withCreateProcess (ucrProc executable ["-G", srcPath]) callout + throwIO $ PE callStack (runtimeErrMsg p (Right e)) + racoError (e :: IOException) = throwIO $ PE callStack (racoErrMsg (Right e)) + p = ucrProc executable ["-G", srcPath] + withCreateProcess p callout `UnliftIO.catch` ucrError callProcess "raco" ["exe", "-o", path, srcPath] `UnliftIO.catch` racoError From ce6eed9374a3e5e4c988818fd63b214365d2aed0 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 18:45:01 -0500 Subject: [PATCH 117/181] some reference info --- parser-typechecker/src/Unison/Runtime/Interface.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 9b9c7499ea..70e8305454 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -533,6 +533,9 @@ prettyCallError = \case else P.lines $ [fromString stdout, "", "---", "", fromString stderr] ] +-- https://hackage.haskell.org/package/process-1.6.18.0/docs/System-Process.html#t:CreateProcess +-- https://hackage.haskell.org/package/base-4.19.0.0/docs/GHC-IO-Exception.html#t:IOError +-- https://hackage.haskell.org/package/base-4.19.0.0/docs/GHC-IO-Exception.html#t:IOErrorType runtimeErrMsg :: CreateProcess -> Either (Int, String, String) IOException -> Pretty ColorText runtimeErrMsg cp error = case error of From ab7495d6bc649cc28c785a41ecb1479ac6998fe9 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 18:52:15 -0500 Subject: [PATCH 118/181] do re-save ~/.stack if package dependencies have changed --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 81a73f8687..80f3123130 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -92,7 +92,7 @@ jobs: if: runner.os != 'Windows' with: path: ~/.stack - key: stack-1_${{matrix.os}}-${{hashFiles('**/stack.yaml')}} + key: stack-1_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} # Fall-back to use the most recent cache for the stack.yaml, or failing that the OS restore-keys: stack-1_${{matrix.os}}- @@ -105,7 +105,7 @@ jobs: path: | C:\Users\runneradmin\AppData\Roaming\stack C:\Users\runneradmin\AppData\Local\Programs\stack - key: stack-1_${{matrix.os}}-${{hashFiles('**/stack.yaml')}} + key: stack-1_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} # Fall-back to use the most recent cache for the stack.yaml, or failing that the OS restore-keys: stack-1_${{matrix.os}}- From 35354736acfd978a002ad9e2468a2a4eea3bddb8 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 18:52:39 -0500 Subject: [PATCH 119/181] do re-save `.stack-work` after build if Haskell files have changed --- .github/workflows/ci.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 80f3123130..abae4b8a55 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -122,8 +122,10 @@ jobs: # recent branch cache. # Then it will save a new cache at this commit sha, which should be used by # the next build on this branch. - key: stack-work-4_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/*.hs')}} - restore-keys: stack-work-4_${{matrix.os}}- + key: stack-work-4_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}-${{hashFiles('**/*.hs')}} + restore-keys: | + stack-work-4_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}- + stack-work-4_${{matrix.os}}- # Install stack by downloading the binary from GitHub. # The installation process differs by OS. From 9042865af27ab66642c23072df209b0bbe75adac Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 19:13:31 -0500 Subject: [PATCH 120/181] more debug info for calling raco --- .../src/Unison/Runtime/Interface.hs | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/parser-typechecker/src/Unison/Runtime/Interface.hs b/parser-typechecker/src/Unison/Runtime/Interface.hs index 70e8305454..2e87b22373 100644 --- a/parser-typechecker/src/Unison/Runtime/Interface.hs +++ b/parser-typechecker/src/Unison/Runtime/Interface.hs @@ -45,7 +45,7 @@ import Data.Set as Set ) import Data.Set qualified as Set import Data.Text (isPrefixOf, unpack) -import GHC.IO.Exception (IOErrorType (NoSuchThing, PermissionDenied), IOException (ioe_description, ioe_type)) +import GHC.IO.Exception (IOErrorType (NoSuchThing, OtherError, PermissionDenied), IOException (ioe_description, ioe_type)) import GHC.Stack (callStack) import System.Directory ( XdgDirectory (XdgCache), @@ -480,11 +480,11 @@ interpEval activeThreads cleanupThreads ctxVar cl ppe tm = evalInContext ppe ctx activeThreads initw `UnliftIO.finally` cleanupThreads -ensureExists :: HasCallStack => CreateProcess -> (CreateProcess -> Either (Int, String, String) IOException -> Pretty ColorText) -> IO () +ensureExists :: HasCallStack => CreateProcess -> (CmdSpec -> Either (Int, String, String) IOException -> Pretty ColorText) -> IO () ensureExists cmd err = ccall >>= \case Nothing -> pure () - Just failure -> dieP $ err cmd failure + Just failure -> dieP $ err (cmdspec cmd) failure where call = readCreateProcessWithExitCode cmd "" >>= \case @@ -499,7 +499,7 @@ ensureRuntimeExists executable = cmd = proc executable ["--help"] ensureRacoExists :: HasCallStack => IO () -ensureRacoExists = ensureExists (shell "raco help") (const racoErrMsg) +ensureRacoExists = ensureExists (shell "raco help") racoErrMsg prettyCmdSpec :: CmdSpec -> Pretty ColorText prettyCmdSpec = \case @@ -536,14 +536,14 @@ prettyCallError = \case -- https://hackage.haskell.org/package/process-1.6.18.0/docs/System-Process.html#t:CreateProcess -- https://hackage.haskell.org/package/base-4.19.0.0/docs/GHC-IO-Exception.html#t:IOError -- https://hackage.haskell.org/package/base-4.19.0.0/docs/GHC-IO-Exception.html#t:IOErrorType -runtimeErrMsg :: CreateProcess -> Either (Int, String, String) IOException -> Pretty ColorText -runtimeErrMsg cp error = +runtimeErrMsg :: CmdSpec -> Either (Int, String, String) IOException -> Pretty ColorText +runtimeErrMsg c error = case error of Right (ioe_type -> NoSuchThing) -> P.lines [ P.wrap "I couldn't find the Unison native runtime. I tried to start it with:", "", - P.indentN 2 $ prettyCmdSpec (cmdspec cp), + P.indentN 2 $ prettyCmdSpec c, "", P.wrap "If that doesn't look right, you can use the `--runtime-path` command line \ @@ -555,7 +555,7 @@ runtimeErrMsg cp error = "I got a 'Permission Denied' error when trying to start the \ \Unison native runtime with:", "", - P.indentN 2 $ prettyCmdSpec (cmdspec cp), + P.indentN 2 $ prettyCmdSpec c, "", P.wrap "Please check the permisssions (e.g. check that the directory is accessible, \ @@ -570,28 +570,39 @@ runtimeErrMsg cp error = [ P.wrap "I got an error when starting the Unison native runtime using:", "", - P.indentN 2 (prettyCmdSpec (System.Process.cmdspec cp)), + P.indentN 2 (prettyCmdSpec c), "", prettyCallError error ] -racoErrMsg :: Either (Int, String, String) IOException -> Pretty ColorText -racoErrMsg error = - P.lines - [ P.wrap - "I can't seem to call `raco`. Please ensure Racket \ - \is installed.", - "", - prettyCallError error, - "", - "See", - "", - P.indentN - 2 - "https://download.racket-lang.org/", - "", - "for how to install Racket manually." - ] +racoErrMsg :: CmdSpec -> Either (Int, String, String) IOException -> Pretty ColorText +racoErrMsg c = \case + Right (ioe_type -> e@OtherError) -> + P.lines + [ P.wrap . fromString $ + "Sorry, I got an error of type '" + ++ show e + ++ "' when I ran `raco`, \ + \and I'm not sure what to do about it.", + "", + "For debugging purposes, the full command was:", + "", + P.indentN 2 (prettyCmdSpec c) + ] + error -> + P.lines + [ P.wrap + "I can't seem to call `raco`. Please ensure Racket \ + \is installed.", + "", + prettyCallError error, + "", + "See", + "", + P.indentN 2 "https://download.racket-lang.org/", + "", + "for how to install Racket manually." + ] nativeCompile :: FilePath -> @@ -828,7 +839,7 @@ nativeEvalInContext executable _ ctx codes base = do callout _ _ _ _ = pure . Left $ "withCreateProcess didn't provide handles" p = ucrProc executable [] - ucrError (e :: IOException) = pure $ Left (runtimeErrMsg p (Right e)) + ucrError (e :: IOException) = pure $ Left (runtimeErrMsg (cmdspec p) (Right e)) withCreateProcess p callout `UnliftIO.catch` ucrError @@ -853,12 +864,15 @@ nativeCompileCodes executable codes base path = do pure () callout _ _ _ _ = fail "withCreateProcess didn't provide handles" ucrError (e :: IOException) = - throwIO $ PE callStack (runtimeErrMsg p (Right e)) - racoError (e :: IOException) = throwIO $ PE callStack (racoErrMsg (Right e)) + throwIO $ PE callStack (runtimeErrMsg (cmdspec p) (Right e)) + racoError (e :: IOException) = + throwIO $ PE callStack (racoErrMsg (makeRacoCmd RawCommand) (Right e)) p = ucrProc executable ["-G", srcPath] + makeRacoCmd :: (FilePath -> [String] -> a) -> a + makeRacoCmd f = f "raco" ["exe", "-o", path, srcPath] withCreateProcess p callout `UnliftIO.catch` ucrError - callProcess "raco" ["exe", "-o", path, srcPath] + makeRacoCmd callProcess `UnliftIO.catch` racoError evalInContext :: From 84188db94397308e765f759d571d42c654f24329 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 19:17:42 -0500 Subject: [PATCH 121/181] yaml nothing useful from windows-2022 after all --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index abae4b8a55..4e5eda0f67 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -69,7 +69,7 @@ jobs: - ubuntu-20.04 - macOS-12 - windows-2019 - - windows-2022 + # - windows-2022 steps: - uses: actions/checkout@v4 @@ -369,7 +369,7 @@ jobs: - ubuntu-20.04 - macOS-12 - windows-2019 - - windows-2022 + # - windows-2022 steps: - name: set up environment id: checks From 8e7ae67ea6af48ee9353910a5912fb24209672f3 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 19:18:33 -0500 Subject: [PATCH 122/181] yaml set 15 minute tmate timeout --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4e5eda0f67..b3b1671161 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -501,3 +501,4 @@ jobs: - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ failure() }} + timeout-minutes: 15 From 053e7da4d56a13560340c12e0a0fd94747811d96 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 19:27:21 -0500 Subject: [PATCH 123/181] try to restore jit binaries before checking for them --- .github/workflows/ci.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b3b1671161..d92d9ff114 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -371,6 +371,12 @@ jobs: - windows-2019 # - windows-2022 steps: + - name: restore jit binaries + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/${{ env.jit_dist }} + key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} + - name: set up environment id: checks run: | @@ -401,12 +407,6 @@ jobs: echo "jit_dist_exe=$jit_dist_exe" >> $GITHUB_ENV echo "ucm=$ucm" >> $GITHUB_ENV - - name: cache jit binaries - uses: actions/cache@v4 - with: - path: ${{ env.jit_dist }} - key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} - - name: Cache Racket dependencies if: steps.checks.outputs.jit_dist_exists == 'false' uses: actions/cache@v4 From f698543b426185a06108b6d1eb0edebd08cb3e15 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 19:31:12 -0500 Subject: [PATCH 124/181] yaml reenable all the ucm tests figure out how to cache them later --- .github/workflows/ci.yaml | 90 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d92d9ff114..0866ff4991 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -201,51 +201,51 @@ jobs: echo "ucm-path=${{env.ucm_local_bin}}/unison" >> $GITHUB_OUTPUT fi - # Run each test suite (tests and transcripts) - # - name: check disk space before - # if: ${{ always() }} - # run: df -h - # - name: unison-cli test - # run: stack --no-terminal build --fast --test unison-cli - # - name: check disk space after - # if: ${{ always() }} - # run: df -h - # - name: unison-core tests - # run: stack --no-terminal build --fast --test unison-core - # - name: unison-parser-typechecker tests - # run: stack --no-terminal build --fast --test unison-parser-typechecker - # - name: unison-sqlite tests - # run: stack --no-terminal build --fast --test unison-sqlite - # - name: unison-syntax tests - # run: stack --no-terminal build --fast --test unison-syntax - # - name: unison-util-bytes tests - # run: stack --no-terminal build --fast --test unison-util-bytes - # - name: unison-util-cache tests - # run: stack --no-terminal build --fast --test unison-util-cache - # - name: unison-util-relation tests - # run: stack --no-terminal build --fast --test unison-util-relation - # - name: round-trip-tests - # run: | - # stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md - # git add unison-src/transcripts-round-trip/main.output.md - # # Fail if any transcripts cause git diffs. - # git diff --cached --ignore-cr-at-eol --exit-code - # stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md - # git add unison-src/transcripts-manual/rewrites.output.md - # # Fail if any transcripts cause git diffs. - # git diff --cached --ignore-cr-at-eol --exit-code - # - name: transcripts - # run: | - # stack --no-terminal exec transcripts - # # Add all changes to the index for when we diff. - # git add --all - # # Fail if any transcripts cause git diffs. - # git diff --cached --ignore-cr-at-eol --exit-code - # - name: cli-integration-tests - # run: stack --no-terminal exec cli-integration-tests - # - name: verify stack ghci startup - # if: runner.os == 'macOS' - # run: echo | stack ghci + Run each test suite (tests and transcripts) + - name: check disk space before + if: ${{ always() }} + run: df -h + - name: unison-cli test + run: stack --no-terminal build --fast --test unison-cli + - name: check disk space after + if: ${{ always() }} + run: df -h + - name: unison-core tests + run: stack --no-terminal build --fast --test unison-core + - name: unison-parser-typechecker tests + run: stack --no-terminal build --fast --test unison-parser-typechecker + - name: unison-sqlite tests + run: stack --no-terminal build --fast --test unison-sqlite + - name: unison-syntax tests + run: stack --no-terminal build --fast --test unison-syntax + - name: unison-util-bytes tests + run: stack --no-terminal build --fast --test unison-util-bytes + - name: unison-util-cache tests + run: stack --no-terminal build --fast --test unison-util-cache + - name: unison-util-relation tests + run: stack --no-terminal build --fast --test unison-util-relation + - name: round-trip-tests + run: | + stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md + git add unison-src/transcripts-round-trip/main.output.md + # Fail if any transcripts cause git diffs. + git diff --cached --ignore-cr-at-eol --exit-code + stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md + git add unison-src/transcripts-manual/rewrites.output.md + # Fail if any transcripts cause git diffs. + git diff --cached --ignore-cr-at-eol --exit-code + - name: transcripts + run: | + stack --no-terminal exec transcripts + # Add all changes to the index for when we diff. + git add --all + # Fail if any transcripts cause git diffs. + git diff --cached --ignore-cr-at-eol --exit-code + - name: cli-integration-tests + run: stack --no-terminal exec cli-integration-tests + - name: verify stack ghci startup + if: runner.os == 'macOS' + run: echo | stack ghci - name: debug check ucm artifact run: | From 1809b6204c2bb9174d54ef124877e865004377df Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 19:43:50 -0500 Subject: [PATCH 125/181] yaml whoops --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0866ff4991..328c9fda7f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -501,4 +501,5 @@ jobs: - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ failure() }} - timeout-minutes: 15 + with: + timeout-minutes: 15 From fa24c6563e0e02b13477bc341df9462373f4ec62 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 19:44:05 -0500 Subject: [PATCH 126/181] another yaml reference --- docs/github-actions-help.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/github-actions-help.md b/docs/github-actions-help.md index 33f127bbc8..f35831e60e 100644 --- a/docs/github-actions-help.md +++ b/docs/github-actions-help.md @@ -20,3 +20,6 @@ Default Environment Variables: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables When using the `cache` action, getting a cache hit on the primary key means you won't update the cache with any changes. + +Workflow syntax: +https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions From 9c075336bd9b79543fd5b2645bb03ddc62c63ac5 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 19:53:13 -0500 Subject: [PATCH 127/181] yaml whoops how would it be to be notified of a syntax error before uploading the thing --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 328c9fda7f..8cda9713f6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -201,7 +201,7 @@ jobs: echo "ucm-path=${{env.ucm_local_bin}}/unison" >> $GITHUB_OUTPUT fi - Run each test suite (tests and transcripts) + # Run each test suite (tests and transcripts) - name: check disk space before if: ${{ always() }} run: df -h From 2d05cb014a25b6e99eb7020949718203f62e2b22 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 20:16:40 -0500 Subject: [PATCH 128/181] yaml simplify and hopefully not break our diffs --- .github/workflows/ci.yaml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8cda9713f6..7a045073f9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -227,20 +227,16 @@ jobs: - name: round-trip-tests run: | stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md - git add unison-src/transcripts-round-trip/main.output.md - # Fail if any transcripts cause git diffs. - git diff --cached --ignore-cr-at-eol --exit-code stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md - git add unison-src/transcripts-manual/rewrites.output.md # Fail if any transcripts cause git diffs. - git diff --cached --ignore-cr-at-eol --exit-code + git diff --ignore-cr-at-eol --exit-code \ + unison-src/transcripts-round-trip/main.output.md \ + unison-src/transcripts-manual/rewrites.output.md - name: transcripts run: | stack --no-terminal exec transcripts - # Add all changes to the index for when we diff. - git add --all # Fail if any transcripts cause git diffs. - git diff --cached --ignore-cr-at-eol --exit-code + git diff --ignore-cr-at-eol --exit-code unison-src/transcripts - name: cli-integration-tests run: stack --no-terminal exec cli-integration-tests - name: verify stack ghci startup @@ -481,22 +477,14 @@ jobs: run: | time ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md - CHANGE=$(git diff unison-src/builtin-tests/jit-tests.output.md) - if [ -n "$CHANGE" ]; then - echo "The jit-tests output has changed" - exit 1 - fi + git diff --exit-code unison-src/builtin-tests/jit-tests.output.md - name: interpreter tests # if: steps.checks.outputs.jit_dist_exists == 'false' run: | time ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md - CHANGE=$(git diff unison-src/builtin-tests/interpreter-tests.output.md) - if [ -n "$CHANGE" ]; then - echo "The interpreter-tests output has changed" - exit 1 - fi + git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From 544bd852e21f6435ebe77f5604574fc29b5bb9a3 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 16 Feb 2024 20:17:12 -0500 Subject: [PATCH 129/181] yaml move ucm local bin path out of repo? --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7a045073f9..7b343db369 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -189,16 +189,16 @@ jobs: --test \ --no-run-tests \ --no-terminal \ - --local-bin-path ${{env.ucm_local_bin}} \ + --local-bin-path ${{runner.temp}}/${{env.ucm_local_bin}} \ --copy-bins - name: output ucm path id: ucm-path run: | if [[ ${{runner.os}} = "Windows" ]]; then - echo "ucm-path=${{env.ucm_local_bin}}/unison.exe" >> $GITHUB_OUTPUT + echo "ucm-path=${{runner.temp}}/${{env.ucm_local_bin}}/unison.exe" >> $GITHUB_OUTPUT else - echo "ucm-path=${{env.ucm_local_bin}}/unison" >> $GITHUB_OUTPUT + echo "ucm-path=${{runner.temp}}/${{env.ucm_local_bin}}/unison" >> $GITHUB_OUTPUT fi # Run each test suite (tests and transcripts) From 7e29e4adb3bdab4836d490624a80c4c07c78888f Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 12:59:16 -0500 Subject: [PATCH 130/181] yaml hopefully skip hopefully unnecessary work --- .github/workflows/ci.yaml | 174 ++++++++++++++++++++++---------------- 1 file changed, 101 insertions(+), 73 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b343db369..86b6ff063a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -73,6 +73,14 @@ jobs: steps: - uses: actions/checkout@v4 + + - name: cache ucm binaries + id: cache-ucm-binaries + uses: actions/cache@v4 + with: + path: ${{runner.temp}}/${{env.ucm_local_bin}} + key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs') }} + # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. # GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to # purge one manually. @@ -80,40 +88,41 @@ jobs: name: record stackage resolver # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files # looks for `resolver: nightly-yyyy-mm-dd` or `resolver: lts-xx.yy` in `stack.yaml` and splits it into - # `nightly` or `lts-xx`. the whole resolver string is put into resolver_long as a backup cache key - # ${{ steps.stackage-resolver.outputs.resolver_short }} - # ${{ steps.stackage-resolver.outputs.resolver_long }} + # `nightly` or `lts-xx`. the whole resolver string is put into $resolver as a backup cache key + # ${{ env.resolver_short }} + # ${{ env.resolver }} run: | - grep resolver stack.yaml | awk '{ x="resolver_short="; if (split($2,a,"-") > 2) print x a[1]; else {split($2,b,"."); print x b[1]}}' >> "$GITHUB_OUTPUT" - grep resolver stack.yaml | awk '{print "resolver_long="$2}' >> "$GITHUB_OUTPUT" + grep resolver stack.yaml | awk '{ x="resolver_short="; if (split($2,a,"-") > 2) print x a[1]; else {split($2,b,"."); print x b[1]}}' >> "$GITHUB_ENV" + grep resolver stack.yaml | awk '{print "resolver="$2}' >> "$GITHUB_ENV" # Cache ~/.stack, keyed by the contents of 'stack.yaml'. - - uses: actions/cache@v4 - name: cache ~/.stack (unix) - if: runner.os != 'Windows' + - name: cache ~/.stack (non-Windows) + uses: actions/cache@v4 + if: runner.os != 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: path: ~/.stack - key: stack-1_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - # Fall-back to use the most recent cache for the stack.yaml, or failing that the OS - restore-keys: stack-1_${{matrix.os}}- + key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} + # Fall-back to use the most recent cache for this resolver + restore-keys: stack-1_${{matrix.os}}-${{env.resolver}}- + save-always: true # Cache ~/.stack, keyed by the contents of 'stack.yaml'. - - uses: actions/cache@v4 - name: cache ~/.stack (Windows) - if: runner.os == 'Windows' + - name: cache ~/.stack (Windows) + uses: actions/cache@v4 + if: runner.os == 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: - save-always: true path: | C:\Users\runneradmin\AppData\Roaming\stack C:\Users\runneradmin\AppData\Local\Programs\stack - key: stack-1_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - # Fall-back to use the most recent cache for the stack.yaml, or failing that the OS - restore-keys: stack-1_${{matrix.os}}- + key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} + # Fall-back to use the most recent cache for this resolver + restore-keys: stack-1_${{matrix.os}}-${{env.resolver}}- + save-always: true # Cache each local package's ~/.stack-work for fast incremental builds in CI. - - uses: actions/cache@v4 - name: cache .stack-work + - name: cache .stack-work + uses: actions/cache@v4 + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: - save-always: true path: | **/.stack-work # Main cache key: commit hash. This should always result in a cache miss... @@ -122,15 +131,17 @@ jobs: # recent branch cache. # Then it will save a new cache at this commit sha, which should be used by # the next build on this branch. - key: stack-work-4_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}-${{hashFiles('**/*.hs')}} + key: stack-work-4_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}-${{hashFiles('**/*.hs')}} restore-keys: | - stack-work-4_${{matrix.os}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}- + stack-work-4_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}- + stack-work-4_${{matrix.os}}-${{env.resolver}}- stack-work-4_${{matrix.os}}- + save-always: true # Install stack by downloading the binary from GitHub. # The installation process differs by OS. - name: install stack (Linux) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' working-directory: ${{ runner.temp }} run: | mkdir stack && cd stack @@ -138,16 +149,16 @@ jobs: echo "$PWD/stack-"* >> $GITHUB_PATH - name: install stack (macOS) + if: runner.os == 'macOS' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' working-directory: ${{ runner.temp }} - if: runner.os == 'macOS' run: | mkdir stack && cd stack curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-osx-x86_64.tar.gz | tar -xz echo "$PWD/stack-"* >> $GITHUB_PATH - name: install stack (windows) + if: runner.os == 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' working-directory: ${{ runner.temp }} - if: runner.os == 'Windows' run: | mkdir stack && cd stack curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-windows-x86_64.tar.gz | tar -xz @@ -166,6 +177,7 @@ jobs: # Build deps, then build local code. Splitting it into two steps just allows us to see how much time each step # takes. - name: build dependencies + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' # Run up to 5 times in a row before giving up. # It's very unlikely that our build-dependencies step will fail on most builds, # so if it fails its almost certainly due to a race condition on the Windows @@ -180,84 +192,107 @@ jobs: fi for (( i = 0; i < $tries; i++ )); do - stack --no-terminal build --fast --only-dependencies && break; + stack build --fast --only-dependencies && break; done - name: build + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: | stack build \ --fast \ --test \ --no-run-tests \ - --no-terminal \ + \ --local-bin-path ${{runner.temp}}/${{env.ucm_local_bin}} \ --copy-bins - - name: output ucm path - id: ucm-path - run: | if [[ ${{runner.os}} = "Windows" ]]; then - echo "ucm-path=${{runner.temp}}/${{env.ucm_local_bin}}/unison.exe" >> $GITHUB_OUTPUT + echo "ucm=${{runner.temp}}/${{env.ucm_local_bin}}/unison.exe" >> $GITHUB_ENV else - echo "ucm-path=${{runner.temp}}/${{env.ucm_local_bin}}/unison" >> $GITHUB_OUTPUT + echo "ucm=${{runner.temp}}/${{env.ucm_local_bin}}/unison" >> $GITHUB_ENV fi # Run each test suite (tests and transcripts) - - name: check disk space before - if: ${{ always() }} - run: df -h - name: unison-cli test - run: stack --no-terminal build --fast --test unison-cli - - name: check disk space after - if: ${{ always() }} - run: df -h + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack build --fast --test unison-cli + - name: unison-core tests - run: stack --no-terminal build --fast --test unison-core + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack build --fast --test unison-core + - name: unison-parser-typechecker tests - run: stack --no-terminal build --fast --test unison-parser-typechecker + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack build --fast --test unison-parser-typechecker + - name: unison-sqlite tests - run: stack --no-terminal build --fast --test unison-sqlite + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack build --fast --test unison-sqlite + - name: unison-syntax tests - run: stack --no-terminal build --fast --test unison-syntax + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack build --fast --test unison-syntax + - name: unison-util-bytes tests - run: stack --no-terminal build --fast --test unison-util-bytes + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack build --fast --test unison-util-bytes + - name: unison-util-cache tests - run: stack --no-terminal build --fast --test unison-util-cache + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack build --fast --test unison-util-cache + - name: unison-util-relation tests - run: stack --no-terminal build --fast --test unison-util-relation + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack build --fast --test unison-util-relation + - name: round-trip-tests + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: | - stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md - stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md + ${{env.ucm}} transcript unison-src/transcripts-round-trip/main.md + ${{env.ucm}} transcript unison-src/transcripts-manual/rewrites.md # Fail if any transcripts cause git diffs. git diff --ignore-cr-at-eol --exit-code \ unison-src/transcripts-round-trip/main.output.md \ unison-src/transcripts-manual/rewrites.output.md + - name: transcripts + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: | - stack --no-terminal exec transcripts + ${{runner.temp}}/${{env.ucm_local_bin}}/transcripts # Fail if any transcripts cause git diffs. git diff --ignore-cr-at-eol --exit-code unison-src/transcripts + - name: cli-integration-tests - run: stack --no-terminal exec cli-integration-tests + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + run: stack exec cli-integration-tests + - name: verify stack ghci startup - if: runner.os == 'macOS' + if: runner.os == 'macOS' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: echo | stack ghci - - name: debug check ucm artifact + - name: cache base codebase + uses: actions/cache@v4 + with: + path: ${{ env.base-codebase }} + # this key probably needs something about the schema version too + key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. + + - name: create base.md codebase + run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md + + - name: interpreter tests + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: | - ls -l ${{ env.ucm_local_bin }} - ls -l ${{ steps.ucm-path.outputs.ucm-path }} + ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md + cat unison-src/builtin-tests/interpreter-tests.output.md + git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md - name: save ucm artifact uses: actions/upload-artifact@v4 with: name: unison-${{ matrix.os }} - path: ${{ steps.ucm-path.outputs.ucm-path }} + path: ${{ env.ucm }} if-no-files-found: error - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} generate-jit-source: if: always() && needs.build-ucm.result == 'success' name: Generate JIT source @@ -454,12 +489,6 @@ jobs: name: jit-binary-${{ matrix.os }} path: ${{ env.jit_dist }}/** - - name: cache base.md codebase - uses: actions/cache@v4 - with: - path: ${{ env.base-codebase}} - key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. - - name: download ucm uses: actions/download-artifact@v4 with: @@ -469,23 +498,22 @@ jobs: - name: set ucm permissions run: chmod +x ${{ env.ucm }} + - name: get base codebase + uses: actions/cache/restore@v4 + with: + path: ${{ env.base-codebase}} + key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. + - name: create base.md codebase run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: jit tests ${{ matrix.os }} # if: steps.checks.outputs.jit_dist_exists == 'false' run: | - time ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md + ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md git diff --exit-code unison-src/builtin-tests/jit-tests.output.md - - name: interpreter tests - # if: steps.checks.outputs.jit_dist_exists == 'false' - run: | - time ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md - cat unison-src/builtin-tests/interpreter-tests.output.md - git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md - - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ failure() }} From 738e4fb7e694fd5d936a077ec1ed707cfb6e55fc Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 13:26:48 -0500 Subject: [PATCH 131/181] yaml rerun if transcripts have changed --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 86b6ff063a..791b2103f5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -79,7 +79,8 @@ jobs: uses: actions/cache@v4 with: path: ${{runner.temp}}/${{env.ucm_local_bin}} - key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs') }} + key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} + restore-keys: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs') }}- # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. # GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to From 7ed1b7da7c80a0b6572f10cec004ad69ae93c6d0 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 14:49:04 -0500 Subject: [PATCH 132/181] yaml fixup windows slashes again --- .github/workflows/ci.yaml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 791b2103f5..a268a3a304 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -74,11 +74,22 @@ jobs: steps: - uses: actions/checkout@v4 + - name: tweak environment + run: | + echo "ucm_local_bin=${runner_temp//\\//}/${ucm_local_bin}" >> $GITHUB_ENV + if [[ ${{runner.os}} = "Windows" ]]; then + echo "ucm=$ucm_local_bin/unison.exe" >> $GITHUB_ENV + echo "transcripts=$ucm_local_bin/transcripts.exe" >> $GITHUB_ENV + else + echo "ucm=$ucm_local_bin/unison" >> $GITHUB_ENV + echo "transcripts=$ucm_local_bin/transcripts" >> $GITHUB_ENV + fi + - name: cache ucm binaries id: cache-ucm-binaries uses: actions/cache@v4 with: - path: ${{runner.temp}}/${{env.ucm_local_bin}} + path: ${{env.ucm_local_bin}} key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} restore-keys: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs') }}- @@ -202,16 +213,9 @@ jobs: --fast \ --test \ --no-run-tests \ - \ - --local-bin-path ${{runner.temp}}/${{env.ucm_local_bin}} \ + --local-bin-path ${{env.ucm_local_bin}} \ --copy-bins - if [[ ${{runner.os}} = "Windows" ]]; then - echo "ucm=${{runner.temp}}/${{env.ucm_local_bin}}/unison.exe" >> $GITHUB_ENV - else - echo "ucm=${{runner.temp}}/${{env.ucm_local_bin}}/unison" >> $GITHUB_ENV - fi - # Run each test suite (tests and transcripts) - name: unison-cli test if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' @@ -258,7 +262,7 @@ jobs: - name: transcripts if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: | - ${{runner.temp}}/${{env.ucm_local_bin}}/transcripts + ${{env.transcripts}} # Fail if any transcripts cause git diffs. git diff --ignore-cr-at-eol --exit-code unison-src/transcripts From 1a2a11e6da24e8bfdce59ad955549358f6d87245 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 14:51:47 -0500 Subject: [PATCH 133/181] yaml case sensitive env var names --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a268a3a304..62e1bf09c9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -76,7 +76,7 @@ jobs: - name: tweak environment run: | - echo "ucm_local_bin=${runner_temp//\\//}/${ucm_local_bin}" >> $GITHUB_ENV + echo "ucm_local_bin=${RUNNER_TEMP//\\//}/${ucm_local_bin}" >> $GITHUB_ENV if [[ ${{runner.os}} = "Windows" ]]; then echo "ucm=$ucm_local_bin/unison.exe" >> $GITHUB_ENV echo "transcripts=$ucm_local_bin/transcripts.exe" >> $GITHUB_ENV From 887b9de536dea6f0f39dbccde652c65c0b09339e Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 14:55:22 -0500 Subject: [PATCH 134/181] yaml blerk --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 62e1bf09c9..b96819c5ba 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -76,7 +76,8 @@ jobs: - name: tweak environment run: | - echo "ucm_local_bin=${RUNNER_TEMP//\\//}/${ucm_local_bin}" >> $GITHUB_ENV + ucm_local_bin="${RUNNER_TEMP//\\//}/${ucm_local_bin}" + echo "ucm_local_bin=$ucm_local_bin" >> $GITHUB_ENV if [[ ${{runner.os}} = "Windows" ]]; then echo "ucm=$ucm_local_bin/unison.exe" >> $GITHUB_ENV echo "transcripts=$ucm_local_bin/transcripts.exe" >> $GITHUB_ENV From f353c30c569291d9222f212357ce01346f1193de Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 16:26:01 -0500 Subject: [PATCH 135/181] yaml skip failing interpreter tests in windows for now --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b96819c5ba..da1285bff1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -286,7 +286,7 @@ jobs: run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: interpreter tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: runner.os != 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: | ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md From e30c29bced8c2c2fb793754674411f178c2f36ea Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 16:28:52 -0500 Subject: [PATCH 136/181] caching tips --- docs/github-actions-help.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/github-actions-help.md b/docs/github-actions-help.md index f35831e60e..a1b8ef43d9 100644 --- a/docs/github-actions-help.md +++ b/docs/github-actions-help.md @@ -16,10 +16,18 @@ e.g. # access with `env.foo` in yaml strings, or `$foo` in bash +### Cache +When using the `cache` action, getting a cache hit on the primary key means you won't update the cache with any changes. + +When picking a key, you have to ask, "Which key, if exactly matched, would mean that I'm already so done that I don't even want to save anything new from this run." +`save-always: true` only if you know there will be nothing new to save, even if a previous run failed. + +Backup restore keys: "Is there a prior run that would be worth starting out from? With the caveat that any irrelevant garbage it includes will be saved into this run too." + +### Reference + Default Environment Variables: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables -When using the `cache` action, getting a cache hit on the primary key means you won't update the cache with any changes. - Workflow syntax: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions From de3d79213395704fa67540c7fcd4e8e466e767e4 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 19:24:10 -0500 Subject: [PATCH 137/181] skip jit integration test on windows --- .github/workflows/ci.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index da1285bff1..b9ef657377 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -406,7 +406,6 @@ jobs: - ubuntu-20.04 - macOS-12 - windows-2019 - # - windows-2022 steps: - name: restore jit binaries uses: actions/cache@v4 @@ -513,8 +512,8 @@ jobs: - name: create base.md codebase run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - - name: jit tests ${{ matrix.os }} - # if: steps.checks.outputs.jit_dist_exists == 'false' + - name: jit integration test ${{ matrix.os }} + if: runner.os != 'Windows' run: | ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md From 905a042f8ef02ba81cb57095f99336087885f50f Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 19:34:27 -0500 Subject: [PATCH 138/181] yaml: `timeout-minutes:` is a step setting, not an actions setting. --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b9ef657377..221f021a11 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -522,5 +522,4 @@ jobs: - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ failure() }} - with: - timeout-minutes: 15 + timeout-minutes: 15 From c42a019be37080a7073d3925cb8dc3346bab365d Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 19:42:15 -0500 Subject: [PATCH 139/181] yaml: skip base pull on cache hit --- .github/workflows/ci.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 221f021a11..3f7bf4e430 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -276,6 +276,7 @@ jobs: run: echo | stack ghci - name: cache base codebase + id: cache-base-codebase uses: actions/cache@v4 with: path: ${{ env.base-codebase }} @@ -283,6 +284,7 @@ jobs: key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. - name: create base.md codebase + if: steps.cache-base-codebase.outputs.cache-hit != 'true' run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: interpreter tests @@ -509,9 +511,6 @@ jobs: path: ${{ env.base-codebase}} key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. - - name: create base.md codebase - run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - - name: jit integration test ${{ matrix.os }} if: runner.os != 'Windows' run: | From 3b3ac4f998477757f948813a04c7fa49be799846 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 22:12:31 -0500 Subject: [PATCH 140/181] yaml move restore jit binaries step relative to environment tweak --- .github/workflows/ci.yaml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3f7bf4e430..94711ed497 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -409,12 +409,6 @@ jobs: - macOS-12 - windows-2019 steps: - - name: restore jit binaries - uses: actions/cache@v4 - with: - path: ${{ runner.temp }}/${{ env.jit_dist }} - key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} - - name: set up environment id: checks run: | @@ -445,6 +439,13 @@ jobs: echo "jit_dist_exe=$jit_dist_exe" >> $GITHUB_ENV echo "ucm=$ucm" >> $GITHUB_ENV + - name: restore jit binaries + id: restore-jit-binaries + uses: actions/cache@v4 + with: + path: ${{ env.jit_dist }} + key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} + - name: Cache Racket dependencies if: steps.checks.outputs.jit_dist_exists == 'false' uses: actions/cache@v4 @@ -485,10 +486,6 @@ jobs: raco exe "$jit_src_scheme"/unison-runtime.rkt raco distribute "$jit_dist" "$jit_exe" - # - name: Setup tmate session - # uses: mxschmitt/action-tmate@v3 - # if: ${{ always() }} && runner.os == 'Windows' - - name: save jit binary if: steps.checks.outputs.jit_dist_exists == 'false' uses: actions/upload-artifact@v4 From 6af7019106bf5ddff45e84fe45e69c05d677f160 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 17 Feb 2024 22:19:16 -0500 Subject: [PATCH 141/181] yaml switch environment tweak relative to restore jit binaries step --- .github/workflows/ci.yaml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 94711ed497..3cccea33d1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -427,12 +427,6 @@ jobs: ucm="${ucm//\\//}.exe" fi - if [[ -f "$jit_dist_exe" ]]; then - echo "jit_dist_exists=true" >> $GITHUB_OUTPUT - else - echo "jit_dist_exists=false" >> $GITHUB_OUTPUT - fi - echo "jit_src_scheme=$jit_src_scheme" >> $GITHUB_ENV echo "jit_exe=$jit_exe" >> $GITHUB_ENV echo "jit_dist=$jit_dist" >> $GITHUB_ENV @@ -447,7 +441,7 @@ jobs: key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} - name: Cache Racket dependencies - if: steps.checks.outputs.jit_dist_exists == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit == 'false' uses: actions/cache@v4 with: path: | @@ -455,21 +449,21 @@ jobs: ~/.local/share/racket key: ${{ runner.os }}-racket-${{env.racket_version}} - uses: Bogdanp/setup-racket@v1.11 - if: steps.checks.outputs.jit_dist_exists == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit == 'false' with: architecture: 'x64' distribution: 'full' variant: 'CS' version: ${{env.racket_version}} - uses: awalsh128/cache-apt-pkgs-action@latest - if: runner.os == 'Linux' && steps.checks.outputs.jit_dist_exists == 'false' + if: runner.os == 'Linux' && steps.restore-jit-binaries.outputs.cache-hit == 'false' # read this if a package isn't installing correctly # https://github.com/awalsh128/cache-apt-pkgs-action#caveats with: packages: libb2-dev version: 1.0 # cache key version afaik - name: download jit source - if: steps.checks.outputs.jit_dist_exists == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit == 'false' uses: actions/download-artifact@v4 with: name: jit-source @@ -478,7 +472,7 @@ jobs: - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - name: build jit binary - if: steps.checks.outputs.jit_dist_exists == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit == 'false' shell: bash run: | cp -R scheme-libs/racket/* "$jit_src_scheme" @@ -487,29 +481,31 @@ jobs: raco distribute "$jit_dist" "$jit_exe" - name: save jit binary - if: steps.checks.outputs.jit_dist_exists == 'false' uses: actions/upload-artifact@v4 with: name: jit-binary-${{ matrix.os }} path: ${{ env.jit_dist }}/** - name: download ucm + if: steps.restore-jit-binaries.outputs.cache-hit == 'false' uses: actions/download-artifact@v4 with: name: unison-${{ matrix.os }} path: ${{ runner.temp }} - name: set ucm permissions + if: steps.restore-jit-binaries.outputs.cache-hit == 'false' run: chmod +x ${{ env.ucm }} - name: get base codebase + if: steps.restore-jit-binaries.outputs.cache-hit == 'false' uses: actions/cache/restore@v4 with: path: ${{ env.base-codebase}} key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. - name: jit integration test ${{ matrix.os }} - if: runner.os != 'Windows' + if: runner.os != 'Windows' && steps.restore-jit-binaries.outputs.cache-hit == 'false' run: | ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md From 799502224e6b9e0d95ce13a9021092a6a6d10ce1 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 21 Feb 2024 13:21:23 -0500 Subject: [PATCH 142/181] update github-actions-help --- docs/github-actions-help.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/github-actions-help.md b/docs/github-actions-help.md index a1b8ef43d9..d8162af482 100644 --- a/docs/github-actions-help.md +++ b/docs/github-actions-help.md @@ -20,7 +20,8 @@ e.g. When using the `cache` action, getting a cache hit on the primary key means you won't update the cache with any changes. When picking a key, you have to ask, "Which key, if exactly matched, would mean that I'm already so done that I don't even want to save anything new from this run." -`save-always: true` only if you know there will be nothing new to save, even if a previous run failed. + +Similarly, `save-always: true` only if a key hit means there will be nothing new to save, even if a previous run failed AND a failed result is worth starting with. Backup restore keys: "Is there a prior run that would be worth starting out from? With the caveat that any irrelevant garbage it includes will be saved into this run too." From 0859ca3159ec84dbc718051d3451ce30b6a1672b Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 22 Feb 2024 21:34:08 -0500 Subject: [PATCH 143/181] yaml: error if nothing to upload --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3cccea33d1..f03d5e4e0d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -392,6 +392,7 @@ jobs: with: name: jit-source path: ${{ env.jit_src_scheme }}/** + if-no-files-found: error build-jit-binary: @@ -485,6 +486,7 @@ jobs: with: name: jit-binary-${{ matrix.os }} path: ${{ env.jit_dist }}/** + if-no-files-found: error - name: download ucm if: steps.restore-jit-binaries.outputs.cache-hit == 'false' From 5e6c6cab54115f0a1fdc9721050a6a85f08b1767 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 22 Feb 2024 22:02:04 -0500 Subject: [PATCH 144/181] yaml: work around https://github.com/actions/cache/issues/1334 --- .github/workflows/ci.yaml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f03d5e4e0d..01600957b0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -442,7 +442,7 @@ jobs: key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} - name: Cache Racket dependencies - if: steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit != 'true' uses: actions/cache@v4 with: path: | @@ -450,21 +450,21 @@ jobs: ~/.local/share/racket key: ${{ runner.os }}-racket-${{env.racket_version}} - uses: Bogdanp/setup-racket@v1.11 - if: steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit != 'true' with: architecture: 'x64' distribution: 'full' variant: 'CS' version: ${{env.racket_version}} - uses: awalsh128/cache-apt-pkgs-action@latest - if: runner.os == 'Linux' && steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: runner.os == 'Linux' && steps.restore-jit-binaries.outputs.cache-hit != 'true' # read this if a package isn't installing correctly # https://github.com/awalsh128/cache-apt-pkgs-action#caveats with: packages: libb2-dev version: 1.0 # cache key version afaik - name: download jit source - if: steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit != 'true' uses: actions/download-artifact@v4 with: name: jit-source @@ -473,7 +473,7 @@ jobs: - uses: actions/checkout@v4 # checkout scheme-libs from unison repo - name: build jit binary - if: steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit != 'true' shell: bash run: | cp -R scheme-libs/racket/* "$jit_src_scheme" @@ -486,28 +486,27 @@ jobs: with: name: jit-binary-${{ matrix.os }} path: ${{ env.jit_dist }}/** - if-no-files-found: error - name: download ucm - if: steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit != 'true' uses: actions/download-artifact@v4 with: name: unison-${{ matrix.os }} path: ${{ runner.temp }} - name: set ucm permissions - if: steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit != 'true' run: chmod +x ${{ env.ucm }} - name: get base codebase - if: steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: steps.restore-jit-binaries.outputs.cache-hit != 'true' uses: actions/cache/restore@v4 with: path: ${{ env.base-codebase}} key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. - name: jit integration test ${{ matrix.os }} - if: runner.os != 'Windows' && steps.restore-jit-binaries.outputs.cache-hit == 'false' + if: runner.os != 'Windows' && steps.restore-jit-binaries.outputs.cache-hit != 'true' run: | ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md From d7eee109db9ff43bfc457855d6fc20f1fd02e98a Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 24 Feb 2024 14:55:31 -0500 Subject: [PATCH 145/181] yaml: will `--embed-dlls` allow jit integration test to succeed on windows? --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 01600957b0..56a0dbd522 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -478,7 +478,7 @@ jobs: run: | cp -R scheme-libs/racket/* "$jit_src_scheme" raco pkg install --auto --skip-installed "$jit_src_scheme"/unison - raco exe "$jit_src_scheme"/unison-runtime.rkt + raco exe --embed-dlls "$jit_src_scheme"/unison-runtime.rkt raco distribute "$jit_dist" "$jit_exe" - name: save jit binary @@ -506,7 +506,7 @@ jobs: key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. - name: jit integration test ${{ matrix.os }} - if: runner.os != 'Windows' && steps.restore-jit-binaries.outputs.cache-hit != 'true' + if: steps.restore-jit-binaries.outputs.cache-hit != 'true' run: | ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md From 50d0e118feb34229ea602f0780a36561908042eb Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sat, 24 Feb 2024 15:45:53 -0500 Subject: [PATCH 146/181] yaml timeout was too short for debugging --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 56a0dbd522..80728c0db8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -515,4 +515,4 @@ jobs: - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ failure() }} - timeout-minutes: 15 + # timeout-minutes: 15 From f608a7a905e8f8e5b4b7d9d059c40f80800611a4 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 27 Feb 2024 12:54:10 -0500 Subject: [PATCH 147/181] update github-actions-help --- docs/github-actions-help.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/github-actions-help.md b/docs/github-actions-help.md index d8162af482..0137da7ded 100644 --- a/docs/github-actions-help.md +++ b/docs/github-actions-help.md @@ -25,6 +25,10 @@ Similarly, `save-always: true` only if a key hit means there will be nothing new Backup restore keys: "Is there a prior run that would be worth starting out from? With the caveat that any irrelevant garbage it includes will be saved into this run too." +### Composite Actions + +Needs to have `shell:` specified on every `run:` + ### Reference Default Environment Variables: From 9412098adbfb3056ac4c70d8f012a184c72f8afd Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 27 Feb 2024 12:54:34 -0500 Subject: [PATCH 148/181] commend --- unison-cli/unison/Main.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/unison-cli/unison/Main.hs b/unison-cli/unison/Main.hs index 1faad3be6c..368f0f78a4 100644 --- a/unison-cli/unison/Main.hs +++ b/unison-cli/unison/Main.hs @@ -354,6 +354,7 @@ main = do RTI.withRuntime False mode Version.gitDescribeWithDate \runtime -> do RTI.withRuntime True mode Version.gitDescribeWithDate \sbRuntime -> action . (runtime,sbRuntime,) + -- startNativeRuntime saves the path to `unison-runtime` =<< RTI.startNativeRuntime Version.gitDescribeWithDate nrtp withConfig :: Maybe CodebasePathOption -> (Config -> IO a) -> IO a withConfig mCodePathOption action = do From 91e4311651f800572121fe7525ab0283559438e5 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 28 Feb 2024 21:06:49 -0500 Subject: [PATCH 149/181] Racket chunked seq fixes for base tests --- scheme-libs/racket/unison/chunked-seq.rkt | 15 ++++++++------- scheme-libs/racket/unison/vector-trie.rkt | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/scheme-libs/racket/unison/chunked-seq.rkt b/scheme-libs/racket/unison/chunked-seq.rkt index e50a39427e..8e8b62172b 100644 --- a/scheme-libs/racket/unison/chunked-seq.rkt +++ b/scheme-libs/racket/unison/chunked-seq.rkt @@ -504,7 +504,7 @@ new-len (λ (chunk) (chunk-copy! chunk 0 first-c 1) - (chunk-copy! chunk first-len last-c 0)))))] + (chunk-copy! chunk (sub1 first-len) last-c 0)))))] [(= first-len 1) (define-values [vt* first-c*] (vector-trie-pop-first vt)) (struct-copy @@ -516,7 +516,7 @@ (struct-copy chunks cs [length (sub1 len)] - [first-chunk (chunk-drop-first last-c)])]) + [first-chunk (chunk-drop-first first-c)])]) (chunk-first first-c))])) (define (chunked-seq-pop-last cs) @@ -573,13 +573,13 @@ [{(single-chunk chunk-a) (single-chunk chunk-b)} (define len (+ (chunk-length chunk-a) (chunk-length chunk-b))) ;; see Note [chunks-length invariant] - (if (< len CHUNK-CAPACITY) + (if (<= len CHUNK-CAPACITY) (single-chunk (chunk-append chunk-a chunk-b)) (chunks len chunk-a empty-vector-trie chunk-b))] [{(single-chunk chunk) (chunks len first-c vt _)} (cond - [(< (+ (chunk-length chunk) (chunk-length first-c)) CHUNK-CAPACITY) + [(<= (+ (chunk-length chunk) (chunk-length first-c)) CHUNK-CAPACITY) (struct-copy chunks cs-b [length (+ (chunk-length chunk) len)] @@ -594,7 +594,7 @@ [{(chunks len _ vt last-c) (single-chunk chunk)} (cond - [(< (+ (chunk-length last-c) (chunk-length chunk)) CHUNK-CAPACITY) + [(<= (+ (chunk-length last-c) (chunk-length chunk)) CHUNK-CAPACITY) (struct-copy chunks cs-a [length (+ len (chunk-length chunk))] @@ -688,9 +688,10 @@ ;; If `first-a` contains too many elements to fit in the next ;; partially-constructed chunk, we need to split it as well. [(> first-a-len insert-i) - (chunk-copy! new-chunk 0 first-a split-i) + (define copy-len (- first-a-len insert-i)) + (chunk-copy! new-chunk 0 first-a copy-len) (transfer-chunk! #:done? #t) - (chunk-slice first-a 0 split-i)] + (chunk-slice first-a 0 copy-len)] ;; Otherwise, we can move the elements from the partially- ;; constructed chunk into the new first chunk. diff --git a/scheme-libs/racket/unison/vector-trie.rkt b/scheme-libs/racket/unison/vector-trie.rkt index 8d64e42258..164a0efef8 100644 --- a/scheme-libs/racket/unison/vector-trie.rkt +++ b/scheme-libs/racket/unison/vector-trie.rkt @@ -719,7 +719,7 @@ (next-leaf!) (vector-copy! new-leaf leaf-split-i leaf 0 leaf-split-i))] [else - (vector-copy! new-leaf leaf-i leaf first-leaf-start leaf-split-i)])))] + (vector-copy! new-leaf leaf-i leaf first-leaf-start leaf-insert-i)])))] [else (make-node (λ (new-node) From 6c69ae64537c72e982c837c285bf217f1c49cfdd Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 28 Feb 2024 21:07:28 -0500 Subject: [PATCH 150/181] Add additional universal compare cases in racket --- scheme-libs/racket/unison/core.ss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scheme-libs/racket/unison/core.ss b/scheme-libs/racket/unison/core.ss index 558120ea3c..23325af9a0 100644 --- a/scheme-libs/racket/unison/core.ss +++ b/scheme-libs/racket/unison/core.ss @@ -270,6 +270,8 @@ (cond [(equal? l r) '=] [(and (number? l) (number? r)) (if (< l r) '< '>)] + [(and (char? l) (char? r)) (if (char)] + [(and (boolean? l) (boolean? r)) (if r '< '>)] [(and (chunked-list? l) (chunked-list? r)) (chunked-list-compare/recur l r universal-compare)] [(and (chunked-string? l) (chunked-string? r)) (chunked-string-compare/recur l r (lambda (a b) (if (char)))] From b4d5da177d5726342b35c9c6fb69b331a6dfe259 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 28 Feb 2024 21:08:09 -0500 Subject: [PATCH 151/181] Define some helper functions for modular arithmetic These attempt to put slow operations behind a branch, so that arithmetic on small enough numbers can remain efficient. --- scheme-libs/racket/unison/boot.ss | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/scheme-libs/racket/unison/boot.ss b/scheme-libs/racket/unison/boot.ss index febd27901c..270259cef2 100644 --- a/scheme-libs/racket/unison/boot.ss +++ b/scheme-libs/racket/unison/boot.ss @@ -20,6 +20,13 @@ data data-case + clamp-integer + clamp-natural + wrap-natural + bit64 + bit63 + nbit63 + expand-sandbox check-sandbox set-sandbox @@ -72,6 +79,7 @@ ; (for (only (racket base) quasisyntax/loc) expand) ; (for-syntax (only-in unison/core syntax->list)) (only-in racket/control prompt0-at control0-at) + racket/performance-hint unison/core unison/data unison/sandbox @@ -591,3 +599,31 @@ (control 'ref-4n0fgs00 k (let ([disp (describe-value f)]) (raise (make-exn:bug "builtin.bug" disp))))]])) + +(begin-encourage-inline + (define mask64 #xffffffffffffffff) + (define mask63 #x7fffffffffffffff) + (define bit63 #x8000000000000000) + (define bit64 #x10000000000000000) + (define nbit63 (- #x8000000000000000)) + + ; Operation to maintain Int values to within a range from + ; -2^63 to 2^63-1. + (define (clamp-integer i) + (if (fixnum? i) i + (let ([j (bitwise-and mask64 i)]) + (if (< j bit63) j + (- j bit64))))) + + ; modular arithmetic appropriate for when a Nat operation can only + ; overflow (be too large a positive number). + (define (clamp-natural n) + (if (fixnum? n) n + (modulo n bit64))) + + ; module arithmetic appropriate for when a Nat operation my either + ; have too large or a negative result. + (define (wrap-natural n) + (if (and (fixnum? n) (exact-nonnegative-integer? n)) n + (modulo n bit64)))) + From a261aa0751af7e4c949164444dcabbd4cce66318 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 28 Feb 2024 21:15:13 -0500 Subject: [PATCH 152/181] Implement modular arithmetic for Int/Nat --- scheme-libs/racket/unison/arithmetic.rkt | 25 +++++------ scheme-libs/racket/unison/math.rkt | 39 ++++++++++------- scheme-libs/racket/unison/primops.ss | 56 +++++++++++++----------- 3 files changed, 66 insertions(+), 54 deletions(-) diff --git a/scheme-libs/racket/unison/arithmetic.rkt b/scheme-libs/racket/unison/arithmetic.rkt index 310a93774a..1e5cd77129 100644 --- a/scheme-libs/racket/unison/arithmetic.rkt +++ b/scheme-libs/racket/unison/arithmetic.rkt @@ -21,23 +21,22 @@ Int.signum ))) -(require racket) -(require racket/fixnum) -(require racket/flonum) -(require racket/performance-hint) -(require unison/boot) +(require racket + racket/fixnum + racket/flonum + racket/performance-hint + unison/boot) (begin-encourage-inline - (define-unison (Nat.+ m n) (+ m n)) + (define-unison (Nat.+ m n) (clamp-natural (+ m n))) (define-unison (Nat.drop m n) (max 0 (- m n))) - - (define-unison (Nat.increment n) (add1 n)) - (define-unison (Int.increment i) (add1 i)) - (define-unison (Int.negate i) (- i)) - (define-unison (Int.+ i j) (+ i j)) - (define-unison (Int.- i j) (- i j)) - (define-unison (Int./ i j) (quotient i j)) + (define-unison (Nat.increment n) (clamp-natural (add1 n))) + (define-unison (Int.increment i) (clamp-integer (add1 i))) + (define-unison (Int.negate i) (if (> i nbit63) (- i) i)) + (define-unison (Int.+ i j) (clamp-integer (+ i j))) + (define-unison (Int.- i j) (clamp-integer (- i j))) + (define-unison (Int./ i j) (floor (/ i j))) (define-unison (Int.signum i) (sgn i)) (define-unison (Float.* x y) (fl* x y)) diff --git a/scheme-libs/racket/unison/math.rkt b/scheme-libs/racket/unison/math.rkt index 0021a8d969..2e34a49987 100644 --- a/scheme-libs/racket/unison/math.rkt +++ b/scheme-libs/racket/unison/math.rkt @@ -1,8 +1,14 @@ #lang racket/base (require math/base - rnrs/arithmetic/fixnums-6 - (only-in unison/boot data-case define-unison)) + racket/performance-hint + rnrs/arithmetic/bitwise-6 + (only-in unison/boot + clamp-integer + clamp-natural + data-case + define-unison + nbit63)) (provide builtin-Float.exp @@ -73,8 +79,8 @@ (define-unison (builtin-Float.min n m) (min n m)) (define-unison (builtin-Float.tan n) (tan n)) (define-unison (builtin-Float.tanh n) (tanh n)) -(define-unison (builtin-Int.* n m) (* n m)) -(define-unison (builtin-Int.pow n m) (expt n m)) +(define-unison (builtin-Int.* n m) (clamp-integer (* n m))) +(define-unison (builtin-Int.pow n m) (clamp-integer (expt n m))) (define-unison (builtin-Int.trailingZeros n) (TZRO n)) (define-unison (builtin-Nat.trailingZeros n) (TZRO n)) (define-unison (builtin-Nat.popCount n) (POPC n)) @@ -85,19 +91,19 @@ (define ACOS acos) (define ACSH acosh) (define ADDF +) -(define ADDI +) +(define (ADDI i j) (clamp-integer (+ i j))) (define SUBF -) -(define SUBI -) +(define (SUBI i j) (clamp-integer (- i j))) (define (SGNI n) (if (< n 0) -1 (if (> n 0) +1 0))) (define MAXF max) (define MINF min) (define MULF *) -(define MULI *) -(define NEGI -) +(define (MULI i j) (clamp-integer (* i j))) +(define (NEGI i) (if (> i nbit63) (- i) i)) (define NTOF exact->inexact) (define POWF expt) -(define POWI expt) -(define POWN expt) +(define (POWI i j) (clamp-integer (expt i j))) +(define (POWN i j) (clamp-natural (expt i j))) (define ASIN asin) (define ASNH asinh) (define ATAN atan) @@ -106,7 +112,10 @@ (define CEIL ceiling) (define FLOR floor) (define COSF cos) -(define TRNF truncate) +(define (TRNF f) + (cond + [(or (= f +inf.0) (= f -inf.0) (eqv? f +nan.0) (eqv? f +nan.f)) 0] + [else (clamp-integer (inexact->exact (truncate f)))])) (define RNDF round) (define SQRT sqrt) (define TANF tan) @@ -115,19 +124,17 @@ (define SINH sinh) (define COSH cosh) (define DIVF /) -(define DIVI /) +(define (DIVI i j) (floor (/ i j))) (define ITOF exact->inexact) (define (EQLF a b) (if (= a b) 1 0)) (define (LEQF a b) (if (<= a b) 1 0)) (define (EQLI a b) (if (= a b) 1 0)) (define (POPC n) - (if (< n 0) - (+ 65 (fxbit-count n)) - (fxbit-count n))) + (modulo (bitwise-bit-count n) 65)) (define (TZRO n) - (let ([bit (fxfirst-bit-set n)]) + (let ([bit (bitwise-first-bit-set n)]) (if (eq? -1 bit) 64 bit))) diff --git a/scheme-libs/racket/unison/primops.ss b/scheme-libs/racket/unison/primops.ss index 218bac9ee8..4448b3b695 100644 --- a/scheme-libs/racket/unison/primops.ss +++ b/scheme-libs/racket/unison/primops.ss @@ -834,11 +834,11 @@ (chunked-bytes-length bs) (lambda (i) (chunked-bytes-ref bs i)))) - (define unison-POp-ADDI +) - (define unison-POp-MULI *) - (define unison-POp-MODI mod) + (define (unison-POp-ADDI i j) (clamp-integer (+ i j))) + (define (unison-POp-MULI i j) (clamp-integer (* i j))) + (define (unison-POp-MODI i j) (clamp-integer (modulo i j))) (define (unison-POp-LEQI a b) (bool (<= a b))) - (define unison-POp-POWN expt) + (define (unison-POp-POWN m n) (clamp-natural (expt m n))) (define unison-POp-LOGF log) (define (reify-exn thunk) @@ -848,7 +848,7 @@ (thunk))) ; Core implemented primops, upon which primops-in-unison can be built. - (define (unison-POp-ADDN m n) (fx+ m n)) + (define (unison-POp-ADDN m n) (clamp-natural (+ m n))) (define (unison-POp-ANDN m n) (bitwise-and m n)) (define unison-POp-BLDS (lambda args-list @@ -857,17 +857,17 @@ (define (unison-POp-CATT l r) (chunked-string-append l r)) (define (unison-POp-CATB l r) (chunked-bytes-append l r)) (define (unison-POp-CMPU l r) (ord (universal-compare l r))) - (define (unison-POp-COMN n) (fxnot n)) + (define (unison-POp-COMN n) (wrap-natural (bitwise-not n))) (define (unison-POp-CONS x xs) (chunked-list-add-first xs x)) - (define (unison-POp-DECI n) (fx1- n)) - (define (unison-POp-INCI n) (fx+ n 1)) - (define (unison-POp-DECN n) (- n 1)) - (define (unison-POp-INCN n) (+ n 1)) - (define (unison-POp-DIVN m n) (fxdiv m n)) + (define (unison-POp-DECI n) (clamp-integer (sub1 n))) + (define (unison-POp-INCI n) (clamp-integer (add1 n))) + (define (unison-POp-DECN n) (wrap-natural (sub1 n))) + (define (unison-POp-INCN n) (clamp-natural (add1 n))) + (define (unison-POp-DIVN m n) (quotient m n)) (define (unison-POp-DRPB n bs) (chunked-bytes-drop bs n)) (define (unison-POp-DRPS n l) (chunked-list-drop l n)) (define (unison-POp-DRPT n t) (chunked-string-drop t n)) - (define (unison-POp-EQLN m n) (bool (fx=? m n))) + (define (unison-POp-EQLN m n) (bool (= m n))) (define (unison-POp-EQLT s t) (bool (equal? s t))) (define (unison-POp-LEQT s t) (bool (chunked-stringchunked-string (number->string n))) (define (unison-POp-LEQN m n) (bool (fx<=? m n))) - (define (unison-POp-LZRO m) (- 64 (fxlength m))) - (define (unison-POp-MULN m n) (* m n)) - (define (unison-POp-MODN m n) (fxmod m n)) + (define (unison-POp-LZRO m) (- 64 (integer-length m))) + (define (unison-POp-MULN m n) (clamp-natural (* m n))) + (define (unison-POp-MODN m n) (modulo m n)) (define (unison-POp-NTOT n) (string->chunked-string (number->string n))) (define (unison-POp-PAKB l) (build-chunked-bytes @@ -900,16 +900,18 @@ (build-chunked-string (chunked-list-length l) (lambda (i) (chunked-list-ref l i)))) - (define (unison-POp-SHLI i k) (fxarithmetic-shift-left i k)) - (define (unison-POp-SHLN n k) (fxarithmetic-shift-left n k)) - (define (unison-POp-SHRI i k) (fxarithmetic-shift-right i k)) - (define (unison-POp-SHRN n k) (fxarithmetic-shift-right n k)) + (define (unison-POp-SHLI i k) + (clamp-integer (bitwise-arithmetic-shift-left i k))) + (define (unison-POp-SHLN n k) + (clamp-natural (bitwise-arithmetic-shift-left n k))) + (define (unison-POp-SHRI i k) (bitwise-arithmetic-shift-right i k)) + (define (unison-POp-SHRN n k) (bitwise-arithmetic-shift-right n k)) (define (unison-POp-SIZS l) (chunked-list-length l)) (define (unison-POp-SIZT t) (chunked-string-length t)) (define (unison-POp-SIZB b) (chunked-bytes-length b)) (define (unison-POp-SNOC xs x) (chunked-list-add-last xs x)) - (define (unison-POp-SUBN m n) (fx- m n)) - (define (unison-POp-SUBI m n) (- m n)) + (define (unison-POp-SUBN m n) (clamp-integer (- m n))) + (define (unison-POp-SUBI m n) (clamp-integer (- m n))) (define (unison-POp-TAKS n s) (chunked-list-take s n)) (define (unison-POp-TAKT n t) (chunked-string-take t n)) (define (unison-POp-TAKB n t) (chunked-bytes-take t n)) @@ -946,10 +948,14 @@ (newline)) (define (unison-POp-TTON s) (let ([mn (string->number (chunked-string->string s))]) - (if (and (fixnum? mn) (>= mn 0)) (some mn) none))) + (if (and (exact-nonnegative-integer? mn) (< mn bit64)) + (some mn) + none))) (define (unison-POp-TTOI s) (let ([mn (string->number (chunked-string->string s))]) - (if (fixnum? mn) (some mn) none))) + (if (and (exact-integer? mn) (>= mn nbit63) (< mn bit63)) + (some mn) + none))) (define (unison-POp-TTOF s) (let ([mn (string->number (chunked-string->string s))]) (if mn (some mn) none))) @@ -994,7 +1000,7 @@ ;; TODO flatten operation on Bytes is a no-op for now (and possibly ever) (define (unison-POp-FLTB b) b) - (define (unison-POp-XORN m n) (fxxor m n)) + (define (unison-POp-XORN m n) (bitwise-xor m n)) (define (unison-POp-VALU c) (decode-value c)) (define (unison-FOp-ImmutableByteArray.read16be bs n) From 805c9f1c87b3eb0b6bdfc2513bbb4bd72701c027 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 28 Feb 2024 21:15:54 -0500 Subject: [PATCH 153/181] Scope.bytearrayOf and missing imports from prior commit --- scheme-libs/racket/unison/primops.ss | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/scheme-libs/racket/unison/primops.ss b/scheme-libs/racket/unison/primops.ss index 4448b3b695..628a7a8713 100644 --- a/scheme-libs/racket/unison/primops.ss +++ b/scheme-libs/racket/unison/primops.ss @@ -139,6 +139,9 @@ builtin-IO.randomBytes builtin-IO.randomBytes:termlink + builtin-Scope.bytearrayOf + builtin-Scope.bytearrayOf:termlink + builtin-Universal.== builtin-Universal.==:termlink builtin-Universal.> @@ -573,17 +576,24 @@ (only (racket) car cdr + exact-integer? + exact-nonnegative-integer? foldl + integer-length bytes->string/utf-8 string->bytes/utf-8 exn:fail:contract? file-stream-buffer-mode with-handlers match + modulo + quotient regexp-match-positions sequence-ref vector-copy! - bytes-copy!) + bytes-copy! + sub1 + add1) (car icar) (cdr icdr)) (unison arithmetic) (unison bytevector) @@ -591,7 +601,13 @@ (only (unison boot) define-unison referent->termlink - termlink->referent) + termlink->referent + clamp-integer + clamp-natural + wrap-natural + bit64 + bit63 + nbit63) (unison data) (unison data-info) (unison math) @@ -713,6 +729,7 @@ (define-builtin-link Pattern.captureAs) (define-builtin-link Pattern.isMatch) (define-builtin-link Char.Class.is) + (define-builtin-link Scope.bytearrayOf) (begin-encourage-inline (define-unison (builtin-Value.toBuiltin v) (unison-quote v)) @@ -788,6 +805,9 @@ (case (universal-compare x y) [(>) 1] [(<) -1] [else 0])) + (define-unison (builtin-Scope.bytearrayOf i n) + (make-bytevector n i)) + (define (hash-string hs) (string-append "#" (bytevector->base32-string b32h hs))) @@ -1400,5 +1420,6 @@ (declare-builtin-link builtin-Universal.<=) (declare-builtin-link builtin-Universal.compare) (declare-builtin-link builtin-Pattern.isMatch) + (declare-builtin-link builtin-Scope.bytearrayOf) (declare-builtin-link builtin-Char.Class.is) ) From dfd482b3c6d10d638dd348c58e0688679f950a5b Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 28 Feb 2024 21:19:54 -0500 Subject: [PATCH 154/181] Racket pattern fixes --- scheme-libs/racket/unison/pattern.rkt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scheme-libs/racket/unison/pattern.rkt b/scheme-libs/racket/unison/pattern.rkt index 0820d71dc0..73f5785ad0 100644 --- a/scheme-libs/racket/unison/pattern.rkt +++ b/scheme-libs/racket/unison/pattern.rkt @@ -269,7 +269,7 @@ (define-values [cstr* captures*] (for/fold ([cstr cstr] [captures captures] - #:result (ok cstr captures)) + #:result (values cstr captures)) ([i (in-range min-count)]) #:break (not cstr) (pat-m cstr captures))) @@ -297,4 +297,9 @@ (p:char (λ (c) (match (pattern-pat cc) [(p:char 'any) #f] - [(p:char p) (not (p c))]))))) + [(p:char p) (not (p c))] + [(p:or p q) + (char-class-and + (char-class-not p) + (char-class-not q))]))))) + From d72f6924787f1b1ad2b10888be2e12baa29a19a7 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 28 Feb 2024 21:22:36 -0500 Subject: [PATCH 155/181] Add a version flag to unison-runtime and rework slightly --- scheme-libs/racket/unison-runtime.rkt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scheme-libs/racket/unison-runtime.rkt b/scheme-libs/racket/unison-runtime.rkt index 34e511e3bb..9287560f6f 100644 --- a/scheme-libs/racket/unison-runtime.rkt +++ b/scheme-libs/racket/unison-runtime.rkt @@ -93,19 +93,23 @@ (write-module srcf main-ref icode)) (define generate-to (make-parameter #f)) +(define show-version (make-parameter #f)) (define (handle-command-line) (command-line #:program "unison-runtime" #:once-any + ["--version" + "display version" + (show-version #t)] [("-G" "--generate-file") file "generate code to " - (generate-to file)] - #:args () - (generate-to))) + (generate-to file)])) -(let ([out (handle-command-line)]) - (if out - (do-generate out) - (do-evaluate))) +(begin + (handle-command-line) + (cond + [(show-version) (displayln "unison-runtime version 0.0.10")] + [(generate-to) (do-generate (generate-to))] + [else (do-evaluate)])) From 5cf73d1c6c27ca94a1f6e321b605c20e2f1b0fbe Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Thu, 29 Feb 2024 20:53:04 -0500 Subject: [PATCH 156/181] Fix char class stuff (more) properly --- scheme-libs/racket/unison/pattern.rkt | 26 ++++++++++++++------------ scheme-libs/racket/unison/primops.ss | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/scheme-libs/racket/unison/pattern.rkt b/scheme-libs/racket/unison/pattern.rkt index 73f5785ad0..ee2fce4d44 100644 --- a/scheme-libs/racket/unison/pattern.rkt +++ b/scheme-libs/racket/unison/pattern.rkt @@ -41,6 +41,7 @@ [replicate (-> pattern? exact-nonnegative-integer? exact-nonnegative-integer? pattern?)] ;; Only valid pattern? in the functions below is p:char [char-class-and (-> pattern? pattern? pattern?)] + [char-class-or (-> pattern? pattern? pattern?)] [char-class-not (-> pattern? pattern?)])) ;; ----------------------------------------------------------------------------- @@ -285,21 +286,22 @@ ;; ----------------------------------------------------------------------------- (define (char-class-and cc1 cc2) - (make-pattern - (p:char - (λ (c) (match (cons (pattern-pat cc1) (pattern-pat cc2)) - [(cons (p:char 'any) (p:char p)) (p c)] - [(cons (p:char p) (p:char 'any)) (p c)] - [(cons (p:char p1) (p:char p2)) (and (p1 c) (p2 c))]))))) + (match* ((pattern-pat cc1) (pattern-pat cc2)) + [((p:char 'any) _) cc2] + [(_ (p:char 'any)) cc1] + [((p:char p) (p:char q)) + (make-pattern (p:char (λ (c) (and (p c) (q c)))))])) (define (char-class-not cc) (make-pattern (p:char (λ (c) (match (pattern-pat cc) [(p:char 'any) #f] - [(p:char p) (not (p c))] - [(p:or p q) - (char-class-and - (char-class-not p) - (char-class-not q))]))))) - + [(p:char p) (not (p c))]))))) + +(define (char-class-or cc1 cc2) + (match* ((pattern-pat cc1) (pattern-pat cc2)) + [((p:char 'any) _) cc1] + [(_ (p:char 'any)) cc2] + [((p:char p) (p:char q)) + (make-pattern (p:char (λ (c) (or (p c) (q c)))))])) diff --git a/scheme-libs/racket/unison/primops.ss b/scheme-libs/racket/unison/primops.ss index 628a7a8713..708fe451bf 100644 --- a/scheme-libs/racket/unison/primops.ss +++ b/scheme-libs/racket/unison/primops.ss @@ -1171,7 +1171,7 @@ (define (unison-FOp-Char.Class.printable) printable) (define (unison-FOp-Char.Class.mark) mark) (define (unison-FOp-Char.Class.separator) separator) - (define (unison-FOp-Char.Class.or p1 p2) (unison-FOp-Pattern.or p1 p2)) + (define (unison-FOp-Char.Class.or p1 p2) (char-class-or p1 p2)) (define (unison-FOp-Char.Class.range a z) (unison-FOp-Text.patterns.charRange a z)) (define (unison-FOp-Char.Class.anyOf cs) (unison-FOp-Text.patterns.charIn cs)) From 46ad01e31f8a09b6d69bdaf73bfba0a026a5b591 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Fri, 1 Mar 2024 12:54:51 -0500 Subject: [PATCH 157/181] Fix racket float to text formatting a bit to match Haskell --- scheme-libs/racket/unison/primops.ss | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scheme-libs/racket/unison/primops.ss b/scheme-libs/racket/unison/primops.ss index 708fe451bf..04ee983902 100644 --- a/scheme-libs/racket/unison/primops.ss +++ b/scheme-libs/racket/unison/primops.ss @@ -595,6 +595,9 @@ sub1 add1) (car icar) (cdr icdr)) + (only (racket string) + string-contains? + string-replace) (unison arithmetic) (unison bytevector) (unison core) @@ -897,7 +900,14 @@ (put-string p ": ") (display (describe-value x) p) (raise (make-exn:bug fnm x)))) - (define (unison-POp-FTOT f) (string->chunked-string (number->string f))) + (define (unison-POp-FTOT f) + (define base (number->string f)) + (define dotted + (if (string-contains? base ".") + base + (string-replace base "e" ".0e"))) + (string->chunked-string + (string-replace dotted "+" ""))) (define (unison-POp-IDXB n bs) (guard (x [else none]) (some (chunked-bytes-ref bs n)))) From 24379d3c88e39818360a379c9eaaf0da614102c0 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Fri, 1 Mar 2024 16:40:30 -0500 Subject: [PATCH 158/181] Tweak fromUtf8 error message; add IOFailure type in scheme Requires bumping the jit implementation version info --- scheme-libs/racket/unison-runtime.rkt | 2 +- scheme-libs/racket/unison/concurrent.ss | 5 ++++- scheme-libs/racket/unison/io.rkt | 8 ++++++-- scheme-libs/racket/unison/primops.ss | 9 ++++++++- scheme-libs/racket/unison/tcp.rkt | 9 +++++++-- scheme-libs/racket/unison/tls.rkt | 17 ++++++++++++++--- unison-cli/src/Unison/JitInfo.hs | 2 +- 7 files changed, 41 insertions(+), 11 deletions(-) diff --git a/scheme-libs/racket/unison-runtime.rkt b/scheme-libs/racket/unison-runtime.rkt index 9287560f6f..05a8989e90 100644 --- a/scheme-libs/racket/unison-runtime.rkt +++ b/scheme-libs/racket/unison-runtime.rkt @@ -110,6 +110,6 @@ (begin (handle-command-line) (cond - [(show-version) (displayln "unison-runtime version 0.0.10")] + [(show-version) (displayln "unison-runtime version 0.0.11")] [(generate-to) (do-generate (generate-to))] [else (do-evaluate)])) diff --git a/scheme-libs/racket/unison/concurrent.ss b/scheme-libs/racket/unison/concurrent.ss index d2b0e11005..04d5a608ec 100644 --- a/scheme-libs/racket/unison/concurrent.ss +++ b/scheme-libs/racket/unison/concurrent.ss @@ -18,6 +18,7 @@ (import (rnrs) (rnrs records syntactic) (unison data) + (unison data-info) (unison core) (unison chunked-seq) (rename @@ -110,7 +111,9 @@ (with-handlers ([exn:break? (lambda (e) (exception "ThreadKilledFailure" (string->chunked-string "thread killed") ()))] - [exn:io? (lambda (e) (exception "IOFailure" (exception->string e) ()))] + [exn:io? + (lambda (e) + (exception unison-iofailure:link (exception->string e) ()))] [exn:arith? (lambda (e) (exception "ArithmeticFailure" (exception->string e) ()))] [exn:bug? (lambda (e) (exn:bug->exception e))] [exn:fail? (lambda (e) (exception "RuntimeFailure" (exception->string e) ()))] diff --git a/scheme-libs/racket/unison/io.rkt b/scheme-libs/racket/unison/io.rkt index 76c540540c..7d95a82bdb 100644 --- a/scheme-libs/racket/unison/io.rkt +++ b/scheme-libs/racket/unison/io.rkt @@ -44,12 +44,16 @@ (define (getFileSize.impl.v3 path) (with-handlers - [[exn:fail:filesystem? (lambda (e) (exception "IOFailure" (exception->string e) '()))]] + [[exn:fail:filesystem? + (lambda (e) + (exception unison-iofailure:link (exception->string e) '()))]] (right (file-size (chunked-string->string path))))) (define (getFileTimestamp.impl.v3 path) (with-handlers - [[exn:fail:filesystem? (lambda (e) (exception "IOFailure" (exception->string e) '()))]] + [[exn:fail:filesystem? + (lambda (e) + (exception unison-iofailure:link (exception->string e) '()))]] (right (file-or-directory-modify-seconds (chunked-string->string path))))) ; in haskell, it's not just file but also directory diff --git a/scheme-libs/racket/unison/primops.ss b/scheme-libs/racket/unison/primops.ss index 04ee983902..1102323487 100644 --- a/scheme-libs/racket/unison/primops.ss +++ b/scheme-libs/racket/unison/primops.ss @@ -1099,7 +1099,14 @@ (define (unison-FOp-Text.fromUtf8.impl.v3 b) (with-handlers ([exn:fail:contract? ; TODO proper typeLink - (lambda (e) (exception "MiscFailure" (exception->string e) ()))]) + (lambda (e) + (exception + unison-iofailure:link + (string->chunked-string + (string-append + "Invalid UTF-8 stream: " + (describe-value b))) + (exception->string e)))]) (right (string->chunked-string (bytes->string/utf-8 (chunked-bytes->bytes b)))))) ;; TODO should we convert Text -> Bytes directly without the intermediate conversions? diff --git a/scheme-libs/racket/unison/tcp.rkt b/scheme-libs/racket/unison/tcp.rkt index 2f20d1d261..28eff2fefe 100644 --- a/scheme-libs/racket/unison/tcp.rkt +++ b/scheme-libs/racket/unison/tcp.rkt @@ -4,6 +4,7 @@ racket/match racket/tcp unison/data + unison/data-info unison/chunked-seq unison/core) @@ -26,7 +27,9 @@ (define (handle-errors fn) (with-handlers - [[exn:fail:network? (lambda (e) (exception "IOFailure" (exception->string e) '()))] + [[exn:fail:network? + (lambda (e) + (exception unison-iofailure:link (exception->string e) '()))] [exn:fail:contract? (lambda (e) (exception "InvalidArguments" (exception->string e) '()))] [(lambda _ #t) (lambda (e) (exception "MiscFailure" (chunked-string->string (format "Unknown exception ~a" (exn->string e))) e))] ] (fn))) @@ -82,7 +85,9 @@ (chunked-string->string port))])]) (with-handlers - [[exn:fail:network? (lambda (e) (exception "IOFailure" (exception->string e) '()))] + [[exn:fail:network? + (lambda (e) + (exception unison-iofailure:link (exception->string e) '()))] [exn:fail:contract? (lambda (e) (exception "InvalidArguments" (exception->string e) '()))] [(lambda _ #t) (lambda (e) (exception "MiscFailure" (string->chunked-string "Unknown exception") e))] ] (let ([listener (tcp-listen (string->number port ) 4 #f (if (equal? 0 hostname) #f hostname))]) diff --git a/scheme-libs/racket/unison/tls.rkt b/scheme-libs/racket/unison/tls.rkt index 31e175814c..ff682fb764 100644 --- a/scheme-libs/racket/unison/tls.rkt +++ b/scheme-libs/racket/unison/tls.rkt @@ -6,6 +6,7 @@ (only-in racket empty?) compatibility/mlist unison/data + unison/data-info unison/chunked-seq unison/core unison/tcp @@ -111,15 +112,25 @@ (define (handle-errors fn) (with-handlers - [[exn:fail:network? (lambda (e) (exception "IOFailure" (exception->string e) '()))] + [[exn:fail:network? + (lambda (e) + (exception unison-iofailure:link (exception->string e) '()))] [exn:fail:contract? (lambda (e) (exception "InvalidArguments" (exception->string e) '()))] [(lambda err (string-contains? (exn->string err) "not valid for hostname")) - (lambda (e) (exception "IOFailure" (string->chunked-string "NameMismatch") '()))] + (lambda (e) + (exception + unison-iofailure:link + (string->chunked-string "NameMismatch") + '()))] [(lambda err (string-contains? (exn->string err) "certificate verify failed")) - (lambda (e) (exception "IOFailure" (string->chunked-string "certificate verify failed") '()))] + (lambda (e) + (exception + unison-iofailure:link + (string->chunked-string "certificate verify failed") + '()))] [(lambda _ #t) (lambda (e) (exception "MiscFailure" (string->chunked-string (format "Unknown exception ~a" (exn->string e))) e))]] (fn))) diff --git a/unison-cli/src/Unison/JitInfo.hs b/unison-cli/src/Unison/JitInfo.hs index a0e429c333..a47b3d5dc5 100644 --- a/unison-cli/src/Unison/JitInfo.hs +++ b/unison-cli/src/Unison/JitInfo.hs @@ -1,4 +1,4 @@ module Unison.JitInfo (currentRelease) where currentRelease :: String -currentRelease = "releases/0.0.10" +currentRelease = "releases/0.0.11" From aa537848c698bf2b3d3822385e1638c728bf3c69 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Mon, 4 Mar 2024 11:52:19 -0500 Subject: [PATCH 159/181] Bump gen-racket-libs version for @unison/internal --- unison-src/transcripts-manual/gen-racket-libs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unison-src/transcripts-manual/gen-racket-libs.md b/unison-src/transcripts-manual/gen-racket-libs.md index 31a118d4d6..964d6bc2ef 100644 --- a/unison-src/transcripts-manual/gen-racket-libs.md +++ b/unison-src/transcripts-manual/gen-racket-libs.md @@ -5,7 +5,7 @@ Next, we'll download the jit project and generate a few Racket files from it. ```ucm .> project.create-empty jit-setup -jit-setup/main> pull @unison/internal/releases/0.0.10 lib.jit +jit-setup/main> pull @unison/internal/releases/0.0.11 lib.jit ``` ```unison From 197ce9a60538840c63c58a725dd1f3a0315dc0d6 Mon Sep 17 00:00:00 2001 From: Arya Irani <538571+aryairani@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:13:34 -0500 Subject: [PATCH 160/181] Update ci.yaml with jit version 0.0.11 --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 80728c0db8..85c94d32ce 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,7 +21,7 @@ env: ormolu_version: "0.5.0.1" racket_version: "8.7" ucm_local_bin: "ucm-local-bin" - jit_version: "@unison/internal/releases/0.0.10" + jit_version: "@unison/internal/releases/0.0.11" jit_src_scheme: "unison-jit-src/scheme-libs/racket" jit_dist: "unison-jit-dist" jit_generator_os: ubuntu-20.04 From 3433362949f86747ce076a873b464abadaec5ab5 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 6 Mar 2024 22:52:58 -0500 Subject: [PATCH 161/181] disable windows jit integration tests until #4705 --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 85c94d32ce..69ee1220a0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -506,7 +506,7 @@ jobs: key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. - name: jit integration test ${{ matrix.os }} - if: steps.restore-jit-binaries.outputs.cache-hit != 'true' + if: runner.os != 'Windows' && steps.restore-jit-binaries.outputs.cache-hit != 'true' run: | ${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md cat unison-src/builtin-tests/jit-tests.output.md From 28dd96b6f53b86cdeda7e8a8fbd728f4f50573ae Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 6 Mar 2024 23:13:05 -0500 Subject: [PATCH 162/181] yaml: temporarily print what's in the cached system stack dir --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 69ee1220a0..4f3996b819 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -176,6 +176,9 @@ jobs: mkdir stack && cd stack curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-windows-x86_64.tar.gz | tar -xz echo "$PWD/stack-"* >> $GITHUB_PATH + # temporarily print what's in the cached system stack dir + ls C:/Users/runneradmin/AppData/Roaming/stack + ls C:/Users/runneradmin/AppData/Local/Programs/stack # One of the transcripts fails if the user's git name hasn't been set. - name: set git user info From 8926e19e793d003d73b8be9c9ffa3e8e7806a891 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 6 Mar 2024 23:13:43 -0500 Subject: [PATCH 163/181] yaml: add test caching and change a bunch of caching stuff and hope for the best --- .github/workflows/ci.yaml | 96 ++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4f3996b819..e49b06c004 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,6 +26,7 @@ env: jit_dist: "unison-jit-dist" jit_generator_os: ubuntu-20.04 base-codebase: "~/.cache/unisonlanguage/base.unison" + test_results: "test-results" jobs: ormolu: @@ -77,6 +78,8 @@ jobs: - name: tweak environment run: | ucm_local_bin="${RUNNER_TEMP//\\//}/${ucm_local_bin}" + test_results="${RUNNER_TEMP//\\//}/${test_results}" + echo "ucm_local_bin=$ucm_local_bin" >> $GITHUB_ENV if [[ ${{runner.os}} = "Windows" ]]; then echo "ucm=$ucm_local_bin/unison.exe" >> $GITHUB_ENV @@ -91,8 +94,14 @@ jobs: uses: actions/cache@v4 with: path: ${{env.ucm_local_bin}} - key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} - restore-keys: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs') }}- + key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs')}} + + - name: cache test results + id: cache-test-results + uses: actions/cache@v4 + with: + path: ${{env.test_results}} + key: unison-src-${{ matrix.os }}-${{ hashFiles('**/ci.yaml', '**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. # GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to @@ -107,20 +116,18 @@ jobs: run: | grep resolver stack.yaml | awk '{ x="resolver_short="; if (split($2,a,"-") > 2) print x a[1]; else {split($2,b,"."); print x b[1]}}' >> "$GITHUB_ENV" grep resolver stack.yaml | awk '{print "resolver="$2}' >> "$GITHUB_ENV" - # Cache ~/.stack, keyed by the contents of 'stack.yaml'. - - name: cache ~/.stack (non-Windows) - uses: actions/cache@v4 + + - name: restore ~/.stack (non-Windows) + uses: actions/cache/restore@v4 if: runner.os != 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: path: ~/.stack key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} # Fall-back to use the most recent cache for this resolver restore-keys: stack-1_${{matrix.os}}-${{env.resolver}}- - save-always: true - # Cache ~/.stack, keyed by the contents of 'stack.yaml'. - - name: cache ~/.stack (Windows) - uses: actions/cache@v4 + - name: restore ~/.stack (Windows) + uses: actions/cache/restore@v4 if: runner.os == 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: path: | @@ -129,11 +136,9 @@ jobs: key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} # Fall-back to use the most recent cache for this resolver restore-keys: stack-1_${{matrix.os}}-${{env.resolver}}- - save-always: true - # Cache each local package's ~/.stack-work for fast incremental builds in CI. - - name: cache .stack-work - uses: actions/cache@v4 + - name: restore .stack-work + uses: actions/cache/restore@v4 if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: path: | @@ -149,7 +154,6 @@ jobs: stack-work-4_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}- stack-work-4_${{matrix.os}}-${{env.resolver}}- stack-work-4_${{matrix.os}}- - save-always: true # Install stack by downloading the binary from GitHub. # The installation process differs by OS. @@ -210,6 +214,7 @@ jobs: for (( i = 0; i < $tries; i++ )); do stack build --fast --only-dependencies && break; done + - name: build if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: | @@ -222,39 +227,39 @@ jobs: # Run each test suite (tests and transcripts) - name: unison-cli test - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack build --fast --test unison-cli - name: unison-core tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack build --fast --test unison-core - name: unison-parser-typechecker tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack build --fast --test unison-parser-typechecker - name: unison-sqlite tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack build --fast --test unison-sqlite - name: unison-syntax tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack build --fast --test unison-syntax - name: unison-util-bytes tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack build --fast --test unison-util-bytes - name: unison-util-cache tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack build --fast --test unison-util-cache - name: unison-util-relation tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack build --fast --test unison-util-relation - name: round-trip-tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: | ${{env.ucm}} transcript unison-src/transcripts-round-trip/main.md ${{env.ucm}} transcript unison-src/transcripts-manual/rewrites.md @@ -264,14 +269,14 @@ jobs: unison-src/transcripts-manual/rewrites.output.md - name: transcripts - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: | ${{env.transcripts}} # Fail if any transcripts cause git diffs. git diff --ignore-cr-at-eol --exit-code unison-src/transcripts - name: cli-integration-tests - if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: steps.cache-test-results.outputs.cache-hit != 'true' run: stack exec cli-integration-tests - name: verify stack ghci startup @@ -283,20 +288,25 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.base-codebase }} - # this key probably needs something about the schema version too - key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. + # key = base transcript contents + sqlite schema version + key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md', '**/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs')}}. - name: create base.md codebase if: steps.cache-base-codebase.outputs.cache-hit != 'true' run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: interpreter tests - if: runner.os != 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' + if: runner.os != 'Windows' && steps.cache-test-results.outputs.cache-hit != 'true' run: | ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md + - name: mark tests as passing + if: steps.cache-test-results.outputs.cache-hit != 'true' + run: | + echo "tests_passed=true" >> "${{env.test_results}}" + - name: save ucm artifact uses: actions/upload-artifact@v4 with: @@ -304,6 +314,28 @@ jobs: path: ${{ env.ucm }} if-no-files-found: error + - name: save ~/.stack (non-Windows) + if: runner.os != 'Windows' + with: + path: ~/.stack + key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} + + - name: save ~/.stack (Windows) + if: runner.os == 'Windows' + with: + path: | + C:\Users\runneradmin\AppData\Roaming\stack + C:\Users\runneradmin\AppData\Local\Programs\stack + key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} + + - name: save .stack-work + uses: actions/cache/save@v4 + with: + path: | + **/.stack-work + key: stack-work-4_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}-${{hashFiles('**/*.hs')}} + + generate-jit-source: if: always() && needs.build-ucm.result == 'success' name: Generate JIT source @@ -515,7 +547,7 @@ jobs: cat unison-src/builtin-tests/jit-tests.output.md git diff --exit-code unison-src/builtin-tests/jit-tests.output.md - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ failure() }} - # timeout-minutes: 15 + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # if: ${{ failure() }} + # timeout-minutes: 15 From eb33604c45d4017fd05617490de0786911b3f59d Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 6 Mar 2024 23:16:44 -0500 Subject: [PATCH 164/181] yaml: forgot a plugin name --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e49b06c004..11ca46be88 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -316,12 +316,14 @@ jobs: - name: save ~/.stack (non-Windows) if: runner.os != 'Windows' + uses: actions/cache/save@v4 with: path: ~/.stack key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - name: save ~/.stack (Windows) if: runner.os == 'Windows' + uses: actions/cache/save@v4 with: path: | C:\Users\runneradmin\AppData\Roaming\stack From 4e22249b4f6b49bcf6f6424b5aa67c10cb396552 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 6 Mar 2024 23:30:58 -0500 Subject: [PATCH 165/181] yaml: temporarily print what's in the stack cache, better --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 11ca46be88..1e75a34066 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -181,7 +181,10 @@ jobs: curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-windows-x86_64.tar.gz | tar -xz echo "$PWD/stack-"* >> $GITHUB_PATH # temporarily print what's in the cached system stack dir + echo "C:/Users/runneradmin/AppData/Roaming/stack:" ls C:/Users/runneradmin/AppData/Roaming/stack + echo "" + echo "C:/Users/runneradmin/AppData/Local/Programs/stack:" ls C:/Users/runneradmin/AppData/Local/Programs/stack # One of the transcripts fails if the user's git name hasn't been set. From 62eab49cfc462c8ab1a4d27ebdc4bb194cdf5dd8 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 6 Mar 2024 23:40:01 -0500 Subject: [PATCH 166/181] yaml: fix test results caching? tests results are cached with the ucm binaries --- .github/workflows/ci.yaml | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1e75a34066..1aaaf53e9c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,7 +26,7 @@ env: jit_dist: "unison-jit-dist" jit_generator_os: ubuntu-20.04 base-codebase: "~/.cache/unisonlanguage/base.unison" - test_results: "test-results" + transcript_results: "transcript-results" jobs: ormolu: @@ -78,7 +78,7 @@ jobs: - name: tweak environment run: | ucm_local_bin="${RUNNER_TEMP//\\//}/${ucm_local_bin}" - test_results="${RUNNER_TEMP//\\//}/${test_results}" + transcript_results="${RUNNER_TEMP//\\//}/${transcript_results}" echo "ucm_local_bin=$ucm_local_bin" >> $GITHUB_ENV if [[ ${{runner.os}} = "Windows" ]]; then @@ -96,12 +96,12 @@ jobs: path: ${{env.ucm_local_bin}} key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs')}} - - name: cache test results - id: cache-test-results + - name: cache transcript results + id: cache-transcript-results uses: actions/cache@v4 with: - path: ${{env.test_results}} - key: unison-src-${{ matrix.os }}-${{ hashFiles('**/ci.yaml', '**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} + path: ${{env.transcript_results}} + key: transcript-results-${{ matrix.os }}-${{ hashFiles('**/ci.yaml', '**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. # GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to @@ -230,39 +230,39 @@ jobs: # Run each test suite (tests and transcripts) - name: unison-cli test - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack build --fast --test unison-cli - name: unison-core tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack build --fast --test unison-core - name: unison-parser-typechecker tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack build --fast --test unison-parser-typechecker - name: unison-sqlite tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack build --fast --test unison-sqlite - name: unison-syntax tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack build --fast --test unison-syntax - name: unison-util-bytes tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack build --fast --test unison-util-bytes - name: unison-util-cache tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack build --fast --test unison-util-cache - name: unison-util-relation tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack build --fast --test unison-util-relation - name: round-trip-tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-transcript-results.outputs.cache-hit != 'true' run: | ${{env.ucm}} transcript unison-src/transcripts-round-trip/main.md ${{env.ucm}} transcript unison-src/transcripts-manual/rewrites.md @@ -272,14 +272,14 @@ jobs: unison-src/transcripts-manual/rewrites.output.md - name: transcripts - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-transcript-results.outputs.cache-hit != 'true' run: | ${{env.transcripts}} # Fail if any transcripts cause git diffs. git diff --ignore-cr-at-eol --exit-code unison-src/transcripts - name: cli-integration-tests - if: steps.cache-test-results.outputs.cache-hit != 'true' + if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: stack exec cli-integration-tests - name: verify stack ghci startup @@ -299,16 +299,16 @@ jobs: run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: interpreter tests - if: runner.os != 'Windows' && steps.cache-test-results.outputs.cache-hit != 'true' + if: runner.os != 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' run: | ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md - - name: mark tests as passing - if: steps.cache-test-results.outputs.cache-hit != 'true' + - name: mark transcripts as passing + if: steps.cache-transcript-results.outputs.cache-hit != 'true' run: | - echo "tests_passed=true" >> "${{env.test_results}}" + echo "transcripts_passed=true" >> "${{env.transcript_results}}" - name: save ucm artifact uses: actions/upload-artifact@v4 From 47c18264535d8b909bc640e8aea9f77fece90452 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 6 Mar 2024 23:48:16 -0500 Subject: [PATCH 167/181] yaml: bikeshed variable names and hope nothing broke --- .github/workflows/ci.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1aaaf53e9c..7433ad5446 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,7 +26,8 @@ env: jit_dist: "unison-jit-dist" jit_generator_os: ubuntu-20.04 base-codebase: "~/.cache/unisonlanguage/base.unison" - transcript_results: "transcript-results" + # refers to all tests that depend on **/unison-src/** + unison_src_test_results: "unison-src-test-results" jobs: ormolu: @@ -78,7 +79,7 @@ jobs: - name: tweak environment run: | ucm_local_bin="${RUNNER_TEMP//\\//}/${ucm_local_bin}" - transcript_results="${RUNNER_TEMP//\\//}/${transcript_results}" + unison_src_test_results="${RUNNER_TEMP//\\//}/${unison_src_test_results}" echo "ucm_local_bin=$ucm_local_bin" >> $GITHUB_ENV if [[ ${{runner.os}} = "Windows" ]]; then @@ -100,7 +101,7 @@ jobs: id: cache-transcript-results uses: actions/cache@v4 with: - path: ${{env.transcript_results}} + path: ${{env.unison_src_test_results}} key: transcript-results-${{ matrix.os }}-${{ hashFiles('**/ci.yaml', '**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. @@ -299,7 +300,8 @@ jobs: run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md - name: interpreter tests - if: runner.os != 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' + # this one should be re-run if the ucm binaries have changed or unison-src/ has changed + if: runner.os != 'Windows' && (steps.cache-ucm-binaries.outputs.cache-hit != 'true' || steps.cache-transcript-results.outputs.cache-hit != 'true') run: | ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md @@ -308,7 +310,7 @@ jobs: - name: mark transcripts as passing if: steps.cache-transcript-results.outputs.cache-hit != 'true' run: | - echo "transcripts_passed=true" >> "${{env.transcript_results}}" + echo "passing=true" >> "${{env.unison_src_test_results}}" - name: save ucm artifact uses: actions/upload-artifact@v4 From 4a08bedee466ab130d74ef9450e5d1dbf73fe2ff Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Wed, 6 Mar 2024 23:54:19 -0500 Subject: [PATCH 168/181] yaml: these were supposed to be part of a previous commit --- .github/workflows/ci.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7433ad5446..2d681a3f4e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -97,12 +97,12 @@ jobs: path: ${{env.ucm_local_bin}} key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs')}} - - name: cache transcript results - id: cache-transcript-results + - name: cache unison-src test results + id: cache-unison-src-test-results uses: actions/cache@v4 with: path: ${{env.unison_src_test_results}} - key: transcript-results-${{ matrix.os }}-${{ hashFiles('**/ci.yaml', '**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} + key: unison-src-test-results-${{ matrix.os }}-${{ hashFiles('**/ci.yaml', '**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. # GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to @@ -263,7 +263,7 @@ jobs: run: stack build --fast --test unison-util-relation - name: round-trip-tests - if: steps.cache-transcript-results.outputs.cache-hit != 'true' + if: steps.cache-unison-src-test-results.outputs.cache-hit != 'true' run: | ${{env.ucm}} transcript unison-src/transcripts-round-trip/main.md ${{env.ucm}} transcript unison-src/transcripts-manual/rewrites.md @@ -273,7 +273,7 @@ jobs: unison-src/transcripts-manual/rewrites.output.md - name: transcripts - if: steps.cache-transcript-results.outputs.cache-hit != 'true' + if: steps.cache-unison-src-test-results.outputs.cache-hit != 'true' run: | ${{env.transcripts}} # Fail if any transcripts cause git diffs. @@ -301,14 +301,14 @@ jobs: - name: interpreter tests # this one should be re-run if the ucm binaries have changed or unison-src/ has changed - if: runner.os != 'Windows' && (steps.cache-ucm-binaries.outputs.cache-hit != 'true' || steps.cache-transcript-results.outputs.cache-hit != 'true') + if: runner.os != 'Windows' && (steps.cache-ucm-binaries.outputs.cache-hit != 'true' || steps.cache-unison-src-test-results.outputs.cache-hit != 'true') run: | ${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md cat unison-src/builtin-tests/interpreter-tests.output.md git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md - name: mark transcripts as passing - if: steps.cache-transcript-results.outputs.cache-hit != 'true' + if: steps.cache-unison-src-test-results.outputs.cache-hit != 'true' run: | echo "passing=true" >> "${{env.unison_src_test_results}}" From 20a0e734a6e7b0781581b03d94ec766d10e83528 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 7 Mar 2024 00:00:50 -0500 Subject: [PATCH 169/181] yaml: call generateSchemeBoot directly from `@unison/internal` --- .github/workflows/ci.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2d681a3f4e..521b42901e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -393,13 +393,6 @@ jobs: jit-setup/main> pull ${{ env.jit_version }} lib.jit ``` ```unison - generateSchemeBoot dir = do - saveDataInfoFile dir dataInfos - saveBaseFile dir bootSpec - saveWrapperFile dir simpleWrapperSpec - saveBaseFile dir builtinSpec - saveWrapperFile dir compoundWrapperSpec - go = generateSchemeBoot "${{ env.jit_src_scheme }}" ``` ```ucm From e026d1336c59f2658f067964b79db1d5928a3577 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Thu, 7 Mar 2024 00:11:26 -0500 Subject: [PATCH 170/181] yaml: cache key vars for invalidation --- .github/workflows/ci.yaml | 44 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 521b42901e..0ddce2c515 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,9 +26,19 @@ env: jit_dist: "unison-jit-dist" jit_generator_os: ubuntu-20.04 base-codebase: "~/.cache/unisonlanguage/base.unison" + # refers to all tests that depend on **/unison-src/** unison_src_test_results: "unison-src-test-results" + # cache key versions, increment to invalidate one + ucm-binaries-cache-key-version: 1 + unison-src-test-results-cache-key-version: 1 + stack-cache-key-version: 1 + stack-work-cache-key-version: 4 + base-codebase-cache-key-version: 1 + jit-src-cache-key-version: 1 + jit-dist-cache-key-version: 1 + jobs: ormolu: runs-on: ubuntu-20.04 @@ -95,14 +105,14 @@ jobs: uses: actions/cache@v4 with: path: ${{env.ucm_local_bin}} - key: ucm-${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs')}} + key: ucm-${{env.ucm-binaries-cache-key-version}}_${{ matrix.os }}-${{ hashFiles('**/stack.yaml', '**/package.yaml', '**/*.hs')}} - name: cache unison-src test results id: cache-unison-src-test-results uses: actions/cache@v4 with: path: ${{env.unison_src_test_results}} - key: unison-src-test-results-${{ matrix.os }}-${{ hashFiles('**/ci.yaml', '**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} + key: unison-src-test-results-${{env.unison-src-test-results-cache-key-version}}_${{ matrix.os }}-${{ hashFiles('**/ci.yaml', '**/stack.yaml', '**/package.yaml', '**/*.hs')}}-${{ hashFiles('**/unison-src/**') }} # The number towards the beginning of the cache keys allow you to manually avoid using a previous cache. # GitHub will automatically delete caches that haven't been accessed in 7 days, but there is no way to @@ -123,9 +133,9 @@ jobs: if: runner.os != 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: path: ~/.stack - key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} + key: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} # Fall-back to use the most recent cache for this resolver - restore-keys: stack-1_${{matrix.os}}-${{env.resolver}}- + restore-keys: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}- - name: restore ~/.stack (Windows) uses: actions/cache/restore@v4 @@ -134,9 +144,9 @@ jobs: path: | C:\Users\runneradmin\AppData\Roaming\stack C:\Users\runneradmin\AppData\Local\Programs\stack - key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} + key: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} # Fall-back to use the most recent cache for this resolver - restore-keys: stack-1_${{matrix.os}}-${{env.resolver}}- + restore-keys: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}- - name: restore .stack-work uses: actions/cache/restore@v4 @@ -150,11 +160,11 @@ jobs: # recent branch cache. # Then it will save a new cache at this commit sha, which should be used by # the next build on this branch. - key: stack-work-4_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}-${{hashFiles('**/*.hs')}} + key: stack-work-${{env.stack-work-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}-${{hashFiles('**/*.hs')}} restore-keys: | - stack-work-4_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}- - stack-work-4_${{matrix.os}}-${{env.resolver}}- - stack-work-4_${{matrix.os}}- + stack-work-${{env.stack-work-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}- + stack-work-${{env.stack-work-cache-key-version}}_${{matrix.os}}-${{env.resolver}}- + stack-work-${{env.stack-work-cache-key-version}}_${{matrix.os}}- # Install stack by downloading the binary from GitHub. # The installation process differs by OS. @@ -293,7 +303,7 @@ jobs: with: path: ${{ env.base-codebase }} # key = base transcript contents + sqlite schema version - key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md', '**/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs')}}. + key: base.unison-${{env.base-codebase-cache-key-version}}_${{hashFiles('**/unison-src/builtin-tests/base.md', '**/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs')}}. - name: create base.md codebase if: steps.cache-base-codebase.outputs.cache-hit != 'true' @@ -324,7 +334,7 @@ jobs: uses: actions/cache/save@v4 with: path: ~/.stack - key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} + key: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - name: save ~/.stack (Windows) if: runner.os == 'Windows' @@ -333,14 +343,14 @@ jobs: path: | C:\Users\runneradmin\AppData\Roaming\stack C:\Users\runneradmin\AppData\Local\Programs\stack - key: stack-1_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} + key: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - name: save .stack-work uses: actions/cache/save@v4 with: path: | **/.stack-work - key: stack-work-4_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}-${{hashFiles('**/*.hs')}} + key: stack-work-${{env.stack-work-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}}-${{hashFiles('**/*.hs')}} generate-jit-source: @@ -358,7 +368,7 @@ jobs: if: runner.os == 'Linux' with: path: ${{ env.jit_src_scheme }} - key: jit_src_scheme.racket_${{env.racket_version}}.jit_${{env.jit_version}} + key: jit_src_scheme-${{env.jit-src-cache-key-version}}.racket_${{env.racket_version}}.jit_${{env.jit_version}} - name: check source exists id: jit_src_exists @@ -474,7 +484,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.jit_dist }} - key: jit_dist.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} + key: jit_dist-${{env.jit-dist-cache-key-version}}.racket_${{ env.racket_version }}.jit_${{ env.jit_version }} - name: Cache Racket dependencies if: steps.restore-jit-binaries.outputs.cache-hit != 'true' @@ -538,7 +548,7 @@ jobs: uses: actions/cache/restore@v4 with: path: ${{ env.base-codebase}} - key: base.unison_${{hashFiles('**/unison-src/builtin-tests/base.md')}}. + key: base.unison-${{env.base-codebase-cache-key-version}}_${{hashFiles('**/unison-src/builtin-tests/base.md', '**/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs')}}. - name: jit integration test ${{ matrix.os }} if: runner.os != 'Windows' && steps.restore-jit-binaries.outputs.cache-hit != 'true' From 4dc10233ee73aeea2b68cd4f8e4c2506af974034 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 8 Mar 2024 11:52:02 -0500 Subject: [PATCH 171/181] CI docs --- .github/workflows/ci.md | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/ci.md diff --git a/.github/workflows/ci.md b/.github/workflows/ci.md new file mode 100644 index 0000000000..42a4ec9731 --- /dev/null +++ b/.github/workflows/ci.md @@ -0,0 +1,88 @@ +The new CI workflow builds `ucm`, generates racket source, and generates `unison-runtime` (aka `ucr`). + +At a high level, the CI process is: +1. On all platforms, build `unisonweb/unison` Haskell program and run tests; save the resulting binaries as build artifacts +2. On Ubuntu, generate and save the Racket sources as a build artifact +3. On all platforms, build the `unison-runtime` Racket program save the resulting binaries as build artifacts. + +### `env` vars at the top of `CI.yaml`: +Some version numbers that are used during CI: +- `ormolu_version: "0.5.0.1"` +- `racket_version: "8.7"` +- `jit_version: "@unison/internal/releases/0.0.11"` + +Some cached directories: + - `ucm_local_bin` a temp path for caching a built `ucm` + - `jit_src_scheme` a temp path for caching generated jit sources + - `unison-jit-dist` + - `base-codebase` a codebase path for caching a codebase generated by `unison-src/builtin-tests/base.md` + - `unison_src_test_results` a temp path for caching the result of passing tests that depend on `unison-src/`, which includes: + - `round-trip-tests` + - `transcripts` + - `unison-src/builtin-tests/interpreter-tests.md` + +`jit_generator_os: ubuntu-20.04` + - afaik, the jit sources are generated in a platform-independent way, so we just choose one platform to generate them on. + +`*-cache-key-version` — increment one of these to invalidate its corresponding cache: + - `ucm-binaries` + - `unison-src-test-results` + - `stack` + - `stack-work` + - `base-codebase` + - `jit-src` + - `jit-dist` + +### Cached directories: + +A built `ucm` is cached in `ucm_local_bin` after a successful build and Haskell tests pass. +- The **cache key** includes the os, `stack.yaml`, any `package.yaml`, and any `.hs` file. +- On an exact cache hit, these steps are skipped, otherwise they are run: + - restore `.stack` + - restore `.stack-work` + - install `stack` + - build `ucm` dependencies + - build `ucm` + - `unison-cli` tests + - `unison-core` tests + - `unison-parser-typechecker` tests + - `unison-sqlite` tests + - `unison-syntax` tests + - `unison-util-bytes` tests + - `unison-util-cache` tests + - `unison-util-relation` tests + - `cli-integration-tests` + - verification of `stack ghci` startup + - `interpreter-tests.md` + +A bit is cached in `unison_src_test_results` after non-Haskell tests in the `unison` repo pass. +- The **cache key** includes os, `stack.yaml`, any `package.yaml`, any `.hs` file, and any file in `unison-src/` +- On an exact cache hit, these steps are skipped, otherwise they are run: + - `round-trip-tests` + - `transcripts` + - `unison-src/builtin-tests/interpreter-tests.md` +- If all steps suceed, the `unison_src_test_results` bit is saved. + +JIT sources are cached in `jit_src_scheme` if the `generate-jit-source` job completes. +- The **cache key** includes the version of Racket, and the release version of `@unison/internal`. +- If the cache contains `{data-info, boot-generated, simple-wrappers, builtin-generated, compound-wrappers}.ss`, then these steps are skipped, otherwise they are run: + - "create transcript" to produce pull `@unison/internal` and run `generateSchemeBoot`. + - download `ucm artifact` saved in the previous step + - set `ucm` permissions + - checkout `unison` repo, which includes some static scheme and racket files. + - run the previously generated transcript +- If all steps succeed, the `jit_src_scheme` cache is saved. + +JIT binaries are cached in `jit_dist` if the `build-jit-binary` job completes. +- The **cache key** includes the version of Racket, and the release version of `@unison/internal`. +- On an exact cache hit, these steps are skipped, otherwise they are run: + - Restore Racket dependencies + - setup Racket + - restore apt cache (Linux only) + - download jit source from previous job + - use `raco` to build jit binary + - download `ucm` artifact from previous job + - set `ucm` permissions + - restore `base` codebase saved in previous job + - jit integration test +- If all of these steps succeed, the `jit_dist` cache is saved. From 98eb284b332a2de9413746fdd3eb5f0802b90769 Mon Sep 17 00:00:00 2001 From: Arya Irani <538571+aryairani@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:53:50 -0500 Subject: [PATCH 172/181] Update ci.md --- .github/workflows/ci.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.md b/.github/workflows/ci.md index 42a4ec9731..1714e37083 100644 --- a/.github/workflows/ci.md +++ b/.github/workflows/ci.md @@ -35,6 +35,7 @@ Some cached directories: ### Cached directories: +#### `ucm_local_bin` A built `ucm` is cached in `ucm_local_bin` after a successful build and Haskell tests pass. - The **cache key** includes the os, `stack.yaml`, any `package.yaml`, and any `.hs` file. - On an exact cache hit, these steps are skipped, otherwise they are run: @@ -55,6 +56,7 @@ A built `ucm` is cached in `ucm_local_bin` after a successful build and Haskell - verification of `stack ghci` startup - `interpreter-tests.md` +#### `unison_src_test_results` A bit is cached in `unison_src_test_results` after non-Haskell tests in the `unison` repo pass. - The **cache key** includes os, `stack.yaml`, any `package.yaml`, any `.hs` file, and any file in `unison-src/` - On an exact cache hit, these steps are skipped, otherwise they are run: @@ -63,6 +65,7 @@ A bit is cached in `unison_src_test_results` after non-Haskell tests in the `uni - `unison-src/builtin-tests/interpreter-tests.md` - If all steps suceed, the `unison_src_test_results` bit is saved. +#### `jit_src_scheme` JIT sources are cached in `jit_src_scheme` if the `generate-jit-source` job completes. - The **cache key** includes the version of Racket, and the release version of `@unison/internal`. - If the cache contains `{data-info, boot-generated, simple-wrappers, builtin-generated, compound-wrappers}.ss`, then these steps are skipped, otherwise they are run: @@ -73,6 +76,7 @@ JIT sources are cached in `jit_src_scheme` if the `generate-jit-source` job comp - run the previously generated transcript - If all steps succeed, the `jit_src_scheme` cache is saved. +#### `jit_dist` JIT binaries are cached in `jit_dist` if the `build-jit-binary` job completes. - The **cache key** includes the version of Racket, and the release version of `@unison/internal`. - On an exact cache hit, these steps are skipped, otherwise they are run: From b0e8c768fe4156e01538431b267cfb98f45bbc16 Mon Sep 17 00:00:00 2001 From: Arya Irani <538571+aryairani@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:56:57 -0500 Subject: [PATCH 173/181] Update ci.md --- .github/workflows/ci.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.md b/.github/workflows/ci.md index 1714e37083..fcf870cee1 100644 --- a/.github/workflows/ci.md +++ b/.github/workflows/ci.md @@ -65,6 +65,10 @@ A bit is cached in `unison_src_test_results` after non-Haskell tests in the `uni - `unison-src/builtin-tests/interpreter-tests.md` - If all steps suceed, the `unison_src_test_results` bit is saved. +#### `base-codebase` +This stores the result of `base.md`, which can be reused later to save the cost of a `pull`. +No steps are skipped on a cache hit; however, a second `pull` will mostly be a no-op. + #### `jit_src_scheme` JIT sources are cached in `jit_src_scheme` if the `generate-jit-source` job completes. - The **cache key** includes the version of Racket, and the release version of `@unison/internal`. From 236d895f951886259b261bfba50bfeca98e4e5ec Mon Sep 17 00:00:00 2001 From: Arya Irani <538571+aryairani@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:58:09 -0500 Subject: [PATCH 174/181] Update ci.md --- .github/workflows/ci.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.md b/.github/workflows/ci.md index fcf870cee1..9a9bf83bcf 100644 --- a/.github/workflows/ci.md +++ b/.github/workflows/ci.md @@ -1,4 +1,4 @@ -The new CI workflow builds `ucm`, generates racket source, and generates `unison-runtime` (aka `ucr`). +The new CI workflow builds `ucm`, generates racket source, and generates `unison-runtime` (aka `ucr`), saving them all as build artifacts. At a high level, the CI process is: 1. On all platforms, build `unisonweb/unison` Haskell program and run tests; save the resulting binaries as build artifacts From db3e48f6b8d8c232913a3d16202240a71b791c28 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 8 Mar 2024 13:01:24 -0500 Subject: [PATCH 175/181] yaml: clarify that you shouldn't have to invalidate build caches --- .github/workflows/ci.md | 2 +- .github/workflows/ci.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.md b/.github/workflows/ci.md index 42a4ec9731..e585deb671 100644 --- a/.github/workflows/ci.md +++ b/.github/workflows/ci.md @@ -24,7 +24,7 @@ Some cached directories: `jit_generator_os: ubuntu-20.04` - afaik, the jit sources are generated in a platform-independent way, so we just choose one platform to generate them on. -`*-cache-key-version` — increment one of these to invalidate its corresponding cache: +`*-cache-key-version` — increment one of these to invalidate its corresponding cache, though you shouldn't have to: - `ucm-binaries` - `unison-src-test-results` - `stack` diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0ddce2c515..bc82f8c8ce 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,7 @@ env: # refers to all tests that depend on **/unison-src/** unison_src_test_results: "unison-src-test-results" - # cache key versions, increment to invalidate one + # cache key versions, increment to invalidate one, though you aren't expected to have to. ucm-binaries-cache-key-version: 1 unison-src-test-results-cache-key-version: 1 stack-cache-key-version: 1 From b7530a56ac8101e7bd9bb2a6d4a35329136a4b72 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 8 Mar 2024 13:11:49 -0500 Subject: [PATCH 176/181] remove `compile.native.{fetch,genlibs}` commands existing ucm commands can be used instead, i.e. `gen-racket-libs.md` --- .../src/Unison/Codebase/Editor/HandleInput.hs | 121 +----------------- .../src/Unison/Codebase/Editor/Input.hs | 4 - .../src/Unison/CommandLine/InputPatterns.hs | 70 ---------- unison-cli/src/Unison/JitInfo.hs | 4 - unison-cli/unison-cli.cabal | 1 - .../transcripts-manual/gen-racket-libs.md | 7 - .../gen-racket-libs.output.md | 55 ++++++-- 7 files changed, 46 insertions(+), 216 deletions(-) delete mode 100644 unison-cli/src/Unison/JitInfo.hs diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs index 37e0116f47..9556d3f821 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs @@ -1,10 +1,7 @@ {-# HLINT ignore "Use tuple-section" #-} {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} -module Unison.Codebase.Editor.HandleInput - ( loop, - ) -where +module Unison.Codebase.Editor.HandleInput (loop) where -- TODO: Don't import backend @@ -19,7 +16,6 @@ import Data.List.Extra (nubOrd) import Data.List.NonEmpty (NonEmpty) import Data.List.NonEmpty qualified as Nel import Data.Map qualified as Map -import Data.Sequence qualified as Seq import Data.Set qualified as Set import Data.Set.NonEmpty (NESet) import Data.Set.NonEmpty qualified as NESet @@ -27,8 +23,6 @@ import Data.Text qualified as Text import Data.These (These (..)) import Data.Time (UTCTime) import Data.Tuple.Extra (uncurry3) -import System.Directory (XdgDirectory (..), createDirectoryIfMissing, doesFileExist, getXdgDirectory) -import System.FilePath (()) import Text.Megaparsec qualified as Megaparsec import U.Codebase.Branch.Diff qualified as V2Branch.Diff import U.Codebase.Causal qualified as V2Causal @@ -47,7 +41,6 @@ import Unison.Cli.MonadUtils qualified as Cli import Unison.Cli.NamesUtils qualified as Cli import Unison.Cli.PrettyPrintUtils qualified as Cli import Unison.Cli.ProjectUtils qualified as ProjectUtils -import Unison.Cli.TypeCheck (typecheckTerm) import Unison.Codebase (Codebase) import Unison.Codebase qualified as Codebase import Unison.Codebase.Branch (Branch (..), Branch0 (..)) @@ -89,7 +82,7 @@ import Unison.Codebase.Editor.HandleInput.ReleaseDraft (handleReleaseDraft) import Unison.Codebase.Editor.HandleInput.Run (handleRun) import Unison.Codebase.Editor.HandleInput.RuntimeUtils qualified as RuntimeUtils import Unison.Codebase.Editor.HandleInput.ShowDefinition (showDefinitions) -import Unison.Codebase.Editor.HandleInput.TermResolution (resolveMainRef, resolveTermRef) +import Unison.Codebase.Editor.HandleInput.TermResolution (resolveMainRef) import Unison.Codebase.Editor.HandleInput.Tests qualified as Tests import Unison.Codebase.Editor.HandleInput.UI (openUI) import Unison.Codebase.Editor.HandleInput.Update (doSlurpAdds, handleUpdate) @@ -100,7 +93,6 @@ import Unison.Codebase.Editor.Input qualified as Input import Unison.Codebase.Editor.Output import Unison.Codebase.Editor.Output qualified as Output import Unison.Codebase.Editor.Output.DumpNamespace qualified as Output.DN -import Unison.Codebase.Editor.RemoteRepo (ReadRemoteNamespace (..)) import Unison.Codebase.Editor.RemoteRepo qualified as RemoteRepo import Unison.Codebase.Editor.Slurp qualified as Slurp import Unison.Codebase.Editor.SlurpResult qualified as SlurpResult @@ -116,13 +108,11 @@ import Unison.Codebase.Path.Parse qualified as Path import Unison.Codebase.Runtime qualified as Runtime import Unison.Codebase.ShortCausalHash qualified as SCH import Unison.Codebase.SqliteCodebase.Conversions qualified as Conversions -import Unison.Codebase.SyncMode qualified as SyncMode import Unison.Codebase.TermEdit (TermEdit (..)) import Unison.Codebase.TermEdit qualified as TermEdit import Unison.Codebase.TermEdit.Typing qualified as TermEdit import Unison.Codebase.TypeEdit (TypeEdit) import Unison.Codebase.TypeEdit qualified as TypeEdit -import Unison.Codebase.Verbosity qualified as Verbosity import Unison.CommandLine.BranchRelativePath (BranchRelativePath) import Unison.CommandLine.Completion qualified as Completion import Unison.CommandLine.DisplayValues qualified as DisplayValues @@ -154,13 +144,12 @@ import Unison.PrettyPrintEnv.Names qualified as PPE import Unison.PrettyPrintEnvDecl qualified as PPE hiding (biasTo, empty) import Unison.PrettyPrintEnvDecl qualified as PPED import Unison.PrettyPrintEnvDecl.Names qualified as PPED -import Unison.Project (ProjectAndBranch (..), ProjectBranchNameOrLatestRelease (..)) +import Unison.Project (ProjectAndBranch (..)) import Unison.Project.Util (projectContextFromPath) import Unison.Reference (Reference, TermReference) import Unison.Reference qualified as Reference import Unison.Referent (Referent) import Unison.Referent qualified as Referent -import Unison.Result qualified as Result import Unison.Runtime.IOSource qualified as IOSource import Unison.Server.Backend (ShallowListEntry (..)) import Unison.Server.Backend qualified as Backend @@ -175,19 +164,17 @@ import Unison.Share.Codeserver qualified as Codeserver import Unison.ShortHash qualified as SH import Unison.Sqlite qualified as Sqlite import Unison.Symbol (Symbol) -import Unison.Syntax.HashQualified qualified as HQ (parseTextWith, toText, unsafeParseText) +import Unison.Syntax.HashQualified qualified as HQ (parseTextWith, toText) import Unison.Syntax.Lexer qualified as L import Unison.Syntax.Lexer qualified as Lexer import Unison.Syntax.Name qualified as Name (toText, toVar, unsafeParseVar) import Unison.Syntax.NameSegment qualified as NameSegment (toEscapedText) import Unison.Syntax.Parser qualified as Parser -import Unison.Syntax.TermPrinter qualified as TP import Unison.Term (Term) import Unison.Term qualified as Term import Unison.Type (Type) import Unison.Type qualified as Type import Unison.Type.Names qualified as Type -import Unison.Typechecker qualified as Typechecker import Unison.UnisonFile (TypecheckedUnisonFile) import Unison.UnisonFile qualified as UF import Unison.UnisonFile.Names qualified as UF @@ -205,7 +192,6 @@ import Unison.Var (Var) import Unison.Var qualified as Var import Unison.WatchKind qualified as WK import UnliftIO.Directory qualified as Directory -import Witch (unsafeFrom) ------------------------------------------------------------------------------------------------------------------------ -- Main loop @@ -975,10 +961,6 @@ loop e = do CompileSchemeI output main -> doCompile True (Text.unpack output) main ExecuteSchemeI main args -> handleRun True main args - GenSchemeLibsI mdir -> - doGenerateSchemeBoot True Nothing mdir - FetchSchemeCompilerI name branch -> - doFetchCompiler name branch IOTestI main -> Tests.handleIOTest main IOTestAllI -> Tests.handleAllIOTests -- UpdateBuiltinsI -> do @@ -1329,11 +1311,6 @@ inputDescription input = ExecuteSchemeI nm args -> pure $ "run.native " <> Text.unwords (nm : fmap Text.pack args) CompileSchemeI fi nm -> pure ("compile.native " <> HQ.toText nm <> " " <> fi) - GenSchemeLibsI mdir -> - pure $ - "compile.native.genlibs" <> Text.pack (maybe "" (" " ++) mdir) - FetchSchemeCompilerI name branch -> - pure ("compile.native.fetch" <> Text.pack name <> " " <> Text.pack branch) CreateAuthorI id name -> pure ("create.author " <> NameSegment.toEscapedText id <> " " <> name) RemoveTermReplacementI src p0 -> do p <- opatch p0 @@ -1915,96 +1892,6 @@ searchBranchScored names0 score queries = pair qn = (\score -> (Just score, result)) <$> score qn (Name.toText name) -compilerPath :: Path.Path' -compilerPath = Path.Path' {Path.unPath' = Left abs} - where - segs = ["unison", "internal"] - rootPath = Path.Path {Path.toSeq = Seq.fromList segs} - abs = Path.Absolute {Path.unabsolute = rootPath} - -doFetchCompiler :: String -> String -> Cli () -doFetchCompiler username branch = - doPullRemoteBranch sourceTarget SyncMode.Complete Input.PullWithoutHistory Verbosity.Silent - where - -- fetching info - prj = - These - (unsafeFrom @Text $ "@" <> Text.pack username <> "/internal") - (ProjectBranchNameOrLatestRelease'Name . unsafeFrom @Text $ Text.pack branch) - - sourceTarget = - PullSourceTarget2 - (ReadShare'ProjectBranch prj) - (This compilerPath) - -getCacheDir :: Cli String -getCacheDir = liftIO $ getXdgDirectory XdgCache "unisonlanguage" - -getSchemeGenLibDir :: Cli String -getSchemeGenLibDir = - Cli.getConfig "SchemeLibs.Generated" >>= \case - Just dir -> pure dir - Nothing -> ( "scheme-libs") <$> getCacheDir - -doGenerateSchemeBoot :: - Bool -> Maybe PPE.PrettyPrintEnv -> Maybe String -> Cli () -doGenerateSchemeBoot force mppe mdir = do - ppe <- maybe (PPED.suffixifiedPPE <$> Cli.currentPrettyPrintEnvDecl) pure mppe - dir <- maybe getSchemeGenLibDir pure mdir - let bootf = dir "unison" "boot-generated.ss" - swrapf = dir "unison" "simple-wrappers.ss" - binf = dir "unison" "builtin-generated.ss" - cwrapf = dir "unison" "compound-wrappers.ss" - dinfof = dir "unison" "data-info.ss" - dirTm = Term.text a (Text.pack dir) - liftIO $ createDirectoryIfMissing True dir - saveData <- Term.ref a <$> resolveTermRef sdName - saveBase <- Term.ref a <$> resolveTermRef sbName - saveWrap <- Term.ref a <$> resolveTermRef swName - gen ppe saveData dinfof dirTm dinfoName - gen ppe saveBase bootf dirTm bootName - gen ppe saveWrap swrapf dirTm simpleWrapName - gen ppe saveBase binf dirTm builtinName - gen ppe saveWrap cwrapf dirTm compoundWrapName - where - a = External - - sbName = HQ.unsafeParseText ".unison.internal.compiler.scheme.saveBaseFile" - swName = HQ.unsafeParseText ".unison.internal.compiler.scheme.saveWrapperFile" - sdName = HQ.unsafeParseText ".unison.internal.compiler.scheme.saveDataInfoFile" - dinfoName = HQ.unsafeParseText ".unison.internal.compiler.scheme.dataInfos" - bootName = HQ.unsafeParseText ".unison.internal.compiler.scheme.bootSpec" - builtinName = HQ.unsafeParseText ".unison.internal.compiler.scheme.builtinSpec" - simpleWrapName = - HQ.unsafeParseText ".unison.internal.compiler.scheme.simpleWrapperSpec" - compoundWrapName = - HQ.unsafeParseText ".unison.internal.compiler.scheme.compoundWrapperSpec" - - gen ppe save file dir nm = - liftIO (doesFileExist file) >>= \b -> when (not b || force) do - spec <- Term.ref a <$> resolveTermRef nm - let make = Term.apps' save [dir, spec] - typecheckAndEval ppe make - -typecheckAndEval :: PPE.PrettyPrintEnv -> Term Symbol Ann -> Cli () -typecheckAndEval ppe tm = do - Cli.Env {codebase, runtime} <- ask - let mty = Runtime.mainType runtime - Cli.runTransaction (typecheckTerm codebase (Term.delay a tm)) >>= \case - -- Type checking succeeded - Result.Result _ (Just ty) - | Typechecker.fitsScheme ty mty -> - () <$ RuntimeUtils.evalUnisonTerm False ppe False tm - | otherwise -> - Cli.returnEarly $ BadMainFunction "run" rendered ty ppe [mty] - Result.Result notes Nothing -> do - currentPath <- Cli.getCurrentPath - let tes = [err | Result.TypeError err <- toList notes] - Cli.returnEarly (TypeErrors currentPath rendered ppe tes) - where - a = External - rendered = Text.pack (P.toPlainUnbroken $ TP.pretty ppe tm) - doCompile :: Bool -> String -> HQ.HashQualified Name -> Cli () doCompile native output main = do Cli.Env {codebase, runtime, nativeRuntime} <- ask diff --git a/unison-cli/src/Unison/Codebase/Editor/Input.hs b/unison-cli/src/Unison/Codebase/Editor/Input.hs index 7b315b8f6e..db52940cc9 100644 --- a/unison-cli/src/Unison/Codebase/Editor/Input.hs +++ b/unison-cli/src/Unison/Codebase/Editor/Input.hs @@ -185,10 +185,6 @@ data Input ExecuteSchemeI Text [String] | -- compile to a scheme file CompileSchemeI Text (HQ.HashQualified Name) - | -- generate scheme libraries, optional target directory - GenSchemeLibsI (Maybe String) - | -- fetch scheme compiler from a given username and branch - FetchSchemeCompilerI String String | TestI TestInput | CreateAuthorI NameSegment {- identifier -} Text {- name -} | -- Display provided definitions. diff --git a/unison-cli/src/Unison/CommandLine/InputPatterns.hs b/unison-cli/src/Unison/CommandLine/InputPatterns.hs index 44827e0e02..ca94f78b4e 100644 --- a/unison-cli/src/Unison/CommandLine/InputPatterns.hs +++ b/unison-cli/src/Unison/CommandLine/InputPatterns.hs @@ -52,7 +52,6 @@ import Unison.CommandLine.FZFResolvers qualified as Resolvers import Unison.CommandLine.InputPattern (ArgumentType (..), InputPattern (InputPattern), IsOptional (..), unionSuggestions) import Unison.CommandLine.InputPattern qualified as I import Unison.HashQualified qualified as HQ -import Unison.JitInfo qualified as JitInfo import Unison.Name (Name) import Unison.Name qualified as Name import Unison.NameSegment (NameSegment) @@ -2540,73 +2539,6 @@ compileScheme = Input.CompileSchemeI (Text.pack file) <$> parseHashQualifiedName main _ -> Left $ showPatternHelp compileScheme -schemeLibgen :: InputPattern -schemeLibgen = - InputPattern - "compile.native.genlibs" - [] - I.Visible - [("target directory", Optional, filePathArg)] - ( P.wrapColumn2 - [ ( makeExample schemeLibgen ["[targetDir]"], - "Generates libraries necessary for scheme compilation.\n\n\ - \There is no need to run this before" - <> P.group (makeExample compileScheme []) - <> "as\ - \ the latter will check if the libraries are missing and\ - \ auto-generate them. However, this will generate the\ - \ libraries even if their files already exist, so if the\ - \ compiler has been upgraded, this can be used to ensure\ - \ the generated libraries are up to date." - ) - ] - ) - \case - [] -> pure $ Input.GenSchemeLibsI Nothing - [dir] -> pure . Input.GenSchemeLibsI $ Just dir - _ -> Left $ showPatternHelp schemeLibgen - -fetchScheme :: InputPattern -fetchScheme = - InputPattern - "compile.native.fetch" - [] - I.Visible - [("name", Optional, noCompletionsArg), ("branch", Optional, noCompletionsArg)] - ( P.wrapColumn2 - [ ( makeExample fetchScheme [], - P.lines . fmap P.wrap $ - [ "Fetches the unison library for compiling to scheme.", - "This is done automatically when" - <> P.group (makeExample compileScheme []) - <> "is run if the library is not already in the\ - \ standard location (unison.internal). However,\ - \ this command will force a pull even if the\ - \ library already exists.", - "You can also specify a user and branch name to pull\ - \ from in order to use an alternate version of the\ - \ unison compiler (for development purposes, for\ - \ example).", - "The default user is `unison`. The default branch\ - \ for the `unison` user is a specified latest\ - \ version of the compiler for stability. The\ - \ default branch for other uses is `main`. The\ - \ command fetches code from a project:", - P.indentN 2 ("@user/internal/branch") - ] - ) - ] - ) - \case - [] -> pure (Input.FetchSchemeCompilerI "unison" JitInfo.currentRelease) - [name] -> pure (Input.FetchSchemeCompilerI name branch) - where - branch - | name == "unison" = JitInfo.currentRelease - | otherwise = "main" - [name, branch] -> pure (Input.FetchSchemeCompilerI name branch) - _ -> Left $ showPatternHelp fetchScheme - createAuthor :: InputPattern createAuthor = InputPattern @@ -3049,7 +2981,6 @@ validInputs = edit, editNamespace, execute, - fetchScheme, find, findAll, findGlobal, @@ -3104,7 +3035,6 @@ validInputs = resetRoot, runScheme, saveExecuteResult, - schemeLibgen, squashMerge, test, testAll, diff --git a/unison-cli/src/Unison/JitInfo.hs b/unison-cli/src/Unison/JitInfo.hs deleted file mode 100644 index a47b3d5dc5..0000000000 --- a/unison-cli/src/Unison/JitInfo.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Unison.JitInfo (currentRelease) where - -currentRelease :: String -currentRelease = "releases/0.0.11" diff --git a/unison-cli/unison-cli.cabal b/unison-cli/unison-cli.cabal index 26aa148567..fa6585699e 100644 --- a/unison-cli/unison-cli.cabal +++ b/unison-cli/unison-cli.cabal @@ -107,7 +107,6 @@ library Unison.CommandLine.OutputMessages Unison.CommandLine.Types Unison.CommandLine.Welcome - Unison.JitInfo Unison.LSP Unison.LSP.CancelRequest Unison.LSP.CodeAction diff --git a/unison-src/transcripts-manual/gen-racket-libs.md b/unison-src/transcripts-manual/gen-racket-libs.md index 964d6bc2ef..38502333cc 100644 --- a/unison-src/transcripts-manual/gen-racket-libs.md +++ b/unison-src/transcripts-manual/gen-racket-libs.md @@ -9,13 +9,6 @@ jit-setup/main> pull @unison/internal/releases/0.0.11 lib.jit ``` ```unison -generateSchemeBoot dir = do - saveDataInfoFile dir dataInfos - saveBaseFile dir bootSpec - saveWrapperFile dir simpleWrapperSpec - saveBaseFile dir builtinSpec - saveWrapperFile dir compoundWrapperSpec - go = generateSchemeBoot "scheme-libs/racket" ``` diff --git a/unison-src/transcripts-manual/gen-racket-libs.output.md b/unison-src/transcripts-manual/gen-racket-libs.output.md index 01c8efdd5e..b59603f1db 100644 --- a/unison-src/transcripts-manual/gen-racket-libs.output.md +++ b/unison-src/transcripts-manual/gen-racket-libs.output.md @@ -1,26 +1,55 @@ -Fetch base, then fetch the compiler, then build the generated -libraries in the racket directory. +When we start out, `./scheme-libs/racket` contains a bunch of library files that we'll need. They define the Unison builtins for Racket. + +Next, we'll download the jit project and generate a few Racket files from it. ```ucm -.> pull @unison/base/releases/2.5.0 .base +.> project.create-empty jit-setup + + 🎉 I've created the project jit-setup. + + 🎨 Type `ui` to explore this project's code in your browser. + 🔭 Discover libraries at https://share.unison-lang.org + 📖 Use `help-topic projects` to learn more about projects. + + Write your first Unison code with UCM: + + 1. Open scratch.u. + 2. Write some Unison code and save the file. + 3. In UCM, type `add` to save it to your new project. + + 🎉 🥳 Happy coding! - Downloaded 12426 entities. +jit-setup/main> pull @unison/internal/releases/0.0.11 lib.jit + + Downloaded 13900 entities. ✅ + + Successfully pulled into lib.jit, which was empty. - Successfully pulled into .base, which was empty. +``` +```unison +go = generateSchemeBoot "scheme-libs/racket" +``` -.> compile.native.fetch +```ucm - Downloaded 1465 entities. + Loading changes detected in scratch.u. - ✅ + I found and typechecked these definitions in scratch.u. If you + do an `add` or `update`, here's how your codebase would + change: + + ⍟ These new definitions are ok to `add`: + + go : '{IO, Exception} () - Successfully updated .unison.internal from - @unison/internal/releases/0.0.10. +``` +```ucm +jit-setup/main> run go -.> compile.native.genlibs scheme-libs/racket + () ``` After executing this, `scheme-libs/racket` will contain the full @@ -35,11 +64,11 @@ them. This is accomplished by running. in the directory where the `unison directory is located. Then the runtime executable can be built with - raco exe scheme-libs/racket/ucr.rkt + raco exe scheme-libs/racket/unison-runtime.rkt and a distributable directory can be produced with: - raco distribute scheme-libs/racket/ucr + raco distribute scheme-libs/racket/unison-runtime At that point, should contain the executable and all dependencies necessary to run it. From 021677d6703ce9b6a11a933fc52e21f8b0bc9edb Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 8 Mar 2024 14:50:30 -0500 Subject: [PATCH 177/181] yaml: update stack caching --- .github/workflows/ci.md | 14 +++++++++++++- .github/workflows/ci.yaml | 9 +++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.md b/.github/workflows/ci.md index 4771391816..89a37a9928 100644 --- a/.github/workflows/ci.md +++ b/.github/workflows/ci.md @@ -35,6 +35,18 @@ Some cached directories: ### Cached directories: +#### `.stack` +- The **cache key** includes the os, the stackage resolver, `stack.yaml`, and any `package.yaml`. + +This currently will re-save on failure, but only if the cache key didn't hit. +If we find we want to re-save even on a cache key miss (e.g. due to `stack` weirdness), we can change the condition. + +#### `.stack-work` +- The **cache key** includes the os, the stackage resolver, `stack.yaml`, and any `package.yaml`. + +This currently will re-save on failure, but only on an cache key miss. +If we find we want to re-save even on a cache key miss (e.g. due to `stack` weirdness), we can change the condition. + #### `ucm_local_bin` A built `ucm` is cached in `ucm_local_bin` after a successful build and Haskell tests pass. - The **cache key** includes the os, `stack.yaml`, any `package.yaml`, and any `.hs` file. @@ -66,7 +78,7 @@ A bit is cached in `unison_src_test_results` after non-Haskell tests in the `uni - If all steps suceed, the `unison_src_test_results` bit is saved. #### `base-codebase` -This stores the result of `base.md`, which can be reused later to save the cost of a `pull`. +This stores the result of `base.md`, which can be reused later to save the cost of a `pull`. No steps are skipped on a cache hit; however, a second `pull` will mostly be a no-op. #### `jit_src_scheme` diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bc82f8c8ce..01bddbb854 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -130,6 +130,7 @@ jobs: - name: restore ~/.stack (non-Windows) uses: actions/cache/restore@v4 + id: cache-stack-unix if: runner.os != 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: path: ~/.stack @@ -139,6 +140,7 @@ jobs: - name: restore ~/.stack (Windows) uses: actions/cache/restore@v4 + id: cache-stack-windows if: runner.os == 'Windows' && steps.cache-ucm-binaries.outputs.cache-hit != 'true' with: path: | @@ -151,6 +153,7 @@ jobs: - name: restore .stack-work uses: actions/cache/restore@v4 if: steps.cache-ucm-binaries.outputs.cache-hit != 'true' + id: cache-stack-work with: path: | **/.stack-work @@ -330,14 +333,14 @@ jobs: if-no-files-found: error - name: save ~/.stack (non-Windows) - if: runner.os != 'Windows' + if: always() && runner.os != 'Windows' && steps.cache-stack-unix.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: ~/.stack key: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - name: save ~/.stack (Windows) - if: runner.os == 'Windows' + if: always() && runner.os == 'Windows' && steps.cache-stack-windows.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: | @@ -346,6 +349,8 @@ jobs: key: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - name: save .stack-work + # can change this to always() if we find this isn't doing the right thing. + if: always() && steps.cache-stack-work.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: | From e8e610d0a8f7c1f0a59c94260d295405e180e6e0 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 8 Mar 2024 14:50:42 -0500 Subject: [PATCH 178/181] do we need `base.output.md`? --- unison-src/builtin-tests/base.output.md | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 unison-src/builtin-tests/base.output.md diff --git a/unison-src/builtin-tests/base.output.md b/unison-src/builtin-tests/base.output.md deleted file mode 100644 index 0d4f73ad90..0000000000 --- a/unison-src/builtin-tests/base.output.md +++ /dev/null @@ -1,23 +0,0 @@ -When this file is modified, CI will create a new codebase and re-run this; -otherwise it may reuse a previously cached codebase. - -Thus, make sure the contents of this file define the contents of the cache -(e.g. don't pull `latest`.) - -```ucm -.> pull @unison/base/releases/2.5.0 .base - - Merging... - - 😶 - - .base was already up-to-date with @unison/base/releases/2.5.0. - -.> compile.native.fetch - - 😶 - - .unison.internal was already up-to-date with - @unison/internal/releases/0.0.3. - -``` From 5034bf4cb891ea92b8a8b7bf213b2a5ea5aa2e19 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 8 Mar 2024 15:46:59 -0500 Subject: [PATCH 179/181] change default ucr location to `$0/runtime/unison-runtime[.exe]` --- unison-cli/transcripts/Transcripts.hs | 6 +++--- unison-cli/unison/Main.hs | 13 +++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/unison-cli/transcripts/Transcripts.hs b/unison-cli/transcripts/Transcripts.hs index 5ca7a59e86..244b213092 100644 --- a/unison-cli/transcripts/Transcripts.hs +++ b/unison-cli/transcripts/Transcripts.hs @@ -10,7 +10,7 @@ import Data.Text qualified as Text import Data.Text.IO qualified as Text import EasyTest import System.Directory -import System.Environment (getArgs) +import System.Environment (getArgs, getExecutablePath) import System.FilePath ( replaceExtension, splitFileName, @@ -157,8 +157,8 @@ defaultConfig :: IO TestConfig defaultConfig = TestConfig Nothing <$> defaultRTP where defaultRTP = do - dir <- getXdgDirectory XdgData ("unisonlanguage" "libexec") - pure (dir "unison-runtime" <.> exeExtension) + ucm <- getExecutablePath + pure (ucm "runtime" "unison-runtime" <.> exeExtension) main :: IO () main = withCP65001 do diff --git a/unison-cli/unison/Main.hs b/unison-cli/unison/Main.hs index b69e2bc319..51f5a7e26f 100644 --- a/unison-cli/unison/Main.hs +++ b/unison-cli/unison/Main.hs @@ -44,11 +44,9 @@ import System.Directory ( canonicalizePath, getCurrentDirectory, removeDirectoryRecursive, - getXdgDirectory, - XdgDirectory(..), exeExtension ) -import System.Environment (getProgName, withArgs) +import System.Environment (getExecutablePath, getProgName, withArgs) import System.Exit qualified as Exit import System.FilePath qualified as FP import System.IO (stderr) @@ -93,11 +91,10 @@ type Runtimes = (RTI.Runtime Symbol, RTI.Runtime Symbol, RTI.Runtime Symbol) fixNativeRuntimePath :: Maybe FilePath -> IO FilePath -fixNativeRuntimePath = maybe dflt pure - where - exe = "unison-runtime" FP.<.> exeExtension - unisonDir = "unisonlanguage" FP. "libexec" - dflt = (FP. exe) <$> getXdgDirectory XdgData unisonDir +fixNativeRuntimePath override = do + ucm <- getExecutablePath + let ucr = ucm FP. "runtime" FP. "unison-runtime" FP.<.> exeExtension + pure $ maybe ucr id override main :: IO () main = do From bf3a99f3a9fac42748a573605f04c00daf8ba341 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 8 Mar 2024 16:28:00 -0500 Subject: [PATCH 180/181] yaml: maybe fix stack caching condition again? --- .github/workflows/ci.md | 12 ++++++++---- .github/workflows/ci.yaml | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.md b/.github/workflows/ci.md index 89a37a9928..009c6f690c 100644 --- a/.github/workflows/ci.md +++ b/.github/workflows/ci.md @@ -35,17 +35,21 @@ Some cached directories: ### Cached directories: +One reason for this change is to reduce the CI time for commits that only change docs, or yaml or other uninteresting things. + #### `.stack` +Caches build dependencies needed by unison packages. + - The **cache key** includes the os, the stackage resolver, `stack.yaml`, and any `package.yaml`. -This currently will re-save on failure, but only if the cache key didn't hit. -If we find we want to re-save even on a cache key miss (e.g. due to `stack` weirdness), we can change the condition. +This currently will re-save on success or failure, but only on a cache miss (source changed).If we find we want to re-save even on a cache key miss (e.g. due to `stack` weirdness), we can change the condition. #### `.stack-work` +Caches build outputs for unison packages themselves. + - The **cache key** includes the os, the stackage resolver, `stack.yaml`, and any `package.yaml`. -This currently will re-save on failure, but only on an cache key miss. -If we find we want to re-save even on a cache key miss (e.g. due to `stack` weirdness), we can change the condition. +This currently will re-save on success or failure, but only on a cache miss (source changed).If we find we want to re-save even on a cache key miss (e.g. due to `stack` weirdness), we can change the condition. #### `ucm_local_bin` A built `ucm` is cached in `ucm_local_bin` after a successful build and Haskell tests pass. diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 01bddbb854..25036899d6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -333,14 +333,14 @@ jobs: if-no-files-found: error - name: save ~/.stack (non-Windows) - if: always() && runner.os != 'Windows' && steps.cache-stack-unix.outputs.cache-hit != 'true' + if: runner.os != 'Windows' && ${{ !canceled() }} && steps.cache-stack-unix.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: ~/.stack key: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - name: save ~/.stack (Windows) - if: always() && runner.os == 'Windows' && steps.cache-stack-windows.outputs.cache-hit != 'true' + if: runner.os == 'Windows' && ${{ !canceled() }} && steps.cache-stack-windows.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: | @@ -350,7 +350,7 @@ jobs: - name: save .stack-work # can change this to always() if we find this isn't doing the right thing. - if: always() && steps.cache-stack-work.outputs.cache-hit != 'true' + if: ${{ !canceled() }} && steps.cache-stack-work.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: | From 9f2645ddc103ae882b44e13a3c6d69288fc47bd3 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Fri, 8 Mar 2024 16:42:42 -0500 Subject: [PATCH 181/181] yaml: predicate requires British spelling --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 25036899d6..042a70862f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -333,14 +333,14 @@ jobs: if-no-files-found: error - name: save ~/.stack (non-Windows) - if: runner.os != 'Windows' && ${{ !canceled() }} && steps.cache-stack-unix.outputs.cache-hit != 'true' + if: runner.os != 'Windows' && ${{ !cancelled() }} && steps.cache-stack-unix.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: ~/.stack key: stack-${{env.stack-cache-key-version}}_${{matrix.os}}-${{env.resolver}}-${{hashFiles('**/stack.yaml', '**/package.yaml')}} - name: save ~/.stack (Windows) - if: runner.os == 'Windows' && ${{ !canceled() }} && steps.cache-stack-windows.outputs.cache-hit != 'true' + if: runner.os == 'Windows' && ${{ !cancelled() }} && steps.cache-stack-windows.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: | @@ -350,7 +350,7 @@ jobs: - name: save .stack-work # can change this to always() if we find this isn't doing the right thing. - if: ${{ !canceled() }} && steps.cache-stack-work.outputs.cache-hit != 'true' + if: ${{ !cancelled() }} && steps.cache-stack-work.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: |