Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrestaFlow — Bitbucket Pipe

Run PrestaFlow tests inside Bitbucket Pipelines: optionally boot a PrestaShop Flashlight instance, execute your suite, upload results (plus error and visual‑regression screenshots) to PrestaFlow, and comment the summary back on the pull request.

Companion of PrestaFlow/github-action and PrestaFlow/gitlab-component — same behaviour, same backend, different CI idioms.

Quick start

# bitbucket-pipelines.yml
image: php:8.3-cli

pipelines:
  pull-requests:
    '**':
      - step:
          name: PrestaFlow
          services: [docker]
          script:
            - pipe: docker://prestaflow/pipe-push:1.0.0
              variables:
                TOKEN: $PRESTAFLOW_TOKEN
                PROJECT_ID: pk_01ABC...
                FLASHLIGHT: 'true'
                PS_VERSION: '9.0.0'
                BITBUCKET_ACCESS_TOKEN: $PRESTAFLOW_BITBUCKET_TOKEN

Full sample: examples/bitbucket-pipelines.yml.

Required repository variables

Add these in Repository settings → Repository variables:

Variable Required Purpose
PRESTAFLOW_TOKEN yes PrestaFlow API token. Mark as Secured.
PRESTAFLOW_BITBUCKET_TOKEN optional Bitbucket Repository Access Token with pullrequest:write scope. Only needed if you want the pipe to post PR summary comments. Mark as Secured.

Variables

Name Default Description
TOKEN PrestaFlow API token. Required.
PROJECT_ID "" PrestaFlow project Product Key (e.g. pk_01ABC…).
API_URL https://api.prestaflow.io PrestaFlow API base URL.
EXECUTE true Run composer run prestaflow:json:file before upload. Set to false if a previous step already produced results.json.
SUITES "" Comma‑separated suites to run (e.g. BackOffice,FrontOffice). Empty runs all.
FLASHLIGHT false Boot a PrestaShop Flashlight Docker container to test against. Requires services: [docker] on the step.
PS_VERSION latest Flashlight image tag when FLASHLIGHT=true.
FLASHLIGHT_MOUNT auto Where to mount the workspace inside the Flashlight container: auto, root, modules, or themes. auto reads composer.json type (prestashop-module / prestashop-theme).
FLASHLIGHT_INIT_SCRIPTS "" Path (absolute or relative to the workspace) to a directory of Flashlight init scripts, mounted read‑only at /tmp/init-scripts.
PR_COMMENT auto Post/update a PR summary comment. Defaults to true on pull‑request pipelines, false otherwise.
UPLOAD_ARTIFACTS true Copy results.json (and prestaflow.env) into $BITBUCKET_PIPE_SHARED_STORAGE_DIR.
VISUAL true Enable visual‑regression round‑trip (baseline download before the run, actual/diff upload after).
BITBUCKET_ACCESS_TOKEN "" Access token used to post PR comments. See PR comments.

Outputs

After the pipe runs, it writes prestaflow.env into the workspace and into $BITBUCKET_PIPE_SHARED_STORAGE_DIR/prestaflow.env (when available). The file contains:

PRESTAFLOW_REPORT_ID=…            # PrestaFlow report ID
PRESTAFLOW_REPORT_URL=…           # https://prestaflow.io/reports/…
PRESTAFLOW_PASSED=42
PRESTAFLOW_FAILED=0
PRESTAFLOW_SKIPPED=3
PRESTAFLOW_TOTAL=45
PRESTAFLOW_DURATION_MS=185432
PRESTAFLOW_STATUS=success         # or "failure"

Consume it in a later step by declaring artifacts: [prestaflow.env] on the pipe step and sourcing it downstream:

- step:
    name: PrestaFlow
    services: [docker]
    artifacts: [prestaflow.env]
    script:
      - pipe: docker://prestaflow/pipe-push:1.0.0
        variables:
          TOKEN: $PRESTAFLOW_TOKEN
          PROJECT_ID: pk_01ABC...

- step:
    name: Notify
    script:
      - . prestaflow.env
      - echo "Report ready → $PRESTAFLOW_REPORT_URL ($PRESTAFLOW_STATUS)"

PR comments

When the pipe runs on a pull‑request pipeline and BITBUCKET_ACCESS_TOKEN is set, it posts (or updates) a summary comment via the Bitbucket Cloud API. Idempotency is done via a hidden marker <!-- prestaflow-run:<project-key> --> inside the comment body.

To create the token:

  1. Repository settings → Access tokens → Create Repository Access Token.
  2. Grant it Pull requests: write.
  3. Add it as a Secured repository variable (e.g. PRESTAFLOW_BITBUCKET_TOKEN) and pass it as BITBUCKET_ACCESS_TOKEN.

If the token is missing, the pipe warns and continues — PR comments are non‑fatal.

Flashlight

Setting FLASHLIGHT: 'true' boots a prestashop/prestashop-flashlight:<PS_VERSION> container plus a mariadb:lts, waits for the storefront to answer, and exports PRESTAFLOW_FO_URL into .env.local for your test suite. The step needs services: [docker].

FLASHLIGHT_MOUNT:

  • auto (default): reads composer.json type and mounts under modules/<name> or themes/<name>; falls back to modules/<repo-basename> with a warning.
  • root: mount workspace at /var/www/html (custom PrestaShop distributions).
  • modules / themes: force the location.

What the pipe does

The container's entrypoint runs these scripts in order — each is a small self‑contained bash script under scripts/:

  1. flashlight.sh — boot Flashlight (opt‑in).
  2. visual-download.sh — pull visual baselines for the current branch.
  3. runner.shcomposer run prestaflow:json:file (unless EXECUTE=false).
  4. upload.sh — POST results.json + error/visual PNGs to the PrestaFlow API.
  5. comment-pr.sh — post/update the PR comment.
  6. outputs.sh — aggregate final counters and exit non‑zero on any test failure.

Publishing

  • Docker Hub: the pipe is distributed as prestaflow/pipe-push:<version>. Build & push:
    docker build -t prestaflow/pipe-push:1.0.0 -t prestaflow/pipe-push:1 -t prestaflow/pipe-push:latest .
    docker push prestaflow/pipe-push:1.0.0
    docker push prestaflow/pipe-push:1
    docker push prestaflow/pipe-push:latest
  • Bitbucket Marketplace: submit this repository at https://bitbucket.org/product/features/pipelines/integrations. Marketplace listings point to the same pipe.yml/Docker image; there's no separate artifact to publish.

License

MIT — see LICENSE.

About

Run PrestaFlow tests in Bitbucket Pipelines: optional PrestaShop setup via Flashlight, upload results, comment PRs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages