Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
318 changes: 318 additions & 0 deletions BUILD_REVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
# Build Process Review

A critical analysis of the ImaForm build process with actionable improvement recommendations.

---

## Executive Summary

The build system has a solid foundation with multi-stage Docker builds, comprehensive health checks, and parallel E2E testing. However, there are **critical bugs that will cause CI failures** and several consistency issues that should be addressed.

| Severity | Count | Impact |
|----------|-------|--------|
| 🔴 Critical | 3 | CI failures, broken builds |
| 🟠 Significant | 5 | Maintenance burden, confusion |
| 🟡 Minor | 6 | Technical debt |

---

## 🔴 Critical Issues

### 1. Missing `test:unit` Script (CI Will Fail)

**File:** `frontend/package.json` + `.github/workflows/test.yml:105`

**Problem:** CI runs `npm run test:unit` but the script doesn't exist.

```json
// Current package.json scripts:
"test": "vitest",
"test:e2e": "playwright test"
// Missing: "test:unit"
```

**Impact:** Every CI run will fail at the frontend test step.

**Fix:** Add the missing script:
```json
"scripts": {
"test": "vitest",
"test:unit": "vitest run --coverage",
"test:e2e": "playwright test"
}
```

---

### 2. Node.js Version Mismatch

**Files:** Multiple locations

| Location | Node Version |
|----------|--------------|
| README.md | 20+ |
| Docker (frontend/Dockerfile) | 20-alpine |
| CI workflows (test.yml, e2e.yml) | 18 |

**Impact:** Tests may pass in CI but fail locally (or vice versa) due to different Node.js behaviors.

**Fix:** Standardize on Node 20 across all workflows:
```yaml
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
```

---

### 3. E2E Workflow Sharding Bug

**File:** `.github/workflows/e2e.yml:47`

**Problem:** The sharding syntax uses `${{ strategy.total-shards }}` which doesn't exist.

```yaml
# Current (broken):
npx playwright test --shard=${{ matrix.shard }}/${{ strategy.total-shards }}

# Should be:
npx playwright test --shard=${{ matrix.shard }}/4
```

**Impact:** E2E tests may fail or run incorrectly.

---

## 🟠 Significant Issues

### 4. Outdated GitHub Actions Versions

**Files:** All workflow files

| Action | Current | Latest | Notes |
|--------|---------|--------|-------|
| actions/checkout | v3 | v4 | Node 20 support |
| actions/setup-node | v3 | v4 | Node 20 support |
| actions/setup-python | v4 | v5 | Python 3.12+ |
| actions/upload-artifact | v3 | v4 | Breaking changes in v4 |
| actions/download-artifact | v3 | v4 | Breaking changes in v4 |
| codecov/codecov-action | v3 | v4 | Better error handling |

**Impact:** Missing security patches, incompatibility with newer features.

**Fix:** Update all action versions to latest stable.

---

### 5. E2E Artifact Download Bug

**File:** `.github/workflows/e2e.yml:98-100`

```yaml
- name: Download all test results
uses: actions/download-artifact@v3
with:
path: playwright-results-* # Wildcards don't work here
```

**Impact:** Test report generation will fail silently.

**Fix:** Use `actions/download-artifact@v4` with `pattern` parameter:
```yaml
- uses: actions/download-artifact@v4
with:
pattern: playwright-results-shard-*
path: all-results
merge-multiple: true
```

---

### 6. Misleading Python Version Documentation

**File:** README.md vs `backend/pyproject.toml`

- README says: "Python 3.11+"
- pyproject.toml requires: `>=3.11,<3.13`

**Impact:** Users trying Python 3.13+ will get confusing dependency errors from Depth-Anything-3.

**Fix:** Update README to state: "Python 3.11 or 3.12 (3.13+ not supported due to Depth-Anything-3)"

---

### 7. UV Tool Misconfiguration

**File:** `backend/pyproject.toml:84-86`

```toml
[tool.uv]
# Limit resolution to Windows to avoid darwin-specific conflicts
environments = ["sys_platform == 'win32'"]
```

**Impact:** This limits UV package resolution to Windows only, which is incorrect for a cross-platform project.

**Fix:** Remove or fix this configuration:
```toml
[tool.uv]
# Exclude problematic platforms if needed
exclude-newer = "2025-01-01" # Pin to stable versions
```

---

### 8. Redundant E2E Test Jobs

**File:** `.github/workflows/e2e.yml`

The workflow runs:
1. Sharded E2E tests (4 shards on Ubuntu, all browsers)
2. Separate Ubuntu Chromium tests
3. Separate macOS Chromium tests
4. Separate Windows Chromium tests
5. Visual regression tests

**Impact:** Redundant testing, increased CI costs and time.

**Fix:** Remove the separate `e2e-tests-on-ubuntu` job (it's covered by sharded tests). Keep macOS/Windows for true cross-platform validation.

---

## 🟡 Minor Issues

### 9. No Dependency Caching in Backend CI

**File:** `.github/workflows/test.yml`

Backend tests reinstall all pip packages every run despite having `cache: 'pip'` on the setup-python action.

**Fix:** Add explicit cache paths:
```yaml
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'backend/requirements.txt'
```

---

### 10. Inconsistent Coverage Output Paths

**Files:** `frontend/vitest.config.ts` + `.github/workflows/test.yml:110`

CI expects: `frontend/coverage/coverage-final.json`
Vitest config may output differently with V8 provider.

**Fix:** Verify Vitest configuration explicitly outputs to the expected path:
```typescript
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
reportsDirectory: './coverage'
}
```

---

### 11. Playwright Browser Installation Redundancy

**File:** `.github/workflows/e2e.yml`

```yaml
- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Install Playwright dependencies
run: sudo apt-get install -y libnss3 ... # Redundant!
```

**Impact:** `--with-deps` already installs system dependencies.

**Fix:** Remove the manual apt-get step.

---

### 12. Missing CI Environment Variable

**File:** `.github/workflows/test.yml`

Sharded E2E tests set `CI: true` but unit tests don't.

**Impact:** Vitest and other tools may behave differently in CI without this flag.

**Fix:** Add `CI: true` to all test steps.

---

### 13. Hardcoded Celery Worker Concurrency

**File:** `docker/docker-compose.yml`

```yaml
command: celery -A app.celery worker --loglevel=info --concurrency=2
```

**Fix:** Use environment variable:
```yaml
command: celery -A app.celery worker --loglevel=info --concurrency=${CELERY_CONCURRENCY:-2}
```

---

### 14. Missing Playwright Browser Cache

**File:** `.github/workflows/e2e.yml`

Playwright browsers are downloaded on every run (~300MB each).

**Fix:** Add caching:
```yaml
- uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('frontend/package-lock.json') }}
```

---

## ✅ Strengths

| Area | Implementation |
|------|----------------|
| Docker | Multi-stage builds, non-root users, health checks |
| Testing | E2E sharding, cross-platform, visual regression |
| Security | Non-root containers, secret management via env |
| Performance | Performance regression detection, automated issue creation |
| Development | Hot reload in dev mode, separate dev/prod configs |

---

## Recommended Priority

1. **Immediate (CI broken):** Fix test:unit script, fix sharding syntax
2. **High (consistency):** Standardize Node.js to 20, update GitHub Actions
3. **Medium (maintenance):** Fix artifact download, remove redundant jobs
4. **Low (optimization):** Add caching, consolidate scripts

---

## Implementation Checklist

- [ ] Add `test:unit` script to `frontend/package.json`
- [ ] Update all workflows to Node 20
- [ ] Update all GitHub Actions to v4/v5
- [ ] Fix Playwright sharding syntax
- [ ] Fix artifact download pattern in e2e.yml
- [ ] Update README Python version documentation
- [ ] Remove/fix UV tool configuration
- [ ] Remove redundant Ubuntu E2E job
- [ ] Add Playwright browser caching
- [ ] Remove manual apt-get in E2E workflow
- [ ] Add `CI: true` to all test steps

---

*Generated: 2026-01-18*