diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index fc9bcda..c1297a1 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -1,3 +1,7 @@ + # Code of Conduct for {project name} Please see the [Community Code of Conduct](https://www.finos.org/code-of-conduct). diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index 3259822..b56d3e5 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -1,3 +1,7 @@ + --- name: 🐛 Bug Report about: If something isn't working as expected 🤔. diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md index b01f152..e9dc56a 100644 --- a/.github/ISSUE_TEMPLATE/Feature_request.md +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -1,3 +1,7 @@ + --- name: 🚀 Feature Request about: I have a suggestion (and may want to implement it 🙂)! diff --git a/.github/ISSUE_TEMPLATE/Support_question.md b/.github/ISSUE_TEMPLATE/Support_question.md index c6c4deb..ab2faf8 100644 --- a/.github/ISSUE_TEMPLATE/Support_question.md +++ b/.github/ISSUE_TEMPLATE/Support_question.md @@ -1,3 +1,7 @@ + --- name: 🤗 Support Question about: If you have a question about configuration, usage, etc. 💬 diff --git a/.github/ISSUE_TEMPLATE/meeting-minutes.md b/.github/ISSUE_TEMPLATE/meeting-minutes.md index 96634de..5921ecc 100644 --- a/.github/ISSUE_TEMPLATE/meeting-minutes.md +++ b/.github/ISSUE_TEMPLATE/meeting-minutes.md @@ -1,3 +1,7 @@ + --- name: "\U0001F91D {project name} Meeting Minutes" about: To track {project name} meeting agenda and attendance diff --git a/.github/workflows/build-python-package.yml b/.github/workflows/build-python-package.yml index 59fbb43..a92393f 100644 --- a/.github/workflows/build-python-package.yml +++ b/.github/workflows/build-python-package.yml @@ -1,3 +1,7 @@ +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## name: Build and Release Wheel on: diff --git a/.github/workflows/check-license-headers.yml b/.github/workflows/check-license-headers.yml new file mode 100644 index 0000000..2d47442 --- /dev/null +++ b/.github/workflows/check-license-headers.yml @@ -0,0 +1,39 @@ +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## +name: Check License Headers + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +jobs: + license-headers: + name: Verify license headers + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install licenseheaders + run: pip install licenseheaders + + - name: Check license headers + run: | + src/license/apply_headers.sh + git diff --exit-code || \ + (echo "One or more files are missing a license header. Run 'src/license/apply_headers.sh' locally to fix." && \ + exit 1) diff --git a/.github/workflows/cve-scanning-python.yml b/.github/workflows/cve-scanning-python.yml index ffb362d..31cacc7 100644 --- a/.github/workflows/cve-scanning-python.yml +++ b/.github/workflows/cve-scanning-python.yml @@ -1,3 +1,7 @@ +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## name: CVE Scanning for Python on: diff --git a/.github/workflows/license-scanning-python.yml b/.github/workflows/license-scanning-python.yml index f0fb0ee..91fcfc9 100644 --- a/.github/workflows/license-scanning-python.yml +++ b/.github/workflows/license-scanning-python.yml @@ -1,3 +1,7 @@ +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## name: License Scanning for Python on: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5c8e54..34b45ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,7 @@ +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## name: Publish to PyPi on: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 927c593..36aa1cb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,3 +1,7 @@ +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## name: Run Unit Tests on: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f3de672 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## +repos: + - repo: local + hooks: + - id: license-headers-dirs + name: Add/check license headers (src, test, .github) + entry: licenseheaders + args: [-t, src/license/header.txt, --dir, src, --dir, test, --dir, .github] + language: python + additional_dependencies: [licenseheaders>=0.8.8] + types_or: [python, yaml, shell, toml] + pass_filenames: false + - id: license-headers-files + name: Add/check license headers (root files) + entry: licenseheaders + args: [-t, src/license/header.txt, --additional-extensions, python=.toml, + -f, build_wheel.sh, dev_clean_setup.sh, netlify.toml, pyproject.toml, + safety-policy.yml, .pre-commit-config.yaml] + language: python + additional_dependencies: [licenseheaders>=0.8.8] + types_or: [python, yaml, shell, toml] + pass_filenames: false diff --git a/README.md b/README.md index 223d37b..754fc67 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,20 @@ Use [dev_clean_setup.sh](https://github.com/Cloudrisk/rune-python-runtime/blob/m ```sh ./dev_clean_setup.sh ``` + +This script installs all dev dependencies and registers the pre-commit hooks, including the license-header check. Every `.py` file under `src/` and `test/` must carry the Apache 2.0 SPDX header: + +```python +# Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +# SPDX-License-Identifier: Apache-2.0 +``` + +To add missing headers to all files at any time, run: + +```sh +src/license/apply_headers.sh +``` + ### 3. Build Use [build_wheel.sh](https://github.com/Cloudrisk/rune-python-runtime/blob/main/build_wheel.sh) to build the package ```sh diff --git a/build_wheel.sh b/build_wheel.sh index d505da1..4878ceb 100755 --- a/build_wheel.sh +++ b/build_wheel.sh @@ -1,4 +1,8 @@ #!/bin/bash +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## function error { diff --git a/dev_clean_setup.sh b/dev_clean_setup.sh index 6fb6085..7665430 100755 --- a/dev_clean_setup.sh +++ b/dev_clean_setup.sh @@ -1,4 +1,8 @@ #!/bin/bash +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## function error { @@ -34,3 +38,5 @@ ${PY_EXE} -m venv --clear .pydevenv || error python -m pip install -e .[dev] --config-settings editable_mode=compat || error + +pre-commit install || error diff --git a/netlify.toml b/netlify.toml index 501aec3..558f6ee 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,2 +1,6 @@ +# +# Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +# SPDX-License-Identifier: Apache-2.0 +# [build] ignore = "/bin/false" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5be3160..b5884c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +# +# Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +# SPDX-License-Identifier: Apache-2.0 +# [build-system] requires = ["setuptools>=64", "setuptools_scm>=8", "wheel>=0.45.1", "pytest-runner>=6.0.1"] build-backend = "setuptools.build_meta" @@ -15,7 +19,9 @@ optional-dependencies.dev = [ "pytest>=9.0.2", "pytest-cov>=7.0.0", "pytest-mock>=3.14.1", - "types-python-dateutil>=2.9.0.20250809" + "types-python-dateutil>=2.9.0.20250809", + "licenseheaders>=0.8.8", + "pre-commit>=3.0.0" ] description = "rune-runtime: the Rune DSL runtime for Python" readme = "README.md" diff --git a/safety-policy.yml b/safety-policy.yml index 4ff2507..a441716 100644 --- a/safety-policy.yml +++ b/safety-policy.yml @@ -1,3 +1,7 @@ +## +## Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +## SPDX-License-Identifier: Apache-2.0 +## security: ignore-cvss-severity-below: 6 ignore-cvss-unknown-severity: False diff --git a/src/license/apply_headers.sh b/src/license/apply_headers.sh new file mode 100755 index 0000000..04e496b --- /dev/null +++ b/src/license/apply_headers.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Applies the Apache 2.0 SPDX license header to all tracked source files. +set -e +TMPL="$(dirname "$0")/header.txt" +licenseheaders -t "$TMPL" --dir src --dir test --dir .github +licenseheaders -t "$TMPL" --additional-extensions python=.toml -f build_wheel.sh dev_clean_setup.sh netlify.toml pyproject.toml safety-policy.yml .pre-commit-config.yaml diff --git a/src/license/header.txt b/src/license/header.txt new file mode 100644 index 0000000..fbb1759 --- /dev/null +++ b/src/license/header.txt @@ -0,0 +1,2 @@ +Copyright (c) 2023-2026 CLOUDRISK Limited and FT Advisory LLC +SPDX-License-Identifier: Apache-2.0 diff --git a/src/rune/runtime/base_data_class.py b/src/rune/runtime/base_data_class.py index 47eab36..28f6d0d 100644 --- a/src/rune/runtime/base_data_class.py +++ b/src/rune/runtime/base_data_class.py @@ -107,7 +107,7 @@ def _unwrap_cow_inputs(cls, data: Any) -> Any: @model_serializer(mode='wrap') def _serialize_refs(self, serializer, info): '''should replace objects with refs while serializing''' - res = serializer(self, info) + res = serializer(self) refs = self._get_rune_refs_container() for property_nm, (key, ref_type) in refs.items(): res[property_nm] = {ref_type.rune_ref_tag: key}