Skip to content

Commit d123105

Browse files
authored
Merge pull request #853 from juanjemdIos/master
running test in every PR with an action. Fixes #845
2 parents 8130a0f + acde842 commit d123105

File tree

4 files changed

+60
-8
lines changed

4 files changed

+60
-8
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Run SOMEF tests before PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev #should be this branch or master?
7+
workflow_dispatch:
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: "3.11"
20+
21+
- name: Install Poetry
22+
run: curl -sSL https://install.python-poetry.org | python3 -
23+
24+
- name: Install dependencies
25+
run: poetry install
26+
27+
- name: Download NLTK data
28+
run: poetry run python -m nltk.downloader wordnet omw-1.4 punkt punkt_tab stopwords
29+
30+
- name: Configure SOMEF
31+
run: poetry run somef configure -a
32+
33+
- name: Run pytest
34+
run: poetry run pytest -v src/somef/test

docs/pom.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,5 @@ package_distribution': [{'result': {'value': 'http://127.0.0.1/websvn/my-project
110110
```
111111
[{'value': 'Java: 1.8', 'name': 'Java', 'version': '1.8'}]
112112
```
113+
114+

src/somef/extract_software_type.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import os
22
from pathlib import Path
33
import nbformat
4+
from nbformat.reader import NotJSONError
45
from chardet import detect
56
import re
67
from .extract_workflows import is_file_workflow
78
from .process_results import Result
89
from .utils import constants
910
from .extract_ontologies import is_file_ontology
11+
1012
import pdb
1113

1214

@@ -301,14 +303,20 @@ def is_notebook_code(file_path):
301303
has_code = False
302304
num_code_cells = 0
303305
num_total_cells = 0
304-
nb = nbformat.read(file_path, as_version=4)
305-
for cell in nb['cells']:
306-
if cell['cell_type'] == 'code':
307-
num_total_cells += 1
308-
if cell['source'].strip():
309-
num_code_cells += 1
310-
has_code = True
311-
return has_code
306+
try:
307+
nb = nbformat.read(file_path, as_version=4)
308+
309+
for cell in nb['cells']:
310+
if cell['cell_type'] == 'code':
311+
num_total_cells += 1
312+
if cell['source'].strip():
313+
num_code_cells += 1
314+
has_code = True
315+
return has_code
316+
except NotJSONError:
317+
return False
318+
except Exception:
319+
return False
312320

313321

314322
def has_code_in_rmd(file_path):

src/somef/somef_cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def cli_get_data(threshold, ignore_classifiers, repo_url=None, doc_src=None, loc
7171
logging.info(f"{servidor} is GitLab.")
7272
bGitLab = True
7373

74+
print(f"DEBUG: {servidor} is_gitlab = {bGitLab}")
7475
if bGitLab:
7576
repo_type = constants.RepositoryType.GITLAB
7677
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
8081
repo_type,
8182
authorization
8283
)
84+
print("\n=== DEBUG GITLAB SELF-HOSTED ===")
85+
print(f"repo_url: {repo_url}")
86+
print(f"owner: {owner}")
87+
print(f"repo_name: {repo_name}")
88+
print(f"def_branch: {def_branch}")
89+
print(f"repo_type: {repo_type}")
90+
print("=================================\n")
8391

8492
# download files and obtain path to download folder
8593
if readme_only:

0 commit comments

Comments
 (0)