Skip to content

Msp fix sourcelink git hash#433

Draft
MaximilianSoerenPollak wants to merge 17 commits intoeclipse-score:mainfrom
MaximilianSoerenPollak:MSP_fix_sourcelink_git_hash
Draft

Msp fix sourcelink git hash#433
MaximilianSoerenPollak wants to merge 17 commits intoeclipse-score:mainfrom
MaximilianSoerenPollak:MSP_fix_sourcelink_git_hash

Conversation

@MaximilianSoerenPollak
Copy link
Contributor

Fixes source_code_linker to find and create correct links to source code & tests

📌 Description

Fixes source_code_linker to find and create correct links to source code & tests

🚨 Impact Analysis

  • This change does not violate any tool requirements and is covered by existing tool requirements
  • This change does not violate any design decisions
  • Otherwise I have created a ticket for new tool qualification

✅ Checklist

  • Added/updated documentation for new or changed features
  • Added/updated tests to cover the changes
  • Followed project coding standards and guidelines

!Note: Currently the tests are pointing somewhere not correctly (always seems like 5-15 lines lower than it should be).
I have not yet figured out why that is.
Also I think some tests are missing too.

I just wanted to ask for a architecture review of this @a-zw

Especially I'm a bit unhappy about how bazel is handeled and unsure if this is the correct way to approach this (with the hacky path appending / cutting).
But I could not think of another way except have two seperate solutions (for each build way).

Please let me know any and all feedback, nothing here is written in stone and I'm happy to change the implementation / architecture of it.

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //src:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.3.0) and connecting to it...
INFO: Invocation ID: fb1c93ca-adee-45e2-8d5d-3225d0497724
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: src
Loading: 0 packages loaded
    currently loading: src
Analyzing: target //src:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //src:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //src:license-check (66 packages loaded, 9 targets configured)

Analyzing: target //src:license-check (70 packages loaded, 9 targets configured)

Analyzing: target //src:license-check (98 packages loaded, 192 targets configured)

Analyzing: target //src:license-check (128 packages loaded, 2477 targets configured)

Analyzing: target //src:license-check (130 packages loaded, 2518 targets configured)

Analyzing: target //src:license-check (140 packages loaded, 2576 targets configured)

Analyzing: target //src:license-check (140 packages loaded, 2576 targets configured)

Analyzing: target //src:license-check (140 packages loaded, 2576 targets configured)

Analyzing: target //src:license-check (144 packages loaded, 4589 targets configured)

INFO: Analyzed target //src:license-check (145 packages loaded, 4715 targets configured).
[11 / 16] Creating runfiles tree bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/score_tooling+/dash/tool/formatters/dash_format_converter.runfiles [for tool]; 0s local ... (2 actions running)
[14 / 16] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
[15 / 16] Building src/license.check.license_check.jar (); 0s disk-cache, multiplex-worker
INFO: Found 1 target...
Target //src:license.check.license_check up-to-date:
  bazel-bin/src/license.check.license_check
  bazel-bin/src/license.check.license_check.jar
INFO: Elapsed time: 22.969s, Critical Path: 2.61s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/src/license.check.license_check src/formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

The created documentation from the pull request is available at: docu-html

"//scripts_bazel:generate_sourcelinks",
"//src/extensions/score_source_code_linker",
] + all_requirements,
pytest_config = "//:pyproject.toml",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also move this to different PR?

Had to enable pyrproject.toml as pytest.ini from score_pytest made it impossible to tests in ref-integration.

Though 'strictly' speaking has nothing to do with this PR

Comment on lines +51 to 55
# assert root.is_absolute(), f"Root path must be absolute. {root} is not"
#assert not file_path.is_absolute(), "File path must be relative to the root"
# assert file_path.is_relative_to(root), (
# f"File path ({file_path}) must be relative to the root ({root})"
# )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to rethink what asserts we can make here if any without blowing everything up

Comment on lines +129 to +130
test_module = (
str(file).split("external/")[-1].split("/")[0].removesuffix("+")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave as is or split in 2 lines / commands for readability?

assert root.is_absolute(), "Root path must be absolute"
assert not file_path.is_absolute(), "File path must be relative to the root"
# assert root.is_absolute(), f"Root path must be absolute. {root} is not"
#assert not file_path.is_absolute(), "File path must be relative to the root"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code is bad. Commented asserts are even more weird to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said in my own comment.

These should either be commented in again or removed, that is correct.
I left them outcommented as it is still unclear which direction the PR goes. Once that is clear we can either remove or enable them again.

# Module can be None if we are not in a combo build
if "external" in str(file):
test_module = (
str(file).split("external/")[-1].split("/")[0].removesuffix("+")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes Bazel internals. There should be a cleaner way which does not break if Bazel changes something there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do very much agree. I hope there is a cleaner way to do it maybe via bazel actions or something unsure currently.
If there is this and may other things can be re-written cleaner and nicer in cooperation with the infra of bazel.

# If external is in the filepath that gets parsed =>
# file is in an external module => combo build
# e.g. .../external/score_docs_as_code+/src/helper_lib/__init__.py
if "external" in str(filepath):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if some module has an external folder in their repo?

I believe a more reliable check should be possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be an issue as it splits on the left and maxsplit=1 therefore only the first external (which will always be the one before module name) will be removed, and if the module itself has some 'external' folder inside of it, that would be preserved.
But I will add a testcase to proof this.

return f"{base_url}/blob/{current_hash}/{link.path}/{link.file}#L{link.line}"


def get_module_has_from_known_good_json(known_good_path: Path) -> dict[str, ModuleInfo]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are not sure about the schema of known_good, we should have more checks and warnings/errors here to diagnose issues quickly (e.g. from some CI log).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the schema inside known good?

According to the ref-int guys the schema may change in some ways inside there, (more 2ndary keys or so) but the actual keys and structure should not change much.
Though if it does we will know.

Theoretically if we have a json schema that the 'known_good' needs to adhere to, to be parsed, would that make sense ?
And then test if the passed in known_good does adhere to that or error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants