From 6090544d8d473536f23193f2188fcd09fbd64436 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Thu, 14 May 2026 14:52:16 +0200 Subject: [PATCH 1/7] publish docker action --- .github/workflows/docker-publish.yml | 33 ++++++++++++++++++++++++++++ Dockerfile | 13 +++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 00000000..8521a9fb --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,33 @@ +name: Build and Publish Docker Image after Release (view instruccions for Docker in readme.md file) + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + push: true + tags: | + juanjeoeg/somef:latest + juanjeoeg/somef:${{ github.event.release.tag_name || 'test' }} diff --git a/Dockerfile b/Dockerfile index a17e50c9..a9edff3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,24 @@ FROM python:3.11 -RUN git clone https://github.com/KnowledgeCaptureAndDiscovery/somef +WORKDIR /somef +COPY . /somef +# RUN git clone https://github.com/KnowledgeCaptureAndDiscovery/somef RUN curl -sSL https://install.python-poetry.org | python3 - -RUN pip install poetry-plugin-shell +ENV PATH="/root/.local/bin:$PATH" -WORKDIR "/somef" +RUN pip install poetry-plugin-shell RUN poetry install +ENV PATH="/somef/.venv/bin:$PATH" +RUN poetry config virtualenvs.in-project true && poetry install + RUN poetry run somef configure -a RUN echo 'source $(poetry env info --path)/bin/activate' >> ~/.bashrc - CMD ["bash", "--login"] + From 76ce438ff2a2dda653bc8727d54d2ce2519b6cf3 Mon Sep 17 00:00:00 2001 From: juanjemdIos <116972173+juanjemdIos@users.noreply.github.com> Date: Thu, 14 May 2026 15:24:17 +0200 Subject: [PATCH 2/7] Fix casing in Docker image tags --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8521a9fb..76544884 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,5 +29,5 @@ jobs: file: Dockerfile push: true tags: | - juanjeoeg/somef:latest - juanjeoeg/somef:${{ github.event.release.tag_name || 'test' }} + juanjeOeg/somef:latest + juanjeOeg/somef:${{ github.event.release.tag_name || 'test' }} From 5106d941ec70971b738aa2bbdb8e14306e63d1b7 Mon Sep 17 00:00:00 2001 From: juanjemdIos <116972173+juanjemdIos@users.noreply.github.com> Date: Thu, 14 May 2026 15:30:05 +0200 Subject: [PATCH 3/7] Fix Docker image repository name in workflow --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 76544884..8521a9fb 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,5 +29,5 @@ jobs: file: Dockerfile push: true tags: | - juanjeOeg/somef:latest - juanjeOeg/somef:${{ github.event.release.tag_name || 'test' }} + juanjeoeg/somef:latest + juanjeoeg/somef:${{ github.event.release.tag_name || 'test' }} From f6dfb9b214a3bf974b3900f690efc4962336f5b3 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Tue, 16 Jun 2026 10:29:22 +0200 Subject: [PATCH 4/7] cff with doi must be referencePublication instead of creditText and parse author names correctly --- src/somef/export/json_export.py | 13 ++- src/somef/test/test_codemeta_export.py | 45 +++++++++++ .../test_data/repositories/sunpy/CITATION.cff | 79 +++++++++++++++++++ 3 files changed, 130 insertions(+), 7 deletions(-) create mode 100644 src/somef/test/test_data/repositories/sunpy/CITATION.cff diff --git a/src/somef/export/json_export.py b/src/somef/export/json_export.py index 85dc6cf1..98714867 100644 --- a/src/somef/export/json_export.py +++ b/src/somef/export/json_export.py @@ -482,10 +482,10 @@ def format_date(date_string): author_list = [] for author in authors: - family_name = author.get("family-names") - given_name = author.get("given-names") + family_name = author.get(constants.PROP_FAMILY_NAME) + given_name = author.get(constants.PROP_GIVEN_NAME) orcid = author.get("orcid") - name = author.get("name") + name = author.get(constants.PROP_NAME) if family_name and given_name: author_entry = { @@ -806,12 +806,11 @@ def parse_contributors(raw): def is_scholarly_article(article_dict): - if article_dict.get("type") in ["SoftwareApplication", "software"]: - return False - + if article_dict.get("doi") or article_dict.get("journal"): return True - + if article_dict.get("type") in ["SoftwareApplication", "software"]: + return False if article_dict.get("type") == "ScholarlyArticle": return True diff --git a/src/somef/test/test_codemeta_export.py b/src/somef/test/test_codemeta_export.py index dd557adf..0d0a1a54 100644 --- a/src/somef/test/test_codemeta_export.py +++ b/src/somef/test/test_codemeta_export.py @@ -812,6 +812,51 @@ def test_author_organization_issue_983(self): assert author.get("email") == "sunpy@googlegroups.com", f"Expected email 'sunpy@googlegroups.com', got: {author.get('email')}" os.remove(output_path) + + + def test_codemeta_sunpy_reference_publication(self): + """ + Checks that a CITATION.cff with DOI, title and structured authors is exported as + referencePublication (not creditText) in codemeta, and that individual authors + are considered Person with familyName/givenName rather than @type Organization. + """ + output_path = test_data_path + 'test_codemeta_sunpy_refpub.json' + + somef_cli.run_cli(threshold=0.9, + ignore_classifiers=False, + repo_url=None, + doc_src=None, + local_repo=test_data_repositories + "sunpy", + in_file=None, + output=None, + graph_out=None, + graph_format="turtle", + codemeta_out=output_path, + pretty=True, + missing=False, + requirements_mode="all") + + with open(output_path, "r") as f: + json_content = json.load(f) + + ref_pub = json_content.get(constants.CAT_CODEMETA_REFERENCEPUBLICATION, []) + # print(f"Reference publications: {ref_pub}") + assert len(ref_pub) > 0, "Expected referencePublication entries" + assert ref_pub[0].get("@type") == "ScholarlyArticle" + + found_person = False + for pub in ref_pub: + for author in pub.get("author", []): + if author.get("@type") == "Person": + assert "familyName" in author + assert "givenName" in author + found_person = True + + assert found_person, "No Person-type author found with familyName/givenName" + + os.remove(output_path) + + @classmethod def tearDownClass(cls): """delete temp file JSON just if all the test pass""" diff --git a/src/somef/test/test_data/repositories/sunpy/CITATION.cff b/src/somef/test/test_data/repositories/sunpy/CITATION.cff new file mode 100644 index 00000000..51695fb8 --- /dev/null +++ b/src/somef/test/test_data/repositories/sunpy/CITATION.cff @@ -0,0 +1,79 @@ +cff-version: '1.1.0' +message: 'Please cite the following work when using this software.' +authors: + - name: 'The SunPy Community' + - family-names: 'Barnes' + given-names: 'Will T.' + - family-names: 'Bobra' + given-names: 'Monica G.' + - family-names: 'Christe' + given-names: 'Steven D.' + - family-names: 'Freij' + given-names: 'Nabil' + - family-names: 'Hayes' + given-names: 'Laura A.' + - family-names: 'Ireland' + given-names: 'Jack' + - family-names: 'Mumford' + given-names: 'Stuart' + - family-names: 'Perez-Suarez' + given-names: 'David' + - family-names: 'Ryan' + given-names: 'Daniel F.' + - family-names: 'Shih' + given-names: 'Albert Y.' + - family-names: 'Chanda' + given-names: 'Prateek' + - family-names: 'Glogowski' + given-names: 'Kolja' + - family-names: 'Hewett' + given-names: 'Russell' + - family-names: 'Hughitt' + given-names: 'V. Keith' + - family-names: 'Hill' + given-names: 'Andrew' + - family-names: 'Hiware' + given-names: 'Kaustubh' + - family-names: 'Inglis' + given-names: 'Andrew' + - family-names: 'Kirk' + given-names: 'Michael S. F.' + - family-names: 'Konge' + given-names: 'Sudarshan' + - family-names: 'Mason' + given-names: 'James Paul' + - family-names: 'Maloney' + given-names: 'Shane Anthony' + - family-names: 'Murray' + given-names: 'Sophie A.' + - family-names: 'Panda' + given-names: 'Asish' + - family-names: 'Park' + given-names: 'Jongyeob' + - family-names: 'Pereira' + given-names: 'Tiago M. D.' + - family-names: 'Reardon' + given-names: 'Kevin' + - family-names: 'Savage' + given-names: 'Sabrina' + - family-names: 'Sipőcz' + given-names: 'Brigitta M.' + - family-names: 'Stansby' + given-names: 'David' + - family-names: 'Jain' + given-names: 'Yash' + - family-names: 'Taylor' + given-names: 'Garrison' + - family-names: 'Yadav' + given-names: 'Tannmay' + - family-names: 'Rajul' + - family-names: 'Dang' + given-names: 'Trung Kien' +doi: '10.3847/1538-4357/ab4f7a' +identifiers: + - type: 'doi' + value: '10.3847/1538-4357/ab4f7a' + - type: 'url' + value: 'https://iopscience.iop.org/article/10.3847/1538-4357/ab4f7a' +title: 'The SunPy Project: Open Source Development and Status of the Version 1.0 Core Package' +url: 'https://iopscience.iop.org/article/10.3847/1538-4357/ab4f7a' \ No newline at end of file From 23831db33fbed7e25cb946cb4a577f78227eff27 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Tue, 16 Jun 2026 10:51:10 +0200 Subject: [PATCH 5/7] Revert "Fix Docker image repository name in workflow" This reverts commit 5106d941ec70971b738aa2bbdb8e14306e63d1b7. --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8521a9fb..76544884 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,5 +29,5 @@ jobs: file: Dockerfile push: true tags: | - juanjeoeg/somef:latest - juanjeoeg/somef:${{ github.event.release.tag_name || 'test' }} + juanjeOeg/somef:latest + juanjeOeg/somef:${{ github.event.release.tag_name || 'test' }} From 73282d10211bd242bb985c965ca7a8696336be75 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Tue, 16 Jun 2026 10:51:10 +0200 Subject: [PATCH 6/7] Revert "Fix casing in Docker image tags" This reverts commit 76ce438ff2a2dda653bc8727d54d2ce2519b6cf3. --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 76544884..8521a9fb 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,5 +29,5 @@ jobs: file: Dockerfile push: true tags: | - juanjeOeg/somef:latest - juanjeOeg/somef:${{ github.event.release.tag_name || 'test' }} + juanjeoeg/somef:latest + juanjeoeg/somef:${{ github.event.release.tag_name || 'test' }} From 6eedd34e1b60e8b83b8941012d8c0bb4bdf26186 Mon Sep 17 00:00:00 2001 From: Juanje Mendoza Date: Tue, 16 Jun 2026 10:51:10 +0200 Subject: [PATCH 7/7] Revert "publish docker action" This reverts commit 6090544d8d473536f23193f2188fcd09fbd64436. --- .github/workflows/docker-publish.yml | 33 ---------------------------- Dockerfile | 13 ++++------- 2 files changed, 4 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 8521a9fb..00000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Build and Publish Docker Image after Release (view instruccions for Docker in readme.md file) - -on: - release: - types: [published] - workflow_dispatch: - -jobs: - build-and-push: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile - push: true - tags: | - juanjeoeg/somef:latest - juanjeoeg/somef:${{ github.event.release.tag_name || 'test' }} diff --git a/Dockerfile b/Dockerfile index a9edff3b..a17e50c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,19 @@ FROM python:3.11 -WORKDIR /somef -COPY . /somef -# RUN git clone https://github.com/KnowledgeCaptureAndDiscovery/somef +RUN git clone https://github.com/KnowledgeCaptureAndDiscovery/somef RUN curl -sSL https://install.python-poetry.org | python3 - -ENV PATH="/root/.local/bin:$PATH" - RUN pip install poetry-plugin-shell -RUN poetry install +WORKDIR "/somef" -ENV PATH="/somef/.venv/bin:$PATH" -RUN poetry config virtualenvs.in-project true && poetry install +RUN poetry install RUN poetry run somef configure -a RUN echo 'source $(poetry env info --path)/bin/activate' >> ~/.bashrc -CMD ["bash", "--login"] +CMD ["bash", "--login"]