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: add generate_empty_layers attribute to js_image_layer #1714

Merged
merged 1 commit into from
May 10, 2024

Conversation

gregmagolan
Copy link
Member

@gregmagolan gregmagolan commented May 10, 2024

Useful for when using js_image_layer with rules_docker in consistent manner for all images regardless of which layers are empty:

RULES_JS_LAYERS = [
    "node",
    "package_store_3p",
    "package_store_1p",
    "node_modules",
    "app",
]

def js_container_layers(name, binary, root, tags = []):
    js_image_layer(
        name = "{}/layers".format(name),
        binary = binary,
        generate_empty_layers = True,
        root = root,
        visibility = ["//visibility:__pkg__"],
    )

    [
        [
            native.filegroup(
                name = "{}/layers/{}.tar".format(name, layer),
                srcs = ["{}/layers".format(name)],
                output_group = layer,
            ),
            container_layer(
                name = "{}/{}_layer".format(name, layer),
                tars = [":{}/layers/{}.tar".format(name, layer)],
                tags = tags + ["manual"],
            ),
        ]
        for layer in RULES_JS_LAYERS
    ]

with generate_empty_layers = False the above example may fail with a message such as:

(18:01:23) ERROR: /home/runner/work/rules_js/rules_js/e2e/js_image_docker/BUILD.bazel:78:16: in tars attribute of container_layer_ rule //:package_store_1p_layer: '//:package_store_1p_tar' does not produce any container_layer_ tars files (expected .tar, .tar.xz, .tar.gz or .tgz). Since this rule was created by the macro 'container_layer', the error might have been caused by the macro implementation

if there are empty layers

@gregmagolan gregmagolan changed the base branch from main to 2.x May 10, 2024 18:00
@gregmagolan gregmagolan changed the title add generate empty layers param to js image layer feat: add generate_empty_layers attribute to js_image_layer May 10, 2024
@gregmagolan gregmagolan requested review from thesayyn and jbedard May 10, 2024 18:02
@gregmagolan gregmagolan force-pushed the add_generate_empty_layers_param_to_js_image_layer branch from 0e2b278 to 4740eac Compare May 10, 2024 18:03
@gregmagolan gregmagolan requested a review from alexeagle May 10, 2024 18:04
Copy link

aspect-workflows bot commented May 10, 2024

Test

1 test target passed

Targets
//docs:update_5_test [k8-fastbuild]                 134ms

Total test execution time was 134ms. 189 tests (99.5%) were fully cached saving 51s.


Test

e2e/bzlmod

All tests were cache hits

4 tests (100.0%) were fully cached saving 467ms.


Test

e2e/gyp_no_install_script

All tests were cache hits

2 tests (100.0%) were fully cached saving 693ms.


Test

e2e/js_image_oci

All tests were cache hits

1 test (100.0%) was fully cached saving 9s.


Test

e2e/npm_link_package

All tests were cache hits

2 tests (100.0%) were fully cached saving 845ms.


Test

e2e/npm_link_package-esm

All tests were cache hits

2 tests (100.0%) were fully cached saving 773ms.


Test

e2e/npm_translate_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/npm_translate_lock_empty

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 271ms.


Test

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 117ms.


Test

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

1 test (100.0%) was fully cached saving 248ms.


Test

e2e/npm_translate_package_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/npm_translate_yarn_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 511ms.


Test

e2e/pnpm_lockfiles

All tests were cache hits

6 tests (100.0%) were fully cached saving 2s.


Test

e2e/pnpm_workspace

All tests were cache hits

8 tests (100.0%) were fully cached saving 3s.


Test

e2e/pnpm_workspace_rerooted

All tests were cache hits

6 tests (100.0%) were fully cached saving 2s.


Test

e2e/repo_mapping

All tests were cache hits

2 tests (100.0%) were fully cached saving 451ms.


Test

e2e/rules_foo

All tests were cache hits

2 tests (100.0%) were fully cached saving 393ms.


Test

e2e/vendored_node

All tests were cache hits

1 test (100.0%) was fully cached saving 187ms.


Buildifier      Format

@gregmagolan gregmagolan force-pushed the add_generate_empty_layers_param_to_js_image_layer branch from 4740eac to 1a85da6 Compare May 10, 2024 18:08
js/private/js_image_layer.bzl Outdated Show resolved Hide resolved
@gregmagolan gregmagolan force-pushed the add_generate_empty_layers_param_to_js_image_layer branch from 1a85da6 to f82745a Compare May 10, 2024 21:06
@gregmagolan gregmagolan merged commit 2dff8a4 into 2.x May 10, 2024
106 checks passed
@gregmagolan gregmagolan deleted the add_generate_empty_layers_param_to_js_image_layer branch May 10, 2024 22:14
jbedard pushed a commit to jbedard/rules_js that referenced this pull request May 14, 2024
jbedard pushed a commit to jbedard/rules_js that referenced this pull request May 16, 2024
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.

3 participants