Skip to content
Draft
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
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# AI Disclosure: This file was largely AI-generated. The AI-generated
# portions are made available under CC0-1.0 and not subject to the
# project's licence. The human contributor has reviewed and verified
# that the code is correct.
#
# SPDX-License-Identifier: EPL-2.0 AND CC0-1.0
# Assisted-by: Anthropic Claude Opus 5.5 (claude-opus-5-5)
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip && pip install -e . --group dev
- run: ruff check src tests
- run: ruff format --check src tests

test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.11", "3.12", "3.13", "3.14"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- run: python -m pip install --upgrade pip && pip install -e . --group dev
- run: pytest
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# AI Disclosure: This file was largely AI-generated. The AI-generated
# portions are made available under CC0-1.0 and not subject to the
# project's licence. The human contributor has reviewed and verified
# that the code is correct.
#
# SPDX-License-Identifier: EPL-2.0 AND CC0-1.0
# Assisted-by: Anthropic Claude Opus 5.5 (claude-opus-5-5)
# Publishes to PyPI when a version tag (v0.9.0, ...) is pushed, via PyPI trusted publishing:
# the PyPI project "dittoctl" must trust this repository and workflow (environment "pypi").
name: Release

on:
push:
tags: ["v*"]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Check that the tag matches the package version
run: |
version=$(python -c 'import re,pathlib; print(re.search(r"__version__ = \"(.+)\"", pathlib.Path("src/dittoctl/__init__.py").read_text()).group(1))')
test "v$version" = "$GITHUB_REF_NAME" || { echo "tag $GITHUB_REF_NAME != version $version"; exit 1; }
- run: python -m pip install --upgrade pip build && pip install -e . --group dev
- run: pytest
- run: python -m build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
__pycache__/
*.py[cod]
.venv/
build/
dist/
*.egg-info/
.pytest_cache/
.ruff_cache/
.coverage
htmlcov/
.idea/
.vscode/
.DS_Store
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Community Code of Conduct

**Version 1.2
August 19, 2020**

## Our Pledge

In the interest of fostering an open and welcoming environment, we as community members, contributors, committers, and project leaders pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

With the support of the Eclipse Foundation staff (the “Staff”), project committers and leaders are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project committers and leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the Eclipse Foundation project or its community in public spaces. Examples of representing a project or community include posting via an official social media account, or acting as a project representative at an online or offline event. Representation of a project may be further defined and clarified by project committers, leaders, or the EMO.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the Staff at codeofconduct@eclipse.org. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The Staff is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project committers or leaders who do not follow the Code of Conduct in good faith may face temporary or permanent repercussions as determined by the Staff.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org) , version 1.4, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct/)
150 changes: 150 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# How to contribute to dittoctl

Thanks for considering a contribution to dittoctl, the command line tool for
[Eclipse Ditto](https://eclipse.dev/ditto/). This page explains the legal requirements, the rules that keep the
code base clean, and how to get a change merged.

## Legal requirements

dittoctl is part of the Eclipse Ditto project and follows the
[Eclipse Foundation Development Process](https://www.eclipse.org/projects/dev_process/). Before we can accept
your contribution:

* Create an [Eclipse Foundation account](https://accounts.eclipse.org/user/register) and sign the
[Eclipse Contributor Agreement (ECA)](https://www.eclipse.org/legal/eca/).
* Add your GitHub username to your Eclipse Foundation account.
* Commit with the email address of your Eclipse Foundation account. The ECA check on each pull request verifies
that every commit author has signed the ECA.

By contributing, you agree that your contribution is licensed under the
[Eclipse Public License 2.0](LICENSE).

## Clean-room rules

dittoctl is implemented only from public sources. This keeps the provenance of every line clear:

* Use only public sources: the [Ditto documentation](https://eclipse.dev/ditto/), Ditto's OpenAPI specification
(`documentation/src/main/resources/openapi/ditto-api-2.yml` in
[eclipse-ditto/ditto](https://github.com/eclipse-ditto/ditto)), and the relevant RFCs (e.g. 7396 merge patch,
7636 PKCE, 8628 device authorization grant).
* Don't copy code, tests, fixtures, templates or documentation from other tools, including internal tools of your
employer, unless their license allows it and the origin is stated in the pull request. Ideas and features may be
taken over, code may not.
* Use synthetic test data only, in made-up namespaces such as `org.example`. Never commit real thing ids, policy
ids, customer namespaces, hostnames, tokens or other data from a real Ditto installation, not even in comments,
examples or commit messages.

## Before you start

* **Create an issue first** in [eclipse-ditto/dittoctl](https://github.com/eclipse-ditto/dittoctl/issues) for new
features and non-trivial bug fixes, so that the approach can be discussed before much work goes into it. Small
bug fixes and maintenance changes (documentation, build, tooling) don't need an issue; explain the change in the
pull request instead.
* **Keep pull requests small**, well below 1,000 changed lines. Larger contributions trigger an IP review by the
Eclipse Foundation. Split bigger changes into several pull requests that build on each other.
* **Open pull requests early**, as drafts while they aren't ready for review.

## Development setup

dittoctl needs Python 3.11 or newer.

```shell
python3 -m venv .venv
.venv/bin/pip install --upgrade pip # pip 25.1+ for dependency groups
.venv/bin/pip install -e . --group dev
```

Before you push, run:

```shell
.venv/bin/pytest
.venv/bin/ruff check src tests && .venv/bin/ruff format --check src tests
.venv/bin/python scripts/gen_reference.py # after changing commands or help texts (a test checks it)
```

CI runs the same checks; the tests run on Linux, macOS and Windows with Python 3.11 to 3.14.

## Code guidelines

* Formatting and linting: [ruff](https://docs.astral.sh/ruff/) with a line length of 120, as configured in
`pyproject.toml`.
* `dittoctl.core` is a library: it never prints, it returns data or raises exceptions. The command line layer in
`dittoctl.cli` parses options, calls `core` and renders the result.
* Every command and every option has a help text; `docs/reference.md` is generated from them. Write help texts so
that people and LLM agents can use a command correctly without reading the code.
* Writes must stay safe: keep `--dry-run`, the `--max-affected` limit, the confirmation of protected contexts and
Ditto's conditional headers working for every command that changes data.
* Add unit tests for every change (pytest, with [respx](https://lundberg.github.io/respx/) to mock Ditto's HTTP
API).
* Use descriptive commit messages that explain why a change was made.

## License header

Every new source file (Python, YAML, TOML) starts with this header, with the current year:

```python
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
```

Files that were largely generated by an AI carry an AI disclosure instead (see below):

```python
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# AI Disclosure: This file was largely AI-generated. The AI-generated
# portions are made available under CC0-1.0 and not subject to the
# project's licence. The human contributor has reviewed and verified
# that the code is correct.
#
# SPDX-License-Identifier: EPL-2.0 AND CC0-1.0
# Assisted-by: Anthropic Claude Opus 5.5 (claude-opus-5-5)
```

Markdown files carry no header; [NOTICE.md](NOTICE.md) covers them. A test checks the headers of all source
files.

## Contributions created with generative AI

Content created with the assistance of an AI is welcome, under the Eclipse Foundation's
[Generative AI Usage Guidelines](https://www.eclipse.org/projects/handbook/#genai):

* You are responsible for the content: review and test it like your own, and only contribute what you understand
and are willing to support.
* Disclose the use of AI: if you would give a human credit for the contribution, give the AI credit. Use the
header with the AI disclosure above for source files that are largely AI-generated, naming the assistant you
used.
* Name the AI assistant in an `Assisted-by:` trailer of the commit message, e.g.
`Assisted-by: Anthropic Claude Opus 5.5 (claude-opus-5-5)`.
* Make sure your use of the AI platform is consistent with its terms of use and with your employer's policy, and
don't put confidential information or personal data into its prompts.

## Submitting a pull request

1. Fork the repository and create a branch for your change.
2. Make the change, with tests and updated documentation (README, generated reference).
3. Push the branch to your fork and open a pull request against `main`.
4. Don't use that branch for other work while the pull request is open.

The project-wide rules of Eclipse Ditto apply as well, for example for approving and merging pull requests: see
[Ditto's CONTRIBUTING.md](https://github.com/eclipse-ditto/ditto/blob/master/CONTRIBUTING.md).

## Code of conduct and security

Please follow the [Code of Conduct](CODE_OF_CONDUCT.md). Report vulnerabilities as described in
[SECURITY.md](SECURITY.md), never in public issues.
Loading
Loading