GitLab CI/CD & Repository Structure

AutoCom uses GitHub as the primary monorepo and GitLab (gitlab.wexron.io) for split repository views, CI pipelines, and code quality tracking.

Repository Structure

The monorepo is split into 31 GitLab projects under the autocommerce group:

autocommerce/
├── main                    # Full monorepo mirror
├── core/
│   ├── frontend            # Next.js web app
│   ├── backend             # Laravel API
│   ├── mobile-app          # Expo React Native app
│   └── docs                # Documentation site
├── services/
│   └── ai-agent            # PydanticAI Python service
├── modules/                # 17 HMVC modules
│   ├── core, orders, products, customers, wms, ai,
│   │   workflows, communications, channel-livechat,
│   │   store-shopify, mobile-app-module
│   ├── reseller-admin, reseller-network,
│   │   reseller-catalog, reseller-orders, reseller-finance
│   └── core-dashboard
├── themes/                 # 5 UI themes
│   ├── theme-shadcn, theme-modern, theme-luma,
│   │   theme-harshita, theme-solace
└── infra/                  # Infrastructure configs
    ├── k8s, docker, nginx

Syncing to GitLab

A sync script splits the monorepo and pushes each subtree to its GitLab project:

bash scripts/sync-to-gitlab.sh

This uses git subtree split for each of the 30 directories + a full monorepo mirror push. SSH on port 2224.

The script is idempotent — safe to run multiple times. Subsequent runs are faster than the first because git caches subtree split history.

CI Pipeline Templates

Shared templates live in ci/templates/ in the monorepo. Each split repo includes its template via:

# .gitlab-ci.yml in each module
include:
  - project: 'autocommerce/main'
    file: 'ci/templates/php-module.yml'
    ref: main

PHP Module Pipeline (22 modules)

Job Stage Blocking? What it does
php-lint lint Yes Syntax check all PHP files
php-code-style lint Advisory PSR-12 check via PHP CS Fixer
module-json-check lint Yes Validates required fields in module.json
frontend-scan lint Advisory Counts TypeScript files
php-static-analysis analyze Advisory PHPStan level 1
code-metrics quality Advisory Lines, files, classes, functions → metrics.json artifact

Python Service Pipeline (AI agent)

Job Stage Blocking?
ruff-lint lint Advisory
type-check lint Advisory (mypy)
pytest test Yes (with coverage)
code-metrics quality Advisory
dependency-audit quality Advisory (pip-audit)

Frontend Pipeline

Job Stage Blocking?
eslint lint Advisory
typecheck lint Advisory (needs full monorepo for @modules/)
unit-tests test Advisory (Vitest)
build build Yes (npm run build)

Backend Pipeline

Job Stage Blocking?
php-lint lint Yes
pest-tests test Advisory (needs full monorepo context)
composer-audit quality Advisory

Status Dashboard

A GitLab Pages dashboard shows pipeline status across all 31 repos:

URL: status-e61e2f.wexron.app

Features:

  • Pipeline status (pass/fail/running) per project
  • Job-level colored dots
  • History sparkline (last 8 runs)
  • Coverage percentages
  • Code metrics (files, lines, classes, functions)
  • Recent commits across all repos
  • Top failing jobs
  • Language breakdown
  • Active contributors

Auto-updates every 15 minutes via scheduled pipeline. Can also be triggered manually.

Runner Configuration

GitLab runners process CI jobs. To handle 31 repos efficiently:

# /etc/gitlab-runner/config.toml
concurrent = 4  # Process 4 jobs in parallel

Adding CI to a New Module

  1. Create .gitlab-ci.yml in the module directory:

    include:
      - project: 'autocommerce/main'
        file: 'ci/templates/php-module.yml'
        ref: main
    
  2. Add the module to scripts/sync-to-gitlab.sh split list

  3. Create the GitLab project:

    curl -s --header "PRIVATE-TOKEN: $TOKEN" "$GL/projects" \
      --data-urlencode "name=Module Name" \
      --data-urlencode "path=module-path" \
      --data-urlencode "namespace_id=$MODULES_GID"
    
  4. Run bash scripts/sync-to-gitlab.sh to push