diff --git a/.gitignore b/.gitignore index ebd004192..fea834436 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,3 @@ tmp/ .licenses/log/ codex.tags - -vendor/proto3-suite diff --git a/README.md b/README.md index c99446be6..6ab7d2c88 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,21 @@ Available options: ## Development -`semantic` is built using [`cabal`](https://www.haskell.org/cabal/) and the [ghc](https://www.haskell.org/ghc/) compiler. To get started: +We use `cabal's` [Nix-style local builds][nix] for development. To get started quickly: -1. **TBD** +```bash +git clone git@github.com:github/semantic.git +cd semantic +git submodule sync --recursive && git submodule update --init --recursive --force +cabal new-build +cabal new-test +``` + +`semantic` requires GHC 8.6.4. We recommend using [`ghcup`][ghcup] to sandbox GHC versions. Our version bounds are based on [Stackage][stackage] LTS versions. The current LTS version is 13.13; `stack` build should also work if you prefer. + +[nix]: https://www.haskell.org/cabal/users-guide/nix-local-build-overview.html +[stackage]: https://stackage.org +[ghcup]: https://www.haskell.org/ghcup/ ## Technology and architecture diff --git a/cabal.project b/cabal.project new file mode 100644 index 000000000..722c7ad73 --- /dev/null +++ b/cabal.project @@ -0,0 +1,3 @@ +packages: vendor/* vendor/proto3-suite vendor/haskell-tree-sitter/languages/* semantic.cabal + +package proto3-suite diff --git a/script/clone-example-repos b/script/clone-example-repos new file mode 100755 index 000000000..148f7310e --- /dev/null +++ b/script/clone-example-repos @@ -0,0 +1,68 @@ +#!/bin/bash +#/ Usage: script/clone-example-repos +#/ +#/ Clone some example repositories for smoke testing parsing and assignment +#/ +#/ NOTES: +#/ - This script is intended to be called by `test/Examples.hs` +#/ - Go and Ruby examples are in submodules +#/ - PHP doesn't have any parse-examples +#/ - Java and Haskell have good examples, but they have assignment failures so currently aren't tested + + +set -e +cd $(dirname "$0")/.. + +dir="vendor/haskell-tree-sitter/languages" + +# clone_repo LOCAL_PATH URL SHA +function clone_repo { + path=$1 + url="https://github.com/$2" + sha=$3 + + if [ ! -d "$path" ]; then + echo "Cloning $url@$sha" + git clone "$url" "$path" + else + echo "$url@$sha already exists" + fi + + pushd "$path" > /dev/null # && git pull -q # NB: Enable this if you need to pin to a different sha for one of the repos. + git reset --hard -q $sha + popd > /dev/null +} + +python_examples="$dir/python/vendor/tree-sitter-python/examples" +clone_repo "$python_examples/numpy" numpy/numpy 058851c5cfc98f50f11237b1c13d77cfd1f40475 +clone_repo "$python_examples/thealgorithms" thealgorithms/python c6be53e1c43f870f5364eef1499ee1b411c966fb +clone_repo "$python_examples/flask" pallets/flask 0b5b4a66ef99c8b91569dd9b9b34911834689d3f +clone_repo "$python_examples/httpie" jakubroztocil/httpie 358342d1c915d6462a080a77aefbb20166d0bd5d +clone_repo "$python_examples/keras" keras-team/keras e59570ae26670f788d6c649191031e4a8824f955 +clone_repo "$python_examples/requests" requests/requests 64bde6582d9b49e9345d9b8df16aaa26dc372d13 +clone_repo "$python_examples/scikit-learn" scikit-learn/scikit-learn d0f63a760d9993a7f68cfc5e1a075700d67c53d3 +clone_repo "$python_examples/scrapy" scrapy/scrapy 65d631329a1434ec013f24341e4b8520241aec70 +clone_repo "$python_examples/pytorch" pytorch/pytorch c865d46736db4afff51690a712e35ed8e3899490 +clone_repo "$python_examples/certbot" certbot/certbot bb8222200a8cbd39a3ce9584ce6dfed6c5d05228 + +ts_examples="$dir/typescript/vendor/tree-sitter-typescript/examples" +clone_repo "$ts_examples/desktop" desktop/desktop d1324f56d02dd9afca5d2e9da545905a7d41d671 + +java_examples="$dir/java/vendor/tree-sitter-java/examples" +clone_repo "$java_examples/elasticsearch" elastic/elasticsearch 4d62640bf116af7e825d89c7319a39c3f2f325b4 +clone_repo "$java_examples/guava" google/guava e24fddc5fff7fd36d33ea38737b6606a7e476845 +clone_repo "$java_examples/RxJava" ReactiveX/RxJava 8a6bf14fc9a61f7c1c0016ca217be02ca86211d2 + +clone_repo "$ts_examples/npm" npm/npm ee147fbbca6f2707d3b16f4fa78f4c4606b2d9b1 + +haskell_examples="$dir/haskell/vendor/tree-sitter-haskell/examples" +clone_repo "$haskell_examples/effects" joshvera/effects 08f5f36f2600362685af593f4b327e933b60bf97 +clone_repo "$haskell_examples/postgrest" PostgRest/postgrest f80cfbf165f951a062b3cbedac4556019905ca49 +clone_repo "$haskell_examples/ivory" GaloisInc/ivory 3d00324ad1c113c7e70957ff6a6d636d271d0fc4 + +go_examples="$dir/go/vendor/tree-sitter-go/examples" +clone_repo "$go_examples/go" "golang/go" "870e12d7bfaea70fb0d743842f5864eb059cb939" +clone_repo "$go_examples/moby" "moby/moby" "f57f260b49b6142366e6bc1274204ee0a1205945" + +ruby_examples="$dir/ruby/vendor/tree-sitter-ruby/examples" +clone_repo "$ruby_examples/ruby_spec" "ruby/spec" "c3e6b9017926f44a76e2b966c4dd35fa84c4cd3b" diff --git a/script/generate-example b/script/generate-example index ec5c7b8b0..aa6d20006 100755 --- a/script/generate-example +++ b/script/generate-example @@ -37,20 +37,20 @@ generate_example () { if [ -e "$fileA" ]; then status $parseFileA - stack exec semantic -- parse --sexpression $fileA > $parseFileA + cabal new-run semantic -- parse --sexpression $fileA > $parseFileA fi if [ -e "$fileB" ]; then status $parseFileB - stack exec semantic -- parse --sexpression $fileB > $parseFileB + cabal new-run semantic -- parse --sexpression $fileB > $parseFileB fi if [ -e "$fileA" -a -e "$fileB" ]; then status $diffFileAB - stack exec semantic -- diff --sexpression $fileA $fileB > $diffFileAB + cabal new-run semantic -- diff --sexpression $fileA $fileB > $diffFileAB status $diffFileBA - stack exec semantic -- diff --sexpression $fileB $fileA > $diffFileBA + cabal new-run semantic -- diff --sexpression $fileB $fileA > $diffFileBA fi } diff --git a/semantic.cabal b/semantic.cabal index 821d93ef2..eca51af0c 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -13,6 +13,8 @@ category: Web build-type: Simple stability: alpha +tested-with: GHC == 8.6.4 + flag release description: Build with optimizations on (for CI or deployment builds) default: False @@ -35,33 +37,36 @@ common haskell , StrictData , TypeApplications +-- Except in case of vendored dependencies, these deps should be expressed +-- as caret-operator bounds relative to a version in Stackage. +-- These are currently pinned to lts-13.13. common dependencies build-depends: base >= 4.8 && < 5 - , aeson - , algebraic-graphs - , async - , bifunctors - , bytestring - , containers - , directory + , aeson ^>= 1.4.2.0 + , algebraic-graphs ^>= 0.3 + , async ^>= 2.2.1 + , bifunctors ^>= 5.5 + , bytestring ^>= 0.10.8.2 + , containers ^>= 0.6.0.1 + , directory ^>= 1.3.3.0 , fastsum - , filepath - , free + , filepath ^>= 1.4.2.1 + , free ^>= 5.1 , fused-effects , fused-effects-exceptions - , hashable + , hashable ^>= 1.2.7.0 , haskell-tree-sitter - , machines - , mtl - , network + , machines ^>= 0.6.4 + , mtl ^>= 2.2.2 + , network ^>= 2.8.0.0 , process - , recursion-schemes - , scientific + , recursion-schemes ^>= 5.1 + , scientific ^>= 0.3.6.2 , safe-exceptions , semilattices - , text - , these - , unix + , text ^>= 1.2.3.1 + , these >= 0.7 && <1 + , unix ^>= 2.7.2.2 , proto3-suite , proto3-wire @@ -276,46 +281,47 @@ library , Tags.Tagging -- Custom Prelude , Prologue + build-depends: base >= 4.8 && < 5 - , ansi-terminal - , array - , attoparsec - , cmark-gfm - , cryptohash - , deepseq - , directory-tree + , ansi-terminal ^>= 0.8.2 + , array ^>= 0.5.3.0 + , attoparsec ^>= 0.13.2.2 + , cmark-gfm == 0.1.8 + , cryptohash ^>= 0.11.9 + , deepseq ^>= 1.4.4.0 + , directory-tree ^>= 0.12.1 , freer-cofreer - , generic-monoid - , ghc-prim - , gitrev - , haskeline - , hostname - , hscolour - , http-client - , http-client-tls - , http-types - , http-media - , kdt - , lens - , mersenne-random-pure64 - , network-uri - , optparse-applicative - , parallel - , parsers - , pretty-show - , prettyprinter - , profunctors - , reducers - , semigroupoids - , servant + , generic-monoid ^>= 0.1.0.0 + , ghc-prim ^>= 0.5.3 + , gitrev ^>= 1.3.1 + , haskeline ^>= 0.7.5.0 + , hostname ^>= 1.0 + , hscolour ^>= 1.24.4 + , http-client ^>= 0.6.2 + , http-client-tls ^>= 0.3.5.3 + , http-types ^>= 0.12.3 + , http-media ^>= 0.7.1.3 + , kdt ^>= 0.2.4 + , lens ^>= 4.17 + , mersenne-random-pure64 ^>= 0.2.2.0 + , network-uri ^>= 2.6.1.0 + , optparse-applicative ^>= 0.14.3.0 + , parallel ^>= 3.2.2.0 + , parsers ^>= 0.12.9 + , prettyprinter ^>= 1.2.1 + , pretty-show ^>= 1.9.5 + , profunctors ^>= 5.3 + , reducers ^>= 3.12.3 + , semigroupoids ^>= 5.3.2 + , servant ^>= 0.15 , shelly - , split - , stm-chans - , template-haskell - , time + , split ^>= 0.2.3.3 + , stm-chans ^>= 3.0.0.4 + , template-haskell ^>= 2.14 + , time ^>= 1.8.0.2 , unliftio-core - , unordered-containers - , vector + , unordered-containers ^>= 0.2.9.0 + , vector ^>= 0.12.0.2 , haskell-tree-sitter , tree-sitter-go , tree-sitter-haskell @@ -391,11 +397,11 @@ test-suite test build-depends: semantic , tree-sitter-json , Glob - , hspec >= 2.4.1 - , hspec-core - , hspec-expectations-pretty-diff - , HUnit - , leancheck + , hspec >= 2.6 && <3 + , hspec-core >= 2.6 && <3 + , hspec-expectations-pretty-diff ^>= 0.7.2.5 + , HUnit ^>= 1.6.0.0 + , leancheck >= 0.8 && <1 , temporary ghc-options: -O0 if flag(release) diff --git a/vendor/proto3-suite b/vendor/proto3-suite new file mode 160000 index 000000000..83f3352f0 --- /dev/null +++ b/vendor/proto3-suite @@ -0,0 +1 @@ +Subproject commit 83f3352f0c7c94ea091e6087f60692eda9991fae diff --git a/vendor/proto3-wire b/vendor/proto3-wire new file mode 160000 index 000000000..84664e22f --- /dev/null +++ b/vendor/proto3-wire @@ -0,0 +1 @@ +Subproject commit 84664e22f01beb67870368f1f88ada5d0ad01f56