Skip to content

Commit

Permalink
Review comments addressed
Browse files Browse the repository at this point in the history
- Switch to `disable_sandbox` defaulting to true
- Removed unused attribute from rule impl
  • Loading branch information
mrmeku committed Apr 30, 2024
1 parent 6ca0aeb commit a3a48b7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 23 deletions.
7 changes: 0 additions & 7 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ nodejs_register_toolchains(
node_version = DEFAULT_NODE_VERSION,
)

load("@aspect_rules_cypress//cypress:repositories.bzl", "cypress_register_toolchains")

cypress_register_toolchains(
name = "cypress",
cypress_version = "12.3.0",
)

# For running our own unit tests
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

Expand Down
16 changes: 8 additions & 8 deletions cypress/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ _cypress_test = rule(
toolchains = js_binary_lib.toolchains + ["@aspect_rules_cypress//cypress:toolchain_type"],
)

def _cypress_test_macro(name, entry_point, cypress, **kwargs):
def _cypress_test_macro(name, entry_point, cypress, disable_sandbox, **kwargs):
tags = kwargs.pop("tags", [])
if not kwargs.pop("allow_sandbox", False):
if disable_sandbox:
tags.append("no-sandbox")
_cypress_test(
name = name,
Expand All @@ -38,7 +38,7 @@ def _cypress_test_macro(name, entry_point, cypress, **kwargs):
def cypress_test(
name,
cypress = "//:node_modules/cypress",
allow_sandbox = False,
disable_sandbox = True,
browsers = [],
**kwargs):
"""cypress_test runs the cypress CLI with the cypress toolchain.
Expand All @@ -52,7 +52,7 @@ def cypress_test(
Args:
name: The name used for this rule and output files
cypress: The cypress npm package which was already linked using an API like npm_link_all_packages.
allow_sandbox: Turn off sandboxing by default to allow electron to perform write operations.
disable_sandbox: Turn off sandboxing by default to allow electron to perform write operations.
Cypress does not expose the underlying electron apis so we
cannot alter the user app data directory to be within the bazel
sandbox.
Expand Down Expand Up @@ -92,7 +92,7 @@ def cypress_test(
name = name,
entry_point = entry_point,
cypress = cypress,
allow_sandbox = allow_sandbox,
disable_sandbox = disable_sandbox,
browsers = browsers,
**kwargs
)
Expand All @@ -101,7 +101,7 @@ def cypress_module_test(
name,
runner,
cypress = "//:node_modules/cypress",
allow_sandbox = False,
disable_sandbox = True,
browsers = [],
**kwargs):
"""cypress_module_test creates a node environment which is hooked up to the cypress toolchain.
Expand Down Expand Up @@ -133,7 +133,7 @@ def cypress_module_test(
runner: JS file to call into the cypress module api
See https://docs.cypress.io/guides/guides/module-api
cypress: The cypress npm package which was already linked using an API like npm_link_all_packages.
allow_sandbox: Turn off sandboxing by default to allow electron to perform write operations.
disable_sandbox: Turn off sandboxing by default to allow electron to perform write operations.
Cypress does not expose the underlying electron apis so we
cannot alter the user app data directory to be within the bazel
sandbox.
Expand Down Expand Up @@ -165,7 +165,7 @@ def cypress_module_test(
name = name,
entry_point = runner,
cypress = cypress,
allow_sandbox = allow_sandbox,
disable_sandbox = disable_sandbox,
browsers = browsers,
**kwargs
)
3 changes: 0 additions & 3 deletions cypress/private/cypress_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ load("@aspect_rules_js//js:libs.bzl", "js_binary_lib", "js_lib_helpers")
load("@bazel_skylib//lib:dicts.bzl", "dicts")

_attrs = dicts.add(js_binary_lib.attrs, {
"allow_sandbox": attr.bool(
default = False,
),
"browsers": attr.label_list(
allow_files = True,
),
Expand Down
8 changes: 4 additions & 4 deletions docs/defs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/workspace/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local_path_override(
)

cypress = use_extension("@aspect_rules_cypress//cypress:extensions.bzl", "cypress")
cypress.toolchain(cypress_version = "12.3.0")
cypress.toolchain(cypress_version = "12.12.0")
use_repo(cypress, "cypress_toolchains")

register_toolchains("@cypress_toolchains//:all")
Expand Down

0 comments on commit a3a48b7

Please sign in to comment.