Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add .bazelrc containing RBE config #8

Closed
wants to merge 5 commits into from
Closed

Conversation

lolski
Copy link
Member

@lolski lolski commented Feb 18, 2019

What is the goal of this PR?

To enable RBE for faster tests. Closes #1.

What are the changes implemented in this PR?

  1. Added RBE configurations in the .bazelrc file. You can then invoke Bazel with RBE like so: bazel ... --config=rbe.
  2. CircleCI will only use RBE if the credential is supplied as an environment variable BAZEL_RBE_CREDENTIAL. The environment variable is set not from the code but from the CircleCI setting for the Graql repository.

@lolski lolski closed this Feb 18, 2019
@lolski lolski deleted the bazel-rbe branch February 18, 2019 10:35
@lolski lolski restored the bazel-rbe branch February 18, 2019 10:35
@lolski lolski added this to the v1.0 milestone Mar 28, 2019
@haikalpribadi haikalpribadi removed this from the 1.0.0 milestone Apr 22, 2019
haikalpribadi pushed a commit that referenced this pull request Jun 25, 2022
## What is the goal of this PR?

Previously, if a TypeQL string contained a syntax error, and also had a trailing newline, an unhelpful error was thrown: `Index 1 out of bounds for length 1`. This was due to a bug in the error handler.

Now, a more helpful error is reported, for instance:
```
There is a syntax error at line 1:
match $x isa thing
                  ^
no viable alternative at input 'match $x isa thing'
```

## What are the changes implemented in this PR?

Suppose we are parsing the following query:
```typeql
match $x isa thing

```
It includes a trailing newline.

Previously, we were attempting to parse the raw unmodified query string. The parser scans to the end of the query string and reports that there is a syntax error on line 2:
```
[TQL03] TypeQL Error: There is a syntax error at line 2:

^
no viable alternative at input 'match $x isa thing\n'
```
Firstly, this is still not a great error - it shows us that the "syntax error" is on a completely empty line.

Secondly, our error handler itself throws an error while trying to handle this error. In the error handler we convert the query string to a `List<String` using `String.split("\n")` with no `limit` parameter, which means that if the final character is a newline, we end up with less lines than we started with; in the example above, we have a 2-line query but only 1 entry in our String list.

We then print out a line from our string list that matches the line number where the error was reported, and boom, we get our `ArrayIndexOutOfBoundsException`.

We _could_ fix it by using `String.split("\n", -1)` which preserves all lines, even if they are blank; but, while that intuitively feels like the more "correct" fix, in practice, the resulting error is much nicer if we actually strip out the trailing newline. So we now use `trim` to strip out all leading and trailing whitespace, which should be intuitive enough for users.

(One thing to consider: should we strip only **trailing** whitespace?)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable Bazel RBE for new Graql repo in CircleCI
2 participants