half-orm-dev 0.17.3a2__py3-none-any.whl → 0.17.3a4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- half_orm_dev/cli/commands/init.py +1 -1
- half_orm_dev/cli/commands/patch.py +9 -9
- half_orm_dev/cli/commands/release.py +14 -13
- half_orm_dev/cli/commands/todo.py +5 -5
- half_orm_dev/cli/main.py +2 -2
- half_orm_dev/patch_manager.py +1 -1
- half_orm_dev/release_file.py +1 -1
- half_orm_dev/release_manager.py +7 -7
- half_orm_dev/repo.py +33 -15
- half_orm_dev/templates/README +224 -19
- half_orm_dev/templates/git-hooks/pre-commit +8 -4
- half_orm_dev/version.txt +1 -1
- half_orm_dev-0.17.3a4.dist-info/METADATA +553 -0
- {half_orm_dev-0.17.3a2.dist-info → half_orm_dev-0.17.3a4.dist-info}/RECORD +18 -18
- half_orm_dev-0.17.3a2.dist-info/METADATA +0 -1284
- {half_orm_dev-0.17.3a2.dist-info → half_orm_dev-0.17.3a4.dist-info}/WHEEL +0 -0
- {half_orm_dev-0.17.3a2.dist-info → half_orm_dev-0.17.3a4.dist-info}/licenses/AUTHORS +0 -0
- {half_orm_dev-0.17.3a2.dist-info → half_orm_dev-0.17.3a4.dist-info}/licenses/LICENSE +0 -0
- {half_orm_dev-0.17.3a2.dist-info → half_orm_dev-0.17.3a4.dist-info}/top_level.txt +0 -0
|
@@ -1,1284 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: half_orm_dev
|
|
3
|
-
Version: 0.17.3a2
|
|
4
|
-
Summary: half_orm development Framework.
|
|
5
|
-
Author-email: Joël Maïzi <joel.maizi@collorg.org>
|
|
6
|
-
License-Expression: GPL-3.0-or-later
|
|
7
|
-
Project-URL: Homepage, https://github.com/collorg/halfORM_dev
|
|
8
|
-
Keywords: postgres,relation-object mapping
|
|
9
|
-
Classifier: Development Status :: 3 - Alpha
|
|
10
|
-
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: Topic :: Software Development :: Build Tools
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
-
Requires-Python: >=3.9
|
|
19
|
-
Description-Content-Type: text/markdown
|
|
20
|
-
License-File: LICENSE
|
|
21
|
-
License-File: AUTHORS
|
|
22
|
-
Requires-Dist: GitPython
|
|
23
|
-
Requires-Dist: click
|
|
24
|
-
Requires-Dist: pydash
|
|
25
|
-
Requires-Dist: pytest
|
|
26
|
-
Requires-Dist: half_orm<0.18.0,>=0.17.1
|
|
27
|
-
Requires-Dist: tomli>=2.0.0; python_version < "3.11"
|
|
28
|
-
Requires-Dist: tomli_w>=1.0.0
|
|
29
|
-
Dynamic: license-file
|
|
30
|
-
Dynamic: requires-dist
|
|
31
|
-
|
|
32
|
-
# half-orm-dev
|
|
33
|
-
|
|
34
|
-
## **WARNING!** half-orm-dev is in alpha development phase!
|
|
35
|
-
|
|
36
|
-
**Git-centric patch management and database versioning for half-orm projects**
|
|
37
|
-
|
|
38
|
-
[](https://www.python.org/downloads/)
|
|
39
|
-
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
40
|
-
[](https://github.com/half-orm/half-orm)
|
|
41
|
-
[](https://pepy.tech/projects/half-orm-dev)
|
|
42
|
-
|
|
43
|
-
Modern development workflow for PostgreSQL databases with automatic code generation, semantic versioning, and production-ready deployment system.
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## 📖 Description
|
|
49
|
-
|
|
50
|
-
`half-orm-dev` provides a complete development lifecycle for database-driven applications:
|
|
51
|
-
- **Git-centric workflow**: Patches stored in Git branches and release files
|
|
52
|
-
- **Semantic versioning**: Automatic version calculation (patch/minor/major)
|
|
53
|
-
- **Code generation**: Python classes auto-generated from schema changes
|
|
54
|
-
- **Safe deployments**: Automatic backups, rollback support, validation
|
|
55
|
-
- **Team collaboration**: Distributed locks, branch notifications, conflict prevention
|
|
56
|
-
- **Test-driven development**: Systematic validation before any integration
|
|
57
|
-
|
|
58
|
-
Perfect for teams managing evolving PostgreSQL schemas with Python applications.
|
|
59
|
-
|
|
60
|
-
## ✨ Features
|
|
61
|
-
|
|
62
|
-
### 🔧 Development
|
|
63
|
-
- **Patch-based development**: Isolated branches for each database change
|
|
64
|
-
- **Automatic code generation**: half-orm Python classes created from schema
|
|
65
|
-
- **Complete testing**: Apply patches with full release context
|
|
66
|
-
- **Conflict detection**: Distributed locks prevent concurrent modifications
|
|
67
|
-
|
|
68
|
-
### 🧪 Test-Driven Development & Validation
|
|
69
|
-
|
|
70
|
-
**Systematic Testing Before Integration**
|
|
71
|
-
|
|
72
|
-
`half-orm-dev` enforces a **test-first approach** that guarantees code quality:
|
|
73
|
-
|
|
74
|
-
**1. Validation on Temporary Branches**
|
|
75
|
-
```bash
|
|
76
|
-
# When closing a patch, tests run FIRST
|
|
77
|
-
# You must be on the patch branch
|
|
78
|
-
git checkout ho-patch/456-user-auth
|
|
79
|
-
half_orm dev patch merge
|
|
80
|
-
|
|
81
|
-
# What happens behind the scenes:
|
|
82
|
-
# 1. Creates temp-valid-1.3.6 branch
|
|
83
|
-
# 2. Merges ALL release patches + new patch
|
|
84
|
-
# 3. Runs pytest tests/
|
|
85
|
-
# 4. If merge and tests PASS → merges patch branch into release branch; changes patch status to "staged" in TOML and commits
|
|
86
|
-
# 5. If anything FAILS → nothing committed (temp branch is deleted)
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**2. No Integration Without Tests**
|
|
90
|
-
- ❌ **BLOCKED**: Patches cannot be added to releases if anything fails
|
|
91
|
-
- ✅ **SAFE**: Only validated code reaches stage/rc/production
|
|
92
|
-
- 🔒 **GUARANTEED**: Every release is testable before deployment
|
|
93
|
-
|
|
94
|
-
**3. Business Logic Testing (TDD Best Practice)**
|
|
95
|
-
```python
|
|
96
|
-
# Your business logic is fully testable
|
|
97
|
-
# Example: tests/test_user_authentication.py
|
|
98
|
-
|
|
99
|
-
def test_user_creation():
|
|
100
|
-
"""Test user creation through half-orm models."""
|
|
101
|
-
user = User(
|
|
102
|
-
username='john',
|
|
103
|
-
email='john@example.com'
|
|
104
|
-
).ho_insert()
|
|
105
|
-
|
|
106
|
-
assert user.id is not None
|
|
107
|
-
assert user.username == 'john'
|
|
108
|
-
|
|
109
|
-
def test_invalid_email_rejected():
|
|
110
|
-
"""Test validation prevents invalid emails."""
|
|
111
|
-
with pytest.raises(ValidationError):
|
|
112
|
-
User(username='john', email='invalid').ho_insert()
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**4. Full Release Context Testing**
|
|
116
|
-
```bash
|
|
117
|
-
# Test your patch with ALL previous patches
|
|
118
|
-
half_orm dev patch apply
|
|
119
|
-
|
|
120
|
-
# What happens:
|
|
121
|
-
# 1. Restores DB to production state
|
|
122
|
-
# 2. Applies all RC patches (if any)
|
|
123
|
-
# 3. Applies all stage patches
|
|
124
|
-
# 4. Applies YOUR patch in correct order
|
|
125
|
-
# 5. Generates code
|
|
126
|
-
# → Your tests run in realistic production-like environment
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
**5. Workflow Integration**
|
|
130
|
-
```
|
|
131
|
-
┌───────────────────────────────────────────────────────────────────┐
|
|
132
|
-
│ Development Cycle with Test Validation │
|
|
133
|
-
├───────────────────────────────────────────────────────────────────┤
|
|
134
|
-
│ 1. Create patch │
|
|
135
|
-
│ 2. Write tests FIRST (TDD) │
|
|
136
|
-
│ 3. Implement feature │
|
|
137
|
-
│ 4. Run tests locally: pytest │
|
|
138
|
-
│ 5. Add to release → AUTOMATIC VALIDATION │
|
|
139
|
-
│ ├─ temp-valid branch created │
|
|
140
|
-
│ | ├─ All patches merged │
|
|
141
|
-
│ | └─ pytest runs automatically │
|
|
142
|
-
│ └─ Only commits if everything is OK │
|
|
143
|
-
│ 6. Promote to RC → Tests validated again, code merged on ho-prod │
|
|
144
|
-
│ 7. Deploy to prod → Tested code only │
|
|
145
|
-
└───────────────────────────────────────────────────────────────────┘
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
**Benefits:**
|
|
149
|
-
- ✅ **Catch Integration Issues Early**: Test interactions between patches
|
|
150
|
-
- ✅ **Prevent Regressions**: Existing tests protect against breaking changes
|
|
151
|
-
- ✅ **Document Behavior**: Tests serve as executable specifications
|
|
152
|
-
- ✅ **Safe Refactoring**: Change implementation with confidence
|
|
153
|
-
- ✅ **Team Collaboration**: Clear expectations for code quality
|
|
154
|
-
|
|
155
|
-
### 📦 Release Management
|
|
156
|
-
- **Semantic versioning**: patch/minor/major increments
|
|
157
|
-
- **Release candidates**: RC validation before production
|
|
158
|
-
- **Sequential promotion**: stage → rc → production workflow
|
|
159
|
-
- **Branch cleanup**: Automatic deletion after RC promotion
|
|
160
|
-
- **Test validation**: Automated testing at every promotion step
|
|
161
|
-
|
|
162
|
-
### 🚀 Production
|
|
163
|
-
- **Safe upgrades**: Automatic database backups before changes
|
|
164
|
-
- **Incremental deployment**: Apply releases sequentially
|
|
165
|
-
- **Dry-run mode**: Preview changes before applying
|
|
166
|
-
- **Version tracking**: Complete release history in database
|
|
167
|
-
- **Rollback support**: Automatic rollback on failures
|
|
168
|
-
|
|
169
|
-
### 👥 Team Collaboration
|
|
170
|
-
- **Distributed locks**: Prevent concurrent ho-prod modifications
|
|
171
|
-
- **Branch notifications**: Alert developers when rebase needed
|
|
172
|
-
- **Multiple stages**: Parallel development of different releases
|
|
173
|
-
- **Git-based coordination**: No external tools required
|
|
174
|
-
|
|
175
|
-
## 🚀 Installation
|
|
176
|
-
|
|
177
|
-
### Prerequisites
|
|
178
|
-
|
|
179
|
-
- Python 3.8+
|
|
180
|
-
- PostgreSQL 12+
|
|
181
|
-
- Git
|
|
182
|
-
- half-orm (`pip install half-orm`)
|
|
183
|
-
|
|
184
|
-
### Install
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
pip install half-orm-dev
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### Verify Installation
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
half_orm dev --help
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## 📖 Quick Start
|
|
197
|
-
|
|
198
|
-
### Initialize New Project
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
# Create project with database
|
|
202
|
-
half_orm dev init myproject --database mydb
|
|
203
|
-
|
|
204
|
-
# Navigate to project
|
|
205
|
-
cd myproject
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### Clone Existing Project
|
|
209
|
-
|
|
210
|
-
```bash
|
|
211
|
-
# Clone from Git
|
|
212
|
-
half_orm dev clone https://github.com/user/project.git
|
|
213
|
-
|
|
214
|
-
# Navigate to project
|
|
215
|
-
cd project
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
### First Patch (TDD Development)
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
# First, create a release integration branch
|
|
222
|
-
half_orm dev release new minor # Creates ho-release/0.1.0
|
|
223
|
-
|
|
224
|
-
# Now create patch (automatically added to candidates)
|
|
225
|
-
half_orm dev patch create 1-users
|
|
226
|
-
# → Auto-added to 0.1.0-patches.toml as "candidate"
|
|
227
|
-
|
|
228
|
-
# Add schema changes
|
|
229
|
-
echo "CREATE TABLE users (id uuid PRIMARY KEY DEFAULT gen_random_uuid(), username TEXT NOT NULL);" > Patches/1-users/01_users.sql
|
|
230
|
-
|
|
231
|
-
# Apply patch - this generates Python code AND test directory structure
|
|
232
|
-
half_orm dev patch apply
|
|
233
|
-
# → Restores database
|
|
234
|
-
# → Applies SQL patches
|
|
235
|
-
# → Generates Python classes (mydb/public/user.py)
|
|
236
|
-
# → Creates test directory structure (tests/public/user/)
|
|
237
|
-
|
|
238
|
-
# Now write business logic tests (TDD approach)
|
|
239
|
-
# IMPORTANT: Test business logic, NOT ORM operations like ho_insert()
|
|
240
|
-
cat > tests/public/user/test_user_business_logic.py << 'EOF'
|
|
241
|
-
from mydb.public.user import User
|
|
242
|
-
|
|
243
|
-
def test_user_creation_with_valid_data():
|
|
244
|
-
"""Test creating a user with valid business logic."""
|
|
245
|
-
# Assuming you implement a create() business method
|
|
246
|
-
user = User.create(username='alice')
|
|
247
|
-
assert user['username'] == 'alice'
|
|
248
|
-
assert user['id'] is not None
|
|
249
|
-
|
|
250
|
-
def test_user_creation_rejects_empty_username():
|
|
251
|
-
"""Test business validation."""
|
|
252
|
-
# Should raise an error if you implement validation
|
|
253
|
-
with pytest.raises(ValueError):
|
|
254
|
-
User.create(username='')
|
|
255
|
-
EOF
|
|
256
|
-
|
|
257
|
-
# Implement business logic in your User class
|
|
258
|
-
cat >> mydb/public/user.py << 'EOF'
|
|
259
|
-
|
|
260
|
-
@classmethod
|
|
261
|
-
def create(cls, username: str):
|
|
262
|
-
"""Business logic for creating a user."""
|
|
263
|
-
if not username or not username.strip():
|
|
264
|
-
raise ValueError("Username cannot be empty")
|
|
265
|
-
return cls(username=username).ho_insert()
|
|
266
|
-
EOF
|
|
267
|
-
|
|
268
|
-
# Run tests
|
|
269
|
-
pytest
|
|
270
|
-
|
|
271
|
-
# Commit your work
|
|
272
|
-
git add .
|
|
273
|
-
git commit -m "Add users table with business logic and tests"
|
|
274
|
-
|
|
275
|
-
# Close patch - integrate to release (automatic validation runs here!)
|
|
276
|
-
# You must be on the patch branch
|
|
277
|
-
git checkout ho-patch/1-users
|
|
278
|
-
half_orm dev patch merge
|
|
279
|
-
# → Status changed to "staged" in TOML
|
|
280
|
-
# → Tests validated automatically
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
## 💻 Development Workflow
|
|
284
|
-
|
|
285
|
-
### Vision: Git-Flow Release Management
|
|
286
|
-
|
|
287
|
-
The workflow follows a **Git-Flow** approach with dedicated integration branches (`ho-release/X.Y.Z`) that serve as **test sandboxes** before production.
|
|
288
|
-
|
|
289
|
-
**Motivation:**
|
|
290
|
-
- Patches are visible and testable on `ho-release/X.Y.Z` before production
|
|
291
|
-
- `ho-prod` remains stable and contains only validated versions (RC or production)
|
|
292
|
-
- Workflow compatible with GitLab/GitHub (milestones, merge requests, issues)
|
|
293
|
-
- No need to create RC just to make a patch accessible
|
|
294
|
-
|
|
295
|
-
### Complete Cycle: Patch → Release → Deploy
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
299
|
-
│ DEVELOPMENT (ho-release/X.Y.Z branch) │
|
|
300
|
-
├─────────────────────────────────────────────────────────────────┤
|
|
301
|
-
│ 1. release new <level> Create ho-release/X.Y.Z │
|
|
302
|
-
│ 2. patch create <id> Create patch (auto in candidates) │
|
|
303
|
-
│ 3. patch apply Apply & test changes │
|
|
304
|
-
│ 4. patch merge Merge into ho-release (TESTS!) │
|
|
305
|
-
│ (run from ho-patch/<id> branch) │
|
|
306
|
-
│ │
|
|
307
|
-
│ RELEASE PROMOTION │
|
|
308
|
-
│ 5. release promote rc Create RC (tags ho-release branch) │
|
|
309
|
-
│ 6. release promote prod Merge to ho-prod + deploy │
|
|
310
|
-
│ │
|
|
311
|
-
│ PRODUCTION DEPLOYMENT │
|
|
312
|
-
│ 7. update Check available releases │
|
|
313
|
-
│ 8. upgrade Apply on production servers │
|
|
314
|
-
│ │
|
|
315
|
-
│ HOTFIX WORKFLOW (urgent fixes) │
|
|
316
|
-
│ 9. release hotfix Reopen production version │
|
|
317
|
-
│ 10. patch create/close Same workflow on hotfix branch │
|
|
318
|
-
│ 11. release promote hotfix Deploy as vX.Y.Z-hotfixN │
|
|
319
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### Workflow Details
|
|
323
|
-
|
|
324
|
-
#### Concepts: Release Files and Patch States
|
|
325
|
-
|
|
326
|
-
**Release Files:**
|
|
327
|
-
```
|
|
328
|
-
.hop/releases/
|
|
329
|
-
├── 0.17.0-patches.toml # Patches in development (TOML format with status)
|
|
330
|
-
├── 0.17.0-rc1.txt # First Release Candidate (snapshot)
|
|
331
|
-
├── 0.17.0-rc2.txt # Second RC (with fixes, snapshot)
|
|
332
|
-
├── 0.17.0.txt # Production version (snapshot)
|
|
333
|
-
├── 0.17.0-hotfix1.txt # Urgent production fix (snapshot)
|
|
334
|
-
└── 0.18.0-patches.toml # Next release in progress
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
**TOML Patches File Format (0.17.0-patches.toml):**
|
|
338
|
-
```toml
|
|
339
|
-
[patches]
|
|
340
|
-
"1-auth" = "candidate" # In development
|
|
341
|
-
"2-api" = "candidate" # In development
|
|
342
|
-
"3-ui" = "staged" # Integrated, awaiting RC
|
|
343
|
-
"4-tests" = "staged" # Integrated, awaiting RC
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
**Patch States:**
|
|
347
|
-
1. **Candidate**: Assigned to release, in development (`"candidate"` in TOML)
|
|
348
|
-
2. **Staged**: Integrated in `ho-release/X.Y.Z`, awaiting promotion (`"staged"` in TOML)
|
|
349
|
-
3. **Released**: Included in deployed production version (in `X.Y.Z.txt` snapshot)
|
|
350
|
-
|
|
351
|
-
**Analogy with GitLab/GitHub:**
|
|
352
|
-
|
|
353
|
-
| half-orm state | File | GitLab/GitHub |
|
|
354
|
-
|----------------|------|---------------|
|
|
355
|
-
| `release new` | Creates `-patches.toml` | Create milestone |
|
|
356
|
-
| `patch create` (on ho-release) | Adds to TOML as "candidate" | Create issue assigned to milestone |
|
|
357
|
-
| Candidate | `"patch-id" = "candidate"` in TOML | Open issue assigned to milestone |
|
|
358
|
-
| `patch merge` | Changes to `"staged"` in TOML | Merge MR and close issue |
|
|
359
|
-
| Stage | `"patch-id" = "staged"` in TOML | Closed issue in milestone |
|
|
360
|
-
| `release promote rc` | Creates `-rcN.txt` snapshot | Create pre-release |
|
|
361
|
-
| RC | `-rcN.txt` | GitHub pre-release |
|
|
362
|
-
| `release promote prod` | Creates `X.Y.Z.txt`, deletes TOML | Create stable release |
|
|
363
|
-
| Production | `X.Y.Z.txt` | Stable release |
|
|
364
|
-
|
|
365
|
-
#### Step 1: Create a New Release
|
|
366
|
-
|
|
367
|
-
```bash
|
|
368
|
-
half_orm dev release new minor
|
|
369
|
-
# → Detects current production version (e.g., 0.16.0)
|
|
370
|
-
# → Calculates next minor version: 0.17.0
|
|
371
|
-
# → Creates branch ho-release/0.17.0 from ho-prod
|
|
372
|
-
# → Creates .hop/releases/0.17.0-patches.toml (empty TOML file)
|
|
373
|
-
# → Commits and pushes to reserve version globally
|
|
374
|
-
# → Automatically switches to ho-release/0.17.0
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
**Output:**
|
|
378
|
-
```
|
|
379
|
-
✅ Release created successfully!
|
|
380
|
-
|
|
381
|
-
Version: 0.17.0
|
|
382
|
-
Release branch: ho-release/0.17.0
|
|
383
|
-
Patches file: .hop/releases/0.17.0-patches.toml
|
|
384
|
-
|
|
385
|
-
📝 Next steps:
|
|
386
|
-
1. Create patches: half_orm dev patch create <patch_id>
|
|
387
|
-
2. Close patches: git checkout ho-patch/<patch_id> && half_orm dev patch merge
|
|
388
|
-
3. Promote to RC: half_orm dev release promote rc
|
|
389
|
-
|
|
390
|
-
ℹ️ Patches will be merged into ho-release/0.17.0 for integration testing
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
#### Step 2: Create a Candidate Patch
|
|
394
|
-
|
|
395
|
-
**Prerequisites:** Must be on `ho-release/0.17.0` branch
|
|
396
|
-
|
|
397
|
-
```bash
|
|
398
|
-
git checkout ho-release/0.17.0
|
|
399
|
-
half_orm dev patch create 6-feature-x
|
|
400
|
-
# → Auto-detects version 0.17.0 from current branch
|
|
401
|
-
# → Creates ho-patch/6-feature-x from ho-release/0.17.0
|
|
402
|
-
# → Adds 6-feature-x to 0.17.0-patches.toml as "candidate"
|
|
403
|
-
# → Switches to ho-patch/6-feature-x
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
**Output:**
|
|
407
|
-
```
|
|
408
|
-
✓ Created patch branch: ho-patch/6-feature-x
|
|
409
|
-
✓ Created patch directory: Patches/6-feature-x/
|
|
410
|
-
✓ Added to candidates: .hop/releases/0.17.0-patches.toml
|
|
411
|
-
✓ Switched to branch: ho-patch/6-feature-x
|
|
412
|
-
|
|
413
|
-
📝 Next steps:
|
|
414
|
-
1. Add SQL/Python files to Patches/6-feature-x/
|
|
415
|
-
2. Run: half_orm dev patch apply
|
|
416
|
-
3. Test your changes
|
|
417
|
-
4. Run: half_orm dev patch merge (already on ho-patch/6-feature-x)
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
#### Step 3: Develop and Test (TDD Approach)
|
|
421
|
-
|
|
422
|
-
```bash
|
|
423
|
-
# Apply patch (on ho-patch/* branch)
|
|
424
|
-
half_orm dev patch apply
|
|
425
|
-
# → Restores database from production state
|
|
426
|
-
# → Applies all release patches + current patch
|
|
427
|
-
# → Generates Python code
|
|
428
|
-
# → Ready for testing
|
|
429
|
-
|
|
430
|
-
# FIRST: Write tests
|
|
431
|
-
cat > tests/public/users/test_users_feature.py << 'EOF'
|
|
432
|
-
def test_feature():
|
|
433
|
-
# Your test here
|
|
434
|
-
assert True
|
|
435
|
-
EOF
|
|
436
|
-
|
|
437
|
-
# Run tests
|
|
438
|
-
pytest
|
|
439
|
-
|
|
440
|
-
# Commit your work
|
|
441
|
-
git add .
|
|
442
|
-
git commit -m "Implement feature with tests"
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
#### Step 4: Close Patch (Integrate to Release)
|
|
446
|
-
|
|
447
|
-
```bash
|
|
448
|
-
# Ensure you're on the patch branch
|
|
449
|
-
git checkout ho-patch/6-feature-x
|
|
450
|
-
|
|
451
|
-
half_orm dev patch merge
|
|
452
|
-
# Complete workflow:
|
|
453
|
-
# → Detects version from 0.17.0-patches.toml
|
|
454
|
-
# → Validates ho-patch/6-feature-x exists
|
|
455
|
-
# → Creates temporary validation branch
|
|
456
|
-
# → Merges ho-patch/6-feature-x into temp branch
|
|
457
|
-
# → Restores database and applies all patches
|
|
458
|
-
# → Runs tests (pytest)
|
|
459
|
-
# → If PASS: Merges into ho-release/0.17.0
|
|
460
|
-
# → Changes 6-feature-x from "candidate" to "staged" in TOML
|
|
461
|
-
# → Deletes branch ho-patch/6-feature-x
|
|
462
|
-
# → Commits and pushes changes
|
|
463
|
-
# → Notifies other candidate patches to sync
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
**Output:**
|
|
467
|
-
```
|
|
468
|
-
✓ Patch closed successfully!
|
|
469
|
-
|
|
470
|
-
Patches file: .hop/releases/0.17.0-patches.toml
|
|
471
|
-
Patch status: 6-feature-x → "staged"
|
|
472
|
-
Tests passed: ✓
|
|
473
|
-
Notified: 2 active branch(es)
|
|
474
|
-
|
|
475
|
-
📝 Next steps:
|
|
476
|
-
• Other developers: git pull && git merge ho-release/0.17.0
|
|
477
|
-
• Continue development: half_orm dev patch create <next_patch_id>
|
|
478
|
-
• Promote to RC: half_orm dev release promote rc
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
**Important:** `patch merge` replaces the old `patch add` command. The semantics are different:
|
|
482
|
-
- **OLD**: `patch add` = "I add my validated patch to release" (from ho-prod)
|
|
483
|
-
- **NEW**: `patch merge` = "I close my work, it's integrated in release" (merge into ho-release)
|
|
484
|
-
|
|
485
|
-
#### Step 5: Synchronize with Other Integrated Patches
|
|
486
|
-
|
|
487
|
-
When another patch is integrated in the release, candidate patches must update:
|
|
488
|
-
|
|
489
|
-
```bash
|
|
490
|
-
git fetch origin
|
|
491
|
-
git merge origin/ho-release/0.17.0
|
|
492
|
-
```
|
|
493
|
-
|
|
494
|
-
#### Step 6: Promote to RC
|
|
495
|
-
|
|
496
|
-
**Sequentiality Rule:** Only the **smallest version** in preparation can be promoted to RC. This guarantees sequential release order.
|
|
497
|
-
|
|
498
|
-
**Example:** If releases `0.17.1`, `0.18.0` and `1.0.0` are in preparation, only `0.17.1` can be promoted to RC.
|
|
499
|
-
|
|
500
|
-
```bash
|
|
501
|
-
half_orm dev release promote rc
|
|
502
|
-
# Complete workflow:
|
|
503
|
-
# → Auto-detects smallest version with -patches.toml containing staged patches
|
|
504
|
-
# → Verifies it's sequential (follows last prod/RC)
|
|
505
|
-
# → Automatically switches to ho-release/X.Y.Z
|
|
506
|
-
# → Finds next RC number (rc1, rc2, etc.)
|
|
507
|
-
# → Creates tag vX.Y.Z-rc1 on ho-release/X.Y.Z (NOT on ho-prod!)
|
|
508
|
-
# → Creates snapshot .hop/releases/X.Y.Z-rc1.txt with staged patches
|
|
509
|
-
# → Resets staged patches to candidates in TOML for potential fixes
|
|
510
|
-
# → Commits and pushes
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
**Output:**
|
|
514
|
-
```
|
|
515
|
-
✓ Success!
|
|
516
|
-
|
|
517
|
-
Version: 0.17.0
|
|
518
|
-
Tag: v0.17.0-rc1
|
|
519
|
-
Branch: ho-release/0.17.0
|
|
520
|
-
|
|
521
|
-
📝 Next steps:
|
|
522
|
-
• Test RC thoroughly
|
|
523
|
-
• Deploy to production: half_orm dev release promote prod
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
**Important Notes:**
|
|
527
|
-
- Tag is created on `ho-release/0.17.0`, **NOT on `ho-prod`**
|
|
528
|
-
- Command **auto-detects** which version to promote (smallest)
|
|
529
|
-
- Cannot "skip" a version: if 0.17.0 isn't in prod, can't promote 0.18.0
|
|
530
|
-
|
|
531
|
-
#### Step 7: Promote to Production
|
|
532
|
-
|
|
533
|
-
**Sequentiality Rule:** Only the **smallest version in preparation** (with a stage file) can be promoted to production.
|
|
534
|
-
|
|
535
|
-
```bash
|
|
536
|
-
half_orm dev release promote prod
|
|
537
|
-
# Complete workflow:
|
|
538
|
-
# → Auto-detects smallest version with -patches.toml containing staged patches
|
|
539
|
-
# → Verifies strict sequentiality (0.17.0 must follow last prod)
|
|
540
|
-
# → Automatically switches to ho-prod
|
|
541
|
-
# → Merges ho-release/0.17.0 into ho-prod (integrates patch code)
|
|
542
|
-
# → Restores database and applies all staged patches from TOML
|
|
543
|
-
# → Generates .hop/model/schema-0.17.0.sql and metadata-0.17.0.sql
|
|
544
|
-
# → Updates symlink .hop/model/schema.sql → schema-0.17.0.sql
|
|
545
|
-
# → Creates .hop/releases/0.17.0.txt snapshot with all patches
|
|
546
|
-
# → Deletes .hop/releases/0.17.0-patches.toml (no longer needed)
|
|
547
|
-
# → Preserves .hop/releases/0.17.0-rc*.txt for history (if any)
|
|
548
|
-
# → Creates tag v0.17.0 on ho-prod
|
|
549
|
-
# → Deletes branch ho-release/0.17.0 (mission complete)
|
|
550
|
-
# → Commits and pushes
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
**Output:**
|
|
554
|
-
```
|
|
555
|
-
✓ Success!
|
|
556
|
-
|
|
557
|
-
Version: 0.17.0
|
|
558
|
-
Tag: v0.17.0
|
|
559
|
-
Branches deleted: ho-release/0.17.0
|
|
560
|
-
|
|
561
|
-
📝 Next steps:
|
|
562
|
-
• Deploy to production servers
|
|
563
|
-
• Start next cycle: half_orm dev release new minor
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
**Important Notes:**
|
|
567
|
-
- This is when patch code is **actually merged into `ho-prod`**, not before
|
|
568
|
-
- Command **auto-detects** smallest version with stage file
|
|
569
|
-
- **Always uses stage file**: RC files are preserved for history but not used for promotion
|
|
570
|
-
- **RC is optional**: Can promote directly from stage to production without creating RC
|
|
571
|
-
- Sequentiality is **strictly enforced**: impossible to promote 0.18.0 if 0.17.0 isn't already in prod
|
|
572
|
-
|
|
573
|
-
#### Step 8/9: Production Upgrade
|
|
574
|
-
|
|
575
|
-
```bash
|
|
576
|
-
# On production server (automatically pulls from origin)
|
|
577
|
-
# Check available releases
|
|
578
|
-
half_orm dev update
|
|
579
|
-
|
|
580
|
-
# Apply upgrade (with automatic backup and git pull)
|
|
581
|
-
half_orm dev upgrade
|
|
582
|
-
```
|
|
583
|
-
|
|
584
|
-
#### Hotfix Workflow (Urgent Production Fixes)
|
|
585
|
-
|
|
586
|
-
**Scenario:** Critical bug discovered in production (v0.17.0) while new release (v0.18.0) is already in development. Production needs fixing **immediately** without waiting for v0.18.0.
|
|
587
|
-
|
|
588
|
-
**Step 1: Reopen Production Version**
|
|
589
|
-
|
|
590
|
-
```bash
|
|
591
|
-
half_orm dev release hotfix
|
|
592
|
-
# Workflow:
|
|
593
|
-
# → Detects production version from model/schema.sql (e.g., 0.17.0)
|
|
594
|
-
# → Verifies tag v0.17.0 exists
|
|
595
|
-
# → Reopens branch ho-release/0.17.0 from tag v0.17.0
|
|
596
|
-
# → Automatically switches to ho-release/0.17.0
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
**Output:**
|
|
600
|
-
```
|
|
601
|
-
✓ Reopened ho-release/0.17.0 from v0.17.0
|
|
602
|
-
✓ Ready for hotfix patches
|
|
603
|
-
|
|
604
|
-
📝 Next steps:
|
|
605
|
-
1. half_orm dev patch create <patch_id>
|
|
606
|
-
2. git checkout ho-patch/<patch_id> && half_orm dev patch merge
|
|
607
|
-
3. half_orm dev release promote hotfix
|
|
608
|
-
```
|
|
609
|
-
|
|
610
|
-
**Important Note:** This is a **break from sequential workflow** as we now have two active release branches simultaneously (`ho-release/0.17.0` and `ho-release/0.18.0`).
|
|
611
|
-
|
|
612
|
-
**Step 2: Create and Integrate Hotfix Patch**
|
|
613
|
-
|
|
614
|
-
The workflow is **identical** to normal workflow:
|
|
615
|
-
|
|
616
|
-
```bash
|
|
617
|
-
# On ho-release/0.17.0
|
|
618
|
-
half_orm dev patch create 999-critical-security-fix
|
|
619
|
-
# ... develop ...
|
|
620
|
-
half_orm dev patch apply
|
|
621
|
-
# ... test ...
|
|
622
|
-
git checkout ho-patch/999-critical-security-fix
|
|
623
|
-
half_orm dev patch merge
|
|
624
|
-
```
|
|
625
|
-
|
|
626
|
-
**Step 3: Promote Hotfix to Production**
|
|
627
|
-
|
|
628
|
-
**Important:** Cannot use `promote prod` as tag `v0.17.0` already exists!
|
|
629
|
-
|
|
630
|
-
```bash
|
|
631
|
-
git checkout ho-prod
|
|
632
|
-
half_orm dev release promote hotfix
|
|
633
|
-
# Hotfix-specific workflow:
|
|
634
|
-
# → Detects hotfix context (tag vX.Y.Z already exists)
|
|
635
|
-
# → Finds next hotfix number (hotfix1, hotfix2, etc.)
|
|
636
|
-
# → Merges ho-release/0.17.0 into ho-prod
|
|
637
|
-
# → Generates model/schema-0.17.0-hotfix1.sql and metadata-0.17.0-hotfix1.sql
|
|
638
|
-
# → Updates symlink model/schema.sql → schema-0.17.0-hotfix1.sql
|
|
639
|
-
# → Creates releases/0.17.0-hotfix1.txt with patch list
|
|
640
|
-
# → Creates tag v0.17.0-hotfix1 on ho-prod
|
|
641
|
-
# → Deletes branch ho-release/0.17.0
|
|
642
|
-
# → Commits and pushes
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
**Output:**
|
|
646
|
-
```
|
|
647
|
-
✓ Hotfix deployed!
|
|
648
|
-
|
|
649
|
-
Version: 0.17.0-hotfix1
|
|
650
|
-
Tag: v0.17.0-hotfix1
|
|
651
|
-
Patches: 999-critical-security-fix
|
|
652
|
-
|
|
653
|
-
📝 Next steps:
|
|
654
|
-
• Deploy to production servers immediately
|
|
655
|
-
• Sync other releases: git checkout ho-release/0.18.0 && git merge ho-prod
|
|
656
|
-
```
|
|
657
|
-
|
|
658
|
-
**Step 4: Sync Other In-Progress Releases**
|
|
659
|
-
|
|
660
|
-
If a release is in development (e.g., 0.18.0), it **must** integrate the hotfix:
|
|
661
|
-
|
|
662
|
-
```bash
|
|
663
|
-
git checkout ho-release/0.18.0
|
|
664
|
-
git merge ho-prod
|
|
665
|
-
# Resolve any conflicts
|
|
666
|
-
git push origin ho-release/0.18.0
|
|
667
|
-
```
|
|
668
|
-
|
|
669
|
-
This guarantees the bugfix won't be lost in the next release.
|
|
670
|
-
|
|
671
|
-
## 📖 Command Reference
|
|
672
|
-
|
|
673
|
-
**NOTE**: use `half_orm dev command --help` for detailed help on each command
|
|
674
|
-
|
|
675
|
-
### Init & Clone
|
|
676
|
-
|
|
677
|
-
```bash
|
|
678
|
-
# Create new project
|
|
679
|
-
half_orm dev init <package_name> --database <db_name>
|
|
680
|
-
|
|
681
|
-
# Clone existing project (automatically pulls from origin)
|
|
682
|
-
half_orm dev clone <git_origin>
|
|
683
|
-
```
|
|
684
|
-
|
|
685
|
-
### Patch Commands
|
|
686
|
-
|
|
687
|
-
```bash
|
|
688
|
-
# Create new patch (must be on ho-release/* branch)
|
|
689
|
-
half_orm dev patch create <patch_id> [-d "description"] [--before <other_patch_id>]
|
|
690
|
-
# → Patches are ordered in the TOML file (insertion order = application order)
|
|
691
|
-
# → Use --before to insert a patch before an existing one
|
|
692
|
-
# → Order matters: patches are applied sequentially
|
|
693
|
-
|
|
694
|
-
# Apply current patch (must be on ho-patch/* branch)
|
|
695
|
-
half_orm dev patch apply
|
|
696
|
-
|
|
697
|
-
# Close patch - integrate to release (AUTOMATIC VALIDATION!)
|
|
698
|
-
# Must be on ho-patch/* branch
|
|
699
|
-
half_orm dev patch merge
|
|
700
|
-
```
|
|
701
|
-
|
|
702
|
-
**Patch Ordering:**
|
|
703
|
-
- Patches are stored in the TOML file in **insertion order**
|
|
704
|
-
- This order determines the **application sequence** (critical for dependencies)
|
|
705
|
-
- Use `--before` option to insert a patch at a specific position
|
|
706
|
-
- Example: If patch B depends on patch A, ensure A is ordered before B
|
|
707
|
-
|
|
708
|
-
### Release Commands
|
|
709
|
-
|
|
710
|
-
```bash
|
|
711
|
-
# Prepare next release (patch/minor/major)
|
|
712
|
-
# Creates ho-release/X.Y.Z branch + candidates.txt + stage.txt
|
|
713
|
-
half_orm dev release new patch
|
|
714
|
-
half_orm dev release new minor
|
|
715
|
-
half_orm dev release new major
|
|
716
|
-
|
|
717
|
-
# Promote stage to RC (automatically pushes)
|
|
718
|
-
# Tags ho-release/X.Y.Z, renames stage → rc
|
|
719
|
-
half_orm dev release promote rc
|
|
720
|
-
|
|
721
|
-
# Promote RC to production (automatically pushes)
|
|
722
|
-
# Merges ho-release/X.Y.Z → ho-prod, creates tag
|
|
723
|
-
half_orm dev release promote prod
|
|
724
|
-
|
|
725
|
-
# Reopen production version for hotfix
|
|
726
|
-
half_orm dev release hotfix
|
|
727
|
-
|
|
728
|
-
# Promote hotfix to production
|
|
729
|
-
half_orm dev release promote hotfix
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
### Production Commands
|
|
733
|
-
|
|
734
|
-
```bash
|
|
735
|
-
# Fetch available releases (automatically pulls from origin)
|
|
736
|
-
half_orm dev update
|
|
737
|
-
|
|
738
|
-
# Apply releases to production (automatically pulls from origin)
|
|
739
|
-
half_orm dev upgrade [--to-release X.Y.Z]
|
|
740
|
-
|
|
741
|
-
# Dry run (simulate upgrade)
|
|
742
|
-
half_orm dev upgrade --dry-run
|
|
743
|
-
```
|
|
744
|
-
|
|
745
|
-
## 🎯 Common Patterns
|
|
746
|
-
|
|
747
|
-
### Pattern 1: Planned Development with Integration Branch
|
|
748
|
-
|
|
749
|
-
```bash
|
|
750
|
-
# Start by creating release integration branch
|
|
751
|
-
half_orm dev release new minor # Creates ho-release/0.17.0
|
|
752
|
-
|
|
753
|
-
# Now on ho-release/0.17.0, create patch
|
|
754
|
-
half_orm dev patch create 123-add-users
|
|
755
|
-
# → Auto-added to 0.17.0-candidates.txt
|
|
756
|
-
|
|
757
|
-
# Add SQL/Python files
|
|
758
|
-
echo "CREATE TABLE users (id SERIAL PRIMARY KEY, username TEXT);" > Patches/123-add-users/01_users.sql
|
|
759
|
-
|
|
760
|
-
# Write tests
|
|
761
|
-
cat > tests/public/test_public_users.py << 'EOF'
|
|
762
|
-
def test_user_creation():
|
|
763
|
-
user = User(username='alice').ho_insert()
|
|
764
|
-
assert user['username'] == 'alice'
|
|
765
|
-
EOF
|
|
766
|
-
|
|
767
|
-
# Apply and test
|
|
768
|
-
half_orm dev patch apply
|
|
769
|
-
pytest # Tests should pass
|
|
770
|
-
|
|
771
|
-
# Commit your work
|
|
772
|
-
git add .
|
|
773
|
-
git commit -m "Implement users table with tests"
|
|
774
|
-
|
|
775
|
-
# Close patch - integrate to release (tests validated automatically!)
|
|
776
|
-
git checkout ho-patch/123-add-users
|
|
777
|
-
half_orm dev patch merge
|
|
778
|
-
# → Status changed to "staged" in TOML
|
|
779
|
-
# → Tests run automatically before integration
|
|
780
|
-
```
|
|
781
|
-
|
|
782
|
-
### Pattern 2: Team Collaboration on Same Release
|
|
783
|
-
|
|
784
|
-
```bash
|
|
785
|
-
# Integration Manager: Create release
|
|
786
|
-
half_orm dev release new minor # Creates ho-release/0.17.0
|
|
787
|
-
|
|
788
|
-
# Developer A: Working on feature
|
|
789
|
-
git checkout ho-release/0.17.0
|
|
790
|
-
half_orm dev patch create 456-dashboard
|
|
791
|
-
# → Added to 0.17.0-patches.toml as candidate
|
|
792
|
-
# ... develop and test ...
|
|
793
|
-
git checkout ho-patch/456-dashboard
|
|
794
|
-
half_orm dev patch merge
|
|
795
|
-
# → Status changed to "staged" in TOML
|
|
796
|
-
|
|
797
|
-
# Developer B: Must sync with A's changes first
|
|
798
|
-
git checkout ho-release/0.17.0
|
|
799
|
-
git pull origin ho-release/0.17.0 # Get A's integrated changes
|
|
800
|
-
|
|
801
|
-
# Then create patch
|
|
802
|
-
half_orm dev patch create 789-reports
|
|
803
|
-
# → Added to 0.17.0-patches.toml as candidate
|
|
804
|
-
# ... develop and test ...
|
|
805
|
-
git merge origin/ho-release/0.17.0 # Sync again before closing
|
|
806
|
-
git checkout ho-patch/789-reports
|
|
807
|
-
half_orm dev patch merge
|
|
808
|
-
# → Tests run with 456 + 789 together!
|
|
809
|
-
|
|
810
|
-
# All patches validated together in stage
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
### Pattern 3: Parallel Development of Different Releases
|
|
814
|
-
|
|
815
|
-
```bash
|
|
816
|
-
# Parallel development of different versions
|
|
817
|
-
# 1. Create multiple release branches
|
|
818
|
-
half_orm dev release new minor # Creates 0.18.0
|
|
819
|
-
half_orm dev release new patch # Creates 0.17.1
|
|
820
|
-
|
|
821
|
-
# 2. Add patches to specific versions
|
|
822
|
-
git checkout ho-release/0.17.1
|
|
823
|
-
half_orm dev patch create 123-hotfix
|
|
824
|
-
git checkout ho-patch/123-hotfix
|
|
825
|
-
half_orm dev patch merge
|
|
826
|
-
|
|
827
|
-
git checkout ho-release/0.18.0
|
|
828
|
-
half_orm dev patch create 456-feature
|
|
829
|
-
git checkout ho-patch/456-feature
|
|
830
|
-
half_orm dev patch merge
|
|
831
|
-
|
|
832
|
-
# 3. Sequential promotion (must promote 0.17.1 before 0.18.0)
|
|
833
|
-
half_orm dev release promote rc # Auto-promotes 0.17.1 (smallest)
|
|
834
|
-
# ... validate ...
|
|
835
|
-
half_orm dev release promote prod # 0.17.1 to production
|
|
836
|
-
# Now can promote 0.18.0
|
|
837
|
-
half_orm dev release promote rc # Auto-promotes 0.18.0
|
|
838
|
-
```
|
|
839
|
-
|
|
840
|
-
### Pattern 4: Incremental RC (Fix Issues)
|
|
841
|
-
|
|
842
|
-
```bash
|
|
843
|
-
# RC1 has issues discovered in testing
|
|
844
|
-
half_orm dev release promote rc # Creates 0.17.0-rc1
|
|
845
|
-
# → Creates rc1.txt snapshot
|
|
846
|
-
# → Staged patches remain in TOML
|
|
847
|
-
|
|
848
|
-
# Found bug in testing, create fix patch
|
|
849
|
-
git checkout ho-release/0.17.0 # Back to integration branch
|
|
850
|
-
half_orm dev patch create 999-rc1-fix
|
|
851
|
-
# → Added to 0.17.0-patches.toml as candidate
|
|
852
|
-
half_orm dev patch apply
|
|
853
|
-
# ... fix and test ...
|
|
854
|
-
|
|
855
|
-
# Close patch - changes status to staged
|
|
856
|
-
git checkout ho-patch/999-rc1-fix
|
|
857
|
-
half_orm dev patch merge
|
|
858
|
-
# → Status changed to "staged" in TOML
|
|
859
|
-
# → Validated automatically
|
|
860
|
-
|
|
861
|
-
# Promote again (creates rc2, automatically pushes)
|
|
862
|
-
half_orm dev release promote rc # Creates 0.17.0-rc2
|
|
863
|
-
# → Creates rc2.txt snapshot with all staged patches
|
|
864
|
-
# → Staged patches remain in TOML
|
|
865
|
-
|
|
866
|
-
# Repeat until RC passes all validation
|
|
867
|
-
```
|
|
868
|
-
|
|
869
|
-
### Pattern 5: Hotfix on Production
|
|
870
|
-
|
|
871
|
-
```bash
|
|
872
|
-
# Bug discovered in production (v0.17.0)
|
|
873
|
-
# New release (v0.18.0) already in development
|
|
874
|
-
|
|
875
|
-
# Reopen production version
|
|
876
|
-
half_orm dev release hotfix
|
|
877
|
-
# → Reopens ho-release/0.17.0 from tag v0.17.0
|
|
878
|
-
# → Creates 0.17.0-patches.toml for hotfix patches
|
|
879
|
-
|
|
880
|
-
# Same workflow as normal patch
|
|
881
|
-
half_orm dev patch create 999-critical-fix
|
|
882
|
-
# → Added to 0.17.0-patches.toml as candidate (with # HOTFIX marker)
|
|
883
|
-
half_orm dev patch apply
|
|
884
|
-
# ... fix and test ...
|
|
885
|
-
git checkout ho-patch/999-critical-fix
|
|
886
|
-
half_orm dev patch merge
|
|
887
|
-
# → Status changed to "staged" in TOML
|
|
888
|
-
|
|
889
|
-
# Promote as hotfix
|
|
890
|
-
git checkout ho-prod
|
|
891
|
-
half_orm dev release promote hotfix
|
|
892
|
-
# → Creates v0.17.0-hotfix1 tag
|
|
893
|
-
# → Creates 0.17.0-hotfix1.txt file
|
|
894
|
-
# → Merges into ho-prod
|
|
895
|
-
|
|
896
|
-
# Sync other in-progress releases
|
|
897
|
-
git checkout ho-release/0.18.0
|
|
898
|
-
git merge ho-prod # Integrate the hotfix
|
|
899
|
-
```
|
|
900
|
-
|
|
901
|
-
### Pattern 6: Production Deployment
|
|
902
|
-
|
|
903
|
-
```bash
|
|
904
|
-
# On production server (commands automatically pull from origin)
|
|
905
|
-
|
|
906
|
-
# Check available releases
|
|
907
|
-
half_orm dev update
|
|
908
|
-
|
|
909
|
-
# Simulate upgrade
|
|
910
|
-
half_orm dev upgrade --dry-run
|
|
911
|
-
|
|
912
|
-
# Apply upgrade (creates backup automatically, pulls from origin)
|
|
913
|
-
half_orm dev upgrade
|
|
914
|
-
|
|
915
|
-
# Or apply specific version
|
|
916
|
-
half_orm dev upgrade --to-release 1.4.0
|
|
917
|
-
```
|
|
918
|
-
|
|
919
|
-
## 🏗️ Architecture
|
|
920
|
-
|
|
921
|
-
### Branch Strategy
|
|
922
|
-
|
|
923
|
-
```
|
|
924
|
-
ho-prod (main production)
|
|
925
|
-
│
|
|
926
|
-
├── ho-release/0.17.0 (integration branch, deleted after prod promotion)
|
|
927
|
-
│ ├── ho-patch/6-feature-x (temporary, deleted after close)
|
|
928
|
-
│ ├── ho-patch/7-bugfix-y (temporary, deleted after close)
|
|
929
|
-
│ └── ho-patch/8-auth-z (temporary, deleted after close)
|
|
930
|
-
│
|
|
931
|
-
└── ho-release/0.18.0 (next version in parallel)
|
|
932
|
-
└── ho-patch/10-new-api (temporary, deleted after close)
|
|
933
|
-
```
|
|
934
|
-
|
|
935
|
-
**Branch types:**
|
|
936
|
-
- **ho-prod**: Main production branch (source of truth, stable)
|
|
937
|
-
- **ho-release/X.Y.Z**: Integration branch for version X.Y.Z (temporary, deleted after prod promotion)
|
|
938
|
-
- **ho-patch/\***: Patch development branches created from ho-release/* (temporary, deleted after close)
|
|
939
|
-
|
|
940
|
-
**Branch Lifecycle:**
|
|
941
|
-
1. `release new` creates `ho-release/X.Y.Z` from `ho-prod`
|
|
942
|
-
2. `patch create` creates `ho-patch/ID` from `ho-release/X.Y.Z`
|
|
943
|
-
3. `patch merge` merges `ho-patch/ID` into `ho-release/X.Y.Z` and deletes `ho-patch/ID`
|
|
944
|
-
4. `release promote prod` merges `ho-release/X.Y.Z` into `ho-prod` and deletes `ho-release/X.Y.Z`
|
|
945
|
-
|
|
946
|
-
**Exception - Hotfix Branches:**
|
|
947
|
-
- `release hotfix` reopens `ho-release/X.Y.Z` from existing tag `vX.Y.Z`
|
|
948
|
-
- Multiple `ho-release/*` branches can exist temporarily (prod version + dev version)
|
|
949
|
-
- After `promote hotfix`, the hotfix branch is deleted
|
|
950
|
-
|
|
951
|
-
### Release Files
|
|
952
|
-
|
|
953
|
-
```
|
|
954
|
-
.hop/releases/
|
|
955
|
-
├── 0.17.0-patches.toml (patches with status: candidate/staged, mutable)
|
|
956
|
-
├── 0.17.0-rc1.txt (first RC snapshot, immutable)
|
|
957
|
-
├── 0.17.0-rc2.txt (fixes from rc1 snapshot, immutable)
|
|
958
|
-
├── 0.17.0.txt (production snapshot, immutable)
|
|
959
|
-
├── 0.17.0-hotfix1.txt (hotfix on production snapshot, immutable)
|
|
960
|
-
└── 0.18.0-patches.toml (next version patches)
|
|
961
|
-
```
|
|
962
|
-
|
|
963
|
-
**File lifecycle (normal workflow):**
|
|
964
|
-
```
|
|
965
|
-
patch create → X.Y.Z-patches.toml (patch added as "candidate")
|
|
966
|
-
↓
|
|
967
|
-
patch merge → X.Y.Z-patches.toml (status changed to "staged")
|
|
968
|
-
↓
|
|
969
|
-
├─→ promote rc → X.Y.Z-rc1.txt snapshot created
|
|
970
|
-
│ staged patches reset to candidates
|
|
971
|
-
│ ↓
|
|
972
|
-
│ promote rc → X.Y.Z-rc2.txt (if fixes needed)
|
|
973
|
-
│
|
|
974
|
-
└─→ promote prod → X.Y.Z.txt snapshot created
|
|
975
|
-
X.Y.Z-patches.toml deleted
|
|
976
|
-
```
|
|
977
|
-
|
|
978
|
-
**Key point:** `promote prod` creates a `.txt` snapshot from staged patches in the TOML file, then deletes the TOML file. RC files are kept for history only.
|
|
979
|
-
|
|
980
|
-
**File lifecycle (hotfix workflow):**
|
|
981
|
-
```
|
|
982
|
-
release hotfix → Reopens X.Y.Z-patches.toml
|
|
983
|
-
↓
|
|
984
|
-
patch merge → X.Y.Z-patches.toml (adds hotfix patches as staged)
|
|
985
|
-
↓
|
|
986
|
-
promote hotfix → X.Y.Z-hotfixN.txt (snapshot created, TOML deleted)
|
|
987
|
-
```
|
|
988
|
-
|
|
989
|
-
**TOML file format:**
|
|
990
|
-
```toml
|
|
991
|
-
[patches]
|
|
992
|
-
"patch-id" = "candidate" # or "staged"
|
|
993
|
-
```
|
|
994
|
-
|
|
995
|
-
**TXT snapshot format (RC/prod/hotfix):**
|
|
996
|
-
- Each line contains a patch ID
|
|
997
|
-
- Lines starting with `#` are comments
|
|
998
|
-
- Empty lines are ignored
|
|
999
|
-
|
|
1000
|
-
### Patch Directory Structure
|
|
1001
|
-
|
|
1002
|
-
```
|
|
1003
|
-
Patches/
|
|
1004
|
-
└── 123-feature-name/
|
|
1005
|
-
├── README.md (auto-generated description)
|
|
1006
|
-
├── 01_schema.sql (schema changes)
|
|
1007
|
-
├── 02_data.sql (data migrations)
|
|
1008
|
-
└── 03_indexes.sql (performance optimizations)
|
|
1009
|
-
```
|
|
1010
|
-
|
|
1011
|
-
**Execution order:** Lexicographic (01, 02, 03...)
|
|
1012
|
-
|
|
1013
|
-
### Semantic Versioning
|
|
1014
|
-
|
|
1015
|
-
```
|
|
1016
|
-
MAJOR.MINOR.PATCH
|
|
1017
|
-
│ │ │
|
|
1018
|
-
│ │ └── Bug fixes, minor changes (1.3.5 → 1.3.6)
|
|
1019
|
-
│ └──────── New features, backward compatible (1.3.5 → 1.4.0)
|
|
1020
|
-
└────────────── Breaking changes (1.3.5 → 2.0.0)
|
|
1021
|
-
```
|
|
1022
|
-
|
|
1023
|
-
### Workflow Rules
|
|
1024
|
-
|
|
1025
|
-
1. **Sequential releases**: Must promote 0.17.0 before 0.17.1 or 0.18.0
|
|
1026
|
-
2. **Auto-detection**: Commands automatically detect smallest version to promote
|
|
1027
|
-
3. **Patch origin**: Must create patches from `ho-release/*` branch, not `ho-prod`
|
|
1028
|
-
4. **Patch lifecycle**: new → candidates → close → stage → rc → prod
|
|
1029
|
-
5. **Branch cleanup**:
|
|
1030
|
-
- `patch merge` deletes `ho-patch/*` branch
|
|
1031
|
-
- `promote prod` deletes `ho-release/*` branch
|
|
1032
|
-
6. **Database restore**: `patch apply` always restores from production state
|
|
1033
|
-
7. **Immutable releases**: RC and production files never modified
|
|
1034
|
-
8. **Automatic Git operations**: Push/pull handled by commands automatically
|
|
1035
|
-
9. **⚠️ SYSTEMATIC TEST VALIDATION**: Tests run before integration (in `patch merge`)
|
|
1036
|
-
10. **Hotfix exception**: Can reopen production version while other releases in progress
|
|
1037
|
-
11. **# HOTFIX marker**: Candidates file marked with `# HOTFIX` comment for hotfix releases
|
|
1038
|
-
|
|
1039
|
-
## 🔧 Troubleshooting
|
|
1040
|
-
|
|
1041
|
-
### Error: "Must be on ho-release/* branch"
|
|
1042
|
-
|
|
1043
|
-
```bash
|
|
1044
|
-
# Solution: Create release or switch to release branch
|
|
1045
|
-
half_orm dev release new minor
|
|
1046
|
-
# or
|
|
1047
|
-
git checkout ho-release/0.17.0
|
|
1048
|
-
```
|
|
1049
|
-
|
|
1050
|
-
### Error: "Must be on ho-patch/* branch"
|
|
1051
|
-
|
|
1052
|
-
```bash
|
|
1053
|
-
# Solution: Create or switch to patch branch
|
|
1054
|
-
# First ensure you're on ho-release/*
|
|
1055
|
-
git checkout ho-release/0.17.0
|
|
1056
|
-
half_orm dev patch create <patch_id>
|
|
1057
|
-
# or
|
|
1058
|
-
git checkout ho-patch/<patch_id>
|
|
1059
|
-
```
|
|
1060
|
-
|
|
1061
|
-
### Error: "Patch not found in candidates file"
|
|
1062
|
-
|
|
1063
|
-
```bash
|
|
1064
|
-
# Solution: Patch must be created from ho-release/* branch
|
|
1065
|
-
# to be automatically added to candidates
|
|
1066
|
-
git checkout ho-release/0.17.0
|
|
1067
|
-
half_orm dev patch create <patch_id>
|
|
1068
|
-
```
|
|
1069
|
-
|
|
1070
|
-
### Error: "Repository is not clean"
|
|
1071
|
-
|
|
1072
|
-
```bash
|
|
1073
|
-
# Solution: Commit or stash changes
|
|
1074
|
-
git status
|
|
1075
|
-
git add .
|
|
1076
|
-
git commit -m "Your message"
|
|
1077
|
-
# or
|
|
1078
|
-
git stash
|
|
1079
|
-
```
|
|
1080
|
-
|
|
1081
|
-
### Error: "Repository not synced with origin"
|
|
1082
|
-
|
|
1083
|
-
```bash
|
|
1084
|
-
# This should not happen - commands handle git operations automatically
|
|
1085
|
-
# If it does occur:
|
|
1086
|
-
git pull origin ho-prod
|
|
1087
|
-
```
|
|
1088
|
-
|
|
1089
|
-
### Error: "No stage releases found"
|
|
1090
|
-
|
|
1091
|
-
```bash
|
|
1092
|
-
# Solution: Prepare a release first
|
|
1093
|
-
half_orm dev release new patch
|
|
1094
|
-
```
|
|
1095
|
-
|
|
1096
|
-
### Error: "Active RC exists"
|
|
1097
|
-
|
|
1098
|
-
```bash
|
|
1099
|
-
# Cannot promote different version while RC exists
|
|
1100
|
-
# Solution: Promote current RC to production first
|
|
1101
|
-
half_orm dev release promote prod
|
|
1102
|
-
|
|
1103
|
-
# Then promote your stage
|
|
1104
|
-
half_orm dev release promote rc
|
|
1105
|
-
```
|
|
1106
|
-
|
|
1107
|
-
### Error: "Tests failed for patch integration"
|
|
1108
|
-
|
|
1109
|
-
```bash
|
|
1110
|
-
# Tests ran on temp-valid branch and failed
|
|
1111
|
-
# Solution: Fix your tests or code
|
|
1112
|
-
half_orm dev patch apply # Test locally first
|
|
1113
|
-
pytest # Verify tests pass
|
|
1114
|
-
|
|
1115
|
-
# Fix issues in your patch
|
|
1116
|
-
vim Patches/123-feature/01_schema.sql
|
|
1117
|
-
vim tests/test_feature.py
|
|
1118
|
-
|
|
1119
|
-
# Try again
|
|
1120
|
-
git checkout ho-patch/123-feature
|
|
1121
|
-
half_orm dev patch merge # Tests will run again
|
|
1122
|
-
```
|
|
1123
|
-
|
|
1124
|
-
### Patch apply failed (SQL error)
|
|
1125
|
-
|
|
1126
|
-
```bash
|
|
1127
|
-
# Database automatically rolled back
|
|
1128
|
-
# Solution: Fix SQL files and re-apply
|
|
1129
|
-
vim Patches/123-feature/01_schema.sql
|
|
1130
|
-
half_orm dev patch apply
|
|
1131
|
-
```
|
|
1132
|
-
|
|
1133
|
-
### Lost after conflicts
|
|
1134
|
-
|
|
1135
|
-
```bash
|
|
1136
|
-
# View repository state
|
|
1137
|
-
git status
|
|
1138
|
-
git log --oneline -10
|
|
1139
|
-
|
|
1140
|
-
# View current branch
|
|
1141
|
-
git branch
|
|
1142
|
-
|
|
1143
|
-
# View remote branches
|
|
1144
|
-
git branch -r
|
|
1145
|
-
|
|
1146
|
-
# Return to safe state
|
|
1147
|
-
git checkout ho-prod
|
|
1148
|
-
# Commands handle git pull automatically
|
|
1149
|
-
```
|
|
1150
|
-
|
|
1151
|
-
## 🎓 Best Practices
|
|
1152
|
-
|
|
1153
|
-
### Patch Development
|
|
1154
|
-
|
|
1155
|
-
✅ **DO:**
|
|
1156
|
-
- **Write tests FIRST** (TDD approach)
|
|
1157
|
-
- Start with exploratory patches (no release needed initially)
|
|
1158
|
-
- Use descriptive patch IDs: `123-add-user-authentication`
|
|
1159
|
-
- Test patches thoroughly before adding to release
|
|
1160
|
-
- Keep patches focused (one feature per patch)
|
|
1161
|
-
- Commit generated code with meaningful messages
|
|
1162
|
-
- Create release when patches are ready to integrate
|
|
1163
|
-
- Run `pytest` locally before `patch merge`
|
|
1164
|
-
|
|
1165
|
-
❌ **DON'T:**
|
|
1166
|
-
- Mix multiple features in one patch
|
|
1167
|
-
- Skip `patch apply` validation
|
|
1168
|
-
- Add untested patches to release
|
|
1169
|
-
- Modify files outside your patch directory
|
|
1170
|
-
- Worry about git push/pull (commands handle it automatically)
|
|
1171
|
-
- Skip writing tests (validation will fail anyway)
|
|
1172
|
-
|
|
1173
|
-
### Release Management
|
|
1174
|
-
|
|
1175
|
-
✅ **DO:**
|
|
1176
|
-
- Prepare releases when patches are ready to integrate
|
|
1177
|
-
- Trust the automatic test validation system
|
|
1178
|
-
- Test RC thoroughly before promoting to production
|
|
1179
|
-
- Use semantic versioning consistently
|
|
1180
|
-
- Document breaking changes in commit messages
|
|
1181
|
-
- Let commands handle git operations automatically
|
|
1182
|
-
- Review test failures carefully before retrying
|
|
1183
|
-
|
|
1184
|
-
❌ **DON'T:**
|
|
1185
|
-
- Skip RC validation (always test before prod)
|
|
1186
|
-
- Promote multiple RCs simultaneously
|
|
1187
|
-
- Skip backup creation in production
|
|
1188
|
-
- Force promote without fixing issues
|
|
1189
|
-
- Manually push/pull (let commands handle it)
|
|
1190
|
-
- Bypass test validation (it's there for your safety)
|
|
1191
|
-
|
|
1192
|
-
### Production Deployment
|
|
1193
|
-
|
|
1194
|
-
✅ **DO:**
|
|
1195
|
-
- Always run `update` first to check available releases
|
|
1196
|
-
- Use `--dry-run` to preview changes
|
|
1197
|
-
- Verify backups exist before upgrade
|
|
1198
|
-
- Monitor application after deployment
|
|
1199
|
-
- Schedule deployments during low-traffic periods
|
|
1200
|
-
- Trust commands to handle git operations
|
|
1201
|
-
- Verify all tests passed in RC before promoting
|
|
1202
|
-
|
|
1203
|
-
❌ **DON'T:**
|
|
1204
|
-
- Deploy without testing in RC first
|
|
1205
|
-
- Skip backup verification
|
|
1206
|
-
- Deploy during peak usage hours
|
|
1207
|
-
- Ignore upgrade warnings
|
|
1208
|
-
- Apply patches directly without releases
|
|
1209
|
-
- Manually git pull (commands do it automatically)
|
|
1210
|
-
- Promote to production if RC tests failed
|
|
1211
|
-
|
|
1212
|
-
### Testing Best Practices
|
|
1213
|
-
|
|
1214
|
-
✅ **DO:**
|
|
1215
|
-
- Write tests for all business logic
|
|
1216
|
-
- Test database constraints and validations
|
|
1217
|
-
- Use fixtures for common test scenarios
|
|
1218
|
-
- Test edge cases and error handling
|
|
1219
|
-
- Keep tests fast and isolated
|
|
1220
|
-
- Document test intentions clearly
|
|
1221
|
-
- Run tests locally before pushing
|
|
1222
|
-
|
|
1223
|
-
❌ **DON'T:**
|
|
1224
|
-
- Skip tests for "simple" changes
|
|
1225
|
-
- Write tests that depend on execution order
|
|
1226
|
-
- Ignore test failures
|
|
1227
|
-
- Write tests without assertions
|
|
1228
|
-
- Test implementation details instead of behavior
|
|
1229
|
-
|
|
1230
|
-
## 📚 Documentation
|
|
1231
|
-
|
|
1232
|
-
- **Quick Reference**: This README
|
|
1233
|
-
|
|
1234
|
-
## 🤝 Contributing
|
|
1235
|
-
|
|
1236
|
-
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
|
|
1237
|
-
|
|
1238
|
-
### Development Setup
|
|
1239
|
-
|
|
1240
|
-
```bash
|
|
1241
|
-
# Clone repository
|
|
1242
|
-
git clone https://github.com/half-orm/half-orm-dev.git
|
|
1243
|
-
cd half-orm-dev
|
|
1244
|
-
|
|
1245
|
-
# Install in development mode
|
|
1246
|
-
pip install -e .
|
|
1247
|
-
|
|
1248
|
-
# Run tests
|
|
1249
|
-
pytest
|
|
1250
|
-
```
|
|
1251
|
-
|
|
1252
|
-
## 📞 Getting Help
|
|
1253
|
-
|
|
1254
|
-
```bash
|
|
1255
|
-
# Command help
|
|
1256
|
-
half_orm dev --help
|
|
1257
|
-
half_orm dev patch --help
|
|
1258
|
-
half_orm dev release --help
|
|
1259
|
-
|
|
1260
|
-
# Specific command help
|
|
1261
|
-
half_orm dev patch create --help
|
|
1262
|
-
half_orm dev release promote --help
|
|
1263
|
-
half_orm dev update --help
|
|
1264
|
-
half_orm dev upgrade --help
|
|
1265
|
-
```
|
|
1266
|
-
|
|
1267
|
-
### Support
|
|
1268
|
-
|
|
1269
|
-
- **Issues**: [GitHub Issues](https://github.com/half-orm/half-orm-dev/issues)
|
|
1270
|
-
- **Documentation**: [docs/](docs/)
|
|
1271
|
-
- **half-orm**: [half-orm Documentation](https://half-orm.github.io/half-orm/latest/)
|
|
1272
|
-
|
|
1273
|
-
## 📄 License
|
|
1274
|
-
|
|
1275
|
-
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
|
|
1276
|
-
|
|
1277
|
-
---
|
|
1278
|
-
|
|
1279
|
-
**Version**: 0.17.0
|
|
1280
|
-
**half-orm**: Compatible with half-orm 0.17.x
|
|
1281
|
-
**Python**: 3.8+
|
|
1282
|
-
**PostgreSQL**: Tested with 13+ (might work with earlier versions)
|
|
1283
|
-
|
|
1284
|
-
Made with ❤️ by the half-orm team
|