From 219127890313789db232252b53bc0e900f9b6868 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 08:18:46 +0100 Subject: [PATCH 01/10] action to run test before a PR. First I'll try in my local repo --- .github/workflows/action-test-before-PR.yml | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/action-test-before-PR.yml diff --git a/.github/workflows/action-test-before-PR.yml b/.github/workflows/action-test-before-PR.yml new file mode 100644 index 00000000..e8186b87 --- /dev/null +++ b/.github/workflows/action-test-before-PR.yml @@ -0,0 +1,28 @@ +name: Run SOMEF tests before PR + +on: + pull_request: + branches: + - master #should be this branch or master? + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.11" + + - name: Install Poetry + run: curl -sSL https://install.python-poetry.org | python3 - + + - name: Install dependencies + run: poetry install + + - name: Run pytest + run: poetry run pytest -v src/somef/test From 93ec63d2d3e3b2c7b78033c894e5105c07fbabc6 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 08:20:41 +0100 Subject: [PATCH 02/10] dumb changed to try the action --- docs/pom.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pom.md b/docs/pom.md index c9f31631..b03dcda7 100644 --- a/docs/pom.md +++ b/docs/pom.md @@ -110,3 +110,5 @@ package_distribution': [{'result': {'value': 'http://127.0.0.1/websvn/my-project ``` [{'value': 'Java: 1.8', 'name': 'Java', 'version': '1.8'}] ``` + + From 76b079895570ef161007469b78a927f45d0e5eb2 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 08:26:42 +0100 Subject: [PATCH 03/10] action test able to run manually --- .github/workflows/action-test-before-PR.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/action-test-before-PR.yml b/.github/workflows/action-test-before-PR.yml index e8186b87..074157e4 100644 --- a/.github/workflows/action-test-before-PR.yml +++ b/.github/workflows/action-test-before-PR.yml @@ -4,7 +4,7 @@ on: pull_request: branches: - master #should be this branch or master? - + workflow_dispatch: jobs: test: runs-on: ubuntu-latest From c02e7adcb78ea231aaa891d7cbb62459fbfc0a68 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 08:32:27 +0100 Subject: [PATCH 04/10] dependencies in action test --- .github/workflows/action-test-before-PR.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/action-test-before-PR.yml b/.github/workflows/action-test-before-PR.yml index 074157e4..4149356b 100644 --- a/.github/workflows/action-test-before-PR.yml +++ b/.github/workflows/action-test-before-PR.yml @@ -24,5 +24,8 @@ jobs: - name: Install dependencies run: poetry install + - name: Download NLTK data + run: poetry run python -m nltk.downloader wordnet + - name: Run pytest run: poetry run pytest -v src/somef/test From 2ceb015e73b03a5a9cb961cf5f8d661ea41629c4 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 08:55:39 +0100 Subject: [PATCH 05/10] bugs in action --- .github/workflows/action-test-before-PR.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/action-test-before-PR.yml b/.github/workflows/action-test-before-PR.yml index 4149356b..82c0a454 100644 --- a/.github/workflows/action-test-before-PR.yml +++ b/.github/workflows/action-test-before-PR.yml @@ -25,7 +25,10 @@ jobs: run: poetry install - name: Download NLTK data - run: poetry run python -m nltk.downloader wordnet + run: poetry run python -m nltk.downloader wordnet punkt punkt_tab + + - name: Copy config.json into src/somef + run: cp config.json src/somef/config.json - name: Run pytest run: poetry run pytest -v src/somef/test From c8a1d4aea6ae23532d1d3e083a14dbe8f518dcc0 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 09:02:29 +0100 Subject: [PATCH 06/10] more bugs --- .github/workflows/action-test-before-PR.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/action-test-before-PR.yml b/.github/workflows/action-test-before-PR.yml index 82c0a454..8dcd370b 100644 --- a/.github/workflows/action-test-before-PR.yml +++ b/.github/workflows/action-test-before-PR.yml @@ -25,10 +25,12 @@ jobs: run: poetry install - name: Download NLTK data - run: poetry run python -m nltk.downloader wordnet punkt punkt_tab + run: poetry run python -m nltk.downloader wordnet omw-1.4 punkt punkt_tab stopwords - - name: Copy config.json into src/somef - run: cp config.json src/somef/config.json + - name: Copy config.json to ~/.somef + run: | + mkdir -p ~/.somef + cp config.json ~/.somef/config.json - name: Run pytest run: poetry run pytest -v src/somef/test From 4bd5f3488f4a5fcde0090e3c463b52f9b5c8824f Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 09:12:55 +0100 Subject: [PATCH 07/10] somef configure --- .github/workflows/action-test-before-PR.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/action-test-before-PR.yml b/.github/workflows/action-test-before-PR.yml index 8dcd370b..af003fe1 100644 --- a/.github/workflows/action-test-before-PR.yml +++ b/.github/workflows/action-test-before-PR.yml @@ -27,10 +27,8 @@ jobs: - name: Download NLTK data run: poetry run python -m nltk.downloader wordnet omw-1.4 punkt punkt_tab stopwords - - name: Copy config.json to ~/.somef - run: | - mkdir -p ~/.somef - cp config.json ~/.somef/config.json + - name: Configure SOMEF + run: poetry run somef configure -a - name: Run pytest run: poetry run pytest -v src/somef/test From a9519f64a07b7651a437d69ff7fa83634a1f243b Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 09:34:05 +0100 Subject: [PATCH 08/10] this works in local but not in action runnint test. --- src/somef/extract_software_type.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/somef/extract_software_type.py b/src/somef/extract_software_type.py index 46577534..43dc695d 100644 --- a/src/somef/extract_software_type.py +++ b/src/somef/extract_software_type.py @@ -1,12 +1,14 @@ import os from pathlib import Path import nbformat +from nbformat.reader import NotJSONError from chardet import detect import re from .extract_workflows import is_file_workflow from .process_results import Result from .utils import constants from .extract_ontologies import is_file_ontology + import pdb @@ -301,14 +303,20 @@ def is_notebook_code(file_path): has_code = False num_code_cells = 0 num_total_cells = 0 - nb = nbformat.read(file_path, as_version=4) - for cell in nb['cells']: - if cell['cell_type'] == 'code': - num_total_cells += 1 - if cell['source'].strip(): - num_code_cells += 1 - has_code = True - return has_code + try: + nb = nbformat.read(file_path, as_version=4) + + for cell in nb['cells']: + if cell['cell_type'] == 'code': + num_total_cells += 1 + if cell['source'].strip(): + num_code_cells += 1 + has_code = True + return has_code + except NotJSONError: + return False + except Exception: + return False def has_code_in_rmd(file_path): From ea905702eb651ae50b15a7061526b99d45c9009c Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 09:40:19 +0100 Subject: [PATCH 09/10] change branch to dev --- .github/workflows/action-test-before-PR.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/action-test-before-PR.yml b/.github/workflows/action-test-before-PR.yml index af003fe1..d2ca2786 100644 --- a/.github/workflows/action-test-before-PR.yml +++ b/.github/workflows/action-test-before-PR.yml @@ -3,7 +3,7 @@ name: Run SOMEF tests before PR on: pull_request: branches: - - master #should be this branch or master? + - dev #should be this branch or master? workflow_dispatch: jobs: test: From acde842e0b7f57ebf6bd6aa9c4ae31674c2390f9 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 11 Dec 2025 11:21:31 +0100 Subject: [PATCH 10/10] some logs for debug --- src/somef/somef_cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/somef/somef_cli.py b/src/somef/somef_cli.py index 80615220..1ea81329 100644 --- a/src/somef/somef_cli.py +++ b/src/somef/somef_cli.py @@ -71,6 +71,7 @@ def cli_get_data(threshold, ignore_classifiers, repo_url=None, doc_src=None, loc logging.info(f"{servidor} is GitLab.") bGitLab = True + print(f"DEBUG: {servidor} is_gitlab = {bGitLab}") if bGitLab: repo_type = constants.RepositoryType.GITLAB repository_metadata, owner, repo_name, def_branch = process_repository.load_online_repository_metadata( @@ -80,6 +81,13 @@ def cli_get_data(threshold, ignore_classifiers, repo_url=None, doc_src=None, loc repo_type, authorization ) + print("\n=== DEBUG GITLAB SELF-HOSTED ===") + print(f"repo_url: {repo_url}") + print(f"owner: {owner}") + print(f"repo_name: {repo_name}") + print(f"def_branch: {def_branch}") + print(f"repo_type: {repo_type}") + print("=================================\n") # download files and obtain path to download folder if readme_only: