Skip to content

Add Allure test reporting for tracking test progress#443

Open
vtz wants to merge 3 commits intojumpstarter-dev:mainfrom
vtz:feature/allure-test-reporting
Open

Add Allure test reporting for tracking test progress#443
vtz wants to merge 3 commits intojumpstarter-dev:mainfrom
vtz:feature/allure-test-reporting

Conversation

@vtz
Copy link
Copy Markdown
Contributor

@vtz vtz commented Apr 9, 2026

Summary

  • Integrate allure-pytest into the test pipeline to generate rich HTML reports with automatic categorization of tests by component (Core, Drivers, CLI, Testing, Kubernetes, Utilities)
  • Add new Makefile targets (test-allure, allure-serve, allure-report) that inject allure-pytest via uv run --with without changing existing test targets
  • Update CI workflow to collect Allure results from all matrix jobs (2 OS × 3 Python versions) and merge them into a single downloadable report artifact

Changes

File What
python/pyproject.toml Add allure-pytest>=2.13.0 to workspace dev deps
python/conftest.py Auto-label tests by package/component; write environment.properties
python/Makefile pkg-test-allure-%, test-allure, allure-serve, allure-report targets
.github/workflows/python-tests.yaml Run make test-allure, upload results per matrix cell, generate combined report
python/.gitignore Ignore allure-results/ and allure-report/
*_test.py (2 files) Example @allure.feature/@allure.story/@allure.severity decorators

Design decisions

  • Non-breaking: existing make test / make pkg-test-<pkg> are untouched. Allure is only activated via the new test-allure targets.
  • Zero per-package config: allure-pytest is injected at runtime with uv run --with allure-pytest, so no individual package pyproject.toml changes needed.
  • Graceful degradation: all allure code in conftest.py is guarded by try/except ImportError, so tests work normally without allure installed.

Test plan

  • cd python && make test still passes without allure (existing behavior preserved)
  • cd python && make test-allure generates results in allure-results/
  • cd python && make allure-serve opens the report in a browser
  • CI workflow uploads allure-results-* artifacts per matrix job
  • CI allure-report job produces a merged HTML report artifact

Made with Cursor

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 9, 2026

Deploy Preview for jumpstarter-docs failed. Why did it fail? →

Name Link
🔨 Latest commit e0daf5e
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/69dc9a829d2b3d000858ae2e

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4aff1a20-2254-462c-b9e6-42a39f4b8b3f

📥 Commits

Reviewing files that changed from the base of the PR and between a470cae and e0daf5e.

📒 Files selected for processing (4)
  • .github/workflows/python-tests.yaml
  • python/.gitignore
  • python/Makefile
  • python/conftest.py
✅ Files skipped from review due to trivial changes (2)
  • python/.gitignore
  • python/conftest.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/python-tests.yaml
  • python/Makefile

📝 Walkthrough

Walkthrough

Adds Allure test reporting: CI uploads per-matrix Allure results and consolidates them into a generated Allure report; Makefile and pyproject updated to run tests with allure-pytest; pytest hooks attach suite metadata and write environment properties; selected tests receive Allure annotations.

Changes

Cohort / File(s) Summary
CI / workflow
​.github/workflows/python-tests.yaml
Replace make test with make test-allure in matrix, always upload python/allure-results/ artifacts per runner, add allure-report job that downloads all allure-results-*, generates consolidated report if results exist, and uploads allure-report/.
Build / tooling
python/Makefile, python/.gitignore, python/pyproject.toml
Define ALLURE_RESULTS_DIR, add per-package and aggregate pkg-test-allure-* and test-allure targets, add clean-allure, allure-report, allure-serve, ignore allure-results/ & allure-report/, and add allure-pytest to dev deps.
Pytest hooks / env metadata
python/conftest.py
Conditionally enable Allure integration: add pytest_collection_modifyitems to set parent/suite markers based on package paths and pytest_sessionstart to create alluredir and write environment.properties (Python, Platform, OS, Architecture).
Test annotations
python/packages/.../driver_test.py, python/packages/.../pytest_test.py
Conditionally import allure with no-op fallback and add Allure decorators (feature, story, severity) to selected tests; test logic unchanged.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor "GH Actions\nMatrix Runners"
    participant "Test Runner\n(make test-allure)"
    participant "GHA Artifact Store"
    participant "Allure Job\n(consolidation)"
    participant "Allure CLI\n(allure-commandline)"
    actor "Allure Report\n(uploaded artifact)"

    "GH Actions\nMatrix Runners"->>Test Runner\n(make test-allure): run pytest with allure-pytest
    Test Runner\n(make test-allure)->>GHA Artifact Store: upload `python/allure-results/` per matrix
    "GH Actions\nMatrix Runners"->>Allure Job\n(consolidation): trigger job after tests
    Allure Job\n(consolidation)->>GHA Artifact Store: download all `allure-results-*`
    Allure Job\n(consolidation)->>Allure CLI\n(allure-commandline): run `allure generate ... --clean` if results present
    Allure CLI\n(allure-commandline)->>Allure Job\n(consolidation): produce `allure-report/`
    Allure Job\n(consolidation)->>Allure Report\n(uploaded artifact): upload consolidated `allure-report/`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • mangelajo

Poem

🐰
I hopped through tests to plant a tiny seed,
Allure blooms tidy from each runner's mead.
Artifacts stacked like carrots in a row,
I nudge the report and watch the garden grow. 🌷

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding Allure test reporting for tracking test progress, which aligns with the PR's core objective.
Description check ✅ Passed The description is detailed and comprehensive, explaining the integration of allure-pytest, design decisions, files changed, and test plan, all of which directly relate to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
python/Makefile (1)

127-131: Consider documenting the allure CLI dependency.

The allure-serve and allure-report targets require the allure CLI to be installed separately (e.g., via npm install -g allure-commandline or system package). This isn't obvious from the Makefile alone.

A comment or note in the help text would improve discoverability:

 allure-serve:
+	# Requires: npm install -g allure-commandline
 	allure serve $(ALLURE_RESULTS_DIR)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@python/Makefile` around lines 127 - 131, Add documentation that the Makefile
targets allure-serve and allure-report require the external allure CLI tool;
update the Makefile (near the allure-serve/allure-report targets or the
help/phony section) to include a short comment noting to install the CLI (e.g.,
npm install -g allure-commandline or system package) and optionally reference
ALLURE_RESULTS_DIR usage so users know the dependency and how to install it
before running those targets.
python/conftest.py (2)

89-91: Specify encoding when writing the environment file.

Using open() without an explicit encoding relies on the system default, which can vary. This is a minor robustness issue.

Proposed fix
-            with open(env_file, "w") as f:
+            with open(env_file, "w", encoding="utf-8") as f:
                 for key, value in props.items():
                     f.write(f"{key}={value}\n")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@python/conftest.py` around lines 89 - 91, The file-write block using with
open(env_file, "w") as f: that iterates over props and writes
f.write(f"{key}={value}\n") should explicitly specify an encoding to avoid
system-default variability; update the open call (where env_file and f are used)
to include encoding="utf-8" (or another chosen explicit encoding) so the
environment file is written deterministically.

54-58: Path extraction may fail on Windows.

Using "/packages/" as a path delimiter won't match Windows-style paths (e.g., C:\...\packages\...). Consider using pathlib for cross-platform compatibility:

Proposed fix
     def _extract_package_name(item):
-        path_str = str(item.path)
-        if "/packages/" in path_str:
-            return path_str.split("/packages/")[1].split("/")[0]
-        return None
+        parts = item.path.parts
+        if "packages" in parts:
+            idx = parts.index("packages")
+            if idx + 1 < len(parts):
+                return parts[idx + 1]
+        return None
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@python/conftest.py` around lines 54 - 58, The _extract_package_name function
uses a hardcoded "/packages/" string which breaks on Windows; change it to use
pathlib: convert item.path to a pathlib.Path (e.g., Path(str(item.path))),
inspect its parts to see if "packages" is present, find the index of "packages"
in path.parts and return the next part as the package name, otherwise return
None; update references to item.path in _extract_package_name to use the
Path-based logic so it works cross-platform.
.github/workflows/python-tests.yaml (1)

109-133: Consider handling empty results gracefully.

The allure-report job may fail if no results were uploaded (e.g., all matrix jobs failed before generating Allure output). The allure generate command will error on an empty or missing directory.

Suggested improvement
       - name: Generate Allure report
         run: |
           npm install -g allure-commandline
+          if [ -d "allure-results" ] && [ "$(ls -A allure-results 2>/dev/null)" ]; then
           allure generate allure-results -o allure-report --clean
+          else
+            echo "No Allure results found, skipping report generation"
+            exit 0
+          fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/python-tests.yaml around lines 109 - 133, The
allure-report job should skip generation/upload when there are no results: after
the "Download all Allure results" step (uses: actions/download-artifact@v4) add
a check for the existence and non-emptiness of the allure-results directory and
only run the "Generate Allure report" (the npm install + allure generate
commands) and the subsequent upload step if files are present; otherwise exit
gracefully (or create a small placeholder file) so that the allure generate
command is never invoked against an empty or missing directory.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@python/packages/jumpstarter-driver-network/jumpstarter_driver_network/driver_test.py`:
- Line 8: Replace the unconditional "import allure" with a guarded import (try:
import allure except ImportError: allure = None) and update any
usages/decorators in driver_test.py to handle allure being None (either wrap
decorator usage with a helper no-op decorator or use conditional getattr calls,
e.g., use a small helper function no_op_decorator = (lambda *a, **k: (lambda f:
f)) and apply getattr(allure, 'severity', no_op_decorator) or only apply
decorators when allure is not None) so tests run when allure-pytest is not
installed.

In `@python/packages/jumpstarter-testing/jumpstarter_testing/pytest_test.py`:
- Line 1: The file jumpstarter_testing/pytest_test.py unconditionally imports
the allure module which will raise ImportError when allure-pytest isn't
installed; change the top-level import to be conditional (e.g., wrap import
allure in try/except ImportError and set allure = None) and ensure any
module-level use (decorators or calls) is guarded (only apply decorators or call
allure.* when allure is not None), or alternatively use
pytest.importorskip("allure") inside tests to skip Allure-specific behavior when
unavailable.

---

Nitpick comments:
In @.github/workflows/python-tests.yaml:
- Around line 109-133: The allure-report job should skip generation/upload when
there are no results: after the "Download all Allure results" step (uses:
actions/download-artifact@v4) add a check for the existence and non-emptiness of
the allure-results directory and only run the "Generate Allure report" (the npm
install + allure generate commands) and the subsequent upload step if files are
present; otherwise exit gracefully (or create a small placeholder file) so that
the allure generate command is never invoked against an empty or missing
directory.

In `@python/conftest.py`:
- Around line 89-91: The file-write block using with open(env_file, "w") as f:
that iterates over props and writes f.write(f"{key}={value}\n") should
explicitly specify an encoding to avoid system-default variability; update the
open call (where env_file and f are used) to include encoding="utf-8" (or
another chosen explicit encoding) so the environment file is written
deterministically.
- Around line 54-58: The _extract_package_name function uses a hardcoded
"/packages/" string which breaks on Windows; change it to use pathlib: convert
item.path to a pathlib.Path (e.g., Path(str(item.path))), inspect its parts to
see if "packages" is present, find the index of "packages" in path.parts and
return the next part as the package name, otherwise return None; update
references to item.path in _extract_package_name to use the Path-based logic so
it works cross-platform.

In `@python/Makefile`:
- Around line 127-131: Add documentation that the Makefile targets allure-serve
and allure-report require the external allure CLI tool; update the Makefile
(near the allure-serve/allure-report targets or the help/phony section) to
include a short comment noting to install the CLI (e.g., npm install -g
allure-commandline or system package) and optionally reference
ALLURE_RESULTS_DIR usage so users know the dependency and how to install it
before running those targets.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a613c694-e2b9-4971-9e5f-3f08a35dbb13

📥 Commits

Reviewing files that changed from the base of the PR and between e1b64f9 and 9581eab.

📒 Files selected for processing (7)
  • .github/workflows/python-tests.yaml
  • python/.gitignore
  • python/Makefile
  • python/conftest.py
  • python/packages/jumpstarter-driver-network/jumpstarter_driver_network/driver_test.py
  • python/packages/jumpstarter-testing/jumpstarter_testing/pytest_test.py
  • python/pyproject.toml

vtz added 2 commits April 11, 2026 13:31
Integrate allure-pytest to generate rich HTML test reports with
automatic test categorization by package and component type (Core,
Drivers, CLI, etc.). CI uploads per-matrix results and merges them
into a single combined report artifact.

Made-with: Cursor
Wrap `import allure` in try/except with a no-op stub so tests
run without errors when allure-pytest is not installed (e.g.
via `make test` instead of `make test-allure`).

Made-with: Cursor
@vtz vtz force-pushed the feature/allure-test-reporting branch from a470cae to 5ad1c2b Compare April 11, 2026 17:31
- Pin allure-commandline@2.32.0 in CI for reproducible builds
- Guard allure-report generation against empty results directory
- Clean stale results at the start of test-allure target
- Add encoding="utf-8" to environment.properties file write
- Document allure CLI requirement in Makefile help and targets
@vtz
Copy link
Copy Markdown
Contributor Author

vtz commented Apr 13, 2026

Addressed review feedback in e0daf5e:

  • Pin allure-commandline version — pinned to @2.32.0 for reproducible CI builds
  • Guard empty resultsallure generate now only runs if results directory is non-empty
  • Clean stale resultsmake test-allure clears allure-results/ before running
  • encoding="utf-8" — added explicit encoding to environment.properties file write
  • Document allure CLI — help text and targets now mention the npm i -g allure-commandline requirement

Intentionally skipped: pathlib-based path extraction for Windows compat — CI runs on Linux and macOS only, and the Makefile itself is Unix-only. Adding Windows path handling would be dead code.

Note: GitHub Actions workflows are in action_required state after the rebase force-push and need maintainer approval to re-run.

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.

1 participant