Skip to content
Merged
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test-and-build:
name: Test and build
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Run Unit Tests
run: npm test

- name: Build
run: npm run build
15 changes: 11 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@ jobs:
with:
node-version: '22'

# 3. Устанавливаем зависимости и собираем
- name: Install and Build
# 3. Устанавливаем зависимости
- name: Install Dependencies
run: npm ci

# 4. Прогоняем юнит-тесты до сборки: упавший тест останавливает деплой
- name: Run Unit Tests
run: npm test

# 5. Собираем
- name: Build
run: |
npm ci
npm run build
mv dist/index.html dist/app.html
# Теперь у нас есть папка dist с готовой игрой

# 4. Отправляем папку dist в репозиторий сайта
# 6. Отправляем папку dist в репозиторий сайта
- name: Push to Website Repository
uses: cpina/github-action-push-to-another-repository@main
env:
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,5 @@ Vite configuration highlights (`vite.config.ts`):

- Duplicate geometry paths: lightweight Three.js mesh vs OpenCascade solid (kept consistent via shared offset helpers).
- Legacy `app.html` at repo root is not the Vite entry; production deploy renames `dist/index.html` → `dist/app.html`.
- No automated test suite; rely on lint and manual verification for releases.
- The calculation engine, pattern dimensions and share-link protocol are covered by Vitest (`npm test`); 2D/3D rendering and the DXF/PDF/STEP exports still rely on the manual checklist in `docs/development.md`.
- `process.env.GEMINI_API_KEY` is defined in Vite config for historical template reasons; the shell calculator does not call Gemini APIs.
37 changes: 28 additions & 9 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,28 @@ Dev server: `http://localhost:3000` (bound to `0.0.0.0`).
| `npm run build` | Production build to `dist/` |
| `npm run preview` | Preview production build |
| `npm run lint` | ESLint (TypeScript + React Hooks + Refresh) |
| `npm run verify` | Numerical and protocol checks (both suites below) |
| `npm run verify:eccentric` | Eccentric cone development vs. independently known values |
| `npm run verify:bend-dimensions` | Bend-line spacing dimensions in all three shape modes |
| `npm run verify:share-link` | Share-link round trip, real link payload, hostile input |
| `npm test` | Vitest unit tests, single run (used by CI) |
| `npm run test:watch` | Vitest in watch mode |

There is currently **no** automated unit/e2e test script in `package.json`.
## Tests

Tests live next to the code they cover (`*.test.ts`) and run in Node — no
browser, WebGL or WASM is needed.

| Suite | Covers |
|-------|--------|
| `math/cylinder.test.ts` | Neutral diameter from OD/ID, developed length, K-factor, weld gap, bend lines |
| `math/cone.test.ts` | Sector radii and angle, gap on the neutral fibre, blank rectangle |
| `math/eccentric-cone.test.ts` | Development vs. independently known values (`docs/eccentric-cone.md` § 7) |
| `math/validation.test.ts` | Invalid and boundary input for every mode |
| `utils/pattern-dimensions.test.ts` | Bend-line spacing dimensions in all three shape modes |
| `shareLink.test.ts` | Share-link round trip, real link payload, hostile input |

Reference values are derived by hand from the closed-form relations in
`docs/calculations.md`, never by pasting the engine's own output. The cylinder
and cone reference cases are also published as validation cases on the
[documentation page](https://cadautoscript.com/docs/utilities/cylindrical-shell-rolling),
so change both together.

## Stack versions (declared)

Expand Down Expand Up @@ -93,10 +109,12 @@ Before merging calculation or export changes:
- [ ] DXF opens in a CAD tool with expected mm scale
- [ ] STEP opens in a CAD tool as an open-seam thick shell
- [ ] Embed share restore (if host available) recomputes matching results
- [ ] `npm run lint`, `npm run verify` and `npm run build` succeed
- [ ] `npm run lint`, `npm test` and `npm run build` succeed

## Deployment

Pull requests run `.github/workflows/ci.yml`: `npm ci`, `npm test`, `npm run build`.

Workflow: `.github/workflows/deploy.yml`

**Trigger:** push to `main`
Expand All @@ -105,9 +123,10 @@ Workflow: `.github/workflows/deploy.yml`

1. Checkout source
2. Setup Node.js 22
3. `npm ci` && `npm run build`
4. `mv dist/index.html dist/app.html`
5. Push `dist/` to `YurMil/cadautoscript.com` at
3. `npm ci`
4. `npm test` — a failing test stops the workflow before anything is built or published
5. `npm run build` && `mv dist/index.html dist/app.html`
6. Push `dist/` to `YurMil/cadautoscript.com` at
`static/utility-apps/cylindrical-shell-rolling`
using `DEPLOY_TOKEN` (`API_TOKEN_GITHUB`)

Expand Down
8 changes: 4 additions & 4 deletions docs/eccentric-cone.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Store (`useShellStore`) получает сеттеры `setEccentricity`, `setS
— порядок ключей таблицы, `mode` первым: store пересчитывает результат на
каждом сеттере, и остальные значения осмысленны только после выбора формы.

Проверка: `npm run verify:share-link` (полный round-trip, реальная ссылка
Проверка: `src/shareLink.test.ts`, `npm test` (полный round-trip, реальная ссылка
с сайта, все значения перечислений, устойчивость к битой нагрузке).

---
Expand Down Expand Up @@ -472,10 +472,10 @@ Store (`useShellStore`) получает сеттеры `setEccentricity`, `setS

## 7. Проверка

Автотест: `tools/verify-eccentric-cone.ts`, запуск
Автотест: `src/features/calculator/math/eccentric-cone.test.ts`, запуск

```bash
npm run verify:eccentric
npm test
```

Числовые сверки (сравнение с независимо известными величинами) и фактически
Expand Down Expand Up @@ -522,7 +522,7 @@ npm run verify:eccentric
| 5. DXF | `utils/dxf-writer.ts` (`addPolyline`, `addText`, `addAlignedDimension`, `generateEccentricConeDxf`), `utils/aligned-dimension.ts` | готово |
| 6. PDF-отчёт с таблицей станций | `utils/eccentric-cone-report.ts` | готово |
| 7. STEP | `cad/types/cad-types.ts`, `cad/geometry/build-eccentric-cone-solid.ts`, `cad-worker.ts` | готово |
| 8. Проверки § 7, share-link, сборка | `tools/verify-eccentric-cone.ts`, `tools/verify-share-link.ts`, `shareLink.ts` | готово |
| 8. Проверки § 7, share-link, сборка | `math/eccentric-cone.test.ts`, `shareLink.test.ts`, `shareLink.ts` | готово |

Реализованные отличия от первоначального плана:

Expand Down
2 changes: 1 addition & 1 deletion docs/export-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ enumerated values are validated against the `SHAPE_TYPES` / `SPEC_TYPES` /
`SEAM_POSITIONS` tuples the unions are derived from rather than a repeated
allow-list.

Implementation: `src/shareLink.ts`. Round-trip checks: `npm run verify:share-link`.
Implementation: `src/shareLink.ts`. Round-trip checks: `src/shareLink.test.ts` (`npm test`).

---

Expand Down
Loading
Loading