From d5f16f44c4cf256914b3fcf03a8b9184098d099b Mon Sep 17 00:00:00 2001 From: Cagri Yonca Date: Wed, 15 Apr 2026 10:58:19 +0200 Subject: [PATCH 1/2] ci: Add Ruff linter as GitHub Action. Executes Ruff as linter tool to check code pattern. Signed-off-by: Paulo Vital Signed-off-by: Cagri Yonca --- .github/workflows/linter.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000..5470d479 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,13 @@ +name: Ruff +on: [ push, pull_request ] +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/ruff-action@v3 + with: + src: >- + ./src + ./tests + ./tests_aws \ No newline at end of file From 6163d0942f19cb2744a85e7417a73b98a107d76d Mon Sep 17 00:00:00 2001 From: Cagri Yonca Date: Wed, 15 Apr 2026 10:58:27 +0200 Subject: [PATCH 2/2] docs: Add setup, testing and coding style sections to the CONTRIBUTING.md Signed-off-by: Cagri Yonca --- CONTRIBUTING.md | 60 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4328f6ad..66288c70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,22 +75,54 @@ local git repository using the following command: git commit -s ``` - +1. **Clone the repository and install dependencies:** + ```shell + git clone https://github.com/instana/python-sensor.git + cd python-sensor + pip install -e ".[dev]" + ``` + + This installs the package in editable mode with development dependencies (pytest, ruff, pre-commit, etc.) + +2. **Set up pre-commit hooks:** + ```shell + pre-commit install + ``` + + This automatically runs Ruff linter and formatter before each commit. + +## Testing and Code Quality + +Before submitting a pull request: + +1. **Run tests:** + ```shell + pytest + ``` + +2. **Check code style:** + ```shell + ruff check ./src ./tests ./tests_aws + ``` + + Or run all pre-commit checks: + ```shell + pre-commit run --all-files + ``` + +**Note:** All pull requests to `main` must pass GitHub Actions checks (Ruff linter + test suite). + +## Coding Style + +- Python 3.9+ compatible code +- Follow PEP 8 style guidelines (enforced by Ruff) +- Include copyright headers in new files (see [Legal](#legal) section) +- Use type hints where appropriate +- Ruff automatically formats code on commit via pre-commit hooks + +Configuration is defined in [`pyproject.toml`](pyproject.toml). For advanced Ruff usage, see [Ruff documentation](https://docs.astral.sh/ruff/).