-
Notifications
You must be signed in to change notification settings - Fork 12k
Use Bazel for repo unit tests #11749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f3f256a
to
0795013
Compare
2f8d914
to
42b5b39
Compare
.circleci/config.yml
Outdated
@@ -127,6 +154,9 @@ workflows: | |||
requires: | |||
- lint | |||
- validate | |||
- test-bazel: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not wise to have separate build and test jobs for bazel. you guarantee that the first test can't start running until the slowest build step is finished, so the total time is longer. Better to let bazel be the only scheduler for its actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into the same job.
BUILD
Outdated
# e.g. node_modules/xpath/docs/function resolvers.md | ||
"node_modules/**/docs/**", | ||
# e.g. node_modules/puppeteer/.local-chromium/mac-536395/chrome-mac/Chromium.app/Contents/Versions/66.0.3347.0/Chromium Framework.framework/Chromium Framework | ||
"node_modules/**/.*/**" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we now also add an exclude for spaces
node_modules/**/* *
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added that one too.
WORKSPACE
Outdated
@@ -1,52 +1,73 @@ | |||
workspace(name = "angular_devkit") | |||
workspace(name = "angular_cli") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note, this change has downstream implications for bazel usage (in angular/angular we load this workspace to get build optimizer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hadn't considered that. Perhaps it's better to leave it as is. WDYT?
WORKSPACE
Outdated
|
||
BAZEL_SKYLIB_VERSION = "0.3.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove this now with rules_typescript 0.16.1
@@ -12,28 +12,19 @@ package(default_visibility = ["//visibility:public"]) | |||
ts_library( | |||
name = "architect", | |||
srcs = glob( | |||
["src/**/*.ts"], | |||
# Currently, this library is used only with the rollup plugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove the comment? was it stale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is not applicable at all. It looks like it was copy pasted from the build-optimizer BUILD file.
data = glob(["**/*.json"]), | ||
deps = [ | ||
"//packages/angular_devkit/core", | ||
"//packages/angular_devkit/core:node", | ||
"@rxjs", | ||
"@rxjs//operators", | ||
], | ||
tsconfig = "//:tsconfig.json", | ||
module_name = "@angular-devkit/architect", | ||
module_root = "src", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we no longer need module root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do, but it's added above (before data).
42b5b39
to
1f36fe9
Compare
.circleci/config.yml
Outdated
@@ -123,7 +142,7 @@ workflows: | |||
requires: | |||
- lint | |||
- validate | |||
- build-bazel: | |||
- bazel: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs update here too
https://github.com/angular/angular-cli/blob/master/.github/angular-robot.yml#L46
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
BUILD
Outdated
|
||
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") | ||
|
||
buildifier( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work all the way now?
I'm curious if it picks up .bzl files too
If this approach works well, I might want to update my other repos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It worked locally when I hacked buildifier to work on windows at all.
Can I ask you to test though? I haven't tested on linux/osx. Plus the hacks to make it work on windows involve setting absolute paths and it's always a bit of a hassle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried testing it and it made edits.
Can we move buildifier to a separate PR?
WORKSPACE
Outdated
) | ||
|
||
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories") | ||
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies") | ||
rules_nodejs_dependencies() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to load nodejs dependencies, the rules_typescript_dependencies() will do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to avoid relying on that transitively though? Inside this project we don't know what rules_typescript
depends on, but we depend directly on rules_nodejs
for node_repositories
and jasmine_node_test
(maybe others too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the advantage is we're sure to get a version of rules_nodejs that works with rules_typescript.
Unlike under NPM, we don't get two versions of rules_nodejs installed if us and one of our deps disagree on the version. So it's our responsibility to get working versions of both, and I think that's easier if we use the same rules_nodejs version as rules_typescript declares a dependency on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a note that we're using it transitively then.
WORKSPACE
Outdated
# rules_typescript_dependencies() also tries to load it but we add it explicitely so we | ||
# don't have hidden dependencies. | ||
# This also means we need to load it before rules_typescript_dependencies(). | ||
RULES_GO_VERSION = "0.14.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
picking out the versions into variables doesn't seem that useful to me, I've avoided it so we can set up renovate to update automatically (I don't think it understands this)
many repos use git_repository
, I avoided that because I thought it might fetch the whole git history and therefore wasteful, but I don't know that for sure. It has the advantage of the version appearing once instead of twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using git_repository
before but asked @gregmagolan and he mentioned that it had been historically flaky (@gregmagolan correct me if I'm wrong).
I think it makes sense to ditch the variable if Renovate doesn't play ball with it though.
WORKSPACE
Outdated
go_rules_dependencies() | ||
|
||
go_register_toolchains() | ||
# # We get Buildifier from here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
deps = [ | ||
":build_optimizer", | ||
"//packages/angular_devkit/core", | ||
# @typings: jasmine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be interesting to sync this to google3 and see if all the tests pass there too
tools/defaults.bzl
Outdated
if not tsconfig: | ||
tsconfig = DEFAULT_TSCONFIG | ||
_ts_library(tsconfig = tsconfig, **kwargs) | ||
if not tsconfig: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually you can remove this now, ts_library#tsconfig
defaults to //:tsconfig.json
as of release 0.15 or so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
5705974
to
71b811b
Compare
@@ -52,7 +52,7 @@ describe('TsLintTaskExecutor', () => { | |||
testRunner.runSchematicAsync('run-task', null, tree), | |||
new Observable<void>(obs => { | |||
process.chdir(getSystemPath(host.root)); | |||
testRunner.logger.subscribe(x => messages.push(x.message)); | |||
testRunner.logger.subscribe((x: logging.LogEntry) => messages.push(x.message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this change? logger
is already a Observable<LogEntry>
, so curious as to why TypeScript doesn't infer this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When made the initial PR this was not being inferred correctly, and I was not sure why. Tried again now and it wasn't a problem anymore. Maybe an older version of tooling?
71b811b
to
7881d93
Compare
a99726b
to
f1a7c81
Compare
f1a7c81
to
4bf5321
Compare
It stops the function from being imported in the unit test.
], | ||
), | ||
module_name = "@angular-devkit/schematics/tasks", | ||
module_root = "tasks", | ||
tsconfig = "//:tsconfig.json", | ||
module_root = "tasks/index.d.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing it to index.d.ts will hide the tasks/node, is that on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean, can you elaborate? I didn't mean to hide any package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tasks/index.ts only export all the tasks, the task executors are exported through tasks/node
Changing module_root to "tasks/index.d.ts" will make tasks/node is not reachable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks!
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.