Skip to content

KNOX-3335: Add pylint pre-push linting for .github/workflows/tests Python integration tests#1245

Open
Raghav-Mah3shwari wants to merge 6 commits into
apache:masterfrom
Raghav-Mah3shwari:KNOX-3335
Open

KNOX-3335: Add pylint pre-push linting for .github/workflows/tests Python integration tests#1245
Raghav-Mah3shwari wants to merge 6 commits into
apache:masterfrom
Raghav-Mah3shwari:KNOX-3335

Conversation

@Raghav-Mah3shwari
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?
This PR adds local pylint linting for Python integration tests under .github/workflows/tests/ and fixes existing pylint violations so the suite passes cleanly.

Linting infrastructure

Added .pylintrc with test-friendly settings (100-char line limit, common test-docstring rules disabled).
Added run_pylint.sh to lint changed or staged .py files under .github/workflows/tests/; creates a local venv (.venv/) and installs requirements.txt plus pylint.
Updated README.md with a Linting (pylint) section covering manual runs and optional git hook setup.
Code quality fixes

Resolved pylint issues across all integration test modules and common_utils.py (line length, trailing whitespace, trailing newlines).
All files under .github/workflows/tests/ now score 10.00/10 with the new config.
No functional changes to test logic — only style and lint tooling.

How was this patch tested?
Pylint (manual)

./.github/workflows/tests/run_pylint.sh
Result: all test_*.py and common_utils.py pass at 10.00/10.

Pylint (targeted)

cd .github/workflows/tests
.venv/bin/pylint --rcfile=.pylintrc -j 0 test_*.py common_utils.py
Result: exit code 0, no violations.

Script behavior

Verified run_pylint.sh creates .venv/ on first run and reuses it on subsequent runs.
Verified it only lints files under .github/workflows/tests/ that are modified or staged.
Integration Tests
No new integration tests were added. This change is lint tooling and style fixes for the existing Docker Compose test suite.

Existing tests in .github/workflows/tests/ were not changed in behavior. To confirm they still pass end-to-end:

docker compose -f ./.github/workflows/compose/docker-compose.yml build knox-dev tests
docker compose -f ./.github/workflows/compose/docker-compose.yml up -d
docker compose -f ./.github/workflows/compose/docker-compose.yml up --exit-code-from tests tests
UI changes
N/A — no UI changes.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Test Results

21 tests   21 ✅  1s ⏱️
 1 suites   0 💤
 1 files     0 ❌

Results for commit fac48ab.

Copy link
Copy Markdown
Contributor

@moresandeep moresandeep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Raghav-Mah3shwari looks like the patch has more changes then linting (that i though), can you please describe all the changes? i.e. the images and changes to docker-compose and why are they needed.
Thanks!

context: ../../../
context: ../../..
dockerfile: .github/workflows/build/Dockerfile
image: apache/knox-dev:${IMAGE_TAG:-master}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we updating the image tag from ${IMAGE_TAG:-master} to knox-dev:master
What if there are multiple parallel builds? this will cause conflicts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good point.. updating it, thank you

@Raghav-Mah3shwari
Copy link
Copy Markdown
Contributor Author

Hi @moresandeep ,
Beyond .pylintrc, run_pylint.sh, and style fixes, there are docker-compose and workflow changes to enforce pylint in CI:

Why docker-compose changed

Previously, the tests service used python:3.9-slim, bind-mounted ../tests, and only ran pytest. There was no lint step in CI.
We now run pylint in the tests container before pytest, so every PR that runs Apache Knox Docker Compose Tests fails on lint violations — no optional git hook required.

Why the images changed

apache/knox-compose-tests:local (new): built from tests/Dockerfile with pylint, .pylintrc, and test sources baked in. Needed so CI has pylint available and lints the same code it tests.
apache/knox-dev:${IMAGE_TAG:-master} (unchanged role): still the Knox runtime for ldap/knox; CI builds this as before.
knox-dev-local (optional, local dev only): builds Knox from source via Dockerfile.local not used by CI.

Other compose tweaks

tests.yml now builds knox-dev and tests (was knox-dev only).
Knox logs use a named volume instead of ./logs bind-mount (more reliable on Docker Desktop).
Removed runtime pip install from the tests command

In a summary we can say that local lint (run_pylint.sh) = fast developer feedback; compose/CI lint = mandatory gate for all PRs.

The tests service builds from ../tests/Dockerfile; without this file
CI fails with "open Dockerfile: no such file or directory".

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants