Skip to content
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

feat(@bazel/jasmine): add coverage reporting #553

Merged
merged 1 commit into from Mar 28, 2019

Conversation

Toxicable
Copy link
Collaborator

@Toxicable Toxicable commented Feb 19, 2019

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Feature (please, look at the "Scope of the project" section in the README.md file)

What is the current behavior?

jasmine_node_test does not report code coverage

What is the new behavior?

jasmine_node_test does reports code coverage

Does this PR introduce a breaking change?

  • Yes
  • No

Example oputput:

:~/Documents/rules_nodejs/packages/jasmine$ bazel run test:coverage
INFO: Invocation ID: c4e9cd85-aad8-4fad-9537-71c8a665861c
INFO: Analysed target //test:coverage (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //test:coverage up-to-date:
  bazel-bin/test/coverage_loader.js
  bazel-bin/test/coverage.sh
INFO: Elapsed time: 0.190s, Critical Path: 0.01s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //test:coverage
-----------------------------------------------------------------------------
Randomized with seed 34724
Started
.


1 spec, 0 failures
Finished in 0.006 seconds
Randomized with seed 34724 (jasmine --random=true --seed=34724)

=============================== Coverage summary ===============================
Statements   : 0% ( 0/48 )
Branches     : 0% ( 0/20 )
Functions    : 0% ( 0/9 )
Lines        : 0% ( 0/47 )
================================================================================

@Toxicable
Copy link
Collaborator Author

While we do have it working so far I'm running into an issue where istanbul is istrumenting files that aren't apart of the sources.
Since we have a well define list of soruces that should be instrumented I think the best option would be to see if istanbul can implement an includes api rather than trying to use thei excludes api.

Without any exlucdes it'll auto discover these files, producing an incorrect sode coverage report.

"/home/f.wiles/Documents/rules_nodejs/third_party/github.com/buffer-from/index.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map-support/source-map-support.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/array-set.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/base64-vlq.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/base64.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/binary-search.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/mapping-list.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/quick-sort.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/source-map-consumer.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/source-map-generator.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/source-node.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/lib/util.js
/home/f.wiles/Documents/rules_nodejs/third_party/github.com/source-map/source-map.js
/home/f.wiles/.cache/bazel/_bazel_f.wiles/6b62bb60168067291695fe6dd86d865d/external/nodejs/bin/yarnpkg/bin/yarn.js
/home/f.wiles/.cache/bazel/_bazel_f.wiles/6b62bb60168067291695fe6dd86d865d/external/nodejs/bin/yarnpkg/lib/cli.js
/home/f.wiles/.cache/bazel/_bazel_f.wiles/6b62bb60168067291695fe6dd86d865d/external/nodejs/bin/yarnpkg/lib/v8-compile-cache.js
/home/f.wiles/Documents/rules_nodejs/packages/jasmine/src/jasmine_runner.js"

@alexeagle
Copy link
Collaborator

Seems like Istanbul hacking might not be needed anymore

In Node.js >=10.10.0 you can now set the environment variable NODE_V8_COVERAGE to a directory, this will result in V8 coverage reports being output in this location.
https://medium.com/the-node-js-collection/rethinking-javascript-test-coverage-5726fb272949

We could try that?

@Toxicable
Copy link
Collaborator Author

Oh wow, that looks awesome.
Yeah we'll have a look into that and see how we can intergrate it with the test runner.

It does mean we'll need to push a requirement on the nodejs version.
Could be done as a warning or maybe a flag to enable coverage collection + an error if the version isn't right.

@Toxicable
Copy link
Collaborator Author

@alexeagle Started inital work on v8-coverage.
the way im planning on doing it is by adding another .js file to the jasmine rule: jasmine_runner_host.js, this file will be the new entry point and will fork itself so it can set the NODE_V8_COVERAGE flag to a known directory for processing after tests and been executed.

However im running into issues where the sub process (jasmine_runner.js) is unable ro resolve "bazel" nodejs paths ie: Cannot find module 'npm_bazel_jasmine/test/foo_test.js' any ideas why this might happen?
Or if there's a better way to set the environment variable to a dir we know and and work on later on

@Toxicable
Copy link
Collaborator Author

I think this is ready for an inital review now

From looking at #312
I was able to execute the forked script, but it feels pretty hacky and I'm not sure if it'll work in other situations.

Executing tests from //test:coverage_test
-----------------------------------------------------------------------------
Randomized with seed 23022
Started
.


1 spec, 0 failures
Finished in 0.014 seconds
Randomized with seed 23022 (jasmine --random=true --seed=23022)

=============================== Coverage summary ===============================
Statements   : 90% ( 9/10 )
Branches     : 60% ( 3/5 )
Functions    : 100% ( 1/1 )
Lines        : 90% ( 9/10 )
================================================================================

@Toxicable Toxicable marked this pull request as ready for review February 22, 2019 20:05
@Toxicable Toxicable changed the title [WIP] feat(@bazel/jasmine): add coverage reporting feat(@bazel/jasmine): add coverage reporting Feb 22, 2019
@Toxicable
Copy link
Collaborator Author

So looks like the fork script hack only works when you run the test with bazel run if you use bazel test it fails to resolve the path.
Any advice how I can hook up these paths?

@alexeagle
Copy link
Collaborator

I don't see why you need to fork a process. We have control over the nodejs options passed to the original nodejs process that starts the tests. Can we set the flag there?

@Toxicable
Copy link
Collaborator Author

Toxicable commented Feb 24, 2019

@alexeagle Sure, all we need is to set the environment variable. I couldn't find how to do that with nodejs_binary

@Toxicable
Copy link
Collaborator Author

Toxicable commented Mar 2, 2019

Quick update here:

I tried doing this without using a forked script but it would appear the coverage file is only written once the node process exits. Meaning this must be done from some other process somehow.

This is what it looks like in that setup for reference
https://github.com/Toxicable/rules_nodejs/blob/169400aa4abbfc10ffd8d078910941d416496e28/packages/jasmine/src/jasmine_runner.js

@Toxicable
Copy link
Collaborator Author

Ignore what I said above, turns out I was all wrong, you can produce coverage without a new process.
I switched to a new lib: v8-coverage which internally starts the Nodejs inspector module.
Can be previewed with bazel run test:coverage_test, gives the output below.

Fabians-MacBook-Air:jasmine fabianwiles$ bazel run test:coverage_test
...
Executing tests from //test:coverage_test
-----------------------------------------------------------------------------
Debugger listening on ws://127.0.0.1:57032/c20d1245-cce8-42e5-b956-437c8b21dddf
For help, see: https://nodejs.org/en/docs/inspector
Randomized with seed 12938
Started
.
1 spec, 0 failures
Finished in 0.008 seconds
Randomized with seed 12938 (jasmine --random=true --seed=12938)

=============================== Coverage summary ===============================
Statements   : 80% ( 8/10 )
Branches     : 75% ( 3/4 )
Functions    : 100% ( 0/0 )
Lines        : 80% ( 8/10 )
================================================================================

@Globegitter
Copy link
Collaborator

@Toxicable if you want to be able to set the env variable before the target starts there is a generic solution, you can use the command rule from here: https://github.com/atlassian/bazel-tools/blob/master/multirun/README.md

Plus I also opened an issue: bazelbuild/bazel#7364 as I (and some of our devs on the team) expected this to be part of bazel in the same way as one can set args generically.

@Globegitter
Copy link
Collaborator

Globegitter commented Mar 3, 2019

Also are there any plans to integrate this with the bazel coverage command? If it is even in a state where one can do that. I do know official coverage support is still a bit of a WIP.

@Toxicable
Copy link
Collaborator Author

Toxicable commented Mar 3, 2019

@Globegitter Ahhh, thanks for the heads up on the command rule.
However, for this situation we'd still need to run some JS after the jasmine_runner has exited, since it would appear that using the NODE_V8_COVERAGE environment variable only writes the coverage once it exits the process. So we would still have to run some JS host that forks into jasmine_runner.
I think the current solution should work, aslong as there's no weird interactions with other apis due to using the inspector api.

As for bazel coverage - I'd definitely like to integrate with it and from here it should easy to do so really since we can go to any coverage format, I just don't know how, I havn't been able to find any docs on how to do so.
So for now using text-summary will work as a stop gap, I'm not sure if we want to merge it in this state without bazel coverage integration though.

@alexeagle
Copy link
Collaborator

I'll discuss with the Bazel team this week about adding proper bazel coverage command. I'll leave it to @Globegitter and @gregmagolan about whether to merge this with a text summary or wait for guidance.

Copy link
Collaborator

@Globegitter Globegitter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo this is useful to already get merged in without bazel coverage support. Just a few comments/questions I left from my side. And as I can see this is now always turned on, right? Might be worth making configurable as not everyone might want the coverage support active. Also might be worth allowing the regex for finding the coverage files to be configurable, but also happy to keep it simple for now and it is always easy to add if anyone would need this.

@@ -64,6 +78,7 @@ def jasmine_node_test(
templated_args = ["$(location :%s_devmode_srcs.MF)" % name],
testonly = 1,
expected_exit_code = expected_exit_code,
configuration_env_vars = ["NODE_V8_COVERAGE"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we expect this to be passed in by the user?

.bazelrc Outdated
@@ -1,12 +0,0 @@
# Print test logs for failed tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?

@@ -0,0 +1,3 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add this to gitignore

@@ -27,6 +33,9 @@ const BAZEL_EXIT_NO_TESTS_FOUND = 4;
// the maximum (See: https://nodejs.org/api/errors.html#errors_error_stacktracelimit)
Error.stackTraceLimit = Infinity;

const IS_TEST_FILE = /[^a-zA-Z0-9](spec|test)\.js$/i;
const IS_MODULE_MODULE = /\/node_modules\//
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to call it this, or maybe a typo?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name I mean btw.

all_data += [Label("//:src/jasmine_runner.js")]
runner_name = name + "." + "runner"

nodejs_binary(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to wrap this in a nodejs_binary compared to how it was before?

@@ -18,6 +18,7 @@ package(default_visibility = ["//visibility:public"])

exports_files([
"src/jasmine_runner.js",
"src/jasmine_runner_host.js",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this file. Leftover?

@Toxicable
Copy link
Collaborator Author

Toxicable commented Mar 12, 2019

@Globegitter Thanks for the review. Will do a tidy up tonight.

Right now it's on no matter what. There is a small perf overhead ~20% with this.
Maybe we should provide an attribute to opt-in incase there's issues we havn't seen with it so far, then later on make a breaking change to switch to opt-out to encourage people to use the coverage report.
Although im not sure how we'd pass down extra flags from nodejs_test into the runner, we'd have to convert this into a actual rule definition right? (i've always struggled to make those work)

Im not sure what you mean by

regex for finding the coverage files to be configurable,

This is the part where we filter out the coverage collected from external source files
https://github.com/bazelbuild/rules_nodejs/pull/553/files#diff-b7f7068522dfd058878f39fba971463aR87
which is just a direct file match, I don't see why you'd want it to be configurable though, this will always pick up all user source files that were in the test, is there case where you'd only want a subset of that?

@Toxicable Toxicable force-pushed the jasmine-coverage branch 2 times, most recently from ad71a3a to f90f6ef Compare March 13, 2019 08:10
@Globegitter
Copy link
Collaborator

Yeah I think we should have coverage turned off by default for now and then later we can switch it on. One way I can see it work is by adding a coverage parameter to the jasmine_node_test macro and if that is set you can pass a custom arg via args to the nodejs_test and then that can be checked in the runner.

@Globegitter
Copy link
Collaborator

About the file match, yeah the static one you have works for idiomatic bazel usage, but I was thinking of code bases like our own where we have common js code in sloppy file group targets that have a bunch of files grouped together even if an app might just need a subset. So in that case we might want to be able to specify our own regex to filter out specific files. But as I said I think it is good to keep it simple and promote idiomatic use. So I think it makes sense to just leave it as is.

@Toxicable
Copy link
Collaborator Author

@Globegitter Ah yes, I see your point, makes sense.

I've implemented the coverage flag and disabled it by default.
Your arguments idea works well here
You can re-enable it with coverage = True in your jasmine_node_test

One remaining point is that I'm using the dep "@npm//v8-coverage" - should we make a npm_bazel_jasmine_deps yarn_install to get this dep from instead?
I've noticed there's been a bit of change about where these deps are coming from lately so not sure on the best option.

@Globegitter
Copy link
Collaborator

I am also not familiar with the new process yet, but as far as I understand, once this is merged a new npm package has to be built and then one just adds the latest @bazel/jasmine to their package.json and will get the dependencies via normal npm resoultion. Maybe @alexeagle or @gregmagolan can fill in on how the release / dependency process is currently working.

@gregmagolan
Copy link
Collaborator

gregmagolan commented Mar 13, 2019

Yes @Globegitter you are correct. /packages/jasmine gets packaged up by //packages/jasmine:npm_package and released as @bazel/jasmine. With yarn_install or npm_install, the npm package installs the npm_bazel_jasmine workspace via the generated @npm://install_bazel_workspaces.bzl and it also pulls in transitive npm deps such as the jasmine npm package.

@gregmagolan
Copy link
Collaborator

For CI & developing & testing locally I made a number shell scripts that build the packages before running the e2e test and examples. You can call ./scripts/build_packages.sh jasmine to build the jasmine package and its is copied out of the bazel-out folder into /dist/jasmine. The e2e tests and examples then link to this package in their package.json.

@gregmagolan
Copy link
Collaborator

So, if @bazel/jasmine requires the v8-coverage npm package then that just needs to be added as a dependency to /packages/jasmine/package.json and it will be pulled into a user's node_modules transitively when the install @bazel/jasmine.

Hmmmm. I think I need to spend some time to document this in DEVELOPING.md :)

@Toxicable
Copy link
Collaborator Author

Toxicable commented Mar 14, 2019

Alrighty, I think we're good to go here now.
I added a bit of a summary to the commit message description of this feature and it's current status.
Also debugging still appears to work even with the internal call the inspector API
v8-coverage is definitely in the package.json so deps should be good once in user land

Copy link
Collaborator

@Globegitter Globegitter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the quick responses @Toxicable. The only thing that would be nice is some e2e test that actually verifies that the coverage report is in the output / is not in the output dependent on the setting. But I would be inclined to get it merged already with this basic smoke test. What do you think @gregmagolan?

Copy link
Collaborator

@gregmagolan gregmagolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @Toxicable. Thanks for the nice addition. Left a few comments. Sorry but you'll need a rebase. We got some jasmine fixes in this morning.

packages/jasmine/src/jasmine_node_test.bzl Outdated Show resolved Hide resolved
packages/jasmine/test/BUILD.bazel Show resolved Hide resolved
packages/jasmine/src/jasmine_runner.js Outdated Show resolved Hide resolved
packages/jasmine/src/jasmine_node_test.bzl Outdated Show resolved Hide resolved
packages/jasmine/src/jasmine_runner.js Outdated Show resolved Hide resolved
Adds Coverage collection support via the V8 Coverage API's
This feature is disabled by default but can be enabled with `coverage = True`
There is a performance overhead (~20%) by enabling this feature
When enabled the only reported is text-summary which outputs the coverage
summary as stdout, but we plan to intergrate with bazel coverage for better reporting
accross a whole repository
@Toxicable
Copy link
Collaborator Author

@gregmagolan Thanks for the review, I've addressed all your points, let me know if there's anything else.
With the exception of adding an e2e test for the text-summary output. Since in my next PR ill be turning that off text-summary and going to lcov in an attempt to intergrade with bazel coverage

@gregmagolan gregmagolan merged commit 9abc78f into bazelbuild:master Mar 28, 2019
@Globegitter
Copy link
Collaborator

@gregmagolan @Toxicable One thing I forgot is documentation, I assume skydoc should pick up the added comment about coverage automatically, but is there anything automatically updating the docs? Looking at https://bazelbuild.github.io/rules_nodejs/jasmine_node_test/jasmine_node_test.html#jasmine_node_test I can not see the new coverage attribute commented.

@gregmagolan
Copy link
Collaborator

@gregmagolan @Toxicable One thing I forgot is documentation, I assume skydoc should pick up the added comment about coverage automatically, but is there anything automatically updating the docs? Looking at https://bazelbuild.github.io/rules_nodejs/jasmine_node_test/jasmine_node_test.html#jasmine_node_test I can not see the new coverage attribute commented.

We typically update the docs with each release so the docstring from jasmine_node_test.bzl will get updated at that point:

def jasmine_node_test(
        ...
        **kwargs):
    """Runs tests in NodeJS using the Jasmine test runner.

    To debug the test, see debugging notes in `nodejs_test`.

    Args:
      name: name of the resulting label
      srcs: JavaScript source files containing Jasmine specs
      data: Runtime dependencies which will be loaded while the test executes
      deps: Other targets which produce JavaScript, such as ts_library
      expected_exit_code: The expected exit code for the test. Defaults to 0.
      tags: bazel tags applied to test
      jasmine: a label providing the jasmine dependency
      coverage: Enables code coverage collection and reporting
      **kwargs: remaining arguments are passed to the test rule
    """

which includes the short description of coverage.

@alexeagle Has done more work on docs and some things have changed since moving to separate npm packages such as @npm//jasmine. I don't know if we have the docs from each package hosted at bazelbuild.github.io yet. The docs there may still be from the legacy /internal/jasmine_node_test rule.

Globegitter added a commit to Globegitter/rules_nodejs that referenced this pull request Jun 6, 2019
Add toolchain files.

Working toolchain setup for normal build.

Early progress on multi-os npm packages.

Introduce @bazel/jasmine package

This will eventually replace the built-in jasmine_node_test rule.
It has the advantage that it brings a transitive dep on the jasmine npm package

Fix broken test; wasn't run on CI

make node_repositories optional

The common WORKSPACE pattern is to pass no arguments to it, and use yarn_install or npm_install
We can make the trivial WORKSPACE file shorter."

Update README

Adds a quickstart section and a listing of rules. I think this can be our manifest of first-party authored rules

Add release instructions for @bazel/jasmine (bazelbuild#552)

Improve jasmine warning message

rel: 0.18.7

Fix release instructions

Update README.md; fix typo

of -> or

Include install_bazel_workspaces in quickstart

README: fix quickstart

npm_package: allow root package to vendor content from external workspace

Add @bazel/typescript package

I checked the content of the built package by diff'ing it against the currently built one

Add minimal testing for new packages/typescript

Cleanup README, add generated API docs

Increase circleci machine size

Now that we have to compile Go, TypeScript, etc to build rules_typescript from source

Generalize npm release for more packages

Fix @bazel/typescript package for downstream usage

Add missing BUILD file to @bazel/typescript package

Revert "Add missing BUILD file to @bazel/typescript package"

This reverts commit 283f140.
It broke the build

Move load() statement at the top.

Bazel might enforce it in the future (--incompatible_bzl_disallow_load_after_statement)

Move @bazel/karma from rules_typescript (bazelbuild#558)

* Move @bazel/karma package to rules_nodejs

* ci: split to more jobs

Add e2e tests for @bazel/jasmine, @bazel/karma & @bazel/typescript npm packages

Update docs for release

rel: 0.26.0-beta.0

Clean up new published markdown docs

Move copy_repository from tools to internal

Refactor /internal/test:node_modules into @npm + fixes (bazelbuild#575)

Fixes:

* `yarn_install/npm_install` `generate_build_file.js` now treats every folder under node_modules as a package regardless of it having a package.json file or not. npm will treat them as such when resolving so we should too.
* jasmine_runner attempts to require jasmine-core from `jasmine/node_modules/jasmine-core` before falling back to `jasmine-core`. this is so that if `jasmine-core`, which is a transitive dep of `jasmine` is not hoisted it can still be required with only the `@npm//jasmine` dep
* jasmine_node_test (in `@bazel/jasmine`) `jasmine` attribute change to `@npm//@bazel/jasmine` since this is the only guaranteed label. `@npm//jasmine` may not exists if it is not hoisted
* symlinked data files in yarn_install & npm_install cause issues if these are used as npm packages via `file://` on linux. copies are made of files instead

Introduce @bazel/labs package.

This follows the same rationale as @angular/labs.
I imagine things like the Webpack plugin should go here until they reach stability

Add renovate.json

Switch build_bazel_rules_typescript to git_repository

Fix commit sha of rules_typescript

rel: 0.26.0

chore(deps): update build_bazel_rules_typescript commit hash to c1b7492

Update rollup_bundle dependencies

We now tree-shake @PURE-annotated code.

Fix @bazel/typescript homepage URL

Fix _copy.sh shebang

/bin/bash does not exist on all systems. E.g. NixOS. This patch uses
`/usr/bin/env bash` instead.

Add yarn 0.13.0 and make it the default version of yarn for node_repositories() (bazelbuild#590)

Fix launcher_template.sh shebang (bazelbuild#589)

Fix release version in README.md

The release script didn't know how to replace the "beta.0" segment

chore(deps): update build_bazel_rules_typescript commit hash to 94cfb6d

Produce native ES modules in rollup es2015 mode

Change the names of the chunk directories. Having dots in the names make users assume these are files, not directories.
Also the 'cs' extension isn't as obvious as 'chunks'.

It seems wrong that the test has to change to grab the default export. Need to figure out still.

Switch from uglify-es to terser.

The former is unmaintained, and we want terser so we can minify es2015 code.

Add buildifier settings for VSCode

Use correct name es2015 rather than es6

Fixes for rollup_bundle refactoring

Change the es2015 primary js output to native modules rather than systemjs

Add minified es2015 output to rollup_bundle

Docs (bazelbuild#596)

* cleanup package.jsons

use repository rather than homepage pointing to github

* fix formatting nits in @bazel/typescript README

Update bazel toolchains pin and add toolchain config target

WIP: switch to stardoc

Move rule docstrings to the doc attribute

Revert docstring move for repository_rule

it doesn't have a doc attribute, and isn't supported by stardoc yet

Fix stardoc to document rules, not the wrapping macros

Add parallelism for test_e2e circleci job

chore(deps): update build_bazel_rules_typescript commit hash to 023eb7b

Add commonjs plugin to rollup_bundle

Lint fix

Update internal/e2e/rollup_fine_grained_deps test after adding commonjs plugin to rollup_bundle

Remove old code

Fix RBE build

Lint fix

Update docs for release

rel: 0.27.0

release process should run locally installed bazel version

fix(@bazel/typescript): remove unknown rules from generated API doc

Hopefully this fixes it so npmjs will render the README

rel: 0.27.1

Remove @bazel/typescript deps on jasmine/karma

These should only be in @bazel/karma package

feat(@bazel/jasmine): add shard_count support

Improve build & reduce ci build time with parallelism

Fixes following big refactoring

rel: 0.27.2

fix(@bazel/jasmine): convert shard vars to number

rel: 0.27.3

Re-do logic from jrunner.execute() in jasmine_runner.js since we're now calling jasmine.getEnv().execute(specs) instead (bazelbuild#609)

chore(deps): update build_bazel_rules_typescript commit hash to 45cf49b

rel: 0.27.4

Support differential loading

web_package rule will now create separate script tags for ESmodule files and es5 javascript.
See the examples/web_package

Also fixes linting nit in the README for the order of attributes.
Add ibazel dependency for local development

chore(deps): update build_bazel_rules_typescript commit hash to 329ecca

Add examples & e2e tests from rules_typescript & related fixes

Enable clang-format for .proto files

Address review comment

Remove unnecessary fencing in /packages/typescript/BUILD.bazel

Add missing .bazelignore files for nested workspaces with node_modules folders

Link deps in package.json files when building & publishing releases

Remove unused build target

Make test sharding work with jasmine focusing

Instead of manually passing the specs, use the built-in filtering mechanism

Update docs for release

rel: 0.27.5

fix yarn_install and npm_install after changed packages

Previously it did not re-copy the package contents, so the bazel workspace would be stale

Fix jasmine entry_point and bootstrap pattern

Update dependency io_bazel_rules_go to v0.18.1

rel: 0.27.6

Fix web_package injector nomodule issue when no matching script ESModule script

Update rules_typescript to 3a85a90

circleci: remove post_checkout step

it's broken on master, and has fallen behind the setup in angular/angular

rel: 0.27.7

Use cacheable http_archive with sha256 for io_bazel as its a very large download (bazelbuild#624)

Add rollup-plugin-amd to rollup_bundle to support bundling *.ngfactory.js AMD files generated by ngc

This is a workaround for the following issue angular/angular#29491

rel: 0.27.8

Update README.md

Fixes bazelbuild#628

chore(deps): update build_bazel_rules_typescript commit hash to d6fe9d4

fix jasmine_node_test with sharding doesn't fail

feat(@bazel/jasmine): add coverage reporting (bazelbuild#553)

Adds Coverage collection support via the V8 Coverage API's
This feature is disabled by default but can be enabled with `coverage = True`
There is a performance overhead (~20%) by enabling this feature
When enabled the only reported is text-summary which outputs the coverage
summary as stdout, but we plan to integrate with bazel coverage for better reporting
across a whole repository

Don't load the deprecated jasmine_node_test from other rules.

This prints extra warnings in users builds that they can't fix (and the warnings don't even indicate what file has the dependency)

fix(docs): Remove unrelated module mappings comments (bazelbuild#634)

The comments were copied from module_mappings.bzl but they are unrelated
to the file in context.

Fix jasmine & jasmine-core requires in jasmine_runner.js (bazelbuild#633)

* Fix jasmine & jasmine-core requires in jasmine_runner.js
* Fix local jasmine package test
* Fix bad require logic that ends up requiring wrong jasmine-core

Don't update gecko driver or selenium stand-alone in webdriver-manager update calls

We don't require either for CI or tests and they are not pinned which led to an intermittent CI failure with the gecko driver recently.

Add jasmine_node_test that fails without fix from bazelbuild#633

rel: 0.27.9

Checkout and test latest angular-bazel-example with latest nodejs rules in CI

Run examples e2e script if it exists in package.json (for angular-bazel-example testing)

Update to latest rules_typescript

Run buildifier.

Clarify install instructions to fix a pitfall (bazelbuild#648)

Fixes bazelbuild#647

Support yarn_install & npm_install `bazelBin` `additionalAttributes` for generated nodejs_binary targets for package.json `bin` files (bazelbuild#649)

Clean packages from yarn cache in process_package_json step of yarn_install that have file:// URIs (bazelbuild#639)

Also includes local development script updates

Add visible alias for the metadata entry of ts_devserver

When writing custom web servers that host your development environment,
it is necessary to have the manifest of all development files that need
to be served. This change reexposes the manifest under the provided
visibility for consumption in such purposes.

feat: Add ng_apf_library rule & dev_scripts_aspect

This commit adds detection logic for NPM packages that are in
the Angular Package Format (APF) and generates `ng_apf_library`
target instead of the default filegroup target.

`ng_apf_library` targets provide a custom `scripts` attribute,
which is then later collected by `dev_scripts_aspect` and
exposed through the `dev_scripts` provider.

dev_scripts are automatically appended to ts_devserver `scripts`
and ts_web_test_suite `srcs` so that they no longer need to be
specified manually.

For more info see design doc:
https://docs.google.com/document/d/16t7s3DplajCEbDwZTXyeYWIBHnXc22nngrXfVitFFNo

test(npm_install): Add angular deps and update golden files

refactor(sources_aspect): collect node_sources and dev_scripts

rel: 0.27.10

fix(e2e/karma): workspace name should be e2e_karma_typescript (bazelbuild#654)

fix(npm_install) exclude test directory (bazelbuild#653)

PR closes bazelbuild#652

Delete per platform deps as well as some other unnecessary code.

Download correct nodejs version and have convinience nodejs.

Lint fix.

Rename build file and add toolchain files to the release package.

Fix lint.

Add toolchain bazel libraries.

Added platforms and fix fetching.

Fix host os.

Special case nodejs name.

Added more debugging logs.

Fix windows builds.

Remove debug statements.

test(karma): Add test for aspect collecting from srcs, deps, runtime_deps

build: remove duplicate dependencies

At the moment jasmine-core and semver are listed both as dependencies and dev dependencies.

Update bazel_skylib dependency to 0.8.0

Fix Buildifier warning

chore(deps): update dependency com_github_mattn_go_isatty to v0.0.7

Fix for bazelbuild#652: Running "bazel run @nodejs//:yarn" twice fails with unlink error

Remove unused file export (bazelbuild#664)

Update scripts to unlink deps in package.json for nested workspaces after builds & tests to reduce local changes (bazelbuild#665)

Update lock files in nested workspaces (bazelbuild#666)

Put @fine_grained_deps_yarn and @fine_grained_deps_npm package.json files in separate folders (bazelbuild#667)

This is part of pre-factoring for switching to user node_modules in yarn_install & npm_install

Update to rollup-plugin-node-resolve 4.2.0 and use new mainFields option

Add .bazelignore to nested workspaces

Update dependency io_bazel_rules_go to v0.18.2

Cleanup mkdirp and unnecessary code in web_package/assembler.js

Fix yarn & npm determinism tests in /internal/e2e/packages

Cleanup rollup bundle variable name

Update bazel_toolchains commit hash to eedddd4

Setup angular-bazel-example for local testing in test_all.sh script

fix(karma): turn on Karma debug logs in DEBUG mode

Cleanup package_example

* rename workspace to internal_e2e_packages
* separate folders for each yarn_install & npm_install as prefactor for user node_modules

chore(deps): update bazel_toolchains commit hash to ed6370d

Replace genrules with copy_file/write_file rules (bazelbuild#658)

The new rules are in bazel_skylib 0.8.0. Their
advantages over genrule are:

- cleaner rule interface
- no Bash required on Windows
- compatible with Bazel's Bash-less test execution
  on Windows

See bazelbuild/bazel#6622

Support for transitive npm dependencies (bazelbuild#675)

Add test for transitive npm deps in rollup_bundle to e2e/typescript_3.1

Preserve symlinks when resolving in rollup_bundle and ensure it does not resolve outside of execroot sandbox

Consolidate node module rules & providers & support transitive npm deps via collect_node_modules_aspect

Introduce a webpack_bundle rule

It lives in the @bazel/labs package for now to set users expectations properly.

Add e2e test for webpack_bundle

chore(deps): update build_bazel_rules_typescript commit hash to 0bd1791

chore(deps): update bazel_toolchains commit hash to 1255911

Fix duplicate deps in yarn_install & npm_install generated scope targets

.

rel: 0.27.11

rel: 0.27.12

chore(deps): update bazel_toolchains commit hash to 9c2e98b

feat(karma): Load karma-* dependencies from @bazel/karma

This commit adds plugins.js to resolve karma-* dependencies installed by
@bazel/karma.

feat(karma): bump karma-jasmine to v2

This would make it consistent with the version of karma-jasmine
used in projects generated by the CLI.
https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/workspace/files/package.json.template#L39

fix(bazel): export getNativeBinary()

`@bazel/bazel` should export getNativeBinary() method so that downstream
consumers can locate the actual Bazel binary and spawn a process using
custom options. If loaded as script the package should work as before.

chore(deps): update dependency io_bazel_rules_go to v0.18.3

Add LICENSE files (bazelbuild#696)

This makes us work with https://www.npmjs.com/package/license-checker

Simplify versions in package.bzl for renovate (bazelbuild#695)

feat(rollup): provide output groupings of js+map for each bundle type

Add jasmine-core dependency to @bazel/jasmine since it is required in its index (bazelbuild#698)

fix: create nodejs_binary rules for non-empty bin entries

Fixes bazelbuild#692

fix(npm_package): deps should allow files

BREAKING CHANGE: npm_package now throws for any files in `srcs` which
do not reside in the same package as the target.

The `deps` attr of `npm_package` should allow files.
A common use case would be named output of other rules, such as
`rollup_bundle`. In which case, user should be able to add
`bundle.umd.js` from `rollup_bundle` to the deps of npm_package.

Windows: fix jasmine_node_test on Windows with TW

Fix the jasmine_node_test() rule on Windows when
tested with Bazel's Windows-native test wrapper
(see bazelbuild/bazel#5508).

jasmine_node_test now uses nodejs_test_macro, so
on Windows it depends on the sh_test (whose output
is an .exe file) and not on nodejs_test (whose
output is a .sh file). The native test wrapper
can't test nodejs_test directly because it can't
create a subprocess for an .sh file.

Fix //internal/npm_package/test:test

Change the file npm_package.spec.js was locating,
from "test.sh" to just "test".

Add missing progress_message to actions (bazelbuild#706)

Fixes bazelbuild#705

chore: update to @bazel/bazel 0.24.1 and other deps (bazelbuild#712)

Updated deps are pinned and will be added renovate shortly so that deps are updated automatically in the future

Update to buildifier 0.22.0 and fix new lint warnings (bazelbuild#713)

Don’t check no-effect warning since doc attribute causes a build error in Ubuntu 14.04 only. Need to update to stardoc. See bazelbuild/buildtools#471 for more details.

Don’t gitignore /internal/npm_install/test/golden/node_modules

Also clean *all* node_modules folders in clean script included nested ones

Don't test on Ubuntu 14.04 (bazelbuild#718)

Ubuntu 14.04 is about to be end-of-life and Bazel CI will stop supporting it shortly afterwards.

Context: https://groups.google.com/d/msg/bazel-dev/_D6XzfNkQQE/8TNKiNmsCAAJ

Remove yarn_install & npm_install dependency on Windows powershell

Fixes angular/angular#29760

Remove /internal/e2e/bazel_workspaces as this coverage is handled by 'bazel run @test_workspace//:bin'

Once bazelbuild/bazel#8090 it can be covered with 'bazel test @test_workspace//...' instead

Run targets in BazelCI

Rollup bundle rule does not resolve external source maps

In order to support external source-maps, the `rollup-plugin-sourcemaps` module has been added to the
rollup configuration. Unfortunately this currently only has an effect on Windows as the sandbox is not
available and the plugin can read the referenced external `.map` files.

When running in the Bazel sandbox or within RBE, these map files can't be read by the plugin because the `.map`
files are omitted from the `run_rollup` action inputs. This causes inconsistent behavior and makes the sourcemaps
plugin a no-op right now.

feat(rollup): provide es5 and minified umd bundles

Closes bazelbuild#685

update pin to bazel toolchains repo

rel: 0.28.0

feat(rollup): add rollup-plugin-json

No --types for rollup_bundle tsc downleveling & make --libs consistent between tsc and tsc-directory

This fixes an issue observed where types files could break downleveling action if they used higher level language constructs

Add check_bazel_version_range function

Return typescript legacy provider from node_modules_library with the npm package's typescript declaration files

Cleanup srcs/deps/scripts attributes in node_module_library and its usage

Generated __pkg targets should not use srcs but should only specify __files targets in deps so that sources_aspect picks up all dev_scripts via deps tree which means the transitive lookup in node_module_library can be removed

Update dependency io_bazel_rules_go to v0.18.4

chore(deps): update build_bazel_rules_typescript commit hash to e50c806

chore(deps): update dependency com_github_kylelemons_godebug to v1

fix(web_package): normalize root paths consistently with ts_devserver

Fixes bazelbuild#728

handle  in expand_path_into_runfiles

Update npm fine grained deps targets to support strict npm deps

Add missing strict npm deps

Example of compile error that turning on strict npm deps resulted in:

```
main.spec.ts:1:21 - error TS2307: transitive dependency on external/npm/node_modules/typescript/lib/typescript.d.ts not allowed. Please add the BUILD target to your rule's deps.
1 import * as ts from 'typescript';
```

Add a `@npm//node_modules/package:package__umd` named_umd_bundle target to npm packages. (bazelbuild#725)

This generates a named-UMD bundle @npm//node_modules/package:package.umd.js if this file does not already exists. For npm packages that don’t ship with named UMD bundles, this target can be used to supply one to rules such as ts_devserver & ts_web_test_suite.

update dependency to v8-coverage@1.0.9

fixes bazelbuild#748

Update rules_webtesting

This fixes the warning /usr/local/google/home/alexeagle/.cache/bazel/_bazel_alexeagle/5c094f47f582dc47fc598194e749d5c0/external/bazel_skylib/skylark_library.bzl:23:1: WARNING: skylark_library.bzl is deprecated and will go away in the future, please use bzl_library.bzl instead.

Turn on npm strict deps by updating to rules_typescript commit that enables it for ts_library

Update docs for release

rel: 0.29.0

Update to bazel 0.25.1 (bazelbuild#752)

* Update to bazel 0.25.1

* Load syntax fix

vendor parse5

This allows us to remove one of our nested yarn install commands.
It makes the first build faster and simplifies how installation works.

chore(deps): update build_bazel_rules_typescript commit hash to 2335368

Lint fix.

Some progress.

Fix build with --incompatible_depset_is_not_iterable

Soon, Bazel will forbid iteration on a depset, it needs to be explicitly
converted to list.

Update @bazel/karma to latest sable Chromium 74 for osx & linux (bazelbuild#766)

OSX Chromium 73+ requires disabling of the sandbox under Bazel
Windows still on Chromium 66 and updating that is a separate task and requires changes to rules_webtesting as the archive name & executable path has changed

Mirror bazel and buildifier

This adds a Windows binary for buildifier

Update build_bazel_rules_typescript commit hash to 695059f

Update protobuf dependency

With this change, the code works with Bazel flag `--incompatible_disable_deprecated_attr_params`, which will be enabled soon.

Add zlib dependency for protobuf

Update dependency io_bazel_rules_go to v0.18.5

rel: 0.29.1

add `ngI18nClosureMode` constant to terser

rel: 0.29.2

feat: user’s workspace node_modules used by yarn_install & npm_install (bazelbuild#704)

Optimize string.match(regex) to regex.test(string) (bazelbuild#704)

Cleanup of internal/e2e tests (bazelbuild#704)

Add clean_legacy_e2e.sh script for local dev (bazelbuild#704)

Lock file updates (bazelbuild#704)

Update to Bazel 0.26.0-rc10 (bazelbuild#704)

Minimum Bazel version is now 0.26.0 as yarn_install & npm_install depend on managed_directories by default (bazelbuild#704)

choose Bazel RC to get tests passing on buildkite (bazelbuild#704)

Remove empty attributes from generated BUILD files (bazelbuild#704)

Filter out .bin and other folders starting with . from list of packages (bazelbuild#704)

Update golden (bazelbuild#704)

Fix examples/angular to use bazel version from root package.json (bazelbuild#704)

update bazel for buildkite again

rc11 was built on wrong platform

Fforward all args to originalResolveFilename

Make sure to test the require resolve behaiour.

Add missing file.

Ensure to pass on all arguments in all cases.

Fix.

Remove debugging statement.

chore(deps): update build_bazel_rules_typescript commit hash to 7b6fde8

chore(deps): update dependency com_github_mattn_go_isatty to v0.0.8

Update docs for release

rel: 0.30.0

Add test coverage for manual_build_file_contents...  (bazelbuild#780)

* Add test coverage for manual_build_file_contents via an example of how to make a target for node_modules/.bin/*

* Address review comment

* Bazel lint

Extract common bazelrc to a shared file (bazelbuild#781)

Add `query --experimental_allow_incremental_repository_updates` to common.bazelrc as its needed for bazel query to run

`run --experimental_allow_incremental_repository_updates` is not needed

Only require Bazel 0.26.0 when using symlinked node_modules in yarn_install or npm_install as this requires the managed directories feature

If symlinked node_modules is not used the minimum Bazel version is 0.21.0

rel: 0.30.1

Cleanup examples_angular now that it uses managed directories

Fix angular-bazel-example test in CI which was crashing and flaking out (bazelbuild#792)

`bazel test //e2e:all` was crashing before the tests even started in CI. Possibly out of memory but not sure how that is possible as it was running in the xlarge 16GB container. This PR moves the angular-bazel-example test to its own CI job (which speeds up overall CI time as its critical path) and runs the same CI tests that angular-bazel-example runs in its own CI.

Add buildozer package mirroring

chore(deps): update build_bazel_rules_typescript commit hash to c160db9

Add jasmine dependency to @bazel/typescript

Update README.md

Fixes bazelbuild#793

Vendor in removeNPMAbsolutePaths (bazelbuild#763)

Fixes npm_install target cycle Bazel crash

Test for npm_install remove removeNPMAbsolutePaths target cycle regression (bazelbuild#763)

This failure only shows up in downstream workspaces so we should use npm_install in a subset of nested workspaces. Changing /examples/parcel & /e2e/bazel_bin to npm_install here.

Remove link_deps & unlink_deps scripts (bazelbuild#795)

Now that yarn_install runs in the user's WORKSPACE we can use relative `file:../../dist/npm_package_foobar` references in nested workspace package.json. Add a touch_deps.sh script which goes through all nested workspaces and dirties them when a package is generated or re-generated.

fix(karma): static_files overwrite files specified in dependencies

Currently when someone specifies a `static_files` target that
transitively brings in a package "X", and there is a target
in the `deps` that transitively also brings in "X", the files
from "X" are accidentally **not** included in the Karma ConcatJS
bundle and the tests will fail since a required dependency is not
executed/included.

Fix typescript package dependency on jasmine package

Introduce @bazel/create package

This gives us an even simpler novice user on-ramp to create a Bazel/npm project

Add unit test for @bazel/create

Include more .bazelrc settings in new workspaces

Create npm_install unless we run under yarn create

check for valid bazel workspace name

Moved output from bazel-bin to dist/bin

code review feedback

fix: license SPDX should be `Apache-2.0` instead of `Apache 2.0` (bazelbuild#803)

The Apache license version 2.0 SPDX short identifier is Apache-2.0

Remove bazelWorkspaces version & compatVersion as we now have a single version policy (bazelbuild#783)

Also fixes & adds test for bazelWorkspaces.rootPath

Remove detection logic for warning on global bazel (bazelbuild#801)

It was failing in some cases, see attached bug.
We shouldn't recommend a global install anyway. using yarn bazel or npx bazel is probably better

Fixes bazelbuild#656

@bazel/create: support --packageManager option

@bazel/create: add --typescript option

Update README to recommend @bazel/create for quickstart

fixes for release process

rel: 0.30.2

another release script fix

Fix for @bazel/create --typescript option coming first

Fix npx comment

Set --preserve-symlinks-main flag along with --preserve-symlinks flag when node version is 10.2.0 or greater (bazelbuild#806)

Bust CircleCI node_modules cache (bazelbuild#806)

Update examples/vendored_node to reflect best practice of specifying node version (bazelbuild#810)

The docs for node_repositories() reflect this now and the reason is that node_repositories() will set node options depending on version used

feat: move to husky hook

Remove node_runfiles dependency

Remove node_runfiles.

Fix compatibility for Bazel 0.27

Add --incompatible_string_join_requires_strings to .bazelrc

This will avoid regressions. The flag can be removed at the end of the
month (after Bazel 0.27 release).

jasmine_node_test macro: pass templated_args through to nodejs_test.

without this, a jasmine_node_test target specifying templated_args
will be broken, since the macro unconditionally passes its own
templated_args. (duplicated keywords in a rule is an error in the
loading phase.)

port bazelbuild#398 to new jasmine_node_test

add a test case for it

Remove es5.min rollup_bundle output from runfiles

Having it there causes it to always be built, whether requested or not.
This partially unblocks using rollup_bundle in dev mode.

BREAKING CHANGE:
if you expect the rollup_bundle es5.min file to be a runtime dependency of a rule, you must now include it in the data[] of that rule

Update to latest rules_typescript commit

Add pre-push hook to check Bazel formatting/lint

It's really annoying to run through an extra CI pass when you forget to do these

chore: add a commit message linter

This sets us up to start automating the changelogs

refactor(bazel): cleanup and simplify the toolchain config

fix(bazel): add missing files

fix(bazel): lint

fix(bazel): lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants