diff --git a/.bazelrc b/.bazelrc index c2907ea7a..666114167 100644 --- a/.bazelrc +++ b/.bazelrc @@ -5,7 +5,7 @@ common:ci --color=no test:ci --test_output=errors build --disk_cache=.bazel-cache/bazel-disk -build --repository_cache=tmp/bazel-repo +build --repository_cache=.bazel-cache/bazel-repo build --color=yes build --jobs=8 build --compilation_mode=fastbuild diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml new file mode 100644 index 000000000..0c74e8985 --- /dev/null +++ b/.github/workflows/bazel.yml @@ -0,0 +1,44 @@ +name: Bazel CI + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + +jobs: + build: + name: Bazel + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' + + - uses: actions/cache@v2 + id: caching-stage + name: Cache Bazel artifacts + with: + path: | + .bazel-cache + bin + /home/runner/.cache + key: ${{ runner.os }}-bazel-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-bazel- + + - name: Download/cache bazel version + if: steps.caching-stage.outputs.cache-hit != 'true' + run: | + if [ ! -f bin/bazel ]; then + curl -LO "https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-linux-x86_64" + mv bazel-3.1.0-linux-x86_64 "bin/bazel" + chmod +x "bin/bazel" + fi + + - name: Build & test + run: | + bin/bazel test --config=ci --test_tag_filters=language-test //... + bin/bazel test --config=ci //semantic-source //semantic:spec diff --git a/WORKSPACE b/WORKSPACE index e446d38dd..e0a7490d1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -8,13 +8,6 @@ workspace(name = "semantic") # Load the repository rule to download an http archive. load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# Load the ability to check out a git repository. -load( - "@bazel_tools//tools/build_defs/repo:git.bzl", - "git_repository", - "new_git_repository", -) - # Download rules_haskell and make it accessible as "@rules_haskell". # # Note: the git_repository clause is a workaround until rules_haskell#1349 [1] @@ -29,10 +22,11 @@ load( # strip_prefix = "rules_haskell-0.12", # urls = ["https://github.com/tweag/rules_haskell/archive/v0.12.tar.gz"], # ) -git_repository( +http_archive( name = "rules_haskell", - remote = "https://github.com/tweag/rules_haskell", - commit = "abaec6502a4474f10b3c367fb5e90173ee0e349c", + sha256 = "78d017aa732b430c0681fff4514503af78a8d8c44df165e603a9433745b16e5e", + strip_prefix = "rules_haskell-abaec6502a4474f10b3c367fb5e90173ee0e349c", + urls = ["https://github.com/tweag/rules_haskell/archive/abaec6502a4474f10b3c367fb5e90173ee0e349c.tar.gz"], ) load( @@ -249,11 +243,11 @@ tree_sitter_node_types_hackage( # Download lingo (which has its own Bazel build instructions). -git_repository( +http_archive( name = "lingo", - commit = "6614b9afe1a519364491c170d6b06ff5cd96153a", - remote = "https://github.com/tclem/lingo-haskell.git", - shallow_since = "1593202797 -0400", + sha256 = "32a5e2d66e4620ff7004acab4802dc948b852ce26725012283a85d41af97275f", + strip_prefix = "lingo-haskell-6614b9afe1a519364491c170d6b06ff5cd96153a", + urls = ["https://github.com/tclem/lingo-haskell/archive/6614b9afe1a519364491c170d6b06ff5cd96153a.tar.gz"], ) load("//:build/example_repos.bzl", "declare_example_repos") diff --git a/build/common.bzl b/build/common.bzl index 3b591ff75..5fd0ea115 100644 --- a/build/common.bzl +++ b/build/common.bzl @@ -9,10 +9,6 @@ load( "@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", ) -load( - "@bazel_tools//tools/build_defs/repo:git.bzl", - "new_git_repository", -) DEVELOPMENT_GHC_FLAGS = ["-O0"] RELEASE_GHC_FLAGS = ["-O1"] diff --git a/build/example_repos.bzl b/build/example_repos.bzl index 46ae6b869..c006fcad5 100644 --- a/build/example_repos.bzl +++ b/build/example_repos.bzl @@ -1,7 +1,6 @@ load( - "@bazel_tools//tools/build_defs/repo:git.bzl", - "git_repository", - "new_git_repository", + "@bazel_tools//tools/build_defs/repo:http.bzl", + "http_archive", ) _all_example_repos = { @@ -11,8 +10,7 @@ _all_example_repos = { ], "commit": "058851c5cfc98f50f11237b1c13d77cfd1f40475", "repo": "numpy/numpy", - "since": "", - "excludes": [], + "sha256": "8e60c567cbab3309afa9508ee61dfd207089ebb0056214fe60e863d81e098824", }, "python": { "data": [ @@ -20,7 +18,8 @@ _all_example_repos = { ], "commit": "c6be53e1c43f870f5364eef1499ee1b411c966fb", "repo": "thealgorithms/python", - "since": "1548508158 +0800", + "prefix": "Python", + "sha256": "bef087151bea1e479701d0ceed831809c1b916f513752dee914e9c7876b46ea9", "excludes": [ "**/data structures/*", "**/binary tree/*", @@ -35,8 +34,7 @@ _all_example_repos = { ], "commit": "0b5b4a66ef99c8b91569dd9b9b34911834689d3f", "repo": "pallets/flask", - "since": "", - "excludes": [], + "sha256": "224d406f11b13cc8e4c7defd8dc94e0df957c1c90977172cfaa2ee88d8f85e77", }, "httpie": { "data": [ @@ -44,8 +42,7 @@ _all_example_repos = { ], "commit": "358342d1c915d6462a080a77aefbb20166d0bd5d", "repo": "jakubroztocil/httpie", - "since": "", - "excludes": [], + "sha256": "2b3172369954d883a2a609dc6bc34a944ce9817afb14733d87f208a40529899c", }, "keras": { "data": [ @@ -53,17 +50,15 @@ _all_example_repos = { ], "commit": "e59570ae26670f788d6c649191031e4a8824f955", "repo": "keras-team/keras", - "since": "1548927621 +0530", - "excludes": [], + "sha256": "2bda5bfd2a2b43d9f4d191e4ed980740429bb86d75e16355b1d33faf9d974ffd", }, "requests": { "data": [ "**/*.py", ], "commit": "64bde6582d9b49e9345d9b8df16aaa26dc372d13", + "sha256": "8f9466ad314b2741c826b164b46bcedb260d424f717fd9553fea5164f493bd20", "repo": "requests/requests", - "since": "", - "excludes": [], }, "scikit-learn": { "data": [ @@ -71,17 +66,15 @@ _all_example_repos = { ], "commit": "d0f63a760d9993a7f68cfc5e1a075700d67c53d3", "repo": "scikit-learn/scikit-learn", - "since": "", - "excludes": [], + "sha256": "4f337b87d45cabd7db9cd3883fd5168accad7f78bc48df3ae633832b4d0f30d0", }, "scrapy": { "data": [ "**/*.py", ], "commit": "65d631329a1434ec013f24341e4b8520241aec70", + "sha256": "27b2dc9b1a55c356eeec651c76fe82be082c0e8980b2e4d9b99a4f63c733685b", "repo": "scrapy/scrapy", - "since": "1548908933 -0300", - "excludes": [], }, "pytorch": { "data": [ @@ -89,17 +82,15 @@ _all_example_repos = { ], "commit": "c865d46736db4afff51690a712e35ed8e3899490", "repo": "pytorch/pytorch", - "since": "1549068372 -0800", - "excludes": [], + "sha256": "7b54b7a3c40aaf68bb9bd7dcc509389d29c5c37241f29c003bd04cd0dafb60ce", }, "certbot": { "data": [ "**/*.py", ], "commit": "bb8222200a8cbd39a3ce9584ce6dfed6c5d05228", + "sha256": "3477f4c04897f7874249e6362567384246f409c62e1ff18c4d6fa54813f484c2", "repo": "certbot/certbot", - "since": "1549052531 -0800", - "excludes": [], }, "spec": { "data": [ @@ -107,8 +98,7 @@ _all_example_repos = { ], "commit": "c3e6b9017926f44a76e2b966c4dd35fa84c4cd3b", "repo": "ruby/spec", - "since": "", - "excludes": [], + "sha256": "33206954ff6fdbf5b872298efc2697c18ad5371eb55007d54f95c08ec7f46bb4", }, "desktop": { "data": [ @@ -116,15 +106,17 @@ _all_example_repos = { ], "commit": "d1324f56d02dd9afca5d2e9da545905a7d41d671", "repo": "desktop/desktop", - "since": "1523834029 +1000", - "excludes": [], + "sha256": "cfd1c6d313ff4e756b59da83f3f7799e021e0d0fe94ee4a93638c9b1aa19b5ca", }, } SEMANTIC_EXTERNAL_TEST_REPOSITORIES = ["@" + k + "//:src" for (k, v) in _all_example_repos.items()] -def _example_repo(name, data, excludes, commit, repo, since): - new_git_repository( +def _example_repo(name, data, repo, commit, since = "", excludes = [], sha256 = "", prefix = ""): + if prefix == "": + prefix = name + + http_archive( name = name, build_file_content = """ filegroup( @@ -133,9 +125,9 @@ filegroup( visibility = ["//visibility:public"] ) """.format(data, excludes), - commit = commit, - remote = "https://github.com/{}.git".format(repo), - shallow_since = since, + strip_prefix = prefix + "-" + commit, + sha256 = sha256, + urls = ["https://github.com/{repo}/archive/{commit}.tar.gz".format(repo = repo, commit = commit)], ) def declare_example_repos(): diff --git a/build/tree_sitter.bzl b/build/tree_sitter.bzl deleted file mode 100644 index 94938f61f..000000000 --- a/build/tree_sitter.bzl +++ /dev/null @@ -1,10 +0,0 @@ -# To provide access to node-types.json files and the contents -# of the packages's corpus/ directory, we define a BUILD file -# that will be injected, via the build_file_contents, into -# the repositories that we download. - -package(default_visibility = ["//visibility:public"]) - -exports_files(glob(["**/node-types.json"])) - -filegroup(name = "corpus", srcs = glob(["**/corpus/*.txt"])) diff --git a/docs/build.md b/docs/build.md index 87a0d9530..28151f0c2 100644 --- a/docs/build.md +++ b/docs/build.md @@ -42,6 +42,7 @@ If this seems complicated, don't worry: most of the time you'll be able to skip 3. **Some packages come with GHC and are not loaded from Stackage**. These include `base`, `containers`, and [others](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/8.10.1-notes.html?highlight=bytestring#included-libraries). To depend on those packages, you use `//:base`, `//:containers`, etc. They are specified in the `BAZEL.build` at the project root. You probably won't need to add any more. 4. **Getting weird errors from the C compiler?** Try setting `export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1` in your `.profile` or whatnot. + ## Quick reference links * **Bazel manual**: https://docs.bazel.build/versions/3.3.0/bazel-overview.html diff --git a/semantic/BUILD.bazel b/semantic/BUILD.bazel index c12037696..88ba215e1 100644 --- a/semantic/BUILD.bazel +++ b/semantic/BUILD.bazel @@ -180,7 +180,6 @@ haskell_test( haskell_test( name = "parse-examples", - timeout = "long", srcs = [ "test/Examples.hs", ],