Skip to content

pytest-allure-host

PyPI version License: MIT

Private, cache-aware Allure report hosting for AWS S3 + CloudFront (OAC) — with history preservation, atomic “latest” promotion, HTML index, manifest tracking, retention pruning, and TTL tagging.

Edge security first: CloudFront (WAF / signed URLs / SSO) + OAC. No public S3 website endpoint. Ever.

Core Features

🔒 Private by Default

CloudFront with OAC over a private bucket ensures zero public ACLs or website hosting exposure.

📈 Trend Preservation

Pulls previous latest/history data before generating new reports to retain Allure trends.

⚡ Atomic Latest

Two-phase latest_tmp/ to latest/ swap with a readiness marker prevents partial states.

🧠 Smart Caching

Immutable assets cached for one year. index.html and optional widgets/ are served with no-cache for instant updates.

🛡️ Scoped IAM

Prefix-scoped List and Get/Put/Delete/Tag/Copy permissions enforce strict least privilege.

🧩 Flexible Usage

Supports CLI or pytest plugin, dry-run mode, LocalStack, metadata enrichment, archiving, and pruning options.

🏷️ Metadata & Manifest

--meta key=val enriches the manifest and HTML index for dashboards and filtering.

♻️ Retention & TTL

--max-keep-runs pruning and --ttl-days tagging integrate with S3 lifecycle rules.

Ready to try it? Head to the Quick Start guide.

One‑liner install & publish

    pip install pytest-allure-host allure-pytest && \
      pytest --alluredir=allure-results && \
      publish-allure --bucket <bucket> --project demo --branch main \
        --cloudfront https://<cf-domain>

Why

Problem Solution
Public S3 website hosting disallowed Private bucket + CloudFront (OAC)
Losing Allure history between runs Pull prior latest/history
Race updating latest/ Two-phase staging with readiness marker
Hard to navigate past runs Manifest + HTML index
Stale UI / caching issues Immutable assets, index.html served no-cache

Core Flow

  1. Gather allure-results (pytest or other producers)
  2. Best-effort pull previous latest/history/
  3. Generate new static Allure report
  4. Upload to immutable /<run_id>/ prefix
  5. Promote staged copy to latest/ (two‑phase swap)
  6. Update manifest + HTML index + optional latest.json
  7. Output Run & Latest URLs
s3://<bucket>/<prefix>/<project>/<branch>/<run_id>/
s3://<bucket>/<prefix>/<project>/<branch>/latest/

Install

pip install pytest-allure-host allure-pytest

Onboarding Checklist ✅

# Description Quick Command / Note
1 Python >= 3.9 python --version
2 Allure CLI (needs Java) allure --version / java -version
3 AWS creds valid aws sts get-caller-identity
4 Private bucket + CloudFront distribution make infra-awscli-setup BUCKET=<name> AWS_REGION=<region> (optional)
5 IAM least privilege (prefix-scoped) See IAM
4 Private bucket + CloudFront distribution allurehost-infra-setup --bucket <name> --region <region> --yes
6 Bucket policy restricts to distribution ARN allurehost-infra-validate or Architecture page
7 Dry-run preflight passes publish-allure ... --check --dry-run

Dry preflight example

    publish-allure \
      --bucket my-allure-reports \
      --project demo \
      --branch main \
      --cloudfront https://dxxxxx.cloudfront.net \
      --check --dry-run

Security Highlight

Keep bucket PRIVATE (Block Public Access ON). Do not enable S3 website hosting. All access flows through CloudFront + OAC.

Troubleshooting (quick):

  • 301 when pulling history → Region mismatch
  • 403 via CloudFront → OAC not attached or bucket policy missing SourceArn
  • Blank SPA route → Ensure 403/404 error mapping to /index.html
  • Missing trends first run → Normal (no history yet)

Architecture (Preview)

flowchart LR
  User --> CF[CloudFront - OAC]
  CF --> S3[Private S3 Bucket]
  CF --> R1[Immutable Run Prefixes]
  CF --> L1[latest/ pointer]

Full detail: Architecture

End-to-End Example (CLI)

# 1. Produce results
pytest --alluredir=allure-results

# 2. Dry preflight (explicit flags)
publish-allure \
  --bucket my-allure-reports \
  --project payments \
  --branch main \
  --cloudfront https://reports.example.com \
  --check --dry-run

# 3. Publish (explicit flags)
publish-allure \
  --bucket my-allure-reports \
  --project payments \
  --branch main \
  --cloudfront https://reports.example.com

Zero‑flags mode

If you ran the Infra CLI setup, it wrote .infra_env and allure-host.yml for you. From the repo root you can now run:

```bash
source .infra_env && publish-allure --check --dry-run
source .infra_env && publish-allure
```

30s Quick Start (CLI)

pytest --alluredir=allure-results
publish-allure \
  --bucket my-allure-reports \
  --project demo \
  --branch main \
  --cloudfront https://reports.example.com

30s Quick Start (pytest plugin)

pytest \
  --allure-bucket my-allure-reports \
  --allure-project demo \
  --allure-branch main \
  --allure-cloudfront https://reports.example.com \
  --alluredir allure-results

Status & Roadmap

  • Current: alpha – interface stabilizing
  • Upcoming: richer metadata columns, provenance, HTML dashboard improvements

License

MIT – see repository LICENSE.


Last updated: {{ git.date }}