Skip to content

Commit 68cb87d

Browse files
author
Patrick Thomson
committed
Get these globs right.
1 parent 86397cf commit 68cb87d

File tree

3 files changed

+38
-29
lines changed

3 files changed

+38
-29
lines changed

build/example_repos.bzl

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,34 @@ load(
44
"new_git_repository",
55
)
66

7-
all_example_repos = {
7+
_all_example_repos = {
88
"numpy": {
99
"data": [
10-
"**/*.rb",
10+
"**/*.py",
1111
],
1212
"commit": "058851c5cfc98f50f11237b1c13d77cfd1f40475",
1313
"repo": "numpy/numpy",
1414
"since": "",
15-
"excludes": ["data structures"],
15+
"excludes": [],
1616
},
1717
"python": {
1818
"data": [
19-
"**/*.rb",
19+
"**/*.py",
2020
],
2121
"commit": "c6be53e1c43f870f5364eef1499ee1b411c966fb",
2222
"repo": "thealgorithms/python",
23-
"since": "",
24-
"excludes": [],
23+
"since": "1548508158 +0800",
24+
"excludes": [
25+
"**/data structures/*",
26+
"**/binary tree/*",
27+
"**/graphs/*",
28+
"**/Random Forest*/*",
29+
"**/* */*",
30+
],
2531
},
2632
"flask": {
2733
"data": [
28-
"**/*.rb",
34+
"**/*.py",
2935
],
3036
"commit": "0b5b4a66ef99c8b91569dd9b9b34911834689d3f",
3137
"repo": "pallets/flask",
@@ -34,7 +40,7 @@ all_example_repos = {
3440
},
3541
"httpie": {
3642
"data": [
37-
"**/*.rb",
43+
"**/*.py",
3844
],
3945
"commit": "358342d1c915d6462a080a77aefbb20166d0bd5d",
4046
"repo": "jakubroztocil/httpie",
@@ -43,16 +49,16 @@ all_example_repos = {
4349
},
4450
"keras": {
4551
"data": [
46-
"**/*.rb",
52+
"**/*.py",
4753
],
4854
"commit": "e59570ae26670f788d6c649191031e4a8824f955",
4955
"repo": "keras-team/keras",
50-
"since": "",
56+
"since": "1548927621 +0530",
5157
"excludes": [],
5258
},
5359
"requests": {
5460
"data": [
55-
"**/*.rb",
61+
"**/*.py",
5662
],
5763
"commit": "64bde6582d9b49e9345d9b8df16aaa26dc372d13",
5864
"repo": "requests/requests",
@@ -61,7 +67,7 @@ all_example_repos = {
6167
},
6268
"scikit-learn": {
6369
"data": [
64-
"**/*.rb",
70+
"**/*.py",
6571
],
6672
"commit": "d0f63a760d9993a7f68cfc5e1a075700d67c53d3",
6773
"repo": "scikit-learn/scikit-learn",
@@ -70,16 +76,16 @@ all_example_repos = {
7076
},
7177
"scrapy": {
7278
"data": [
73-
"**/*.rb",
79+
"**/*.py",
7480
],
7581
"commit": "65d631329a1434ec013f24341e4b8520241aec70",
7682
"repo": "scrapy/scrapy",
77-
"since": "",
83+
"since": "1548908933 -0300",
7884
"excludes": [],
7985
},
8086
"pytorch": {
8187
"data": [
82-
"**/*.rb",
88+
"**/*.py",
8389
],
8490
"commit": "c865d46736db4afff51690a712e35ed8e3899490",
8591
"repo": "pytorch/pytorch",
@@ -88,11 +94,11 @@ all_example_repos = {
8894
},
8995
"certbot": {
9096
"data": [
91-
"**/*.rb",
97+
"**/*.py",
9298
],
9399
"commit": "bb8222200a8cbd39a3ce9584ce6dfed6c5d05228",
94100
"repo": "certbot/certbot",
95-
"since": "",
101+
"since": "1549052531 -0800",
96102
"excludes": [],
97103
},
98104
"spec": {
@@ -106,18 +112,18 @@ all_example_repos = {
106112
},
107113
"desktop": {
108114
"data": [
109-
"**/*.rb",
115+
"**/*.[tj]s",
110116
],
111-
"commit": "d1324f56d02dd9afca5d2e9da545905",
117+
"commit": "d1324f56d02dd9afca5d2e9da545905a7d41d671",
112118
"repo": "desktop/desktop",
113-
"since": "",
119+
"since": "1523834029 +1000",
114120
"excludes": [],
115121
},
116122
}
117123

118-
all_repo_deps = ["@" + k + "//:src" for (k, v) in all_example_repos.items()]
124+
semantic_external_test_repositories = ["@" + k + "//:src" for (k, v) in _all_example_repos.items()]
119125

120-
def example_repo(name, data, excludes, commit, repo):
126+
def _example_repo(name, data, excludes, commit, repo, since):
121127
new_git_repository(
122128
name = name,
123129
build_file_content = """
@@ -129,8 +135,9 @@ filegroup(
129135
""".format(data, excludes),
130136
commit = commit,
131137
remote = "https://github.com/{}.git".format(repo),
138+
shallow_since = since,
132139
)
133140

134141
def declare_example_repos():
135-
for k, v in all_example_repos.items():
136-
example_repo(name = k, data = v["data"], excludes = v["excludes"], commit = v["commit"], repo = v["repo"])
142+
for k, v in _all_example_repos.items():
143+
_example_repo(name = k, data = v["data"], excludes = v["excludes"], commit = v["commit"], repo = v["repo"], since = v["since"])

docs/build.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Semantic project supports builds with the Bazel build system. This is unconv
1010

1111
Assuming you're on macOS, run the script located at ~script/bootstrap-bazel~. This uses Homebrew to install Bazel and creates the `.bazel-cache` directory.
1212

13-
The first time you run `bazel build`
13+
The first time you run `bazel build`, it'll take some time, as Bazel will compile all of Stackage. Fear not: you won't have to do this again.
1414

1515
## `cabal``stack` cheatsheet
1616

@@ -36,7 +36,7 @@ If this seems complicated, don't worry: most of the time you'll be able to skip
3636
## Things to know
3737

3838
1. **Don't generally run `bazel clean`**. Since Bazel builds are reproducible, there's very little reason to clean, unless somehow your whole cache got irrevocably corrupted.
39-
2. **You can load a REPL for any target by appending `@repl`.**
39+
2. **You can load a REPL for any target by appending `@repl`.** (with the exception of the language packages, due to [this](https://github.com/tweag/rules_haskell/issues/1377)).
4040
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.
4141

4242
## Quick reference links
@@ -58,4 +58,6 @@ The default `.bazelrc` file imports a `.bazelrc.local` file if it's present; use
5858

5959
## Custom rules
6060

61-
We have two custom rules, defined in `build/common.bzl`. The first, `tree_sitter_node_types_archive`, uses the `http_archive` rule to download a specified tree-sitter grammar's `node-types.json` file. These calls declare new top-level targets, so they're only present in the top-level `WORKSPACE` file. The second, `semantic_language_library`, takes care of the boilerplate associated with declaring a target for a `semantic-LANG` language package (as these packages' contents are identical, their target declarations are almost identical).
61+
We have two common custom rules, defined in `build/common.bzl`. The first, `tree_sitter_node_types_archive`, uses the `http_archive` rule to download a specified tree-sitter grammar's `node-types.json` file. These calls declare new top-level targets, so they're only present in the top-level `WORKSPACE` file. The second, `semantic_language_library`, takes care of the boilerplate associated with declaring a target for a `semantic-LANG` language package (as these packages' contents are identical, their target declarations are almost identical).
62+
63+
For the purposes of setting up the examples upon which the `parse-examples` test depends, we have code in `build/example_repos.bzl` which defines them, checks them out, and computes the set of target names. You shouldn't need to change or modify this, unless you're adding new repos.

semantic/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ load(
2121
)
2222
load(
2323
"//:build/example_repos.bzl",
24-
"all_repo_deps",
24+
"semantic_external_test_repositories",
2525
)
2626

2727
haskell_toolchain_library(name = "ghc-prim")
@@ -197,7 +197,7 @@ haskell_test(
197197
"test/fixtures/javascript/**/*.js",
198198
"test/fixtures/typescript/**/*.ts",
199199
"test/fixtures/cli/*.json",
200-
]) + all_repo_deps,
200+
]) + semantic_external_test_repositories,
201201
deps = semantic_common_dependencies + [
202202
":fixtureshim",
203203
"//:base",

0 commit comments

Comments
 (0)