Skip to content
Merged
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
175 changes: 64 additions & 111 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,116 +1,69 @@
name: Lint and Test

on:
workflow_call:
workflow_call:

jobs:
run_unit_tests:
runs-on: ubuntu-latest
if: 1 == 0
strategy:
fail-fast: false

steps:
- name: Repo checkout
uses: actions/checkout@main

- name: Set up Python 3.
uses: actions/setup-python@main
with:
python-version: 3.12

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Install dependencies
id: install_deps
run: uv sync

- name: run pytest -rP tests/
id: run_pytest
run: |
uv run pytest --cov=credit_engine --cov-report=xml -rP tests/
continue-on-error: true

- name: Send to Codecov
id: send_to_codecov
uses: codecov/codecov-action@main
continue-on-error: true
with:
files: ./coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: outcome failure
if: steps.run_pytest.outcome != 'success' || steps.send_to_codecov.outcome != 'success'
run: |
echo "Python tests: ${{ steps.run_pytest.outcome }}"
echo "upload coverage: ${{ steps.send_to_codecov.outcome }}"
exit 1

- name: outcome success
run: |
echo "Python tests: ${{ steps.run_pytest.outcome }}"
echo "upload coverage: ${{ steps.send_to_codecov.outcome }}"
exit 0

run_linkml_tasks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read

steps:
- name: Repo checkout
uses: actions/checkout@main

- name: Set up Python 3.
uses: actions/setup-python@main
with:
python-version: 3.12

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Install dependencies
id: install_deps
run: uv sync

- name: Lint linkml file
id: lint_linkml
run: |
make lint-no-warn
continue-on-error: true

- name: Validate sample data against the schema
id: test_sample_data
run: |
make test-sample-data
continue-on-error: true

- name: Validate sample data against JSONschema
id: test_sample_data_jsonschema
run: |
make test-sample-data-jsonschema
continue-on-error: true

- name: Test documentation generation
id: test_docgen
run: |
uv sync --group docs
make gendoc
continue-on-error: true

- name: outcome failure
if: steps.lint_linkml.outcome != 'success' || steps.test_sample_data.outcome != 'success' || steps.test_sample_data_jsonschema.outcome != 'success' || steps.test_docgen.outcome != 'success'
run: |
echo "linkml linting: ${{ steps.lint_linkml.outcome }}"
echo "sample data validation: ${{ steps.test_sample_data.outcome }}"
echo "sample data JSON Schema validation: ${{ steps.test_sample_data_jsonschema.outcome }}"
echo "documentation generator: ${{ steps.test_docgen.outcome }}"
exit 1

- name: outcome success
if: steps.lint_linkml.outcome == 'success' && steps.test_sample_data.outcome == 'success' && steps.test_sample_data_jsonschema.outcome == 'success' && steps.test_docgen.outcome == 'success'
run: |
echo All tests passed successfully!
exit 0
jobs:
run_linkml_tasks:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Repo checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

- name: Setup python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
with:
python-version: "3.14"

- name: Install uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e
with:
python-version: 3.14

- name: Install project
run: uv sync --frozen --group docs

Check warning on line 30 in .github/workflows/run_tests.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=kbase_credit_engine&issues=AaFq-_Gw2rLupZiuGdPH&open=AaFq-_Gw2rLupZiuGdPH&pullRequest=271

- name: Lint linkml file
id: lint_linkml
run: |
make lint-no-warn
continue-on-error: true

- name: Validate sample data against the schema
id: test_sample_data
run: |
make test-sample-data
continue-on-error: true

- name: Validate sample data against JSONschema
id: test_sample_data_jsonschema
run: |
make test-sample-data-jsonschema
continue-on-error: true

- name: Test documentation generation
id: test_docgen
run: |
make gendoc
continue-on-error: true

- name: outcome failure
if: steps.lint_linkml.outcome != 'success' || steps.test_sample_data.outcome != 'success' || steps.test_sample_data_jsonschema.outcome != 'success' || steps.test_docgen.outcome != 'success'
run: |
echo "linkml linting: ${{ steps.lint_linkml.outcome }}"
echo "sample data validation: ${{ steps.test_sample_data.outcome }}"
echo "sample data JSON Schema validation: ${{ steps.test_sample_data_jsonschema.outcome }}"
echo "documentation generator: ${{ steps.test_docgen.outcome }}"
exit 1

- name: outcome success
if: steps.lint_linkml.outcome == 'success' && steps.test_sample_data.outcome == 'success' && steps.test_sample_data_jsonschema.outcome == 'success' && steps.test_docgen.outcome == 'success'
run: |
echo All tests passed successfully!
exit 0
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
51 changes: 51 additions & 0 deletions .github/workflows/update_kbase_dois.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Update KBase DOI List

on:
schedule:
# Runs weekly on Mondays at 08:00 UTC
- cron: "0 8 * * 1"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-kbase-dois:
runs-on: ubuntu-latest
name: Generate and update KBase DOI list
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: main

- name: Setup python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
with:
python-version: "3.14"

- name: Install uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e
with:
python-version: 3.14

- name: Install project
run: uv sync --frozen

Check warning on line 34 in .github/workflows/update_kbase_dois.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=kbase_credit_engine&issues=AaFq-_IO2rLupZiuGdPI&open=AaFq-_IO2rLupZiuGdPI&pullRequest=271

- name: Generate KBase DOI list
run: uv run --frozen scripts/gen_kbase_doi_list.py

Check warning on line 37 in .github/workflows/update_kbase_dois.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--no-build" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=kbase_credit_engine&issues=AaFq-f16Kxt_Z9obgaSd&open=AaFq-f16Kxt_Z9obgaSd&pullRequest=271

- name: Create Pull Request with updated KBase DOI list
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1
with:
token: ${{ secrets.GHCR_TOKEN || github.token }}
add-paths: |
src/docs/pages/kbase_dois.md
base: main
branch: update-kbase-dois
delete-branch: true
commit-message: "Update KBase FAIR Narratives DOI list"
title: "Update KBase FAIR Narratives DOI list"
body: |
Automated weekly update of `src/docs/pages/kbase_dois.md` generated by `scripts/gen_kbase_doi_list.py`.
126 changes: 60 additions & 66 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,57 @@
[project]
name = "credit-engine"
version = "0.1.0"
description = "Add your description here"
description = "Standardised citation metadata for scientific datasets."
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"check-jsonschema>=0.33.0",
"linkml>=1.9.1",
]

[dependency-groups]
dev = [
"ruff>=0.11.0",
]
data_import = [
"asteval>=1.0.6",
"dlt[deltalake,duckdb,parquet]>=1.10.0",
"httpx>=0.28.1",
"ipykernel>=6.29.5",
"json-merge-patch>=0.3.0",
"jsonpatch>=1.33",
"pyyaml>=6.0.2",
"streamlit>=1.45.0",
"vcrpy>=7.0.0",
"xmlschema>=4.0.1",
]
erdantic = [
"erdantic>=1.1.0.post1",
"pygraphviz>=1.14",
]
docs = [
"mkdocs-material>=9.6.9",
"mkdocs-mermaid2-plugin>=1.2.1",
"check-jsonschema>=0.38.2",
"dlt>=1.31.0",
"jsonschema[format]>=4.26.0",
"linkml>=1.12.1",
"linkml-runtime>=1.12.1",
]

[tool.ruff]
line-length = 120

# Assume Python 3.12.
target-version = "py312"
# Assume Python 3.14.
target-version = "py314"

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
"__pypackages__",
"_build",
".bzr",
".direnv",
".eggs",
".git-rewrite",
".git",
".github",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"*.pyc",
"buck-out",
"build",
"deps",
"dist",
"node_modules",
"other_schema",
"python-coverage",
"sample_data",
"venv",
]

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -91,12 +104,12 @@ select = [
"TD", # flake8-todos
"FIX", # flake8-fixme
"ERA", # eradicate
# "PD", # pandas-vet
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PL", # Pylint
"TRY", # tryceratops
"FLY", # flynt
# "NPY", # NumPy-specific rules
"NPY", # NumPy-specific rules
"AIR", # Airflow
"PERF", # Perflint
"FURB", # refurb
Expand All @@ -116,42 +129,23 @@ ignore = [
"E203",
"E501",
"ISC001",
"S101",
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["S101"] # use of assert

[tool.ruff.lint.mccabe]
# Flag errors (`C901`) whenever the complexity level exceeds 15.
max-complexity = 15

# Exclude a variety of commonly ignored directories.
exclude = [
"__pypackages__",
"_build",
".bzr",
".direnv",
".eggs",
".git-rewrite",
".git",
".github",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"*.pyc",
"buck-out",
"build",
"deps",
"dist",
"node_modules",
"other_schema",
"python-coverage",
"sample_data",
"venv",
[dependency-groups]
dev = [
"ruff>=0.17.2",
]
docs = [
"mkdocs-material>=9.7.7",
"mkdocs-mermaid2-plugin>=1.2.3",
]
erd = [
"erdantic>=1.2.1",
]
per-file-ignores = {}
Loading
Loading