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(builtin): add configuration_env_vars to npm_package_bin #1549

Merged
merged 2 commits into from
Jan 14, 2020

Conversation

gregmagolan
Copy link
Collaborator

@gregmagolan gregmagolan commented Jan 14, 2020

This behaves similarly to configuration_env_vars in nodejs_binary except it passes the env vars to the process via the env attribute of ctx.actions.run.

Also add support for picking up env vars from ctx.configuration.default_shell_env if they are not found in ctx.vars.

  • ctx.vars will contain values from --define=FOO=BAR
  • ctx.configuration.default_shell_env will --action_env=FOO=BAR (but not from --action_env=FOO).

test: add test coverage for npm_package_bin configuration_env_vars

And test coverage for using --action_env=FOO=BAR to pass env variables to npm_package_bin & nodejs_binary

This behaves similarly to `configuration_env_vars` in `nodejs_binary` except it passes the env vars to the process via the `env` attribute of `ctx.actions.run`.

Also add support for picking up env vars from `ctx.configuration.default_shell_env` if they are not found in `ctx.vars`.

* `ctx.vars` will contain values from `--define=FOO=BAR`
* `ctx.configuration.default_shell_env` will `--action_env=FOO=BAR` (but not from `--action_env=FOO`).
And test coverage for using --action_env=FOO=BAR to pass env variables to npm_package_bin & nodejs_binary
@gregmagolan
Copy link
Collaborator Author

This unblocks #1516 which is failing as the NG_BUILD_CACHE needs to be passed to the arcitect() rule and neither --define=NG_BUILD_CACHE=false or --action_env=NG_BUILD_CACHE=false work right now.

With this change either of those will work if configuration_env_vars is used with the target:

architect(
    name = "build",
    args = [
        "frontend:build",
        "--outputPath=$(@D)",
    ],
    data = glob(
        [
            "src/*",
            "src/**",
        ],
        exclude = [
            "src/**/*.spec.ts",
            "src/test.ts",
        ],
    ) + [
        "angular.json",
        "browserslist",
        "tsconfig.app.json",
        "tsconfig.json",
        "@npm//mime",
        "@npm//@angular/cli",
        "@npm//@angular/core",
        "@npm//@angular/router",
        "@npm//@angular/platform-browser-dynamic",
        "@npm//@angular-devkit/architect-cli",
        "@npm//@angular-devkit/build-angular",
    ],
    output_dir = True,
    configuration_env_vars = ["NG_BUILD_CACHE"]
)

@gregmagolan
Copy link
Collaborator Author

Related issue for reference: #1548

@gregmagolan gregmagolan merged commit cdc93bd into bazel-contrib:master Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants