Skip to content

Commit 0720311

Browse files
authored
docs: fix issues and improve the source finder tutorial (#924)
Signed-off-by: behnazh-w <[email protected]>
1 parent b5afe0d commit 0720311

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

tests/repo_finder/resources/find_source_report_schema.json renamed to docs/source/_static/schemastore/find_source_report_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "macaron-json-report-schema",
4-
"title": "Macaron JSON Report",
3+
"$id": "macaron-source-finder-json-report-schema",
4+
"title": "Macaron Source Finder JSON Report",
55
"$comment": "For any details about the schema specification and validation documentation, see https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-00 and https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00.",
66
"type": "object",
77
"properties": {

docs/source/pages/tutorials/source_finder.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Source Finder
77

88
This tutorial demonstrates how Macaron can find the source commit of a given artifact, and optionally the source repository, while performing no analyses. This operation exists as a standalone feature, using the ``find-source`` command, for users that wish to utilise only these features of Macaron without spending time performing additional unnecessary steps.
99

10-
Unlike the integrated commit finder (demonstrated in another tutorial :doc:`here </pages/tutorials/source_finder>`), the ``find-source`` command does not require cloning the target repository, thereby saving time in many cases, and disk space in all cases. For those who still wish to clone the repository as part of the process, a configuration option exists and will be explained below.
10+
Unlike the integrated commit finder (demonstrated in another tutorial :doc:`here </pages/tutorials/commit_finder>`), the ``find-source`` command does not require cloning the target repository, thereby saving time in many cases, and disk space in all cases. For those who still wish to clone the repository as part of the process, a configuration option exists and will be explained below.
1111

1212
******************************
1313
Installation and Prerequisites
@@ -52,7 +52,7 @@ To open the report and view the contents, you can use the following:
5252
5353
open output/reports/npm/semver/semver.source.json
5454
55-
Inside you will find the ``repo`` and ``commit`` properties have been populated with ``https://github.com/npm/node-semver`` and ``eb1380b1ecd74f6572831294d55ef4537dfe1a2a`` respectively. As this is a GitHub repository, Macaron also creates a URL that leads directly to the reported commit, found under the ``url`` property.
55+
Inside you will find the ``repo`` and ``commit`` properties have been populated with ``https://github.com/npm/node-semver`` and ``eb1380b1ecd74f6572831294d55ef4537dfe1a2a`` respectively. As this is a GitHub repository, Macaron also creates a URL that leads directly to the reported commit, found under the ``url`` property. You can find the JSON schema for this output file :download:`here <../../_static/schemastore/find_source_report_schema.json>`.
5656

5757
If the repository for an artifact is already known, the ``find-source`` command can be given it to save looking it up again. To do this, the command changes to:
5858

@@ -66,7 +66,7 @@ If the repository for an artifact is already known, the ``find-source`` command
6666
Execution with Clone
6767
********************
6868

69-
For the case where cloning the repository is desirable, perhaps because further use of the contents are planned, Macaron requires this to be specified in a custom ``ini`` configuration file that is passed as input. See `How to change the default configuration </pages/using#change-config>`_ for more details. Within the configuration file the following option should be set:
69+
For the case where cloning the repository is desirable, perhaps because further use of the contents are planned, Macaron requires this to be specified in a custom ``ini`` configuration file that is passed as input. See :ref:`How to change the default configuration <change-config>` for more details. Within the configuration file the following option should be set:
7070

7171
.. code-block:: ini
7272
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "macaron-source-finder-json-report-schema",
4+
"title": "Macaron Source Finder JSON Report",
5+
"$comment": "For any details about the schema specification and validation documentation, see https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-00 and https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00.",
6+
"type": "object",
7+
"properties": {
8+
"purl": {
9+
"type": "string"
10+
},
11+
"commit": {
12+
"type": "string"
13+
},
14+
"repo": {
15+
"type": "string"
16+
},
17+
"repo_validated": {
18+
"type": "boolean"
19+
},
20+
"commit_validated": {
21+
"type": "boolean"
22+
},
23+
"url": {
24+
"type": "string"
25+
}
26+
}
27+
}

tests/integration/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def configure_logging(verbose: bool) -> None:
8787

8888
DEFAULT_SCHEMAS: dict[str, Sequence[str]] = {
8989
"output_json_report": ["tests", "schema_validation", "report_schema.json"],
90-
"find_source_json_report": ["tests", "repo_finder", "resources", "find_source_report_schema.json"],
90+
"find_source_json_report": ["src", "macaron", "resources", "schemastore", "find_source_report_schema.json"],
9191
}
9292

9393

tests/repo_finder/test_report_schema.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33

44
"""This module tests the report schema of the repo finder."""
55
import json
6-
from pathlib import Path
6+
import os
77
from typing import Any
88

99
import jsonschema
1010
import pytest
1111

12+
from macaron import MACARON_PATH
1213
from macaron.repo_finder.repo_utils import create_report
1314

1415

1516
@pytest.fixture(name="json_schema")
1617
def json_schema_() -> Any:
1718
"""Load and return the JSON schema."""
18-
with open(Path(__file__).parent.joinpath("resources", "find_source_report_schema.json"), encoding="utf-8") as file:
19+
with open(
20+
os.path.join(MACARON_PATH, "resources", "schemastore", "find_source_report_schema.json"), encoding="utf-8"
21+
) as file:
1922
return json.load(file)
2023

2124

0 commit comments

Comments
 (0)