Run PrestaFlow tests inside GitLab CI: optionally boot a PrestaShop instance with Flashlight, execute your PrestaFlow test suites, upload the report (with error and visual-regression screenshots), and comment the run summary on the merge request.
This is a straight port of the PrestaFlow GitHub Action —
same inputs, same upload endpoint (POST /ci/github-action, which is provider-agnostic
on the backend), same MR/PR comment format.
The component lives on GitHub (PrestaFlow/gitlab-component). GitLab's Catalog
include: - component: shorthand only resolves against $CI_SERVER_FQDN (typically
gitlab.com), so pick one of the two ways to consume it:
Push this repository as a mirror to gitlab.com/prestaflow/ci, then in your
.gitlab-ci.yml:
include:
- component: gitlab.com/prestaflow/ci/prestaflow@v0.1.0inputs:
token: $PRESTAFLOW_TOKENPublish the release on GitLab so the ref shows in the CI/CD Catalog listing.
If you do not want to maintain a mirror, git clone the component in a
before_script and include: a local file:
default:
before_script:
- if [ ! -d .prestaflow-component ]; thengit clone --depth 1 --branch v0.1.0https://github.com/PrestaFlow/gitlab-component.git .prestaflow-component;fiinclude:
- local: .prestaflow-component/templates/prestaflow.ymlinputs:
token: $PRESTAFLOW_TOKENEither way, the scripts run directly from the checked-out component sources
($CI_PROJECT_DIR/.prestaflow-component/scripts/*.sh in Option B, or the path
resolved by $CI_COMPONENT_REF_PATH-style variables in Option A). The template's
before_script handles the clone in Option A too — see Script bundling
below.
include:
- component: gitlab.com/prestaflow/ci/prestaflow@v0.1.0inputs:
token: $PRESTAFLOW_TOKENproject_id: pk_01ABCDEFflashlight: "true"ps_version: "9.0.0"suites: "BackOffice,FrontOffice"visual: "true"mr_comment: "true"variables:
# Required for MR comments — CI_JOB_TOKEN cannot post notes.GITLAB_TOKEN: $GITLAB_TOKENPRESTAFLOW_TOKEN and GITLAB_TOKEN must be defined as masked CI/CD
variables in your project settings.
| Name | Default | Description |
|---|---|---|
api_url | https://api.prestaflow.io | PrestaFlow API base URL. |
token | (required) | PrestaFlow API token — pass through a masked CI variable. |
project_id | "" | PrestaFlow project Product Key (pk_...). Optional if the token is scoped. |
execute | "true" | Run composer run prestaflow:json:file before upload. |
suites | "" | Comma-separated suite list (BackOffice,FrontOffice). Empty = all. |
flashlight | "false" | Start a PrestaShop Flashlight Docker instance. Requires docker:dind. |
ps_version | "latest" | Flashlight image tag (9.0.0, 8.1.7, latest). Ignored unless flashlight=true. |
flashlight_mount | "auto" | auto | root | modules | themes. Where the workspace is mounted inside PrestaShop. |
flashlight_init_scripts | "" | Path (absolute or relative to $CI_PROJECT_DIR) to a dir of init scripts, mounted at /tmp/init-scripts read-only. |
mr_comment | "" (auto) | Post/update the Merge Request note. Auto-detected: true on MR pipelines, false otherwise. |
upload_artifacts | "true" | Attach results.json + screenshots as GitLab artifacts. |
visual | "true" | Enable the visual-regression round-trip (download baselines before, upload actual/diff after). |
| Variable | Required for | Notes |
|---|---|---|
PRESTAFLOW_TOKEN | Uploading results | Mask it. Passed as token input. |
GITLAB_TOKEN | MR comments | Project or personal access token with api scope. CI_JOB_TOKENcannot post MR notes. |
The job writes prestaflow.env and exposes it via artifacts:reports:dotenv, so
any downstream job in the same pipeline can consume the values as environment
variables:
| Variable | Description |
|---|---|
PRESTAFLOW_REPORT_ID | PrestaFlow report ID. |
PRESTAFLOW_REPORT_URL | URL of the report on prestaflow.io. |
PRESTAFLOW_PASSED | Number of passing tests. |
PRESTAFLOW_FAILED | Number of failing tests. |
PRESTAFLOW_SKIPPED | Number of skipped tests. |
PRESTAFLOW_TOTAL | Total number of tests. |
PRESTAFLOW_DURATION_MS | Total execution duration in milliseconds. |
PRESTAFLOW_STATUS | success if failed==0, else failure. |
Example downstream consumption:
notify:
stage: deployneeds:
- job: prestaflowartifacts: truescript:
- echo "Report at $PRESTAFLOW_REPORT_URL ($PRESTAFLOW_STATUS)"GitLab CI Components ship YAML only — they do not copy the component
repository's files into the runner's workspace. To reach scripts/*.sh at
runtime, the template's before_script clones the component's source into
$CI_PROJECT_DIR/.prestaflow-component/ (idempotent — skipped if present, as
happens when the consumer already cloned in their own before_script per
Option B). The scripts are then invoked as
bash .prestaflow-component/scripts/<name>.sh.
The clone URL and ref default to this GitHub repo at main; override with the
component_repo / component_ref inputs if you fork or pin.
To publish this component on gitlab.com's CI/CD Catalog:
git clone --mirror https://github.com/PrestaFlow/gitlab-component.git
cd gitlab-component.git
git remote add gitlab https://gitlab.com/prestaflow/ci.git
git push --mirror gitlabThen in the gitlab.com project, tag a release (v0.1.0, v0.2.0, …) and enable
"CI/CD Catalog project" in Settings → General. Consumers can then use the
canonical component: shorthand.
The port is behavior-for-behavior with two small platform-imposed changes:
- PR comment auth. The GitHub Action uses the auto-injected
GITHUB_TOKEN. GitLab'sCI_JOB_TOKENcannot create merge-request notes, so this component requires an explicitGITLAB_TOKENCI variable (documented above). - Outputs. The GitHub Action sets step outputs via
core.setOutput. On GitLab, outputs are conveyed through adotenvartifact (prestaflow.env). Downstream jobs consume them by declaringneeds: [{ job: prestaflow, artifacts: true }].
Everything else — inputs, Flashlight boot, visual round-trip, results upload,
comment marker format (<!-- prestaflow-run:<projectKey> -->) — matches.
MIT — see LICENSE.