-
-
Notifications
You must be signed in to change notification settings - Fork 203
Create a ScanCode.io pipeline to integrate Grimoire #2202
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d99c2a3
Add initial support for the npm-health ScanGrimoireLab pipeline
ziadhany 2cf316a
Remove metrics_model.py
ziadhany f43ce89
Fix Ruff format
ziadhany f136fb4
Update grimoirelab and format output
ziadhany 8119c52
Fix VCS URL validation
ziadhany 1f17332
Don't download the input
ziadhany 1004106
Update the pipeline settings env variables
ziadhany 2622926
Make sure the pipeline can run as addon
ziadhany 6864d33
Split the pipeline into multiple steps.
ziadhany 5dc01b6
Refactor and rename pipeline to ScanRepoHealth
ziadhany 0a9c3f8
Update the pipeline to work with new healthcode update
ziadhany ad8c12f
Update the expected output for scan_repo_health pipeline
ziadhany aadde58
Add the result to project extra_data
ziadhany c4bd343
Add the result to project extra_data
ziadhany be59314
Update Use environ.get instead of getattr(settings,)
ziadhany d1613eb
Add support for healthycode docker image deployment
ziadhany 66a3759
Use Docker Compose Build Context
ziadhany 47d06fb
Update docker compose file
ziadhany a7aa49d
Update error messages and docs
ziadhany 01eb611
Update the code to work with the latest healthcode changes
ziadhany e46daf5
Add a docs to the pipeline
ziadhany 1d80f7a
Fix a typo in the docs
ziadhany 6588009
Move the implementation logic into the pipes
ziadhany dd5125e
Update the default env for GrimoireLab
ziadhany File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
|
ziadhany marked this conversation as resolved.
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| .. _tutorial_web_ui_scan_repo_health: | ||
|
|
||
| Scan repo health (Web UI) | ||
| ========================= | ||
|
|
||
| This tutorial guides you through scanning the health | ||
| of a git repository using the ScanCode.io Web UI. | ||
|
|
||
| .. note:: | ||
| This tutorial assumes you have a recent version of ScanCode.io installed | ||
| locally on your machine and **running with Docker**. | ||
| If you do not have it installed, see our :ref:`installation` guide for instructions. | ||
|
|
||
| Requirements | ||
| ------------ | ||
|
|
||
| Before you follow the instructions in this tutorial, you need to: | ||
|
|
||
| - Install **ScanCode.io** locally. | ||
| - Access to the web application from your preferred browser on http://localhost/ or | ||
| http://localhost:8001/ if you run on a local development setup. | ||
| - Make sure the following GrimoireLab | ||
| service is correctly configured: :ref:`scancodeio_settings_grimoirelab`. | ||
|
|
||
| Instructions | ||
| ------------ | ||
|
|
||
| 1. From the homepage, click the ``New Project`` button. | ||
| 2. Enter ``npm-example-repo-health`` as the project **Name** for example. | ||
| 3. Add a valid git repository url into the **Download URL** field: | ||
| https://github.com/aboutcode-org/npm-project-example | ||
| 4. Select ``scan_repo_health`` from the **Pipeline** dropdown. | ||
| 5. Check the **Execute pipeline now** box to run the pipeline immediately upon creation. | ||
| 6. Click **Create**. | ||
|
|
||
| .. image:: images/tutorial-web-ui-project-form-repo-health.png | ||
| :alt: Create project form for repo health scan | ||
|
|
||
| 7. Once the pipeline execution is complete, you can download the generated output result in | ||
| **JSON** format (for example, ``metrics-2026-09-10-12-02-38.json``) | ||
| or directly view the data from the project's result view. | ||
|
|
||
| .. image:: images/tutorial-web-ui-project-form-repo-health-result.png | ||
| :alt: Scan repo health output pipeline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # http://nexb.com and https://github.com/aboutcode-org/scancode.io | ||
| # The ScanCode.io software is licensed under the Apache License version 2.0. | ||
| # Data generated with ScanCode.io is provided as-is without warranties. | ||
| # ScanCode is a trademark of nexB Inc. | ||
| # | ||
| # You may not use this software except in compliance with the License. | ||
| # You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software distributed | ||
| # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
| # CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations under the License. | ||
| # | ||
| # Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
| # OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
| # ScanCode.io should be considered or used as legal advice. Consult an Attorney | ||
| # for any legal advice. | ||
| # | ||
| # ScanCode.io is a free software code scanning tool from nexB Inc. and others. | ||
| # Visit https://github.com/aboutcode-org/scancode.io for support and download. | ||
|
|
||
| from scanpipe.pipelines import Pipeline | ||
| from scanpipe.pipes import repo_health | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_ECOSYSTEM | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_METRICS_EXECUTABLE | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_OPENSEARCH_INDEX | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_OPENSEARCH_PASSWORD | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_OPENSEARCH_URL | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_OPENSEARCH_USERNAME | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_PASSWORD | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_PROJECT | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_URL | ||
| from scanpipe.pipes.repo_health import GRIMOIRELAB_USERNAME | ||
|
|
||
|
|
||
| class ScanRepoHealth(Pipeline): | ||
| """Run a Repo Health scan to extract repository metrics and health score.""" | ||
|
|
||
| results_url = "/project/{slug}/resources/?extra_data=grimoire_data" | ||
| download_inputs = False | ||
|
|
||
| @classmethod | ||
| def steps(cls): | ||
| return ( | ||
| cls.get_repo_url_input, | ||
| cls.collect_and_store_grimoire_metric, | ||
| cls.format_metrics_output, | ||
| ) | ||
|
|
||
| @classmethod | ||
| def get_availability(cls): | ||
| if not ( | ||
| GRIMOIRELAB_METRICS_EXECUTABLE | ||
| and GRIMOIRELAB_OPENSEARCH_INDEX | ||
| and GRIMOIRELAB_OPENSEARCH_PASSWORD | ||
| and GRIMOIRELAB_OPENSEARCH_URL | ||
| and GRIMOIRELAB_OPENSEARCH_USERNAME | ||
| and GRIMOIRELAB_PASSWORD | ||
| and GRIMOIRELAB_URL | ||
| and GRIMOIRELAB_USERNAME | ||
| and GRIMOIRELAB_ECOSYSTEM | ||
| and GRIMOIRELAB_PROJECT | ||
| ): | ||
| return "Grimoirelab is not configured." | ||
|
|
||
| def get_repo_url_input(self): | ||
| """Validate and extract the repository URL from the project's input sources""" | ||
| self.repo_url = repo_health.get_repo_url_input(project=self.project) | ||
|
|
||
| def collect_and_store_grimoire_metric(self): | ||
| """ | ||
| Run the grimoirelab-metrics command against the input source. | ||
| Save the generated metrics JSON to the project output directory. | ||
| """ | ||
| self.metrics_output_path = repo_health.collect_and_store_grimoire_metric( | ||
| project=self.project, repo_url=self.repo_url, logger=self.log | ||
| ) | ||
|
|
||
| def format_metrics_output(self): | ||
|
ziadhany marked this conversation as resolved.
|
||
| """ | ||
| Format the GrimoireLab metrics output by extracting the repository URL, | ||
| score, and metrics from the generated JSON and overwriting it with a | ||
| simplified structure, and updating the project's extra data. | ||
| """ | ||
| repo_health.format_metrics_output( | ||
| project=self.project, metrics_output_path=self.metrics_output_path | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.