diff --git a/.github/workflows/_internal-e2e.yaml b/.github/workflows/_internal-e2e.yaml
new file mode 100644
index 00000000..346e2d5d
--- /dev/null
+++ b/.github/workflows/_internal-e2e.yaml
@@ -0,0 +1,139 @@
+name: E2E Test
+
+on:
+ workflow_dispatch: {}
+ push:
+ branches:
+ - main
+ paths:
+ - "_test/demo-package/Test/e2e/**"
+ - "warden/**"
+ - "setup-magento/**"
+ - ".github/workflows/_internal-e2e.yaml"
+ - "!(**/*.md)"
+ pull_request:
+ branches:
+ - main
+ paths:
+ - "_test/demo-package/Test/e2e/**"
+ - "warden/**"
+ - "setup-magento/**"
+ - ".github/workflows/_internal-e2e.yaml"
+ - "!(**/*.md)"
+
+# Standing up the whole stack costs a runner for a while; there is no reason to
+# keep paying for a run whose commit has already been superseded.
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ storefront-smoke-test:
+ name: "storefront tests"
+ if: "!startsWith(github.head_ref, 'release-please')"
+ runs-on: ubuntu-latest
+ timeout-minutes: 60
+ env:
+ # setup:install, the hostname the runner resolves and the URL the browser
+ # opens all have to agree, so they are derived from one place.
+ TRAEFIK_DOMAIN: mageos.test
+ TRAEFIK_SUBDOMAIN: app
+ E2E_DIRECTORY: actions/_test/demo-package/Test/e2e
+ # Pinned rather than taken from supported-version: this workflow is here
+ # to tell us whether the action still serves a store, so a service bump
+ # elsewhere should not change what it reports. The release pipeline picks
+ # its own versions.
+ PHP_VERSION: "8.4"
+ COMPOSER_VERSION: "2.10.2"
+ steps:
+ # Not at the workspace root: warden/setup-environment checks the Warden
+ # CLI out into warden/ there, which is where this repository keeps that
+ # action, and the checkout would land on top of it.
+ - uses: actions/checkout@v6
+ with:
+ path: actions
+
+ # mode: extension is how the other internal workflows get a project onto
+ # disk -- composer create-project --no-install, into ./_ghamagento. The
+ # dependencies are then installed inside the container, by the PHP version
+ # that will serve them.
+ - name: Create the Mage-OS project
+ uses: ./actions/setup-magento
+ with:
+ php-version: ${{ env.PHP_VERSION }}
+ tools: "composer:v2"
+ mode: extension
+ magento_repository: "https://repo.mage-os.org/"
+ magento_version: "mage-os/project-community-edition:4.0.0"
+
+ - name: Serve the store in Warden
+ id: warden
+ uses: ./actions/warden/setup-environment
+ with:
+ base_directory: "./_ghamagento"
+ php_version: ${{ env.PHP_VERSION }}
+ composer_version: ${{ env.COMPOSER_VERSION }}
+ database: "mariadb:11.8"
+ search: "opensearch:3.4"
+ rabbitmq: "rabbitmq:4.2"
+ redis: "redis:7.4"
+ varnish: "varnish:8.0"
+ run_composer_install: 1
+ run_setup_install: 1
+ run_admin_user_creation: 1
+ run_magento_config_preset: 1
+ run_reindex: 1
+ traefik_domain: ${{ env.TRAEFIK_DOMAIN }}
+ traefik_subdomain: ${{ env.TRAEFIK_SUBDOMAIN }}
+ # The three inputs a browser needs, and nothing a PHPUnit suite pays for.
+ base_url: "https://${{ env.TRAEFIK_SUBDOMAIN }}.${{ env.TRAEFIK_DOMAIN }}/"
+ configure_host_resolution: 1
+ run_static_content_deploy: 1
+ static_content_themes: "Magento/luma"
+
+ # Separate from the test run so that "the store was never reachable" and
+ # "the store rendered the wrong thing" are different red steps.
+ - name: Confirm the store answers on the resolved hostname
+ run: curl --silent --show-error --fail --insecure --head "${{ steps.warden.outputs.base_url }}" | head -1
+
+ # A bare setup:install has nothing to buy. The command reindexes itself.
+ # Streamed in rather than copied: the project directories are owned by the
+ # container's user.
+ - name: Seed the catalog
+ working-directory: ./_ghamagento
+ shell: bash
+ env:
+ PROFILE: ${{ github.workspace }}/${{ env.E2E_DIRECTORY }}/fixtures/mageos-e2e.xml
+ run: |
+ export WARDEN="$(dirname $(pwd))/warden/bin/warden"
+ ${WARDEN} env exec -T php-fpm bash -c 'cat > /tmp/mageos-e2e.xml' < "${PROFILE}"
+ ${WARDEN} env exec -T php-fpm bin/magento setup:performance:generate-fixtures /tmp/mageos-e2e.xml
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: npm
+ cache-dependency-path: ${{ env.E2E_DIRECTORY }}/package-lock.json
+
+ - name: Install Playwright
+ working-directory: ${{ env.E2E_DIRECTORY }}
+ run: |
+ npm ci
+ npx playwright install --with-deps chromium
+
+ - name: Run the storefront tests
+ working-directory: ${{ env.E2E_DIRECTORY }}
+ env:
+ PLAYWRIGHT_BASE_URL: ${{ steps.warden.outputs.base_url }}
+ run: npx playwright test
+
+ - name: Upload the Playwright report
+ if: ${{ !cancelled() }}
+ uses: actions/upload-artifact@v4
+ with:
+ name: playwright-report
+ path: |
+ ${{ env.E2E_DIRECTORY }}/playwright-report
+ ${{ env.E2E_DIRECTORY }}/test-results
+ retention-days: 30
+ if-no-files-found: ignore
diff --git a/.github/workflows/e2e-README.md b/.github/workflows/e2e-README.md
new file mode 100644
index 00000000..e8b1c098
--- /dev/null
+++ b/.github/workflows/e2e-README.md
@@ -0,0 +1,156 @@
+# Browser-based E2E Tests for Mage-OS
+
+A Github Workflow that stands a Mage-OS store up, **serves it**, and points a
+browser-based test runner at it.
+
+This is not the PHPUnit-based suite that upstream calls "functional tests". It
+installs a store, serves it through Traefik and Varnish on a resolvable
+hostname, optionally seeds a catalog, and runs a browser against the result.
+
+## Inputs
+
+See the [e2e.yaml](./e2e.yaml)
+
+### What to install
+
+| Input | Description | Required | Default |
+| -------------------- | --------------------------------------------------------------------------- | -------- | ----------------------------- |
+| magento_version | The package to install, e.g. `mage-os/project-community-edition:4.0.0` | true | NULL |
+| magento_repository | The composer repository to install it from | false | https://repo.mage-os.org/ |
+| php_version | The PHP version that installs and serves the store | false | 8.4 |
+| composer_version | The Composer version used inside the container | false | 2.10.2 |
+
+A release gate points `magento_repository` at the preview repository and
+`magento_version` at the release being built, which is how it tests the
+artifact about to be tagged rather than whatever is already published.
+
+### What to serve it with
+
+| Input | Description | Required | Default |
+| ---------------------- | ------------------------------------------------------------------------- | -------- | --------------- |
+| database | Database service and version | false | mariadb:11.8 |
+| search | Search service and version | false | opensearch:3.4 |
+| rabbitmq | Message queue service and version | false | rabbitmq:4.2 |
+| redis | Cache service and version | false | redis:7.4 |
+| varnish | HTTP cache service and version | false | varnish:8.0 |
+| static_content_themes | Space separated themes to deploy static content for. Empty deploys every theme, which is considerably slower. | false | Magento/luma |
+
+### Where the suite comes from
+
+| Input | Description | Required | Default |
+| ----------------- | ---------------------------------------------------------------- | -------- | --------------------------------- |
+| suite_repository | The repository holding the test suite | false | mage-os/github-actions |
+| suite_ref | The ref to check it out at | false | main |
+| test_directory | The suite's directory, relative to the root of `suite_repository` | false | _test/demo-package/Test/e2e |
+
+The defaults point at the suite this repository carries for its own canary. A
+caller with a suite of its own overrides all three.
+
+### How to run it
+
+| Input | Description | Required | Default |
+| ------------------------ | ------------------------------------------------------------------ | -------- | -------------------- |
+| test_command | The command to run, from `test_directory` | false | `npx playwright test` |
+| node_version | Node version for the runner | false | 22 |
+| fixture_profile | A performance-toolkit profile to seed, relative to the suite root. Empty skips seeding. | false | _test/demo-package/Test/e2e/fixtures/mageos-e2e.xml |
+| timeout_minutes | Job timeout | false | 60 |
+| artifact_name | Name of the uploaded report artifact | false | playwright-report |
+| artifact_retention_days | How long the report is kept | false | 30 |
+
+## Secrets
+
+| Input | Description | Required | Default |
+| ------------- | --------------------------------------------------------------------------- | -------- | ------- |
+| composer_auth | JSON string of composer credentials | false | NULL |
+
+## Outputs
+
+| Output | Description |
+| -------- | ------------------------------------- |
+| base_url | The URL the store was served on |
+
+## `test_command`
+
+The workflow does not know what test runner you use. `test_command` is run from
+`test_directory` with `PLAYWRIGHT_BASE_URL` already set to the served store, so
+a caller can pass grep filters, shards, a different reporter, or something that
+is not Playwright at all, without this workflow growing an input per flag.
+
+The command arrives through the environment rather than interpolated into the
+script, so its quoting is bash's problem and not the expression engine's.
+
+**Keep evidence policy out of it.** `trace`, `video` and `screenshot` belong in
+the suite's own config, where they are reviewable. A CLI flag overrides the
+config, and `--trace on` records a trace for every passing test, which uploads
+a large artifact for no benefit. The default command carries no flags for that
+reason.
+
+### A setup phase
+
+Playwright's project `dependencies` are the mechanism for shared state that is
+expensive to build -- an authenticated admin or customer session saved as
+`storageState` and reused by every spec that needs it. Express that in the
+suite's config rather than as two `--grep` / `--grep-invert` invocations in
+`test_command`: two invocations write to the same report directory, so the
+second overwrites the first and a failing setup phase loses its own evidence.
+One command, one report, one exit code.
+
+Data is a different matter. Catalog and configuration are seeded through
+`fixture_profile` by the CLI in seconds; doing the same work through a browser
+would be slower and flakier for no gain.
+
+## Fixtures
+
+`fixture_profile` is a [performance
+toolkit](https://developer.adobe.com/commerce/php/development/tools/performance-toolkit/)
+profile, applied with `setup:performance:generate-fixtures`. The command
+reindexes as part of its own run, so no `indexer:reindex` follows it.
+
+A bare `setup:install` has no salable product, so any suite that reaches a
+product page or a checkout needs this. Leave it empty for a suite that asserts
+only on what a bare install provides.
+
+## Usage
+
+```yaml
+jobs:
+ e2e:
+ uses: mage-os/github-actions/.github/workflows/e2e.yaml@main
+ with:
+ magento_version: "mage-os/project-community-edition:4.0.0"
+```
+
+Gating a release on the artifact that is about to be tagged:
+
+```yaml
+jobs:
+ storefront-check:
+ needs: [ deploy ]
+ uses: mage-os/github-actions/.github/workflows/e2e.yaml@main
+ with:
+ magento_repository: ${{ inputs.repo }}
+ magento_version: "mage-os/project-community-edition:${{ inputs.mageos_release }}"
+ artifact_name: "storefront-check-${{ inputs.mageos_release }}"
+```
+
+Running a suite of your own:
+
+```yaml
+jobs:
+ e2e:
+ uses: mage-os/github-actions/.github/workflows/e2e.yaml@main
+ with:
+ magento_version: "mage-os/project-community-edition:4.0.0"
+ suite_repository: my-org/my-e2e-tests
+ suite_ref: v1.2.0
+ test_directory: "."
+ test_command: "npx playwright test --grep @smoke"
+ fixture_profile: "fixtures/minimal.xml"
+```
+
+## Where things end up on the runner
+
+`warden/setup-environment` checks the Warden CLI out into `warden/` at the
+workspace root, and `base_directory` has to sit exactly one level below it.
+That is why the suite is checked out into `suite/` and the store into
+`_ghamagento/`, and why neither is at the workspace root.
diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml
new file mode 100644
index 00000000..cd1d8563
--- /dev/null
+++ b/.github/workflows/e2e.yaml
@@ -0,0 +1,241 @@
+name: E2E Tests
+
+# A reusable workflow that stands a Mage-OS store up, serves it, and points a
+# browser-based test runner at it.
+#
+# It does not know what runner that is: test_command is an input, so a caller
+# can pass grep filters, shards, a different reporter, or something that is not
+# Playwright at all, without this workflow growing an input per flag.
+#
+# Own-repo actions are referenced by full ref rather than by "./", as
+# integration.yaml and full-integration-tests.yaml do. A relative path in a
+# reusable workflow resolves against the caller's checkout, which is not this
+# repository when the caller is the release pipeline.
+
+on:
+ workflow_call:
+ inputs:
+ # What to install.
+ magento_version:
+ required: true
+ type: string
+ description: "The package to install, e.g. mage-os/project-community-edition:4.0.0."
+ magento_repository:
+ required: false
+ type: string
+ default: "https://repo.mage-os.org/"
+ description: "The composer repository to install it from. A release gate points this at the preview repository."
+ php_version:
+ required: false
+ type: string
+ default: "8.4"
+ composer_version:
+ required: false
+ type: string
+ default: "2.10.2"
+
+ # What to serve it with.
+ database:
+ required: false
+ type: string
+ default: "mariadb:11.8"
+ search:
+ required: false
+ type: string
+ default: "opensearch:3.4"
+ rabbitmq:
+ required: false
+ type: string
+ default: "rabbitmq:4.2"
+ redis:
+ required: false
+ type: string
+ default: "redis:7.4"
+ varnish:
+ required: false
+ type: string
+ default: "varnish:8.0"
+ static_content_themes:
+ required: false
+ type: string
+ default: "Magento/luma"
+ description: "Space separated themes to deploy static content for. Empty deploys every theme, which is considerably slower."
+
+ # Where the suite comes from. The default is the suite this repository
+ # carries for its own canary; a caller with a suite of its own overrides
+ # both of these.
+ suite_repository:
+ required: false
+ type: string
+ default: "mage-os/github-actions"
+ suite_ref:
+ required: false
+ type: string
+ default: "main"
+ test_directory:
+ required: false
+ type: string
+ default: "_test/demo-package/Test/e2e"
+ description: "The suite's directory, relative to the root of suite_repository."
+
+ # How to run it.
+ test_command:
+ required: false
+ type: string
+ default: "npx playwright test"
+ description: >
+ Run from test_directory with PLAYWRIGHT_BASE_URL set. Keep evidence
+ policy (trace, video, screenshot) in the suite's own config rather
+ than in flags here: a CLI flag overrides the config, and a gate that
+ records a trace for every passing test uploads a large artifact for
+ no benefit.
+ node_version:
+ required: false
+ type: string
+ default: "22"
+ fixture_profile:
+ required: false
+ type: string
+ default: "_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml"
+ description: >
+ A performance-toolkit profile, relative to the root of
+ suite_repository, seeded before the tests run. Empty skips seeding,
+ which is right for a suite that asserts only on what a bare
+ setup:install provides.
+
+ # Housekeeping.
+ timeout_minutes:
+ required: false
+ type: number
+ default: 60
+ artifact_name:
+ required: false
+ type: string
+ default: "playwright-report"
+ description: "Give this a release-specific name when several gates upload to the same run."
+ artifact_retention_days:
+ required: false
+ type: number
+ default: 30
+
+ secrets:
+ composer_auth:
+ required: false
+
+ outputs:
+ base_url:
+ description: "The URL the store was served on."
+ value: ${{ jobs.e2e.outputs.base_url }}
+
+jobs:
+ e2e:
+ name: "e2e tests"
+ runs-on: ubuntu-latest
+ timeout-minutes: ${{ inputs.timeout_minutes }}
+ outputs:
+ base_url: ${{ steps.warden.outputs.base_url }}
+
+ env:
+ TRAEFIK_DOMAIN: mageos.test
+ TRAEFIK_SUBDOMAIN: app
+ # The suite is checked out here, and the tests run in SUITE/
.
+ SUITE: suite
+
+ steps:
+ # Not at the workspace root: warden/setup-environment checks the Warden CLI
+ # out into warden/ there, and base_directory has to sit exactly one level
+ # below it.
+ - name: Check out the test suite
+ uses: actions/checkout@v6
+ with:
+ repository: ${{ inputs.suite_repository }}
+ ref: ${{ inputs.suite_ref }}
+ path: suite
+
+ - name: Create the Mage-OS project
+ uses: mage-os/github-actions/setup-magento@main
+ with:
+ php-version: ${{ inputs.php_version }}
+ tools: "composer:v2"
+ mode: extension
+ magento_repository: ${{ inputs.magento_repository }}
+ magento_version: ${{ inputs.magento_version }}
+ composer_auth: ${{ secrets.composer_auth }}
+
+ - name: Serve the store in Warden
+ id: warden
+ uses: mage-os/github-actions/warden/setup-environment@main
+ with:
+ base_directory: "./_ghamagento"
+ php_version: ${{ inputs.php_version }}
+ composer_version: ${{ inputs.composer_version }}
+ database: ${{ inputs.database }}
+ search: ${{ inputs.search }}
+ rabbitmq: ${{ inputs.rabbitmq }}
+ redis: ${{ inputs.redis }}
+ varnish: ${{ inputs.varnish }}
+ run_composer_install: 1
+ run_setup_install: 1
+ run_admin_user_creation: 1
+ run_magento_config_preset: 1
+ run_reindex: 1
+ traefik_domain: ${{ env.TRAEFIK_DOMAIN }}
+ traefik_subdomain: ${{ env.TRAEFIK_SUBDOMAIN }}
+ base_url: "https://${{ env.TRAEFIK_SUBDOMAIN }}.${{ env.TRAEFIK_DOMAIN }}/"
+ configure_host_resolution: 1
+ run_static_content_deploy: 1
+ static_content_themes: ${{ inputs.static_content_themes }}
+
+ # Separate from the test run so that "the store was never reachable" and
+ # "the store rendered the wrong thing" are different red steps.
+ - name: Confirm the store answers on the resolved hostname
+ run: curl --silent --show-error --fail --insecure --head "${{ steps.warden.outputs.base_url }}" | head -1
+
+ # A bare setup:install has nothing to buy. The command reindexes itself.
+ # Streamed in rather than copied: the project directories are owned by the
+ # container's user.
+ - name: Seed the catalog
+ if: inputs.fixture_profile != ''
+ working-directory: ./_ghamagento
+ shell: bash
+ env:
+ PROFILE: ${{ github.workspace }}/${{ env.SUITE }}/${{ inputs.fixture_profile }}
+ run: |
+ export WARDEN="$(dirname $(pwd))/warden/bin/warden"
+ ${WARDEN} env exec -T php-fpm bash -c 'cat > /tmp/fixture-profile.xml' < "${PROFILE}"
+ ${WARDEN} env exec -T php-fpm bin/magento setup:performance:generate-fixtures /tmp/fixture-profile.xml
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: ${{ inputs.node_version }}
+ cache: npm
+ cache-dependency-path: ${{ env.SUITE }}/${{ inputs.test_directory }}/package-lock.json
+
+ - name: Install the test runner
+ working-directory: ${{ env.SUITE }}/${{ inputs.test_directory }}
+ run: |
+ npm ci
+ npx playwright install --with-deps chromium
+
+ # The command arrives through the environment rather than interpolated into
+ # the script, so its quoting is bash's problem and not the expression
+ # engine's.
+ - name: Run the tests
+ working-directory: ${{ env.SUITE }}/${{ inputs.test_directory }}
+ env:
+ TEST_COMMAND: ${{ inputs.test_command }}
+ PLAYWRIGHT_BASE_URL: ${{ steps.warden.outputs.base_url }}
+ run: bash -c "$TEST_COMMAND"
+
+ # A failing gate is read by someone deciding whether to ship, so the
+ # evidence has to outlive the run.
+ - name: Upload the test report
+ if: ${{ !cancelled() }}
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ inputs.artifact_name }}
+ path: |
+ ${{ env.SUITE }}/${{ inputs.test_directory }}/playwright-report
+ ${{ env.SUITE }}/${{ inputs.test_directory }}/test-results
+ retention-days: ${{ inputs.artifact_retention_days }}
+ if-no-files-found: ignore
diff --git a/_test/demo-package/Test/e2e/.env b/_test/demo-package/Test/e2e/.env
deleted file mode 100644
index d0f3f161..00000000
--- a/_test/demo-package/Test/e2e/.env
+++ /dev/null
@@ -1 +0,0 @@
-PLAYWRIGHT_BASE_URL=https://hyva-demo.elgentos.io/
diff --git a/_test/demo-package/Test/e2e/.env.example b/_test/demo-package/Test/e2e/.env.example
new file mode 100644
index 00000000..735dc1a9
--- /dev/null
+++ b/_test/demo-package/Test/e2e/.env.example
@@ -0,0 +1,3 @@
+# The store the suite opens. There is no default: a suite that silently tests
+# someone else's demo store is worse than one that refuses to start.
+PLAYWRIGHT_BASE_URL=https://app.mageos.test/
diff --git a/_test/demo-package/Test/e2e/.gitignore b/_test/demo-package/Test/e2e/.gitignore
new file mode 100644
index 00000000..3c3e172c
--- /dev/null
+++ b/_test/demo-package/Test/e2e/.gitignore
@@ -0,0 +1,4 @@
+node_modules/
+playwright-report/
+test-results/
+.env
diff --git a/_test/demo-package/Test/e2e/README.md b/_test/demo-package/Test/e2e/README.md
index 36c8d271..daf1bd8b 100644
--- a/_test/demo-package/Test/e2e/README.md
+++ b/_test/demo-package/Test/e2e/README.md
@@ -1,5 +1,128 @@
-cd e2e
-npm install -D @playwright/test
-npx playwright install
-npm install -D dotenv
-npx playwright test hello-magento.spec.ts
+# Storefront tests
+
+A small Playwright suite that proves a Mage-OS storefront is **being served**
+and **can take an order** -- installed, reachable over HTTP(S), rendering with
+its static content deployed, and able to carry a guest from a category listing
+to a persisted order.
+
+It is the canary for [`warden/setup-environment`](../../../../warden/setup-environment):
+`.github/workflows/_internal-e2e.yaml` stands a store up with that action on
+every change to it and runs this suite against the result.
+
+| Spec | Needs fixtures | Asserts |
+| --- | --- | --- |
+| `hello-magento.spec.ts` | no | the Luma homepage renders with static content deployed |
+| `guest-checkout.spec.ts` | yes | catalog -> product -> cart -> shipping -> payment -> order |
+
+## Running it against a store
+
+```bash
+cp .env.example .env # then point PLAYWRIGHT_BASE_URL at your store
+npm ci
+npx playwright install --with-deps chromium
+npm test
+```
+
+`guest-checkout.spec.ts` needs a salable product, which a bare `setup:install`
+does not have. Seed one first -- see [Fixtures](#fixtures).
+
+There is no default base URL. A suite that silently falls back to some public
+demo store reports green about a store nobody asked about.
+
+## Why the assertions look like that
+
+A `200` is not evidence of a storefront. The admin login page, a CMS no-route
+page and a Magento error page all answer `200`, and all of them have a header,
+a footer, a `` and no console errors. So each assertion here is one that
+fails against something that should not pass:
+
+| Assertion | What it rejects |
+| --- | --- |
+| `body` has `cms-index-index` | Any other route answering 200 -- `/admin`, a 404 CMS page |
+| `[data-block="minicart"]` is attached | A storefront page rendered without the Luma layout |
+| A stylesheet parsed into CSS rules | A store whose `pub/static` was never deployed |
+
+Before changing an assertion, check that it still fails for the reason it was
+written. Do that with a throwaway spec, not by repointing `PLAYWRIGHT_BASE_URL`
+at the admin URL: a base URL with a path in it will not do what you expect,
+because `page.goto("/")` resolves against the origin and drops the path, so you
+end up testing the homepage again and watching it pass.
+
+```ts
+// negative-control.spec.ts -- delete it afterwards
+import { test, expect } from "@playwright/test";
+
+test("the admin login page must not satisfy the homepage assertions", async ({ page }) => {
+ const response = await page.goto("/admin"); // your backend frontName
+ expect(response?.status()).toBe(200); // it answers 200 -- that is the point
+ await expect(page.locator("body")).toHaveClass(/cms-index-index/);
+});
+```
+
+Against a real store that fails on the body class alone, with the 200 and the
+stylesheets both satisfied:
+
+```
+Expected pattern: /cms-index-index/
+Received string: "m137-admin-theme adminhtml-auth-login page-layout-admin-login"
+```
+
+For the static content assertion, clear `pub/static` and reload.
+
+## Fixtures
+
+`fixtures/mageos-e2e.xml` is a performance-toolkit profile, run with the
+command the toolkit ships:
+
+```bash
+bin/magento setup:performance:generate-fixtures path/to/fixtures/mageos-e2e.xml
+```
+
+Measured on Mage-OS 4.0.0 under Warden: **12s wall clock**, including the
+reindex the command runs itself -- no separate `indexer:reindex` needed. It is
+idempotent: re-running it does not duplicate anything.
+
+It produces 20 simple products (`product_dynamic_1` .. `product_dynamic_20`),
+one configurable with three variations, and two categories that appear in the
+main navigation. The SKUs are deterministic, which is the thing sample data
+cannot offer: no assertion breaks because a product was renamed upstream.
+
+### Why not a profile that already exists
+
+Core ships five profiles, and the smallest is not small:
+
+| Profile | simple products | categories | customers | orders | images |
+| --- | --- | --- | --- | --- | --- |
+| `small` | 800 | 30 | 200 | 80 | 100 |
+| `medium` | 24,000 | 300 | 2,000 | 50,000 | 1,000 |
+| `large` | 300,000 | 3,000 | 5,000 | 100,000 | 2,000 |
+
+They exist to benchmark a store under catalog weight. Core ships nothing for
+functional seeding, so this profile is that.
+
+### Why not sample data
+
+`magento2-sample-data` is mirrored into `repo.mage-os.org`, so it is installable
+without Adobe credentials. But it is hundreds of megabytes, and its *content*
+changes between releases -- an assertion on "Joust Duffle Bag" is an assertion
+about sample data, not about Mage-OS. A gate that goes red because a product was
+renamed is a gate people switch off.
+
+### Two things to know about the profile
+
+`small.xml` sets `admin/security/use_form_key` to `0` and
+`admin_account_sharing` to `1`. Reasonable for load testing, wrong here: a gate
+running against a store with admin CSRF protection disabled is not testing the
+store we ship. Do not copy those over.
+
+`ConfigsApplyFixture` iterates `$configs['config']` as a list, but a single
+`` element collapses to a flat map, so the fixture iterates that
+element's own values and fatals with `Cannot access offset of type string on
+string`. `small.xml` carries four entries, so upstream never sees it. Keep at
+least two in the `` block.
+
+## What the checkout spec does not cover
+
+Registered-customer checkout, a real payment gateway, taxes, discounts and
+multi-address shipping. Each wants fixtures of its own, and none of them is on
+the path between "we tagged a release" and "a shopper can buy something".
diff --git a/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml b/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml
new file mode 100644
index 00000000..b5965c09
--- /dev/null
+++ b/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml
@@ -0,0 +1,102 @@
+
+
+
+
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+
+
+ 20
+
+
+
+
+ 3
+
+
+ Configurable Product %s
+ 1
+
+
+
+ 2
+ 1
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+
+ system/smtp/disable
+ default
+ 0
+ 1
+
+
+
+ carriers/flatrate/active
+ default
+ 0
+ 1
+
+
+
+
+
+ catalog_category_productfalse
+ catalog_product_categoryfalse
+ catalog_product_pricefalse
+ catalog_product_attributefalse
+ cataloginventory_stockfalse
+ catalogsearch_fulltextfalse
+
+
+
diff --git a/_test/demo-package/Test/e2e/guest-checkout.spec.ts b/_test/demo-package/Test/e2e/guest-checkout.spec.ts
new file mode 100644
index 00000000..1e16c6a5
--- /dev/null
+++ b/_test/demo-package/Test/e2e/guest-checkout.spec.ts
@@ -0,0 +1,191 @@
+import { test, expect, type Page } from '@playwright/test';
+
+// The deepest path a storefront check can walk: catalog -> product -> cart ->
+// shipping -> payment -> order. It touches the layered navigation, the price
+// index, the quote, the shipping and payment method pools, the order
+// placement and the private-content sections that Varnish punches holes for.
+// If a release breaks any of those, this fails and the homepage check does not.
+//
+// It needs a salable product, which a bare setup:install does not have. See
+// fixtures/mageos-e2e.xml.
+
+const shopper = {
+ email: `mageos-e2e-${Date.now()}@example.com`,
+ firstname: 'Mage',
+ lastname: 'Tester',
+ street: '1 Open Source Way',
+ city: 'Austin',
+ regionId: process.env.E2E_REGION_ID ?? '57', // Texas
+ postcode: '78701',
+ telephone: '5125550123',
+ countryId: process.env.E2E_COUNTRY_ID ?? 'US',
+};
+
+// Every selector below is Luma's. Keeping them in one place is what makes the
+// Hyva variant of this suite a copy of this file with a different map, rather
+// than a rewrite.
+const luma = {
+ navCategory: '.navigation li.level0 > a',
+ productItem: '.product-item-info',
+ productItemLink: 'a.product-item-link',
+ addToCart: '#product-addtocart-button',
+ swatchGroup: '.swatch-attribute',
+ swatchOption: '.swatch-option:not(.disabled)',
+ optionSelect: 'select.super-attribute-select',
+ cartSuccess: '.message-success',
+ minicartCounter: '.minicart-wrapper .counter-number',
+ cartItemName: '.cart.item .product-item-name',
+ proceedToCheckout: 'button[data-role="proceed-to-checkout"]',
+ checkoutEmail: '#customer-email',
+ shippingForm: '#co-shipping-form',
+ shippingMethod: 'input[value="flatrate_flatrate"]',
+ nextButton: 'button[data-role="opc-continue"]',
+ paymentSection: '#checkout-step-payment',
+ placeOrder: '#checkout-payment-method-load button.action.checkout.primary',
+ successPageTitle: '.page-title',
+ successBlock: '.checkout-success',
+};
+
+// A configurable product will not go into the cart until every attribute has a
+// value, and which product the catalog lists first is not ours to decide. So
+// pick the first available value for whatever the page asks for, and let the
+// spec work on a simple product, a configurable, or a merchant's own catalog.
+async function selectRequiredOptions(page: Page) {
+ const swatchGroups = page.locator(luma.swatchGroup);
+ for (let i = 0; i < (await swatchGroups.count()); i++) {
+ const option = swatchGroups.nth(i).locator(luma.swatchOption).first();
+ if (await option.count()) {
+ await option.click();
+ }
+ }
+
+ // Configurables render dropdowns instead of swatches when the attribute
+ // has no swatch values, which is what the fixture profile produces.
+ const selects = page.locator(luma.optionSelect);
+ for (let i = 0; i < (await selects.count()); i++) {
+ const select = selects.nth(i);
+ const values = await select
+ .locator('option')
+ .evaluateAll((options) =>
+ options.map((option) => (option as HTMLOptionElement).value).filter(Boolean),
+ );
+ if (values.length) {
+ await select.selectOption(values[0]);
+ }
+ }
+}
+
+async function fillShippingAddress(page: Page) {
+ const form = page.locator(luma.shippingForm);
+
+ // The country select repopulates the region field, so it goes first.
+ await form.locator('select[name="country_id"]').selectOption(shopper.countryId);
+ await form.locator('input[name="firstname"]').fill(shopper.firstname);
+ await form.locator('input[name="lastname"]').fill(shopper.lastname);
+ await form.locator('input[name="street[0]"]').fill(shopper.street);
+ await form.locator('input[name="city"]').fill(shopper.city);
+
+ // Magento renders either a region select or a free-text input depending on
+ // the country. Handle whichever is actually on the page.
+ const regionSelect = form.locator('select[name="region_id"]');
+ if (await regionSelect.isVisible()) {
+ await regionSelect.selectOption(shopper.regionId);
+ } else {
+ await form.locator('input[name="region"]').fill('Texas');
+ }
+
+ await form.locator('input[name="postcode"]').fill(shopper.postcode);
+ await form.locator('input[name="telephone"]').fill(shopper.telephone);
+}
+
+test.describe('Guest checkout', () => {
+ test('places an order as a guest', { tag: ['@checkout', '@guest'] }, async ({ page }) => {
+ await test.step('a category in the main navigation lists products', async () => {
+ await page.goto('/');
+
+ const category = page.locator(luma.navCategory).first();
+ await expect(category, 'the fixture categories should appear in the main navigation').toBeVisible();
+ await category.click();
+
+ await expect(page.locator('body')).toHaveClass(/catalog-category-view/);
+ // Not toBeVisible on .first(): an empty category still renders the
+ // listing wrapper, and a priced, indexed, in-stock product is the
+ // thing being asserted.
+ await expect(page.locator(luma.productItem).first()).toBeVisible();
+ });
+
+ await test.step('the product page offers the product for sale', async () => {
+ await page.locator(luma.productItemLink).first().click();
+
+ await expect(page.locator('body')).toHaveClass(/catalog-product-view/);
+ await expect(page.locator('.page-title')).toBeVisible();
+ // A price proves the price index ran. Out-of-stock or unindexed
+ // products render a page but no add-to-cart button.
+ await expect(page.locator('.product-info-main .price').first()).toBeVisible();
+ await expect(page.locator(luma.addToCart)).toBeEnabled();
+ });
+
+ await test.step('adding to the cart updates the minicart', async () => {
+ await selectRequiredOptions(page);
+ await page.locator(luma.addToCart).click();
+
+ // customer-data arrives over a separate /customer/section/load
+ // request that Varnish must not have cached. A stale minicart here
+ // is a real bug, so assert the counter, not just the message.
+ await expect(page.locator(luma.cartSuccess)).toContainText('to your shopping cart');
+ await expect(page.locator(luma.minicartCounter)).toHaveText('1');
+ });
+
+ await test.step('the cart holds the line item', async () => {
+ await page.goto('/checkout/cart/');
+
+ await expect(page.locator('body')).toHaveClass(/checkout-cart-index/);
+ await expect(page.locator(luma.cartItemName)).toHaveCount(1);
+ await expect(page.locator(luma.proceedToCheckout)).toBeEnabled();
+ });
+
+ await test.step('the shipping step accepts a guest address and a rate', async () => {
+ await page.locator(luma.proceedToCheckout).click();
+
+ await expect(page.locator(luma.checkoutEmail)).toBeVisible();
+ await page.locator(luma.checkoutEmail).fill(shopper.email);
+ await fillShippingAddress(page);
+
+ // The rate pool is requested from the server once the address is
+ // complete. No rate means no checkout, which is a release blocker.
+ const flatRate = page.locator(luma.shippingMethod);
+ await expect(flatRate, 'Flat Rate should be offered for the shipping address').toBeVisible();
+ await flatRate.check();
+
+ await page.locator(luma.nextButton).click();
+ });
+
+ await test.step('the payment step places the order', async () => {
+ await expect(page.locator(luma.paymentSection)).toBeVisible();
+
+ // Check / Money order is active by default and is the only method
+ // on a store with no gateway credentials, so it is already
+ // selected. Assert rather than click, so a store that offers
+ // nothing fails here instead of timing out on Place Order.
+ const checkmo = page.locator('input[value="checkmo"]');
+ await expect(checkmo, 'Check / Money order should be available').toBeChecked();
+
+ await page.locator(luma.placeOrder).click();
+ });
+
+ await test.step('the order is confirmed with an increment id', async () => {
+ await expect(page).toHaveURL(/checkout\/onepage\/success/);
+ // The confirmation copy is in the page heading; the increment id is
+ // in the block below it.
+ await expect(page.locator(luma.successPageTitle)).toContainText('Thank you for your purchase');
+ await expect(page.locator(luma.successBlock)).toBeVisible();
+
+ // An increment id proves the order was persisted, not just that a
+ // success page rendered. Matched as a pattern rather than through
+ // a selector: success.phtml wraps the id in a.order-number only
+ // when the viewer can open the order, so a guest gets a bare
+ // . Digits also keep this assertion locale-independent.
+ await expect(page.locator(luma.successBlock)).toContainText(/\d{9}/);
+ });
+ });
+});
diff --git a/_test/demo-package/Test/e2e/hello-magento.spec.ts b/_test/demo-package/Test/e2e/hello-magento.spec.ts
index 37762363..5de89855 100644
--- a/_test/demo-package/Test/e2e/hello-magento.spec.ts
+++ b/_test/demo-package/Test/e2e/hello-magento.spec.ts
@@ -1,20 +1,40 @@
import { test, expect } from '@playwright/test';
-test.describe('Page health checks', () => {
- test('Homepage_returns_200', {tag: ['@smoke', '@cold']}, async ({page}) => {
- const homepageURL = process.env.PLAYWRIGHT_BASE_URL || process.env.BASE_URL;
- if (!homepageURL) {
- throw new Error("PLAYWRIGHT_BASE_URL has not been defined in the .env file.");
- }
+// A 200 proves very little on its own: the admin login page, a CMS no-route
+// page and a Magento error page all answer 200 and all carry a header, a
+// footer and a title. Every assertion below is here because it fails on
+// something a storefront check should not accept.
+test.describe('Storefront smoke test', () => {
+ test('serves the Luma homepage with its static content deployed', { tag: ['@smoke', '@cold'] }, async ({ page }) => {
+ const response = await page.goto('/');
- const homepageResponsePromise = page.waitForResponse(homepageURL);
- await page.goto(homepageURL);
- const homepageResponse = await homepageResponsePromise;
- expect(homepageResponse.status(), 'Homepage should return 200').toBe(200);
+ await test.step('the homepage responds 200', async () => {
+ expect(response?.status(), 'the homepage should respond 200').toBe(200);
+ });
- const pageTtitle = page.getByRole('heading', {level: 1})
+ await test.step('the response is the storefront homepage, not some other 200', async () => {
+ // Luma puts the resolved route in the body class, which is the
+ // cheapest way to tell the homepage apart from /admin or a 404.
+ await expect(page.locator('body')).toHaveClass(/cms-index-index/);
+ await expect(page.locator('[data-block="minicart"]')).toBeAttached();
+ });
- await expect(pageTtitle, 'Homepage has a visible title').toBeVisible();
- await expect(pageTtitle).toHaveText(/\S+/);
- })
-})
+ await test.step('static content is deployed', async () => {
+ await expect(page.locator('link[rel="stylesheet"]').first()).toBeAttached();
+
+ // A stylesheet that 404s is still a link element, so ask the
+ // browser whether any of them parsed into rules. Without this the
+ // test passes against a store whose pub/static is empty.
+ const ruleCount = await page.evaluate(() =>
+ Array.from(document.styleSheets).reduce((total, sheet) => {
+ try {
+ return total + sheet.cssRules.length;
+ } catch {
+ return total;
+ }
+ }, 0),
+ );
+ expect(ruleCount, 'at least one stylesheet should have loaded').toBeGreaterThan(0);
+ });
+ });
+});
diff --git a/_test/demo-package/Test/e2e/package-lock.json b/_test/demo-package/Test/e2e/package-lock.json
new file mode 100644
index 00000000..363816ae
--- /dev/null
+++ b/_test/demo-package/Test/e2e/package-lock.json
@@ -0,0 +1,77 @@
+{
+ "name": "demo-package-e2e",
+ "version": "0.0.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "demo-package-e2e",
+ "version": "0.0.0",
+ "devDependencies": {
+ "@playwright/test": "1.64.1",
+ "dotenv": "^18.0.9"
+ }
+ },
+ "node_modules/@playwright/test": {
+ "version": "1.64.1",
+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz",
+ "integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "playwright": "1.64.1"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
+ "node_modules/dotenv": {
+ "version": "18.0.9",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.9.tgz",
+ "integrity": "sha512-3fVOW4cB02R066PUSwn8O4TJyz9NckQl7F81blIbaq9jKBm2tSmOKky7ZHIXzGvkVPXCSn6jkpziBPZdGFs8Tw==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "bin": {
+ "dotenv": "dist/index.cjs"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://dotenvx.com"
+ }
+ },
+ "node_modules/playwright": {
+ "version": "1.64.1",
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz",
+ "integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "playwright-core": "1.64.1"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
+ "node_modules/playwright-core": {
+ "version": "1.64.1",
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz",
+ "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "playwright-core": "cli.js"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ }
+ }
+}
diff --git a/_test/demo-package/Test/e2e/package.json b/_test/demo-package/Test/e2e/package.json
new file mode 100644
index 00000000..65e5465a
--- /dev/null
+++ b/_test/demo-package/Test/e2e/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "demo-package-e2e",
+ "version": "0.0.0",
+ "private": true,
+ "description": "Minimal Playwright suite proving a Mage-OS storefront is actually served.",
+ "scripts": {
+ "test": "playwright test"
+ },
+ "devDependencies": {
+ "@playwright/test": "1.64.1",
+ "dotenv": "^18.0.9"
+ }
+}
diff --git a/_test/demo-package/Test/e2e/playwright.config.ts b/_test/demo-package/Test/e2e/playwright.config.ts
index a71c8359..eed3cadf 100644
--- a/_test/demo-package/Test/e2e/playwright.config.ts
+++ b/_test/demo-package/Test/e2e/playwright.config.ts
@@ -1,8 +1,43 @@
-import { defineConfig } from '@playwright/test';
+import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';
dotenv.config();
+const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? process.env.BASE_URL;
+
+if (!baseURL) {
+ throw new Error(
+ 'No store to test: set PLAYWRIGHT_BASE_URL, e.g. https://app.mageos.test/ (see .env.example).',
+ );
+}
+
export default defineConfig({
testDir: '.',
+ // A cold Magento page can take a while on a shared runner; everything here
+ // is deliberately slower than a Playwright default.
+ timeout: 120_000,
+ expect: { timeout: 20_000 },
+ workers: 1,
+ fullyParallel: false,
+ forbidOnly: !!process.env.CI,
+ retries: process.env.CI ? 1 : 0,
+ reporter: process.env.CI
+ ? [['github'], ['list'], ['html', { open: 'never' }]]
+ : [['list'], ['html', { open: 'never' }]],
+ use: {
+ baseURL,
+ // Warden serves the environment under its own certificate authority,
+ // which is not installed on a GitHub runner.
+ ignoreHTTPSErrors: true,
+ navigationTimeout: 90_000,
+ actionTimeout: 20_000,
+ // retain-on-failure, not on-first-retry: the first failure is the one
+ // that has to carry its own evidence. A release gate that fails is
+ // read by someone deciding whether to ship, and "re-run it and watch"
+ // is not an answer at that point.
+ trace: 'retain-on-failure',
+ screenshot: 'only-on-failure',
+ video: 'retain-on-failure',
+ },
+ projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
});
diff --git a/warden/setup-environment/README.md b/warden/setup-environment/README.md
new file mode 100644
index 00000000..77aaa131
--- /dev/null
+++ b/warden/setup-environment/README.md
@@ -0,0 +1,84 @@
+# Setup Mage-OS in Warden
+
+Brings up a full Mage-OS service stack on the runner using
+[Warden](https://github.com/wardenenv/warden), and optionally installs Magento
+into it.
+
+Used by [`full-integration-tests.yaml`](../../.github/workflows/full-integration-tests.yaml)
+and [`nx-integration-tests.yml`](../../.github/workflows/nx-integration-tests.yml).
+
+## Usage
+
+```yaml
+- uses: mage-os/github-actions/warden/setup-environment@main
+ with:
+ php_version: '8.4'
+ database: 'mariadb:11.4'
+ search: 'opensearch:3.3'
+ run_composer_install: '1'
+ run_setup_install: '1'
+```
+
+### Browser-based tests
+
+PHPUnit suites drive Magento's own bootstrap and never make an HTTP request, so
+they need nothing beyond the above. A browser does. Three things have to be true
+before one can reach the storefront, and all three are off by default:
+
+```yaml
+- uses: mage-os/github-actions/warden/setup-environment@main
+ id: warden
+ with:
+ php_version: '8.4'
+ run_composer_install: '1'
+ run_setup_install: '1'
+ # Install on the URL the environment is actually served on, otherwise
+ # Magento redirects the browser to its default base URL.
+ base_url: 'https://app.mageos.test/'
+ # Warden uses dnsmasq locally; a runner has no such resolver.
+ configure_host_resolution: '1'
+ # Without deployed static content the storefront returns 200 and renders
+ # nothing.
+ run_static_content_deploy: '1'
+ static_content_themes: 'Magento/luma'
+
+- run: npx playwright test
+ env:
+ E2E_BASE_URL: ${{ steps.warden.outputs.base_url }}
+```
+
+## Inputs
+
+| Name | Default | Description |
+| --- | --- | --- |
+| `warden_version` | `0.14.2` | Warden version to use. |
+| `php_version` | `8.2` | PHP version in the Warden containers. |
+| `composer_version` | `2.2.22` | Composer version to use. |
+| `database` | `mariadb:10.6` | `distribution:version` of the database. |
+| `search` | `opensearch:2.5` | Search engine; `elasticsearch:*` or `opensearch:*`. |
+| `varnish` | `varnish:7.3` | Varnish version, or `null` to disable. |
+| `rabbitmq` | `rabbitmq:3.11` | RabbitMQ version, or `null` to disable. |
+| `redis` | `redis:7.0` | Redis version, or `null` to disable. |
+| `base_directory` | `./` | Base directory of the Mage-OS codebase. |
+| `run_composer_install` | `0` | Run `composer install`. |
+| `run_setup_install` | `0` | Run `setup:install`. |
+| `run_setup_upgrade` | `0` | Run `setup:upgrade`. |
+| `run_reindex` | `0` | Run `indexer:reindex`. |
+| `run_production_deploy_mode` | `0` | Run `deploy:mode:set production`. |
+| `run_magento_config_preset` | `0` | Apply the test-oriented config preset. |
+| `run_admin_user_creation` | `0` | Create an `admin` / `abcABC123` user. |
+| `env_name` | `mageos` | `WARDEN_ENV_NAME`. |
+| `traefik_domain` | `mageos.test` | `TRAEFIK_DOMAIN`. |
+| `traefik_subdomain` | `app` | `TRAEFIK_SUBDOMAIN`. |
+| `backend_frontname` | `admin` | Admin frontName passed to `setup:install`. |
+| `base_url` | *(empty)* | Passed as `--base-url` with `--use-rewrites=1`. Empty leaves Magento's default. |
+| `configure_host_resolution` | `0` | Resolve `.` to `127.0.0.1` on the runner. |
+| `run_static_content_deploy` | `0` | Run `setup:static-content:deploy`. |
+| `static_content_languages` | `en_US` | Space separated locales to deploy. |
+| `static_content_themes` | *(empty)* | Space separated themes, e.g. `Magento/luma`. Empty deploys every theme. |
+
+## Outputs
+
+| Name | Description |
+| --- | --- |
+| `base_url` | The URL the environment is served on, derived from `traefik_subdomain` and `traefik_domain`. |
diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml
index f38b9e8b..275259f2 100644
--- a/warden/setup-environment/action.yml
+++ b/warden/setup-environment/action.yml
@@ -83,6 +83,56 @@ inputs:
default: "./"
description: "Base directory for the Mage-OS codebase."
+ env_name:
+ required: false
+ default: "mageos"
+ description: "Warden environment name (WARDEN_ENV_NAME)."
+
+ traefik_domain:
+ required: false
+ default: "mageos.test"
+ description: "Traefik domain the environment is served on (TRAEFIK_DOMAIN)."
+
+ traefik_subdomain:
+ required: false
+ default: "app"
+ description: "Traefik subdomain the environment is served on (TRAEFIK_SUBDOMAIN)."
+
+ backend_frontname:
+ required: false
+ default: "admin"
+ description: "Admin frontName passed to setup:install. Pinning this keeps the admin URL predictable, which browser-based tests need."
+
+ base_url:
+ required: false
+ default: ""
+ description: "Base URL passed to setup:install as --base-url. Empty leaves Magento's default, which is what non-browser test suites want."
+
+ configure_host_resolution:
+ required: false
+ default: "0"
+ description: "Whether to resolve the Traefik hostname on the runner itself, so tools outside the containers (a browser, curl) can reach the store."
+
+ run_static_content_deploy:
+ required: false
+ default: "0"
+ description: "Whether to run setup:static-content:deploy. Required before a browser can render the storefront; pointless for PHPUnit suites."
+
+ static_content_languages:
+ required: false
+ default: "en_US"
+ description: "Space separated locales to deploy static content for."
+
+ static_content_themes:
+ required: false
+ default: ""
+ description: "Space separated themes to deploy static content for, e.g. 'Magento/luma'. Empty deploys every theme, which is considerably slower."
+
+outputs:
+ base_url:
+ description: "The URL the environment is served on, for callers that need to point a browser at it."
+ value: ${{ steps.resolve-base-url.outputs.base_url }}
+
runs:
using: composite
steps:
@@ -104,6 +154,9 @@ runs:
VARNISH: ${{ inputs.varnish }}
RABBITMQ: ${{ inputs.rabbitmq }}
REDIS: ${{ inputs.redis }}
+ ENV_NAME: ${{ inputs.env_name }}
+ TRAEFIK_DOMAIN_INPUT: ${{ inputs.traefik_domain }}
+ TRAEFIK_SUBDOMAIN_INPUT: ${{ inputs.traefik_subdomain }}
run: |
# Splitting database input to distribution and version
DB_DISTRIBUTION=${DATABASE%%:*}
@@ -149,12 +202,12 @@ runs:
# Creating .env file by substituting variables directly in the template
cat << EOF > .env
- WARDEN_ENV_NAME=mageos
+ WARDEN_ENV_NAME=${ENV_NAME}
WARDEN_ENV_TYPE=magento2
WARDEN_WEB_ROOT=/
- TRAEFIK_DOMAIN=mageos.test
- TRAEFIK_SUBDOMAIN=app
+ TRAEFIK_DOMAIN=${TRAEFIK_DOMAIN_INPUT}
+ TRAEFIK_SUBDOMAIN=${TRAEFIK_SUBDOMAIN_INPUT}
WARDEN_DB=1
WARDEN_ELASTICSEARCH=${WARDEN_ELASTICSEARCH}
@@ -196,6 +249,15 @@ runs:
echo ".env created"
cat .env
+ - name: Resolve served base URL
+ id: resolve-base-url
+ shell: bash
+ env:
+ TRAEFIK_DOMAIN_INPUT: ${{ inputs.traefik_domain }}
+ TRAEFIK_SUBDOMAIN_INPUT: ${{ inputs.traefik_subdomain }}
+ run: |
+ echo "base_url=https://${TRAEFIK_SUBDOMAIN_INPUT}.${TRAEFIK_DOMAIN_INPUT}/" >> "$GITHUB_OUTPUT"
+
- name: Warden svc up && Warden env up
working-directory: ${{ inputs.base_directory }}
shell: bash
@@ -211,6 +273,18 @@ runs:
export WARDEN="$(dirname $(pwd))/warden/bin/warden"
${WARDEN} env exec -T php-fpm sudo chmod -R 777 .
+ - name: Resolve the Traefik hostname on the runner
+ if: ${{ inputs.configure_host_resolution == '1' }}
+ shell: bash
+ env:
+ HOSTNAME_TO_RESOLVE: ${{ inputs.traefik_subdomain }}.${{ inputs.traefik_domain }}
+ run: |
+ # Warden relies on dnsmasq locally; a runner has no such resolver, so
+ # anything running outside the containers -- a browser, curl -- cannot
+ # reach the store without this.
+ echo "127.0.0.1 ${HOSTNAME_TO_RESOLVE}" | sudo tee -a /etc/hosts
+ getent hosts "${HOSTNAME_TO_RESOLVE}"
+
- name: Wait for environment to be ready
working-directory: ${{ inputs.base_directory }}
shell: bash
@@ -263,6 +337,8 @@ runs:
RABBITMQ: ${{ inputs.rabbitmq }}
VARNISH: ${{ inputs.varnish }}
RUN_SETUP_INSTALL: ${{ inputs.run_setup_install }}
+ BACKEND_FRONTNAME: ${{ inputs.backend_frontname }}
+ BASE_URL: ${{ inputs.base_url }}
run: |
if [ $RUN_SETUP_INSTALL == "1" ]; then
SEARCH_ENGINE_VERSION=${SEARCH##*:}
@@ -291,7 +367,13 @@ runs:
esac
declare -a PARAMETERS
- PARAMETERS+=(--backend-frontname=admin --db-host=db --db-name=magento --db-user=magento --db-password=magento)
+ PARAMETERS+=(--backend-frontname=${BACKEND_FRONTNAME} --db-host=db --db-name=magento --db-user=magento --db-password=magento)
+
+ # Magento otherwise installs on its default base URL, which a browser
+ # pointed at the Traefik hostname would be redirected away from.
+ if [[ -n $BASE_URL ]]; then
+ PARAMETERS+=(--base-url=${BASE_URL} --use-rewrites=1)
+ fi
if [[ -n $REDIS ]]; then
PARAMETERS+=(--session-save=redis --session-save-redis-host=redis --session-save-redis-port=6379 --session-save-redis-db=2 --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0 --cache-backend-redis-port=6379 --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=1 --page-cache-redis-port=6379)
@@ -374,6 +456,27 @@ runs:
echo "Skipping deploy:mode:set production"
fi
+ - name: Deploy static content
+ working-directory: ${{ inputs.base_directory }}
+ shell: bash
+ env:
+ LANGUAGES: ${{ inputs.static_content_languages }}
+ THEMES: ${{ inputs.static_content_themes }}
+ run: |
+ if [ ${{ inputs.run_static_content_deploy }} == "1" ]; then
+ export WARDEN="$(dirname $(pwd))/warden/bin/warden"
+ declare -a DEPLOY_ARGS
+ DEPLOY_ARGS+=(${LANGUAGES})
+ DEPLOY_ARGS+=(-f)
+ # Deploying every theme costs minutes a browser test does not need.
+ for THEME in ${THEMES}; do
+ DEPLOY_ARGS+=(--theme "${THEME}")
+ done
+ ${WARDEN} env exec -T php-fpm bin/magento setup:static-content:deploy "${DEPLOY_ARGS[@]}"
+ else
+ echo "Skipping setup:static-content:deploy"
+ fi
+
- name: Run Magento Re-indexation
working-directory: ${{ inputs.base_directory }}
shell: bash