Modular logistics and supply chain operating system (LSOS)
JavaScript driver-appfleet-managementfreight-managementinfrastructureinventory-managementlast-mile-deliverylogisticsondemandopen-sourceorder-managementroute-optimizationsupply-chain-managementtracking-and-monitoringtransport-management-systemtransportationwarehouse-management
ci: add root-repo test + install-smoke CI and coverage gating
Ronald A. Richardsone7b0d891025a
diff --git a/.github/workflows/api.yml b/.github/workflows/api.ymlnew file mode 100644index 00000000..e755fbc8--- /dev/null+++ b/.github/workflows/api.yml@@ -0,0 +1,115 @@+name: API CI++# Runs the host Laravel app's PHPUnit suite (api/tests) against real MySQL + Redis+# service containers, then reports coverage over api/app. The extension packages+# (core-api, fleetops-api, …) have their own CI in their own repos; this workflow+# covers the host application that wires them together.++on:+ push:+ branches: [main]+ tags:+ - 'v*'+ pull_request:+ branches: [main]++defaults:+ run:+ working-directory: api++jobs:+ test:+ name: PHPUnit + Coverage+ runs-on: ubuntu-latest++ services:+ mysql:+ image: mysql:8.0-oracle+ env:+ MYSQL_ALLOW_EMPTY_PASSWORD: "yes"+ MYSQL_DATABASE: fleetbase_test+ ports:+ - 3306:3306+ options: >-+ --health-cmd="mysqladmin ping -h 127.0.0.1"+ --health-interval=10s+ --health-timeout=5s+ --health-retries=10++ redis:+ image: redis:7-alpine+ ports:+ - 6379:6379+ options: >-+ --health-cmd="redis-cli ping"+ --health-interval=10s+ --health-timeout=5s+ --health-retries=10++ env:+ # Test DB/cache/queue point at the service containers. Feature tests that+ # use RefreshDatabase will migrate into fleetbase_test.+ DB_CONNECTION: mysql+ DB_HOST: 127.0.0.1+ DB_PORT: 3306+ DB_DATABASE: fleetbase_test+ DB_USERNAME: root+ DB_PASSWORD: ""+ REDIS_HOST: 127.0.0.1+ REDIS_PORT: 6379+ CACHE_DRIVER: array+ QUEUE_CONNECTION: sync+ SESSION_DRIVER: array+ MAIL_MAILER: array++ steps:+ - name: Checkout code+ uses: actions/checkout@v4++ - name: Setup PHP+ uses: shivammathur/setup-php@v2+ with:+ php-version: '8.2'+ extensions: mbstring, xml, gd, zip, pdo_mysql, redis, sockets, intl, bcmath, gmp, geos+ coverage: xdebug++ - name: Install additional system packages+ run: |+ sudo apt-get update+ sudo apt-get install -y libzip-dev libgd-dev libgeos-dev libgmp-dev default-mysql-client libicu-dev++ - name: Configure Composer auth for GitHub+ run: composer config --global github-oauth.github.com "${{ secrets._GITHUB_AUTH_TOKEN }}"++ - name: Prepare environment file+ run: |+ [ -f .env ] || cp .env.example .env+ php artisan key:generate --force || true++ - name: Install dependencies+ run: composer install --prefer-dist --no-progress --no-interaction++ - name: Run tests+ run: composer test:unit++ - name: Generate coverage report+ run: composer coverage:baseline++ - name: Upload coverage to Codecov+ uses: codecov/codecov-action@v4+ with:+ files: api/coverage/clover.xml+ flags: api+ name: api-coverage+ fail_ci_if_error: false+ env:+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}++ # Coverage gate. Target is 100% (composer coverage:check --fail-under=100).+ # continue-on-error is TEMPORARY: the host-app suite is a starter suite and+ # not yet at 100%. Remove `continue-on-error` (making this a required,+ # blocking check) once api/app is fully covered — the "flip to required"+ # step described in the plan.+ - name: Enforce coverage threshold (100%)+ continue-on-error: true+ run: composer coverage:checkdiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex a718efe0..5886191a 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1,5 +1,13 @@name: Fleetbase CI+# Image-build gate: proves the Docker images still bake from source.+# This is one of four sibling checks that together gate `main`:+# - ci.yml → this file: docker bake (images build)+# - install-smoke.yml → fresh install boots and serves (docker compose + deploy.sh + health)+# - api.yml → host Laravel PHPUnit suite + coverage+# - console.yml → Ember QUnit suite + coverage+# Mark all four as required status checks in branch protection so a red PR is blocked.+on:push:branches: [ main ]@@ -7,6 +15,7 @@ on:- 'v*'pull_request:branches: [ main ]+ workflow_dispatch:jobs:build:diff --git a/.github/workflows/console.yml b/.github/workflows/console.ymlnew file mode 100644index 00000000..01de83e7--- /dev/null+++ b/.github/workflows/console.yml@@ -0,0 +1,91 @@+name: Console CI++# Runs the Ember console's lint + QUnit suite + coverage from the monorepo root.+# NOTE: console/ is tracked directly in this repo (not a submodule), and GitHub+# only executes workflows under the repo-root .github/workflows/. So THIS file —+# not console/.github/workflows/ci.yml — is what gates the console in fleetbase-dev.++on:+ push:+ branches: [main]+ tags:+ - 'v*'+ pull_request:+ branches: [main]++env:+ NODE_VERSION: 22.x++defaults:+ run:+ working-directory: console++jobs:+ build-and-test:+ name: Lint, Test, Build+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v4++ - name: Setup Node.js ${{ env.NODE_VERSION }}+ uses: actions/setup-node@v4+ with:+ node-version: ${{ env.NODE_VERSION }}++ - name: Setup pnpm+ uses: pnpm/action-setup@v4+ with:+ version: latest++ - name: Get pnpm Store Directory+ id: pnpm-cache+ shell: bash+ run: echo "STORE_PATH=$(pnpm store path)" >> "$GITHUB_OUTPUT"++ - uses: actions/cache@v4+ name: Setup pnpm Cache+ with:+ path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('console/pnpm-lock.yaml') }}+ restore-keys: |+ ${{ runner.os }}-pnpm-store-++ - name: Create .npmrc+ run: |+ if [[ -n "${{ secrets._GITHUB_AUTH_TOKEN }}" ]]; then+ echo "@fleetbase:registry=https://npm.pkg.github.com/" > .npmrc+ echo "//npm.pkg.github.com/:_authToken=${{ secrets._GITHUB_AUTH_TOKEN }}" >> .npmrc+ fi++ - name: Install Dependencies+ run: pnpm install++ - name: Lint+ run: pnpm run lint++ # The step that was previously missing everywhere for the console: actually+ # running the existing QUnit suite (tests/unit + tests/integration), here+ # with coverage instrumentation.+ - name: Test (with coverage)+ run: pnpm run test:ember:coverage++ - name: Upload coverage to Codecov+ uses: codecov/codecov-action@v4+ with:+ files: console/coverage/lcov.info+ flags: console+ name: console-coverage+ fail_ci_if_error: false+ env:+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}++ # Coverage gate. Target is 100% (scripts/coverage-check.mjs).+ # continue-on-error is TEMPORARY — remove it to make this a required,+ # blocking check once the console suite reaches 100% coverage.+ - name: Enforce coverage threshold (100%)+ continue-on-error: true+ run: pnpm run coverage:check -- --fail-under=100++ - name: Build (production)+ run: npx ember build --environment productiondiff --git a/.github/workflows/install-smoke.yml b/.github/workflows/install-smoke.ymlnew file mode 100644index 00000000..586ad51d--- /dev/null+++ b/.github/workflows/install-smoke.yml@@ -0,0 +1,130 @@+name: Install Smoke Test++# Proves that a fresh clone actually installs and serves — the thing an end user does.+# Builds the API image from source, runs the real non-interactive installer+# (scripts/docker-install.sh, which brings the stack up and runs api/deploy.sh:+# migrate / sandbox:migrate / seed / create-permissions / registry:init), then+# asserts migrations ran and both the API (:8000/health) and Console (:4200) respond.++on:+ push:+ branches: [main]+ tags:+ - 'v*'+ pull_request:+ branches: [main]+ workflow_dispatch:++concurrency:+ group: install-smoke-${{ github.ref }}+ cancel-in-progress: true++jobs:+ install-smoke:+ name: Fresh Install Boots and Serves+ runs-on: ubuntu-latest+ timeout-minutes: 45++ steps:+ - name: Checkout Code+ uses: actions/checkout@v4+ with:+ submodules: recursive++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v3++ # The extension packages (fleetbase/core-api, fleetops-api, …) resolve from+ # GitHub via composer github-oauth during the image build. Without this token+ # the API image build cannot install dependencies. Same secret the deploy+ # workflows already use.+ - name: Check composer auth availability+ id: auth+ run: |+ if [[ -n "${{ secrets._GITHUB_AUTH_TOKEN }}" ]]; then+ echo "available=true" >> "$GITHUB_OUTPUT"+ else+ echo "available=false" >> "$GITHUB_OUTPUT"+ echo "::warning::_GITHUB_AUTH_TOKEN is not set; the API image build will likely fail to resolve private Fleetbase packages. Configure this secret to enable the install smoke test."+ fi++ # docker-compose.yml pins application/queue/scheduler to+ # fleetbase/fleetbase-api:latest. Build that tag locally from THIS checkout so+ # the smoke test exercises source, not the last published image.+ - name: Build API image from source+ if: steps.auth.outputs.available == 'true'+ run: |+ docker build \+ --file docker/Dockerfile \+ --target app \+ --build-arg GITHUB_AUTH_KEY="${{ secrets._GITHUB_AUTH_TOKEN }}" \+ --build-arg ENVIRONMENT=development \+ --tag fleetbase/fleetbase-api:latest \+ .++ # The repo currently commits a live MySQL datadir at docker/database/mysql+ # (mounted into the db container). Start from a clean volume so the installer's+ # freshly generated credentials initialize a fresh database instead of colliding+ # with stale committed data.+ - name: Ensure clean database volume+ if: steps.auth.outputs.available == 'true'+ run: |+ sudo rm -rf docker/database/mysql+ mkdir -p docker/database/mysql++ - name: Run non-interactive installer+ if: steps.auth.outputs.available == 'true'+ run: |+ # Ensure the API .env the compose file mounts exists.+ [ -f api/.env ] || cp api/.env.example api/.env 2>/dev/null || touch api/.env+ bash scripts/docker-install.sh --non-interactive++ - name: Assert migrations ran+ if: steps.auth.outputs.available == 'true'+ run: |+ set -euo pipefail+ echo "Migration status:"+ docker compose exec -T application php artisan migrate:status | tee /tmp/migrate-status.txt+ # A successful install must show at least one "Ran" migration and no "Pending".+ grep -Eiq "ran|yes" /tmp/migrate-status.txt+ if grep -Eiq "pending" /tmp/migrate-status.txt; then+ echo "::error::Pending migrations remain after install"; exit 1+ fi++ - name: Smoke test HTTP endpoints+ if: steps.auth.outputs.available == 'true'+ run: |+ set -uo pipefail++ wait_for() {+ local name="$1" url="$2" expect="$3" tries=30+ echo "Waiting for $name at $url ..."+ for i in $(seq 1 $tries); do+ body="$(curl -fsS --max-time 5 "$url" 2>/dev/null || true)"+ if echo "$body" | grep -q "$expect"; then+ echo "✔ $name responded: $body"+ return 0+ fi+ sleep 5+ done+ echo "::error::$name did not respond with '$expect' at $url after $((tries*5))s"+ return 1+ }++ # API health route (registered in api/app/Providers/RouteServiceProvider.php).+ wait_for "API /health" "http://localhost:8000/health" '"status"'+ # Console SPA shell.+ wait_for "Console" "http://localhost:4200" "<!DOCTYPE html>" || \+ wait_for "Console" "http://localhost:4200" "<html"++ - name: Dump logs on failure+ if: failure() && steps.auth.outputs.available == 'true'+ run: |+ echo "===== docker compose ps ====="+ docker compose ps || true+ echo "===== docker compose logs ====="+ docker compose logs --no-color --tail=300 || true++ - name: Tear down+ if: always() && steps.auth.outputs.available == 'true'+ run: docker compose down -v || truediff --git a/api/.gitignore b/api/.gitignoreindex d4f37a5e..c7e3015c 100644--- a/api/.gitignore+++ b/api/.gitignore@@ -6,6 +6,8 @@.env.env.backup.phpunit.result.cache+.phpunit.cache+/coveragedocker-compose.override.ymlHomestead.jsonHomestead.yamldiff --git a/api/composer.json b/api/composer.jsonindex a16084bb..1ce1a297 100644--- a/api/composer.json+++ b/api/composer.json@@ -105,6 +105,17 @@],"clean-logs": ["composer run-script clear-logs"+ ],+ "test:unit": "phpunit --colors=always",+ "test:coverage:clover": "mkdir -p coverage && XDEBUG_MODE=coverage phpunit --coverage-clover=coverage/clover.xml --colors=always",+ "coverage:summary": "php scripts/coverage-summary.php coverage/clover.xml",+ "coverage:check": "php scripts/coverage-summary.php coverage/clover.xml --fail-under=100",+ "coverage:baseline": [+ "@test:coverage:clover",+ "@coverage:summary"+ ],+ "test": [+ "@test:unit"]},"extra": {diff --git a/api/phpunit.xml b/api/phpunit.xmlindex 4ae4d979..2447662a 100644--- a/api/phpunit.xml+++ b/api/phpunit.xml@@ -1,31 +1,27 @@<?xml version="1.0" encoding="UTF-8"?>-<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"- xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"- bootstrap="vendor/autoload.php"- colors="true"->- <testsuites>- <testsuite name="Unit">- <directory suffix="Test.php">./tests/Unit</directory>- </testsuite>- <testsuite name="Feature">- <directory suffix="Test.php">./tests/Feature</directory>- </testsuite>- </testsuites>- <coverage processUncoveredFiles="true">- <include>- <directory suffix=".php">./app</directory>- </include>- </coverage>- <php>- <server name="APP_ENV" value="testing"/>- <server name="BCRYPT_ROUNDS" value="4"/>- <server name="CACHE_DRIVER" value="array"/>- <!-- <server name="DB_CONNECTION" value="sqlite"/> -->- <!-- <server name="DB_DATABASE" value=":memory:"/> -->- <server name="MAIL_MAILER" value="array"/>- <server name="QUEUE_CONNECTION" value="sync"/>- <server name="SESSION_DRIVER" value="array"/>- <server name="TELESCOPE_ENABLED" value="false"/>- </php>+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">+ <testsuites>+ <testsuite name="Unit">+ <directory suffix="Test.php">./tests/Unit</directory>+ </testsuite>+ <testsuite name="Feature">+ <directory suffix="Test.php">./tests/Feature</directory>+ </testsuite>+ </testsuites>+ <php>+ <server name="APP_ENV" value="testing"/>+ <server name="BCRYPT_ROUNDS" value="4"/>+ <server name="CACHE_DRIVER" value="array"/>+ <!-- <server name="DB_CONNECTION" value="sqlite"/> -->+ <!-- <server name="DB_DATABASE" value=":memory:"/> -->+ <server name="MAIL_MAILER" value="array"/>+ <server name="QUEUE_CONNECTION" value="sync"/>+ <server name="SESSION_DRIVER" value="array"/>+ <server name="TELESCOPE_ENABLED" value="false"/>+ </php>+ <source>+ <include>+ <directory suffix=".php">./app</directory>+ </include>+ </source></phpunit>diff --git a/api/scripts/coverage-summary.php b/api/scripts/coverage-summary.phpnew file mode 100644index 00000000..a5c4f960--- /dev/null+++ b/api/scripts/coverage-summary.php@@ -0,0 +1,98 @@+<?php++declare(strict_types=1);++// Summarizes a Clover coverage report for the host API app (coverage over ./app)+// and optionally enforces a minimum line-coverage threshold.+//+// Usage:+// php scripts/coverage-summary.php [path/to/clover.xml] [--fail-under=100]+//+// Ported from the Fleetbase extension packages' scripts/coverage-summary.php so+// the host app holds the same coverage bar and reporting format.++$cloverPath = 'coverage/clover.xml';+$failUnder = null;++foreach (array_slice($argv, 1) as $arg) {+ if (str_starts_with($arg, '--fail-under=')) {+ $failUnder = (float) substr($arg, strlen('--fail-under='));++ continue;+ }++ if ($arg !== '') {+ $cloverPath = $arg;+ }+}++if (!is_file($cloverPath)) {+ fwrite(STDERR, "Coverage file not found: {$cloverPath}\n");+ fwrite(STDERR, "Run `composer test:coverage:clover` first.\n");+ exit(1);+}++$xml = simplexml_load_file($cloverPath);+if (!$xml) {+ fwrite(STDERR, "Unable to parse Clover coverage file: {$cloverPath}\n");+ exit(1);+}++function coveragePercent(int $covered, int $total): float+{+ return $total === 0 ? 0.0 : round(($covered / $total) * 100, 2);+}++function intMetric(SimpleXMLElement $node, string $name): int+{+ return (int) ($node->metrics[$name] ?? 0);+}++$project = $xml->project;+$metrics = $project->metrics;++$statements = (int) ($metrics['statements'] ?? 0);+$coveredStatements = (int) ($metrics['coveredstatements'] ?? 0);+$methods = (int) ($metrics['methods'] ?? 0);+$coveredMethods = (int) ($metrics['coveredmethods'] ?? 0);+$classes = (int) ($metrics['classes'] ?? 0);+$coveredClasses = (int) ($metrics['coveredclasses'] ?? 0);++$files = [];++foreach ($project->xpath('.//file') ?: [] as $file) {+ $path = (string) $file['name'];+ $fileStatements = intMetric($file, 'statements');+ $coveredFileLines = intMetric($file, 'coveredstatements');++ if ($fileStatements === 0) {+ continue;+ }++ $files[] = [+ 'path' => $path,+ 'covered' => $coveredFileLines,+ 'statements' => $fileStatements,+ 'percent' => coveragePercent($coveredFileLines, $fileStatements),+ ];+}++usort($files, function (array $a, array $b): int {+ return $a['percent'] <=> $b['percent']+ ?: $b['statements'] <=> $a['statements'];+});++printf("Line coverage: %.2f%% (%d/%d statements)\n", coveragePercent($coveredStatements, $statements), $coveredStatements, $statements);+printf("Method coverage: %.2f%% (%d/%d methods)\n", coveragePercent($coveredMethods, $methods), $coveredMethods, $methods);+printf("Class coverage: %.2f%% (%d/%d classes)\n", coveragePercent($coveredClasses, $classes), $coveredClasses, $classes);++echo "\nLowest covered files:\n";+foreach (array_slice($files, 0, 20) as $file) {+ $relativePath = preg_replace('#^' . preg_quote(getcwd(), '#') . '/?#', '', $file['path']);+ printf(" %6.2f%% %5d/%-5d %s\n", $file['percent'], $file['covered'], $file['statements'], $relativePath ?: $file['path']);+}++if ($failUnder !== null && coveragePercent($coveredStatements, $statements) < $failUnder) {+ fwrite(STDERR, sprintf("\nCoverage %.2f%% is below the required %.2f%% line threshold.\n", coveragePercent($coveredStatements, $statements), $failUnder));+ exit(1);+}diff --git a/api/tests/Feature/ExampleTest.php b/api/tests/Feature/ExampleTest.phpdeleted file mode 100644index 4ae02bc5..00000000--- a/api/tests/Feature/ExampleTest.php+++ /dev/null@@ -1,21 +0,0 @@-<?php--namespace Tests\Feature;--use Illuminate\Foundation\Testing\RefreshDatabase;-use Tests\TestCase;--class ExampleTest extends TestCase-{- /**- * A basic test example.- *- * @return void- */- public function test_example()- {- $response = $this->get('/');-- $response->assertStatus(200);- }-}diff --git a/api/tests/Feature/HealthCheckTest.php b/api/tests/Feature/HealthCheckTest.phpnew file mode 100644index 00000000..25cbb3b7--- /dev/null+++ b/api/tests/Feature/HealthCheckTest.php@@ -0,0 +1,31 @@+<?php++namespace Tests\Feature;++use Tests\TestCase;++/**+ * Verifies the host application boots and serves its two unauthenticated+ * liveness endpoints. This is the in-process complement to the install-smoke+ * CI job (which curls the same routes against a running container).+ */+class HealthCheckTest extends TestCase+{+ public function test_root_route_returns_welcome_payload(): void+ {+ $response = $this->get('/');++ $response->assertStatus(200);+ $response->assertJsonPath('message', 'Fleetbase API');+ $response->assertJsonStructure(['message', 'version', 'fleetbase', 'ms']);+ }++ public function test_health_route_reports_ok(): void+ {+ $response = $this->get('/health');++ $response->assertStatus(200);+ $response->assertJsonPath('status', 'ok');+ $response->assertJsonStructure(['status', 'time']);+ }+}diff --git a/api/tests/Unit/AppServiceProviderTest.php b/api/tests/Unit/AppServiceProviderTest.phpnew file mode 100644index 00000000..d47b3589--- /dev/null+++ b/api/tests/Unit/AppServiceProviderTest.php@@ -0,0 +1,78 @@+<?php++namespace Tests\Unit;++use App\Providers\AppServiceProvider;+use ReflectionMethod;+use Tests\TestCase;++/**+ * Covers the meaningful logic in AppServiceProvider — outbound HTTP logging+ * helpers (URL secret redaction, elapsed-time calc, caller trace) and the+ * early-return when tracing is disabled.+ */+class AppServiceProviderTest extends TestCase+{+ private function provider(): AppServiceProvider+ {+ return new AppServiceProvider($this->app);+ }++ private function invoke(AppServiceProvider $provider, string $method, array $args = [])+ {+ $ref = new ReflectionMethod($provider, $method);+ $ref->setAccessible(true);++ return $ref->invokeArgs($provider, $args);+ }++ public function test_redacts_sensitive_query_parameters(): void+ {+ $url = 'https://api.example.com/v1/things?token=supersecret&api_key=abc123&page=2';++ $redacted = $this->invoke($this->provider(), 'redactOutboundHttpUrl', [$url]);++ $this->assertStringNotContainsString('supersecret', $redacted);+ $this->assertStringNotContainsString('abc123', $redacted);+ $this->assertStringContainsString('token=[redacted]', $redacted);+ $this->assertStringContainsString('api_key=[redacted]', $redacted);+ // Non-sensitive params are preserved.+ $this->assertStringContainsString('page=2', $redacted);+ }++ public function test_redact_leaves_urls_without_secrets_untouched(): void+ {+ $url = 'https://api.example.com/v1/things?page=2';++ $this->assertSame($url, $this->invoke($this->provider(), 'redactOutboundHttpUrl', [$url]));+ }++ public function test_elapsed_milliseconds_is_non_negative_integer(): void+ {+ $started = microtime(true) - 0.05; // 50ms ago++ $elapsed = $this->invoke($this->provider(), 'elapsedMilliseconds', [$started]);++ $this->assertIsInt($elapsed);+ $this->assertGreaterThanOrEqual(0, $elapsed);+ }++ public function test_outbound_http_trace_excludes_vendor_frames(): void+ {+ $trace = $this->invoke($this->provider(), 'outboundHttpTrace');++ $this->assertIsArray($trace);+ foreach ($trace as $frame) {+ $this->assertStringNotContainsString('/vendor/', $frame);+ }+ }++ public function test_boot_is_noop_when_tracing_disabled(): void+ {+ // HTTP_CLIENT_TRACE_ENABLED is unset in the testing env, so boot() should+ // return without registering global HTTP middleware and without throwing.+ $this->provider()->boot();++ $this->assertTrue(true);+ }+}diff --git a/api/tests/Unit/EventServiceProviderTest.php b/api/tests/Unit/EventServiceProviderTest.phpnew file mode 100644index 00000000..32a063f4--- /dev/null+++ b/api/tests/Unit/EventServiceProviderTest.php@@ -0,0 +1,21 @@+<?php++namespace Tests\Unit;++use App\Providers\EventServiceProvider;+use Illuminate\Auth\Events\Registered;+use Illuminate\Auth\Listeners\SendEmailVerificationNotification;+use Tests\TestCase;++class EventServiceProviderTest extends TestCase+{+ public function test_registered_event_sends_email_verification(): void+ {+ $provider = new EventServiceProvider($this->app);++ $listen = $provider->listens();++ $this->assertArrayHasKey(Registered::class, $listen);+ $this->assertContains(SendEmailVerificationNotification::class, $listen[Registered::class]);+ }+}diff --git a/api/tests/Unit/ExampleTest.php b/api/tests/Unit/ExampleTest.phpdeleted file mode 100644index 62e8c3cd..00000000--- a/api/tests/Unit/ExampleTest.php+++ /dev/null@@ -1,18 +0,0 @@-<?php--namespace Tests\Unit;--use PHPUnit\Framework\TestCase;--class ExampleTest extends TestCase-{- /**- * A basic test example.- *- * @return void- */- public function test_example()- {- $this->assertTrue(true);- }-}diff --git a/api/tests/Unit/UserModelTest.php b/api/tests/Unit/UserModelTest.phpnew file mode 100644index 00000000..36a11942--- /dev/null+++ b/api/tests/Unit/UserModelTest.php@@ -0,0 +1,32 @@+<?php++namespace Tests\Unit;++use App\Models\User;+use Tests\TestCase;++class UserModelTest extends TestCase+{+ public function test_mass_assignable_attributes(): void+ {+ $user = new User();++ $this->assertSame(['name', 'email', 'password'], $user->getFillable());+ }++ public function test_hidden_attributes_are_not_serialized(): void+ {+ $user = new User();++ $this->assertContains('password', $user->getHidden());+ $this->assertContains('remember_token', $user->getHidden());+ }++ public function test_email_verified_at_is_cast_to_datetime(): void+ {+ $user = new User();++ $this->assertArrayHasKey('email_verified_at', $user->getCasts());+ $this->assertSame('datetime', $user->getCasts()['email_verified_at']);+ }+}diff --git a/codecov.yml b/codecov.ymlnew file mode 100644index 00000000..370440b2--- /dev/null+++ b/codecov.yml@@ -0,0 +1,34 @@+# Codecov configuration for the Fleetbase monorepo (host apps only).+# The api/ (Laravel) and console/ (Ember) coverage reports are uploaded from+# .github/workflows/api.yml and console.yml under distinct flags so each app's+# coverage is tracked independently. Extension packages report from their own repos.++coverage:+ status:+ project:+ default:+ # Do not fail the Codecov check on a small dip while suites are being+ # built up to 100%. The hard 100% gate lives in each workflow+ # (coverage:check / coverage-check.mjs) and is flipped to required there.+ target: auto+ threshold: 1%+ informational: true+ patch:+ default:+ informational: true++flags:+ api:+ paths:+ - api/app+ console:+ paths:+ - console/app++comment:+ layout: "reach, diff, flags, files"+ require_changes: false++# Suppress the "waiting for other uploads" behavior across unrelated jobs.+codecov:+ require_ci_to_pass: falsediff --git a/console/.github/workflows/ci.yml b/console/.github/workflows/ci.ymldeleted file mode 100644index e4fa62fb..00000000--- a/console/.github/workflows/ci.yml+++ /dev/null@@ -1,60 +0,0 @@-name: Ember CI--on:- push:- branches: [ main ]- tags:- - 'v*'- pull_request:- branches: [ main ]--jobs:- build:- runs-on: ubuntu-latest-- strategy:- matrix:- node-version: [18.x] # Build on Node.js 18-- steps:- - uses: actions/checkout@v2-- - name: Setup Node.js ${{ matrix.node-version }}- uses: actions/setup-node@v2- with:- node-version: ${{ matrix.node-version }}-- - name: Setup pnpm- uses: pnpm/[email protected]- with:- version: latest-- - name: Get pnpm Store Directory- id: pnpm-cache- shell: bash- run: |- echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT-- - uses: actions/cache@v3- name: Setup pnpm Cache- with:- path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}- restore-keys: |- ${{ runner.os }}-pnpm-store--- - name: Create .npmrc- run: |- if [[ -n "${{ secrets._GITHUB_AUTH_TOKEN }}" ]]; then- echo "@fleetbase:registry=https://npm.pkg.github.com/" > .npmrc- echo "//npm.pkg.github.com/:_authToken=${{ secrets._GITHUB_AUTH_TOKEN }}" >> .npmrc- fi-- - name: Install Dependencies- run: pnpm install-- - name: Lint- run: pnpm run lint-- - name: Build- run: npx ember build --environment production\ No newline at end of filediff --git a/console/config/coverage.js b/console/config/coverage.jsnew file mode 100644index 00000000..8fb9732d--- /dev/null+++ b/console/config/coverage.js@@ -0,0 +1,17 @@+'use strict';++// Configuration for ember-cli-code-coverage.+// Coverage is only instrumented when the COVERAGE env var is truthy+// (e.g. `COVERAGE=true ember test` / `pnpm test:ember:coverage`), so it never+// slows down normal `ember test` runs.+//+// Reporters:+// - lcov → coverage/lcov.info (uploaded to Codecov)+// - json-summary → coverage/coverage-summary.json (read by scripts/coverage-check.mjs)+// - text-summary → printed to the console+module.exports = {+ coverageEnvVar: 'COVERAGE',+ reporters: ['lcov', 'json-summary', 'text-summary'],+ // Exclude generated/vendor and test files from the coverage denominator.+ excludes: ['*/mirage/**', '*/tests/**', '**/*-test.js'],+};diff --git a/console/package.json b/console/package.jsonindex efd9e30a..64c998e6 100644--- a/console/package.json+++ b/console/package.json@@ -24,7 +24,9 @@"start": "ember serve","start:dev": "ember serve --environment development","test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"",- "test:ember": "ember test"+ "test:ember": "ember test",+ "test:ember:coverage": "COVERAGE=true ember test",+ "coverage:check": "node scripts/coverage-check.mjs"},"ember-addon": {"paths": [diff --git a/console/scripts/coverage-check.mjs b/console/scripts/coverage-check.mjsnew file mode 100644index 00000000..8d6604c6--- /dev/null+++ b/console/scripts/coverage-check.mjs@@ -0,0 +1,48 @@+#!/usr/bin/env node+// Fails (exit 1) if total coverage is below the threshold.+// Reads coverage/coverage-summary.json produced by ember-cli-code-coverage+// (json-summary reporter). Run after `pnpm test:ember:coverage`.+//+// Usage:+// node scripts/coverage-check.mjs [--fail-under=100]+//+// Mirrors the backend packages' scripts/coverage-summary.php --fail-under gate+// so the console holds the same 100% bar once its suite reaches it.++import { readFileSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { dirname, resolve } from 'node:path';++const __dirname = dirname(fileURLToPath(import.meta.url));+const summaryPath = resolve(__dirname, '..', 'coverage', 'coverage-summary.json');++const failUnderArg = process.argv.find((a) => a.startsWith('--fail-under='));+const failUnder = failUnderArg ? parseFloat(failUnderArg.split('=')[1]) : 100;++let summary;+try {+ summary = JSON.parse(readFileSync(summaryPath, 'utf8'));+} catch (err) {+ console.error(`✖ Could not read coverage summary at ${summaryPath}.`);+ console.error(' Run `pnpm test:ember:coverage` first (COVERAGE=true).');+ console.error(` ${err.message}`);+ process.exit(1);+}++const total = summary.total;+const metrics = ['lines', 'statements', 'functions', 'branches'];+let failed = false;++console.log(`Coverage summary (threshold: ${failUnder}%)`);+for (const metric of metrics) {+ const pct = total?.[metric]?.pct ?? 0;+ const ok = pct >= failUnder;+ console.log(` ${ok ? '✔' : '✖'} ${metric.padEnd(11)} ${pct}%`);+ if (!ok) failed = true;+}++if (failed) {+ console.error(`\n✖ Coverage is below ${failUnder}%.`);+ process.exit(1);+}+console.log(`\n✔ Coverage meets the ${failUnder}% threshold.`);