mirror of
https://github.com/unisonweb/unison.git
synced 2024-10-04 13:47:26 +03:00
Merge branch 'trunk' into kylegoetz-udp
This commit is contained in:
commit
407ffdd53e
80
.github/workflows/ci.yaml
vendored
80
.github/workflows/ci.yaml
vendored
@ -64,7 +64,7 @@ jobs:
|
||||
with:
|
||||
commit_message: automatically run ormolu
|
||||
build-ucm:
|
||||
name: Build UCM ${{ matrix.os }}
|
||||
name: build ucm
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
# Run each build to completion, regardless of if any have failed
|
||||
@ -207,7 +207,7 @@ jobs:
|
||||
cache-prefix: ci
|
||||
|
||||
transcripts:
|
||||
name: Run transcripts
|
||||
name: run transcripts
|
||||
needs: build-ucm
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@ -278,7 +278,7 @@ jobs:
|
||||
echo "passing=true" >> "${{env.transcript_test_results}}"
|
||||
|
||||
interpreter-tests:
|
||||
name: Run interpreter tests
|
||||
name: run interpreter tests
|
||||
needs: build-ucm
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@ -342,12 +342,13 @@ jobs:
|
||||
cat unison-src/builtin-tests/interpreter-tests.output.md
|
||||
git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md
|
||||
- name: mark interpreter tests as passing
|
||||
if: steps.cache-interpreter-test-results.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
echo "passing=true" >> "${{env.interpreter_test_results}}"
|
||||
|
||||
generate-jit-source:
|
||||
if: always() && needs.build-ucm.result == 'success'
|
||||
name: Generate JIT source
|
||||
name: generate jit source
|
||||
needs: build-ucm
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
@ -433,7 +434,7 @@ jobs:
|
||||
|
||||
build-jit-binary:
|
||||
if: always() && needs.generate-jit-source.result == 'success'
|
||||
name: Build JIT binary ${{ matrix.os }}
|
||||
name: build jit binary
|
||||
needs: generate-jit-source
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@ -470,46 +471,75 @@ jobs:
|
||||
echo "jit_dist_exe=$jit_dist_exe" >> $GITHUB_ENV
|
||||
echo "ucm=$ucm" >> $GITHUB_ENV
|
||||
|
||||
- name: restore jit binaries
|
||||
id: restore-jit-binaries
|
||||
- name: cache jit binaries
|
||||
id: cache-jit-binaries
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.jit_dist }}
|
||||
key: jit_dist-racket_${{ env.racket_version }}.jit_${{ env.jit_version }}
|
||||
key: jit_dist-${{ matrix.os }}.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}
|
||||
|
||||
- name: Cache Racket dependencies
|
||||
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/racket
|
||||
~/.local/share/racket
|
||||
key: ${{ runner.os }}-racket-${{env.racket_version}}
|
||||
key: ${{ matrix.os }}-racket-${{env.racket_version}}
|
||||
|
||||
- uses: Bogdanp/setup-racket@v1.11
|
||||
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
if: steps.cache-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 != 'true'
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
scripts/get-share-hash.sh
|
||||
scheme-libs
|
||||
unison-src/builtin-tests/jit-tests.tpl.md
|
||||
unison-src/transcripts-using-base/serialized-cases/case-00.v4.ser
|
||||
|
||||
- name: look up hash for runtime tests
|
||||
run: |
|
||||
echo "runtime_tests_causalhash=$(scripts/get-share-hash.sh ${{env.runtime_tests_version}})" >> $GITHUB_ENV
|
||||
|
||||
- name: cache jit test results
|
||||
id: cache-jit-test-results
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{env.jit_test_results}}
|
||||
key: jit-test-results.${{ matrix.os }}.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}.tests_${{env.runtime_tests_causalhash}}
|
||||
|
||||
- name: install libb2 (linux)
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
if: |
|
||||
runner.os == 'Linux'
|
||||
&& steps.cache-jit-test-results.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: install libb2 (macos)
|
||||
if: |
|
||||
runner.os == 'macOS'
|
||||
&& steps.cache-jit-test-results.outputs.cache-hit != 'true'
|
||||
run: brew install libb2
|
||||
|
||||
- name: download jit source
|
||||
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: jit-source
|
||||
path: ${{ env.jit_src_scheme }}
|
||||
|
||||
- uses: actions/checkout@v4 # checkout scheme-libs from unison repo
|
||||
|
||||
- name: build jit binary
|
||||
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
if: steps.cache-jit-binaries.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
cp -R scheme-libs/racket/* "$jit_src_scheme"
|
||||
@ -523,25 +553,14 @@ jobs:
|
||||
name: jit-binary-${{ matrix.os }}
|
||||
path: ${{ env.jit_dist }}/**
|
||||
|
||||
- name: look up hash for runtime tests
|
||||
run: |
|
||||
echo "runtime_tests_causalhash=$(scripts/get-share-hash.sh ${{env.runtime_tests_version}})" >> $GITHUB_ENV
|
||||
|
||||
- name: cache jit test results
|
||||
id: cache-jit-test-results
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{env.jit_test_results}}
|
||||
key: jit-test-results.racket_${{ env.racket_version }}.jit_${{ env.jit_version }}.tests_${{env.runtime_tests_causalhash}}
|
||||
|
||||
- name: cache testing codebase
|
||||
id: cache-testing-codebase
|
||||
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.runtime_tests_codebase }}
|
||||
key: runtime-tests-codebase-${{env.runtime_tests_causalhash}}
|
||||
restore-keys: runtime-tests-codebase-
|
||||
key: runtime-tests-codebase-${{ matrix.os }}-${{env.runtime_tests_causalhash}}
|
||||
restore-keys: runtime-tests-codebase-${{ matrix.os }}-
|
||||
|
||||
- name: download ucm
|
||||
if: steps.cache-jit-test-results.outputs.cache-hit != 'true'
|
||||
@ -565,6 +584,7 @@ jobs:
|
||||
git diff --exit-code unison-src/builtin-tests/jit-tests.output.md
|
||||
|
||||
- name: mark jit tests as passing
|
||||
if: runner.os != 'Windows' && steps.cache-jit-test-results.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
echo "passing=true" >> "${{env.jit_test_results}}"
|
||||
|
||||
|
16
.mergify.yml
16
.mergify.yml
@ -1,9 +1,19 @@
|
||||
pull_request_rules:
|
||||
- name: automatic merge on CI success and review
|
||||
conditions:
|
||||
- status-success=ubuntu-20.04
|
||||
- status-success=macOS-12
|
||||
- status-success=windows-2019
|
||||
- check-success=build ucm (ubuntu-20.04)
|
||||
- check-success=build ucm (macOS-12)
|
||||
- check-success=build ucm (windows-2019)
|
||||
- check-success=run transcripts (ubuntu-20.04)
|
||||
- check-success=run transcripts (macOS-12)
|
||||
- check-success=run transcripts (windows-2019)
|
||||
- check-success=run interpreter tests (ubuntu-20.04)
|
||||
- check-success=run interpreter tests (macOS-12)
|
||||
# - check-success=run interpreter tests (windows-2019)
|
||||
- check-success=generate jit source
|
||||
- check-success=build jit binary (ubuntu-20.04)
|
||||
- check-success=build jit binary (macOS-12)
|
||||
- check-success=build jit binary (windows-2019)
|
||||
- label=ready-to-merge
|
||||
- "#approved-reviews-by>=1"
|
||||
actions:
|
||||
|
@ -16,6 +16,7 @@ module Unison.Builtin
|
||||
typeOf,
|
||||
typeLookup,
|
||||
termRefTypes,
|
||||
termRefTypeReferences,
|
||||
)
|
||||
where
|
||||
|
||||
@ -323,7 +324,7 @@ termNameRefs = Map.mapKeys Name.unsafeParseText $ foldl' go mempty (stripVersion
|
||||
"tried to alias `" <> r <> "` before it was declared."
|
||||
Just t -> Map.insert name t m
|
||||
|
||||
termRefTypes :: Map R.Reference Type
|
||||
termRefTypes :: Map R.TermReference Type
|
||||
termRefTypes = foldl' go mempty builtinsSrc
|
||||
where
|
||||
go m = \case
|
||||
@ -331,6 +332,9 @@ termRefTypes = foldl' go mempty builtinsSrc
|
||||
D r t -> Map.insert (R.Builtin r) t m
|
||||
_ -> m
|
||||
|
||||
termRefTypeReferences :: Map R.TermReference R.TypeReference
|
||||
termRefTypeReferences = H.typeToReference <$> termRefTypes
|
||||
|
||||
typeOf :: a -> (Type -> a) -> R.Reference -> a
|
||||
typeOf a f r = maybe a f (Map.lookup r termRefTypes)
|
||||
|
||||
|
@ -12,7 +12,7 @@ import Unison.ConstructorType qualified as CT
|
||||
import Unison.DataDeclaration (DataDeclaration (..), Modifier (Structural, Unique))
|
||||
import Unison.DataDeclaration qualified as DD
|
||||
import Unison.DataDeclaration.ConstructorId (ConstructorId)
|
||||
import Unison.Hashing.V2.Convert (hashDataDecls)
|
||||
import Unison.Hashing.V2.Convert (hashDataDecls, typeToReference)
|
||||
import Unison.Pattern qualified as Pattern
|
||||
import Unison.Reference (Reference)
|
||||
import Unison.Reference qualified as Reference
|
||||
@ -46,7 +46,7 @@ pairRef = lookupDeclRef "Tuple"
|
||||
optionalRef = lookupDeclRef "Optional"
|
||||
eitherRef = lookupDeclRef "Either"
|
||||
|
||||
testResultRef, linkRef, docRef, ioErrorRef, stdHandleRef :: Reference
|
||||
testResultRef, testResultListRef, linkRef, docRef, ioErrorRef, stdHandleRef :: Reference
|
||||
failureRef, ioFailureRef, tlsFailureRef, arrayFailureRef :: Reference
|
||||
cryptoFailureRef :: Reference
|
||||
exceptionRef, tlsSignedCertRef, tlsPrivateKeyRef :: Reference
|
||||
@ -57,6 +57,9 @@ isTestRef = lookupDeclRef "IsTest"
|
||||
|
||||
testResultRef = lookupDeclRef "Test.Result"
|
||||
|
||||
-- Reference for [Test.Result]
|
||||
testResultListRef = typeToReference @Symbol (testResultListType ())
|
||||
|
||||
linkRef = lookupDeclRef "Link"
|
||||
|
||||
docRef = lookupDeclRef "Doc"
|
||||
@ -723,7 +726,7 @@ pattern LinkType ty <- Term.App' (Term.Constructor' (ConstructorReference LinkRe
|
||||
unitType,
|
||||
pairType,
|
||||
optionalType,
|
||||
testResultType,
|
||||
testResultListType,
|
||||
eitherType,
|
||||
ioErrorType,
|
||||
fileModeType,
|
||||
@ -739,7 +742,7 @@ unitType a = Type.ref a unitRef
|
||||
-- used for the type of the argument to force a thunk
|
||||
thunkArgType = unitType
|
||||
pairType a = Type.ref a pairRef
|
||||
testResultType a = Type.app a (Type.list a) (Type.ref a testResultRef)
|
||||
testResultListType a = Type.app a (Type.list a) (Type.ref a testResultRef)
|
||||
optionalType a = Type.ref a optionalRef
|
||||
eitherType a = Type.ref a eitherRef
|
||||
ioErrorType a = Type.ref a ioErrorRef
|
||||
|
@ -81,4 +81,4 @@ builtinIOTestTypes a =
|
||||
)
|
||||
where
|
||||
delayed = Type.arrow a (Type.ref a DD.unitRef)
|
||||
delayedResultWithEffects es = delayed (Type.effect a es (DD.testResultType a))
|
||||
delayedResultWithEffects es = delayed (Type.effect a es (DD.testResultListType a))
|
||||
|
@ -835,8 +835,10 @@ nativeEvalInContext executable _ ctx codes base = do
|
||||
UnliftIO.hClose pin
|
||||
let unit = Data RF.unitRef 0 [] []
|
||||
sunit = Data RF.pairRef 0 [] [unit, unit]
|
||||
waitForProcess ph
|
||||
decodeResult $ Right sunit
|
||||
waitForProcess ph >>= \case
|
||||
ExitSuccess -> decodeResult $ Right sunit
|
||||
ExitFailure _ ->
|
||||
pure . Left $ "native evaluation failed"
|
||||
-- TODO: actualy receive output from subprocess
|
||||
-- decodeResult . deserializeValue =<< BS.hGetContents pout
|
||||
callout _ _ _ _ =
|
||||
|
@ -110,7 +110,7 @@ typecheckingTerm uf =
|
||||
bindings =
|
||||
terms uf <> testWatches <> watchesOfOtherKinds TestWatch uf
|
||||
-- we make sure each test has type Test.Result
|
||||
f w = let wa = ABT.annotation w in Term.ann wa w (DD.testResultType wa)
|
||||
f w = let wa = ABT.annotation w in Term.ann wa w (DD.testResultListType wa)
|
||||
testWatches = map (second f) $ watchesOfKind TestWatch uf
|
||||
|
||||
-- backwards compatibility with the old data type
|
||||
|
@ -54,7 +54,7 @@ showDefinitions outputLoc pped terms types misses = do
|
||||
Cli.respond $ DisplayDefinitions renderedCodePretty
|
||||
Just fp -> do
|
||||
-- We build an 'isTest' check to prepend "test>" to tests in a scratch file.
|
||||
testRefs <- Cli.runTransaction (Codebase.filterTermsByReferenceIdHavingType codebase (DD.testResultType mempty) (Map.keysSet terms & Set.mapMaybe Reference.toId))
|
||||
testRefs <- Cli.runTransaction (Codebase.filterTermsByReferenceIdHavingType codebase (DD.testResultListType mempty) (Map.keysSet terms & Set.mapMaybe Reference.toId))
|
||||
let isTest r = Set.member r testRefs
|
||||
let isSourceFile = True
|
||||
let renderedCodePretty = renderCodePretty pped isSourceFile isTest terms types
|
||||
|
@ -60,7 +60,7 @@ handleTest :: TestInput -> Cli ()
|
||||
handleTest TestInput {includeLibNamespace, showFailures, showSuccesses} = do
|
||||
Cli.Env {codebase} <- ask
|
||||
|
||||
testRefs <- findTermsOfTypes codebase includeLibNamespace (NESet.singleton (DD.testResultType mempty))
|
||||
testRefs <- findTermsOfTypes codebase includeLibNamespace (NESet.singleton (DD.testResultListType mempty))
|
||||
|
||||
cachedTests <-
|
||||
Map.fromList <$> Cli.runTransaction do
|
||||
|
@ -310,7 +310,7 @@ addDefinitionsToUnisonFile abort codebase doFindCtorNames (terms, types) =
|
||||
Set.fromList [v | (v, _, _) <- uf.terms]
|
||||
<> foldMap (\x -> Set.fromList [v | (v, _, _) <- x]) uf.watches
|
||||
|
||||
isTest = Typechecker.isEqual (Decls.testResultType mempty)
|
||||
isTest = Typechecker.isEqual (Decls.testResultListType mempty)
|
||||
|
||||
-- given a dependent hash, include that component in the scratch file
|
||||
-- todo: wundefined: cut off constructor name prefixes
|
||||
|
@ -454,7 +454,7 @@ getTermTag codebase r sig = do
|
||||
-- A term is a test if it has the type [test.Result]
|
||||
let isTest = case sig of
|
||||
Just t ->
|
||||
Typechecker.isEqual t (Decls.testResultType mempty)
|
||||
Typechecker.isEqual t (Decls.testResultListType mempty)
|
||||
Nothing -> False
|
||||
constructorType <- case r of
|
||||
V2Referent.Ref {} -> pure Nothing
|
||||
|
@ -39,7 +39,7 @@ import Unison.ShortHash qualified as SH
|
||||
import Unison.Syntax.HashQualified qualified as HQ (parseText)
|
||||
import Unison.Syntax.HashQualified' qualified as HQ' (parseText)
|
||||
import Unison.Syntax.Name qualified as Name (parseTextEither, toText)
|
||||
import Unison.Syntax.NameSegment qualified as NameSegment (toEscapedText)
|
||||
import Unison.Syntax.NameSegment qualified as NameSegment
|
||||
import Unison.Util.Pretty (Width (..))
|
||||
|
||||
instance ToJSON Hash where
|
||||
@ -173,6 +173,12 @@ instance ToJSONKey Name where
|
||||
instance ToSchema Name where
|
||||
declareNamedSchema _ = declareNamedSchema (Proxy @Text)
|
||||
|
||||
instance ToJSON NameSegment where
|
||||
toJSON = toJSON . NameSegment.toEscapedText
|
||||
|
||||
instance ToJSONKey NameSegment where
|
||||
toJSONKey = contramap NameSegment.toEscapedText (toJSONKey @Text)
|
||||
|
||||
deriving anyclass instance ToParamSchema ShortCausalHash
|
||||
|
||||
instance ToParamSchema ShortHash where
|
||||
|
Loading…
Reference in New Issue
Block a user