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 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/).