Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Changed CI into one workflow with required backend and frontend checks (#15039)

Damian Legawiec84e9fbd997d8
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 35f3667249..c775595482 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -340,7 +340,7 @@ See `packages/dashboard/README.md` for the full architecture (auth, permissions,
### Working on the storefront
-The [Next.js storefront](https://github.com/spree/storefront) is a separate repository. `pnpm storefront:dev` clones it into `storefront/` (gitignored) on first run, on its **`6-0-dev`** branch — `main` targets the released Store API and won't work against this monorepo's backend. Unlike `server/`, the clone keeps its `.git`: commit and push storefront changes from inside `storefront/`.
+The [Next.js storefront](https://github.com/spree/storefront) is a separate repository. `pnpm storefront:dev` clones it into `storefront/` (gitignored) on first run, on its `main` branch. Unlike `server/`, the clone keeps its `.git`: commit and push storefront changes from inside `storefront/`.
```bash
# Terminal 1: backend
@@ -361,7 +361,7 @@ Every boot regenerates `storefront/.env.local` with the backend URL and the seed
### Dashboard E2E tests
-The React dashboard ships an end-to-end suite running on [Playwright](https://playwright.dev/) against a real Rails backend — no mocks. The spec files exercise the full UI: login, staff invitation, invitee signup. CI runs the same suite via the `dashboard-e2e` job in `.github/workflows/packages.yml`.
+The React dashboard ships an end-to-end suite running on [Playwright](https://playwright.dev/) against a real Rails backend — no mocks. The spec files exercise the full UI: login, staff invitation, invitee signup. CI runs the same suite via the `dashboard-e2e` job in `.github/workflows/frontend.yml`.
To run locally you need Ruby (the suite boots a real Rails server) and a one-time browser install:
diff --git a/.github/workflows/tests.yml b/.github/workflows/backend.yml
similarity index 91%
rename from .github/workflows/tests.yml
rename to .github/workflows/backend.yml
index 14672ef79f..5bdc69a8db 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/backend.yml
@@ -1,19 +1,11 @@
-name: Tests
+name: Backend
+# Called by ci.yml, which runs this suite only when relevant files changed.
on:
- push:
- branches: [main, '6-0-dev', '*-stable']
- paths:
- - 'spree/**'
- - '.github/workflows/tests.yml'
- pull_request:
- paths:
- - 'spree/**'
- - '.github/workflows/tests.yml'
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
+ workflow_call:
+ secrets:
+ CODECOV_TOKEN:
+ required: false
permissions:
contents: read
@@ -118,7 +110,7 @@ jobs:
done
test-postgres:
- name: "PostgreSQL - ${{ matrix.project }} (${{ matrix.shard }}/${{ matrix.total_shards }})"
+ name: "Test ${{ matrix.project }} (PostgreSQL, ${{ matrix.shard }}/${{ matrix.total_shards }})"
needs: build-postgres
runs-on: ubuntu-latest
strategy:
@@ -142,12 +134,10 @@ jobs:
# they saved. This is also the only job with the Meilisearch service,
# so spree_meilisearch's integration spec runs here.
- { project: providers, dirs: "providers/easypost providers/meilisearch providers/paypal providers/stripe", shard: 1, total_shards: 1, procs: 2 }
- # dashboard: 1 runner × 2 procs (tiny suite — SPA host)
- - { project: dashboard, shard: 1, total_shards: 1, procs: 2 }
- # mcp: 1 runner × 2 procs (tiny suite — optional MCP server gem)
- - { project: mcp, shard: 1, total_shards: 1, procs: 2 }
- # opentelemetry: 1 runner × 2 procs (tiny suite — optional tracing gem)
- - { project: opentelemetry, shard: 1, total_shards: 1, procs: 2 }
+ # optional-gems: 1 runner × 2 procs — dashboard, mcp and opentelemetry
+ # share a lane. Each suite runs in seconds, far less than a runner's
+ # setup, so a runner each only added queue time.
+ - { project: optional-gems, dirs: "dashboard mcp opentelemetry", flags: dashboard, shard: 1, total_shards: 1, procs: 2 }
services:
postgres:
image: postgres:16
@@ -255,11 +245,14 @@ jobs:
SUITE_DIRS: ${{ matrix.dirs || matrix.project }}
run: |
mkdir -p ${{ github.workspace }}/tmp/test-results/rspec
+ # Run every suite in a shared lane even when an earlier one fails.
+ status=0
for suite_dir in $SUITE_DIRS; do
suite_name=$(basename "$suite_dir")
RSPEC_OPTS="--order random --format progress -r rspec_junit_formatter --format RspecJunitFormatter -o ${{ github.workspace }}/tmp/test-results/rspec/${suite_name}-${{ matrix.shard }}-\$TEST_ENV_NUMBER.xml" \
- bash -c "cd '$suite_dir' && bundle exec rake parallel_shard"
+ bash -c "cd '$suite_dir' && bundle exec rake parallel_shard" || status=1
done
+ exit "$status"
- name: Upload coverage to Codecov
if: always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
@@ -267,7 +260,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ github.workspace }}/coverage
- flags: ${{ matrix.project }}
+ flags: ${{ matrix.flags || matrix.project }}
name: ${{ matrix.project }}-shard-${{ matrix.shard }}
fail_ci_if_error: false
@@ -288,7 +281,7 @@ jobs:
if-no-files-found: ignore
test-mysql:
- name: "MySQL - ${{ matrix.project }} (${{ matrix.shard }}/${{ matrix.total_shards }})"
+ name: "Test ${{ matrix.project }} (MySQL, ${{ matrix.shard }}/${{ matrix.total_shards }})"
needs: build-mysql
runs-on: ubuntu-latest
strategy:
@@ -308,12 +301,10 @@ jobs:
# No Meilisearch service here, so spree_meilisearch's integration spec
# skips itself; its unit specs still run against MySQL.
- { project: providers, dirs: "providers/easypost providers/meilisearch providers/paypal providers/stripe", shard: 1, total_shards: 1, procs: 2 }
- # dashboard: 1 runner × 2 procs (tiny suite — SPA host)
- - { project: dashboard, shard: 1, total_shards: 1, procs: 2 }
- # mcp: 1 runner × 2 procs (tiny suite — optional MCP server gem)
- - { project: mcp, shard: 1, total_shards: 1, procs: 2 }
- # opentelemetry: 1 runner × 2 procs (tiny suite — optional tracing gem)
- - { project: opentelemetry, shard: 1, total_shards: 1, procs: 2 }
+ # optional-gems: 1 runner × 2 procs — dashboard, mcp and opentelemetry
+ # share a lane. Each suite runs in seconds, far less than a runner's
+ # setup, so a runner each only added queue time.
+ - { project: optional-gems, dirs: "dashboard mcp opentelemetry", flags: dashboard, shard: 1, total_shards: 1, procs: 2 }
services:
mysql:
image: mysql:8.0
@@ -404,11 +395,14 @@ jobs:
SUITE_DIRS: ${{ matrix.dirs || matrix.project }}
run: |
mkdir -p ${{ github.workspace }}/tmp/test-results/rspec
+ # Run every suite in a shared lane even when an earlier one fails.
+ status=0
for suite_dir in $SUITE_DIRS; do
suite_name=$(basename "$suite_dir")
RSPEC_OPTS="--order random --format progress -r rspec_junit_formatter --format RspecJunitFormatter -o ${{ github.workspace }}/tmp/test-results/rspec/${suite_name}-${{ matrix.shard }}-\$TEST_ENV_NUMBER.xml" \
- bash -c "cd '$suite_dir' && bundle exec rake parallel_shard"
+ bash -c "cd '$suite_dir' && bundle exec rake parallel_shard" || status=1
done
+ exit "$status"
- name: Upload test results
if: always()
@@ -427,7 +421,7 @@ jobs:
if-no-files-found: ignore
brakeman:
- name: Brakeman
+ name: "Security scan (Brakeman)"
needs: build-postgres
runs-on: ubuntu-latest
env:
@@ -474,3 +468,4 @@ jobs:
name: brakeman-reports
path: spree/brakeman-*.*
if-no-files-found: ignore
+
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000000..1a52ade4f2
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,109 @@
+name: CI
+
+# Starts on every pull request, merge queue entry and push, so the two
+# required checks (backend, frontend) always report. Each suite runs only when
+# files it covers changed; a suite that was not needed counts as passing.
+on:
+ push:
+ branches: [main, '*-stable']
+ pull_request:
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ changes:
+ name: "Detect changes"
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: read
+ outputs:
+ backend: ${{ steps.filter.outputs.backend }}
+ frontend: ${{ steps.filter.outputs.frontend }}
+ steps:
+ - uses: actions/checkout@v7
+ if: github.event_name != 'pull_request'
+
+ - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
+ id: filter
+ with:
+ # Pushes compare against the branch's previous commit.
+ base: ${{ github.event_name == 'push' && github.ref_name || '' }}
+ filters: |
+ backend:
+ - "spree/**"
+ - ".github/workflows/ci.yml"
+ - ".github/workflows/backend.yml"
+ frontend:
+ - "packages/**"
+ - "spree/api/app/**"
+ - "spree/api/lib/typelizer/**"
+ - "spree/core/app/**"
+ - "docs/developer/**"
+ - "docs/api-reference/**"
+ - "docs/integrations/**"
+ - "pnpm-lock.yaml"
+ - "turbo.json"
+ - "biome.json"
+ - "package.json"
+ - "pnpm-workspace.yaml"
+ - "scripts/sync-starter.mjs"
+ - "scripts/check-dependency-ranges.mjs"
+ - ".github/workflows/ci.yml"
+ - ".github/workflows/frontend.yml"
+
+ backend-suite:
+ name: "Backend"
+ needs: changes
+ if: needs.changes.outputs.backend == 'true'
+ uses: ./.github/workflows/backend.yml
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+
+ frontend-suite:
+ name: "Frontend"
+ needs: changes
+ if: needs.changes.outputs.frontend == 'true'
+ uses: ./.github/workflows/frontend.yml
+
+ # The two checks branch protection requires. Each fails on any failed or
+ # cancelled job in its suite, and passes when the suite passed or was skipped.
+ backend:
+ name: "backend"
+ needs: [changes, backend-suite]
+ if: always()
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check results
+ env:
+ RESULTS: ${{ join(needs.*.result, ' ') }}
+ run: |
+ for result in $RESULTS; do
+ if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
+ echo "A required job finished as: $result"
+ exit 1
+ fi
+ done
+
+ frontend:
+ name: "frontend"
+ needs: [changes, frontend-suite]
+ if: always()
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check results
+ env:
+ RESULTS: ${{ join(needs.*.result, ' ') }}
+ run: |
+ for result in $RESULTS; do
+ if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
+ echo "A required job finished as: $result"
+ exit 1
+ fi
+ done
diff --git a/.github/workflows/packages.yml b/.github/workflows/frontend.yml
similarity index 87%
rename from .github/workflows/packages.yml
rename to .github/workflows/frontend.yml
index 470a14aa15..32f5c13cfd 100644
--- a/.github/workflows/packages.yml
+++ b/.github/workflows/frontend.yml
@@ -1,52 +1,15 @@
-name: Packages
+name: Frontend
+# Called by ci.yml, which runs this suite only when relevant files changed.
on:
- push:
- branches: [main, '6-0-dev']
- paths:
- - "packages/**"
- - "spree/api/app/**"
- - "spree/api/lib/typelizer/**"
- - "spree/core/app/**"
- - "docs/developer/**"
- - "docs/api-reference/**"
- - "docs/integrations/**"
- - "pnpm-lock.yaml"
- - "turbo.json"
- - "biome.json"
- - "package.json"
- - "pnpm-workspace.yaml"
- - "scripts/sync-starter.mjs"
- - "scripts/check-dependency-ranges.mjs"
- - ".github/workflows/packages.yml"
- pull_request:
- paths:
- - "packages/**"
- - "spree/api/app/**"
- - "spree/api/lib/typelizer/**"
- - "spree/core/app/**"
- - "docs/developer/**"
- - "docs/api-reference/**"
- - "docs/integrations/**"
- - "pnpm-lock.yaml"
- - "turbo.json"
- - "biome.json"
- - "package.json"
- - "pnpm-workspace.yaml"
- - "scripts/sync-starter.mjs"
- - "scripts/check-dependency-ranges.mjs"
- - ".github/workflows/packages.yml"
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
+ workflow_call:
permissions:
contents: read
jobs:
check:
- name: "Typecheck, Test & Build"
+ name: "Lint, typecheck, test and build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
@@ -136,7 +99,7 @@ jobs:
# @spree/* package is a symlink resolved under the root overrides, while a
# generated app installs packed tarballs on its own.
scaffolded-app:
- name: "Scaffolded app - Typecheck & Lint"
+ name: "Scaffolded app (typecheck and lint)"
runs-on: ubuntu-latest
steps:
# Runs the pull request's install and build scripts; nothing needs an
@@ -233,7 +196,7 @@ jobs:
exit "$status"
sdk-integration:
- name: "SDK Integration Tests"
+ name: "SDK integration tests"
runs-on: ubuntu-latest
env:
RAILS_ENV: test
@@ -268,7 +231,7 @@ jobs:
run: pnpm test:integration
dashboard-e2e:
- name: "Dashboard - E2E (${{ matrix.shard }}/4)"
+ name: "Dashboard E2E (${{ matrix.shard }}/4)"
runs-on: ubuntu-latest
# Each shard is a full isolated stack (own Rails + SQLite + Vite), so
# shards can't interfere through shared server state the way parallel
@@ -386,18 +349,3 @@ jobs:
packages/dashboard/test-results-first-run/
retention-days: 14
- # Stable single-status roll-up of the shard matrix, keeping the check name
- # branch-protection rules and status badges can pin against.
- dashboard-e2e-result:
- name: "Dashboard - E2E"
- needs: dashboard-e2e
- if: ${{ !cancelled() }}
- runs-on: ubuntu-latest
- steps:
- - name: Check shard results
- run: |
- if [ "${{ needs.dashboard-e2e.result }}" != "success" ]; then
- echo "One or more E2E shards did not succeed: ${{ needs.dashboard-e2e.result }}"
- exit 1
- fi
- echo "All E2E shards passed."
diff --git a/.gitignore b/.gitignore
index 6f92312a86..f413a20bd4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,7 +61,7 @@ server/
.env
.env.*
!.env.example
-# Per-worktree clone of spree/storefront (branch 6-0-dev), provisioned by
+# Per-worktree clone of spree/storefront (branch main), provisioned by
# scripts/worktree/setup.sh. Keeps its own .git — commit and push from inside it.
storefront/
**/node_modules
diff --git a/docs/developer/contributing/developing-spree.mdx b/docs/developer/contributing/developing-spree.mdx
index 292e9e6465..3cb342cd0d 100644
--- a/docs/developer/contributing/developing-spree.mdx
+++ b/docs/developer/contributing/developing-spree.mdx
@@ -267,7 +267,7 @@ See the [dashboard README](https://github.com/spree/spree/blob/main/packages/das
### Dashboard E2E tests
-The React dashboard ships an end-to-end suite running on [Playwright](https://playwright.dev/) against a real Rails backend — no mocks. The spec files exercise the full UI: login, staff invitation, invitee signup. CI runs the same suite via the `dashboard-e2e` job in `.github/workflows/packages.yml`.
+The React dashboard ships an end-to-end suite running on [Playwright](https://playwright.dev/) against a real Rails backend — no mocks. The spec files exercise the full UI: login, staff invitation, invitee signup. CI runs the same suite via the `dashboard-e2e` job in `.github/workflows/frontend.yml`.
To run locally you need Ruby (the suite boots a real Rails server) and a one-time browser install: