bazelbuild / rules_nodejs

NodeJS toolchain for Bazel.

Home Page:https://bazelbuild.github.io/rules_nodejs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bazel rule jasmine_test fails stating `copying files failed`

0x4ngK4n opened this issue · comments

What happened?

Project structure:

[root]

  • spec
    -- index.spec.ts
  • src
    -- index.ts
    tsconfig.json
    package.json
    package-lock.json
    BUILD
    WORKSPACE

WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

##############
## JS RULEZ ##
##############

http_archive(
    name = "aspect_rules_js",
    sha256 = "e3e6c3d42491e2938f4239a3d04259a58adc83e21e352346ad4ef62f87e76125",
    strip_prefix = "rules_js-1.30.0",
    url = "https://github.com/aspect-build/rules_js/releases/download/v1.30.0/rules_js-v1.30.0.tar.gz",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")

nodejs_register_toolchains(
    name = "nodejs",
    node_version = DEFAULT_NODE_VERSION,
)

##############
## TS RULEZ ##
##############

http_archive(
    name = "aspect_rules_ts",
    sha256 = "7d964d57c6e9a54b0ce20f27e5ea84e5b42b6db2148ab7eb18d7110a082380de",
    strip_prefix = "rules_ts-1.2.4",
    url = "https://github.com/aspect-build/rules_ts/releases/download/v1.2.4/rules_ts-v1.2.4.tar.gz",
)


##################
# rules_ts setup #
##################
# Fetches the rules_ts dependencies.
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
# Alternatively, you can skip calling this function, so long as you've
# already fetched all the dependencies.
load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")

rules_ts_dependencies(
    # This keeps the TypeScript version in-sync with the editor, \
    # which is typically best.
    ts_version_from = "//:package.json",

    # Alternatively, you could pick a specific version, or use
    # load("@aspect_rules_ts//ts:repositories.bzl", "LATEST_VERSION")
    # ts_version = LATEST_VERSION
)

nodejs_register_toolchains(
    name= "node",
    node_version = DEFAULT_NODE_VERSION,
)

# Register aspect_bazel_lib toolchains;
# If you use npm_translate_lock or npm_import from aspect_rules_js \
# you can omit this block.
load("@aspect_bazel_lib//lib:repositories.bzl", \
"register_copy_directory_toolchains", \
"register_copy_to_directory_toolchains")

register_copy_directory_toolchains()

register_copy_to_directory_toolchains()


################
## JASMINE RULEZ ##
################

http_archive(
    name = "aspect_rules_jasmine",
    sha256 = "4c16ef202d1e53fd880e8ecc9e0796802201ea9c89fa32f52d5d633fff858cac",
    strip_prefix = "rules_jasmine-1.1.1",
    url = "https://github.com/aspect-build/rules_jasmine/releases/download/v1.1.1/rules_jasmine-v1.1.1.tar.gz",
)

#######################
# rules_jasmine setup #
#######################
# Fetches the rules_jest dependencies.
load("@aspect_rules_jasmine//jasmine:dependencies.bzl", "rules_jasmine_dependencies")

# Fetch dependencies which users need as well
rules_jasmine_dependencies()

BUILD file:

load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_jasmine//jasmine:defs.bzl", "jasmine_test")

ts_project(
    name="transpile",
    srcs = ["src/index.ts"],
    tsconfig= "//:tsconfig.json",
    allow_js=True,
    resolve_json_module=True
)

jasmine_test(
    name = "test",
    args = ["spec/*.spec.js"],
    chdir = package_name(),
    data = [
        ":transpile",
        "spec/index.spec.ts",
    ],
    node_modules = "//:node_modules",
)

src/index.ts:

#!/usr/bin/env node

"use strict";
export function adder (one: number, two: number) {
    return one + two
}

export function concatenate (one: string, two: string) {
    return one + two
}


console.log("Hello! Welcome.");

spec/index.spec.ts

let { adder, concatenate } = require('../src/index.ts');

describe('adder module', function() {
    it('test_adder', function(){
        expect(adder(1,2)).toBe(3)
    });
});

bazel --version

bazel 6.2.1-homebrew

Error Output:

angkanchanda@Hackbook %bazel run //:test
INFO: Analyzed target //:test (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /Users/angkanchanda/Desktop/ts_test/BUILD:12:13: Copying file node_modules/jasmine-reporters failed: (Exit 1): bash failed: error executing command (from target //:test) /bin/bash -c 'cp -f "$1" "$2"' '' node_modules/jasmine-reporters bazel-out/darwin-fastbuild/bin/node_modules/jasmine-reporters
cp: node_modules/jasmine-reporters is a directory (not copied).
ERROR: /Users/angkanchanda/Desktop/ts_test/BUILD:12:13: Copying file node_modules/jasmine failed: (Exit 1): bash failed: error executing command (from target //:test) /bin/bash -c 'cp -f "$1" "$2"' '' node_modules/jasmine bazel-out/darwin-fastbuild/bin/node_modules/jasmine
cp: node_modules/jasmine is a directory (not copied).
Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.256s, Critical Path: 0.08s
INFO: 9 processes: 5 internal, 1 darwin-sandbox, 3 local.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target

Version

Development (host) and target OS/architectures:

Output of bazel --version:

Version of rules_nodejs, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

No response

Any other information?

No response

If this is an aspect_rules_jasmine issue this should be filed under https://github.com/aspect-build/rules_jasmine/

The @bazel/jasmine package in this repo is no longer maintained, and your example seems to have aspect_rules_jasmine?

This issue has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs in 30 days. Note as of rules_nodejs v6 the rules_nodejs repository contains only the core nodejs toolchain and @bazel/runfiles package. All rulesets are removed and unmaintained. For alternate rulesets suggestions include https://github.com/aspect-build/rules_js, https://github.com/aspect-build/rules_ts Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

This issue was automatically closed because it went 30 days without any activity since it was labeled "Can Close?"