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

Sonarqube executable target do not dereference its runfiles symlinks. #11

Open
EnnioTorre opened this issue Nov 12, 2020 · 0 comments
Open

Comments

@EnnioTorre
Copy link

Hi,

I cannot get the scm information uplodaed on the SonarQube server.
Simple code snippet using the bazel examples.

This is the BUILD file under the root directory, same location of the .git.

filegroup(
    name = "git",
    srcs = glob(
        [".git/**"],
        exclude = [".git/**/*[*"],  # gitk creates temp files with []
    ),
    visibility = ["//visibility:public"],
)

Following is instead the BUILD under the java-tutorial folder.

load("@rules_java//java:defs.bzl", "java_binary")

java_binary(
    name = "ProjectRunner",
    srcs = glob(["src/main/java/com/example/*.java"]),
)

load("@rules_java//java:defs.bzl", "java_test")

java_test(
    name = "ProjectRunnerTest",
    srcs = ["src/test/java/com/example/GreatingTest.java"],
    test_class = "com.example.GreatingTest",
    deps = [
        "//java-tutorial:ProjectRunner",
        
    ],
)

filegroup(
    name = "coverage_report",
    srcs = ["bazel-out/_coverage/_coverage_report.dat"], # Created manually
    tags = ["manual"],
    visibility = ["//visibility:public"],
)

load("@bazel_sonarqube//:defs.bzl", "sonarqube")

sonarqube(
    name = "sq",
    project_key = "com.example.project:project",
    project_name = "My Project",
    srcs = glob(["src/main/java/com/example/*.java"]),
    coverage_report = ":coverage_report",
    targets = [
        "//java-tutorial:ProjectRunner",
    ],
    scm_info = ["//:git"],
    tags = ["manual"],
    sq_properties_template = "example-prop_copy.tpl",
)

Sonarqube cannot read from the .git directory, scm files are not are not readable.

INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 2 source files to be analyzed
INFO: SCM Publisher 0/2 source files have been analyzed (done) | time=93ms
WARN: Missing blame information for the following files:
WARN: * java-tutorial/src/main/java/com/example/Greeting.java
WARN: * java-tutorial/src/main/java/com/example/ProjectRunner.java
WARN: This may lead to missing/broken features in SonarQube

More info.

INFO: Base dir: /root/.cache/bazel/_bazel_root/c094d1e8783f928ddd8321888260df40/execroot/main/bazel-out/k8-fastbuild/bin/java-tutorial/sq.runfiles/main

ls -la /root/.cache/bazel/_bazel_root/c094d1e8783f928ddd8321888260df40/execroot/main/bazel-out/k8-fastbuild/bin/java-tutorial/sq.runfiles/main
total 24
drwxr-xr-x 6 root root 4096 Nov 12 18:58 .
drwxr-xr-x 5 root root 4096 Nov 12 18:58 ..
drwxr-xr-x 7 root root 4096 Nov 12 18:45 .git
drwxr-xr-x 3 root root 4096 Nov 12 18:59 .scannerwork
drwxr-xr-x 4 root root 4096 Nov 12 18:10 external
drwxr-xr-x 4 root root 4096 Nov 12 18:58 java-tutorial

git blame java-tutorial/src/main/java/com/example/Greeting.java
fatal: no such path 'bazel-out/k8-fastbuild/bin/java-tutorial/sq.runfiles/main/java-tutorial/src/main/java/com/example/Greeting.java' in HEAD

The .git has broken links!!!

the correct one seem to be under /.cache/bazel/_bazel_root/c094d1e8783f928ddd8321888260df40/execroot/main

/.cache/bazel/_bazel_root/c094d1e8783f928ddd8321888260df40/execroot/main# git blame java-tutorial/src/main/java/com/example/Greeting.java
001bd290 (Serge Pomorski 2017-06-06 14:38:22 -0400 1) package com.example;
001bd290 (Serge Pomorski 2017-06-06 14:38:22 -0400 2)
7cfc2470 (Xùdōng Yáng 2020-05-12 20:33:50 +1000 3) public class Greeting {
00000000 (Not Committed Yet 2020-11-12 19:08:53 +0100 4) public static String sayHi() {
001bd290 (Serge Pomorski 2017-06-06 14:38:22 -0400 5) System.out.println("Hi!");
00000000 (Not Committed Yet 2020-11-12 19:08:53 +0100 6) return "Hi!";
001bd290 (Serge Pomorski 2017-06-06 14:38:22 -0400 7) }
001bd290 (Serge Pomorski 2017-06-06 14:38:22 -0400 8) }
001bd290 (Serge Pomorski 2017-06-06 14:38:22 -0400 9)

Can you suggest a work around/fix ?

Thanks.

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

No branches or pull requests

1 participant