Skip to content
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

Add test for FRSM-01-F1 metric to search codemeta.json file at the project root #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions fuji_server/data/software_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,14 @@
"pattern": [
"pom\\.xml"
]
},
"CodeMeta": {
"category": [
"documentation"
],
"parse": "full",
"pattern": [
"codemeta\\.json"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def __init__(self, fuji_instance):

# Create map from metric test names to class functions. This is necessary as functions may be reused for different metrics relating to licenses.
self.metric_test_map = { # overall map
"testUniqueIdentifier": ["FRSM-01-F1-1"],
"testIdentifierScheme": ["FRSM-01-F1-2"],
"testSchemeCommonlyUsed": ["FRSM-01-F1-3"],
"testCodeMetaJSONAtRoot": ["FRSM-01-F1-1"],
"testUniqueIdentifier": ["FRSM-01-F1-2"],
"testIdentifierScheme": ["FRSM-01-F1-3"],
"testSchemeCommonlyUsed": ["FRSM-01-F1-4"],
"testDOIInReadme": ["FRSM-01-F1-CESSDA-1"],
"testReleasesSemanticVersioning": ["FRSM-01-F1-CESSDA-2"],
"testReleasesDOI": ["FRSM-01-F1-CESSDA-3"],
Expand Down Expand Up @@ -138,13 +139,45 @@ def testReleasesDOI(self):
self.logger.warning(f"{self.metric_identifier} : Test for DOIs of releases is not implemented.")
return test_status

def testCodeMetaJSONAtRoot(self):
"""The software has a CodeMeta file located at project root.

Returns:
bool: True if the test was defined and passed. False otherwise.
"""
agnostic_test_name = "testCodeMetaJSONAtRoot"
test_status = False
test_defined = False
for test_id in self.metric_test_map[agnostic_test_name]:
if self.isTestDefined(test_id):
test_defined = True
break
if test_defined:
test_score = self.getTestConfigScore(test_id)
codemeta_files = self.fuji.github_data.get("CodeMeta", None)
if codemeta_files is not None and len(codemeta_files) > 0:
codemeta_file = codemeta_files[0]["path"]
test_status = True
self.maturity = max(self.getTestConfigMaturity(test_id), self.maturity)
self.setEvaluationCriteriumScore(test_id, test_score, "pass")
self.score.earned += test_score
self.logger.log(
self.fuji.LOG_SUCCESS,
f"{self.metric_identifier} : Found CodeMeta file {codemeta_file} at repository root ({test_id}).",
)
if not test_status:
self.logger.warning(f"{self.metric_identifier} : Did not find a CodeMeta file at repository root ({test_id}).")
return test_status

def evaluate(self):
if self.metric_identifier in self.metrics:
self.result = UniquePersistentIdentifierSoftware(
id=self.metric_number, metric_identifier=self.metric_identifier, metric_name=self.metric_name
)
self.output = UniquePersistentIdentifierSoftwareOutput()
self.result.test_status = "fail"
if self.testCodeMetaJSONAtRoot():
self.result.test_status = "pass"
if self.testUniqueIdentifier():
self.result.test_status = "pass"
if self.testIdentifierScheme():
Expand Down
8 changes: 6 additions & 2 deletions fuji_server/yaml/metrics_v0.7_software.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ metrics:
test_scoring_mechanism: cumulative
metric_tests:
- metric_test_identifier: FRSM-01-F1-1
metric_test_name: The software has a human and machine-readable unique identifier that is resolvable to a machine-readable landing page and follows a defined unique identifier syntax.
metric_test_name: The software has a CodeMeta file located at project root.
metric_test_score: 1
metric_test_maturity: 1
- metric_test_identifier: FRSM-01-F1-2
metric_test_name: The software has a human and machine-readable unique identifier that is resolvable to a machine-readable landing page and follows a defined unique identifier syntax.
metric_test_score: 1
metric_test_maturity: 1
- metric_test_identifier: FRSM-01-F1-3
metric_test_name: The identifier uses an identifier scheme that guarantees globally uniqueness and persistence.
metric_test_score: 1
metric_test_maturity: 2
- metric_test_identifier: FRSM-01-F1-3
- metric_test_identifier: FRSM-01-F1-4
metric_test_name: The identifier scheme is commonly used in the domain.
metric_test_score: 1
metric_test_maturity: 3
Expand Down