Skip to content

Commit 9f0d7f9

Browse files
committed
update maintainers guide
1 parent f17b79a commit 9f0d7f9

File tree

1 file changed

+125
-111
lines changed

1 file changed

+125
-111
lines changed

MAINTAINERS_GUIDE.md

Lines changed: 125 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2,146 +2,172 @@
22

33
See the [Makefile](./Makefile) if you need to install and test locally. Just type `make` to get the help.
44

5-
## 🔧 Build Pipeline and File Preservation
5+
## 🚀 Release & Publishing
66

7-
### OpenAPI Client Generation
7+
### Automated Release Process (Default)
88

9-
The field-manager-python-client is automatically generated from OpenAPI specifications using `openapi-python-client`. To ensure custom code is preserved during regeneration:
9+
The system automatically checks for new OpenAPI specifications daily:
1010

11-
#### ✅ Files That Are Preserved
12-
- `field_manager_python_client/auth.py` - **Custom authentication module**
13-
- `field_manager_python_client/__init__.py` - **Preserved through custom template**
11+
1. **Nightly Check**: GitHub Actions runs at midnight UTC to check for API changes
12+
2. **PR Creation**: If changes are detected, a PR is automatically created with the new version
13+
3. **Manual Review**: A developer manually reviews and approves/rejects the PR
14+
4. **Release Creation**: If approved, developer creates a GitHub release with the version tag from `pyproject.toml`
15+
5. **Auto-Publish**: The release triggers `release.yaml` workflow, which publishes to PyPI
1416

15-
#### ⚠️ Files That Are Regenerated
16-
- All files in `field_manager_python_client/api/`
17-
- All files in `field_manager_python_client/models/`
18-
- `field_manager_python_client/client.py`
19-
- `field_manager_python_client/errors.py`
20-
- `field_manager_python_client/types.py`
17+
### Manual Release Process (Override)
2118

22-
### Custom Template System
19+
For urgent fixes or custom releases (like `4.6.25.post1`):
2320

24-
The build system uses custom templates in the `templates/` directory:
21+
1. **Update Version Override**:
22+
```bash
23+
# Edit config.yaml
24+
package_version_override: 4.6.25.post1
25+
```
2526

26-
- `templates/package_init.py.jinja` - **Ensures auth imports are preserved in __init__.py**
27-
- `templates/pyproject.toml.jinja` - Package metadata template
28-
- `templates/README.md.jinja` - Package README template
27+
2. **Generate Client**:
28+
```bash
29+
make generate
30+
```
2931

30-
### Generation Process
32+
3. **Commit Changes**:
33+
```bash
34+
git add field-manager-python-client/pyproject.toml
35+
git commit -m "Update version to 4.6.25.post1 - reason for release"
36+
git push origin trunk
37+
```
3138

32-
```bash
33-
# Full regeneration process
34-
make generate
39+
4. **Create GitHub Release**:
40+
- Go to: https://github.com/norwegian-geotechnical-institute/field-manager-python-client/releases
41+
- Click "Create a new release"
42+
- **Tag**: `v4.6.25.post1` (must match pyproject.toml version with `v` prefix)
43+
- **Title**: `4.6.25.post1 - Brief description`
44+
- **Description**: What changed and why
45+
- Click "Publish release"
3546

36-
# This runs:
37-
# 1. Download latest OpenAPI spec
38-
# 2. Extract version info
39-
# 3. Generate client code with custom templates
40-
# 4. Preserve auth.py and custom __init__.py imports
41-
```
47+
5. **Monitor Publication**:
48+
- Watch GitHub Actions: https://github.com/norwegian-geotechnical-institute/field-manager-python-client/actions
49+
- Verify on PyPI: https://pypi.org/project/field-manager-python-client/
50+
51+
### Release Troubleshooting
52+
53+
**Common Issues:**
54+
- **Missing PYPI_TOKEN**: Ensure repository has the secret configured
55+
- **Version conflict**: PyPI won't allow republishing the same version number
56+
- **Tag mismatch**: GitHub release tag must match `pyproject.toml` version (with `v` prefix)
57+
58+
## 🔧 Development Workflow
4259

43-
### ✅ Verification After Generation
60+
### OpenAPI Client Generation
61+
62+
The client is auto-generated from OpenAPI specifications. Key points:
63+
64+
**✅ Files Preserved During Generation:**
65+
- `field_manager_python_client/auth.py` - Custom authentication module
66+
- `field_manager_python_client/__init__.py` - Preserved via custom template
67+
68+
**⚠️ Files Automatically Regenerated:**
69+
- `field_manager_python_client/api/` - All API endpoints
70+
- `field_manager_python_client/models/` - All data models
71+
- `field_manager_python_client/client.py`, `errors.py`, `types.py`
4472

45-
After running `make generate`, verify these files are preserved:
73+
### Local Development
4674

4775
```bash
48-
# Check auth module exists
49-
ls -la field-manager-python-client/field_manager_python_client/auth.py
76+
# Generate client from latest API
77+
make generate
5078

51-
# Check __init__.py includes auth imports
52-
grep -n "from .auth import" field-manager-python-client/field_manager_python_client/__init__.py
79+
# Verify auth module is preserved
80+
ls field-manager-python-client/field_manager_python_client/auth.py
5381

54-
# Should show lines like:
55-
# from .auth import authenticate, get_test_client, get_prod_client, TokenManager
82+
# Check auth imports are included
83+
grep "from .auth import" field-manager-python_client/field_manager_python_client/__init__.py
5684
```
5785

58-
## 📚 Examples Directory Management
86+
### Custom Templates
87+
88+
The `templates/` directory contains Jinja2 templates that preserve custom code:
89+
- `templates/package_init.py.jinja` - Ensures auth imports in `__init__.py`
90+
- `templates/pyproject.toml.jinja` - Package metadata
91+
- `templates/README.md.jinja` - Package documentation
92+
93+
## 📚 Examples Management
5994

6095
### Structure
6196
```
6297
examples/
6398
├── setup.py # Automated setup script
64-
├── requirements.txt # Dependencies with version switching
65-
├── README.md # Comprehensive documentation
66-
├── QUICKSTART.md # 5-minute setup guide
67-
├── output/ # Git-ignored output directory
99+
├── requirements.txt # Package dependencies
68100
├── examples/ # Example scripts
101+
├── output/ # Git-ignored outputs
69102
└── venv/ # Git-ignored virtual environment
70103
```
71104

72-
### Key Features
73-
- **Virtual environment based**: No more Poetry complexity
74-
- **Version switching**: Easy toggle between published/local package
75-
- **Output management**: All outputs go to `output/` directory (git-ignored)
76-
- **Automated setup**: `python setup.py` handles everything
77-
78-
### Adding New Examples
105+
### Testing Examples
79106

80-
1. **Create the example** in `examples/examples/`
81-
2. **Use new authentication**: `from field_manager_python_client import get_test_client`
82-
3. **Save outputs** to `output/` directory using `Path("output")`
83-
4. **Document clearly** with comments and error handling
84-
5. **Test with both** published and local package versions
85-
86-
## 🚀 Release Process
87-
88-
### 1. Pre-Release Checks
89107
```bash
90-
# Ensure auth.py is preserved
91-
make generate
92-
git status # auth.py should be unchanged
93-
94-
# Test examples work
95108
cd examples
96-
python setup.py --local
97-
source venv/bin/activate
98-
python examples/ex_organizations_new_auth.py
99-
```
100-
101-
### 2. Version Update
102-
- OpenAPI client version is auto-extracted from `openapi.json`
103-
- Update package version if needed in `config.yaml`
104109

105-
### 3. Examples Testing
106-
```bash
107-
cd examples
108110
# Test with published version
109111
python setup.py
110112
source venv/bin/activate
111-
python examples/ex_organizations_new_auth.py
113+
python examples/ex_authentication_demo.py
112114

113-
# Test with local version
115+
# Test with local development version
114116
python setup.py --local
115-
python examples/ex_organizations_new_auth.py
117+
python examples/ex_authentication_demo.py
116118
```
117119

118-
## 🔐 Authentication System
120+
### Adding New Examples
119121

120-
### Architecture
121-
The authentication is now integrated into the main package:
122+
1. Create script in `examples/examples/`
123+
2. Use new authentication: `from field_manager_python_client import get_test_client`
124+
3. Save outputs to `output/` directory (git-ignored)
125+
4. Include clear documentation and error handling
122126

127+
## 🔐 Authentication System
128+
129+
### Core Components
123130
- **Module**: `field_manager_python_client/auth.py`
124-
- **Exports**: `authenticate`, `get_test_client`, `get_prod_client`, `TokenManager`
125-
- **Environment configs**: Built-in for test/prod
126-
- **Token management**: Automatic caching and refresh
131+
- **Main Functions**: `authenticate()`, `get_test_client()`, `get_prod_client()`
132+
- **Token Management**: `TokenManager` class with auto-refresh
133+
- **Environments**: Built-in configs for test/production
127134

128-
### Preservation Strategy
129-
The `auth.py` file is **NOT** generated by openapi-python-client, so it's naturally preserved. The `__init__.py` imports are preserved through the custom template `templates/package_init.py.jinja`.
135+
### Key Features
136+
- Automatic token caching and refresh
137+
- Support for SSO and password authentication
138+
- Organization-specific auth method detection
139+
- Environment-specific configurations
130140

131-
## 🐛 Troubleshooting
141+
## ✅ Pre-Release Checklist
142+
143+
Before any release:
132144

133-
### Auth Module Missing After Generation
134145
```bash
135-
# Check if auth.py exists
136-
ls field-manager-python-client/field_manager_python_client/auth.py
146+
# 1. Ensure auth module is preserved
147+
make generate
148+
git status # auth.py should be unchanged
149+
150+
# 2. Test examples work
151+
cd examples
152+
python setup.py --local
153+
source venv/bin/activate
154+
python examples/ex_authentication_demo.py
137155

138-
# If missing, restore from git
139-
git checkout field-manager-python-client/field_manager_python_client/auth.py
156+
# 3. Verify auth imports
157+
python -c "from field_manager_python_client import authenticate; print('✅ Auth module working')"
140158
```
141159

142-
### Missing Auth Imports in __init__.py
160+
## 🐛 Common Issues
161+
162+
### Auth Module Missing After Generation
143163
```bash
144-
# Check custom template
164+
# Restore from git if accidentally removed
165+
git checkout field-manager-python_client/field_manager_python_client/auth.py
166+
```
167+
168+
### Missing Auth Imports
169+
```bash
170+
# Check template exists
145171
cat templates/package_init.py.jinja
146172

147173
# Regenerate with custom template
@@ -151,27 +177,15 @@ make generate
151177
### Examples Not Working
152178
```bash
153179
cd examples
154-
# Clean reinstall
155-
rm -rf venv
180+
rm -rf venv # Clean slate
156181
python setup.py
157182
```
158183

159-
## 🔄 Continuous Integration
160-
161-
### Pipeline Considerations
162-
1. **Test auth preservation**: Verify `auth.py` unchanged after generation
163-
2. **Test examples**: Run examples with both published and local packages
164-
3. **Version compatibility**: Ensure examples work with current package version
165-
166-
### Recommended CI Steps
167-
```bash
168-
# 1. Generate and verify preservation
169-
make generate
170-
git diff --exit-code field-manager-python-client/field_manager_python_client/auth.py
171-
172-
# 2. Test examples setup
173-
cd examples && python setup.py --skip-test
184+
---
174185

175-
# 3. Test auth imports
176-
python -c "from field_manager_python_client import authenticate; print('OK')"
177-
```
186+
**Quick Commands Reference:**
187+
- `make generate` - Regenerate client from OpenAPI
188+
- `make help` - Show all available commands
189+
- `cd examples && python setup.py` - Set up examples environment
190+
- `git push origin trunk` - Push changes
191+
- Create GitHub release → Auto-publish to PyPI

0 commit comments

Comments
 (0)