|
| 1 | +# GitHub Actions Workflows |
| 2 | + |
| 3 | +This directory contains the CI/CD workflows for the NocoDB Simple Client project. |
| 4 | + |
| 5 | +## Workflows Overview |
| 6 | + |
| 7 | +### 1. `python-automatic-release.yml` |
| 8 | +**Purpose**: Automated releases on main branch |
| 9 | +**Trigger**: Push to `main` branch |
| 10 | +**Tests**: Unit tests only (fast, no external dependencies) |
| 11 | +**Dependencies**: None (uses mocks) |
| 12 | + |
| 13 | +### 2. `feature-test.yml` |
| 14 | +**Purpose**: Comprehensive testing on feature branches |
| 15 | +**Trigger**: Push to `feature-*` branches |
| 16 | +**Tests**: Unit tests + Integration tests with live NocoDB |
| 17 | +**Dependencies**: Automatic NocoDB setup with SQLite |
| 18 | + |
| 19 | +## Workflow Details |
| 20 | + |
| 21 | +### Release Workflow (`python-automatic-release.yml`) |
| 22 | +- **Fast execution** (~2-3 minutes) |
| 23 | +- **No external dependencies** |
| 24 | +- **All Python versions** (3.8-3.12) |
| 25 | +- **Unit tests only** via `--ci` flag |
| 26 | +- **Automatic versioning** and PyPI publishing |
| 27 | + |
| 28 | +### Feature Testing Workflow (`feature-test.yml`) |
| 29 | + |
| 30 | +#### Job 1: Unit Tests |
| 31 | +- **Matrix**: Python 3.9, 3.11, 3.12 |
| 32 | +- **Duration**: ~2-4 minutes |
| 33 | +- **Dependencies**: None (mocked) |
| 34 | +- **Purpose**: Fast feedback on basic functionality |
| 35 | + |
| 36 | +#### Job 2: Integration Tests |
| 37 | +- **Setup**: Automatic NocoDB instance with SQLite |
| 38 | +- **User Creation**: Automated admin user setup |
| 39 | +- **API Token**: Dynamic token generation |
| 40 | +- **Tests**: Full integration test suite |
| 41 | +- **Duration**: ~8-12 minutes |
| 42 | +- **Environment Variables**: Automatically configured |
| 43 | + |
| 44 | +#### Job 3: Performance Tests (Optional) |
| 45 | +- **Trigger**: PR label `test-performance` |
| 46 | +- **Setup**: Optimized NocoDB instance |
| 47 | +- **Tests**: Performance benchmarks |
| 48 | +- **Reduced Dataset**: CI-appropriate test sizes |
| 49 | + |
| 50 | +## NocoDB Setup Process |
| 51 | + |
| 52 | +The feature workflow automatically: |
| 53 | + |
| 54 | +1. **Starts NocoDB Container**: |
| 55 | + ```bash |
| 56 | + docker run -d --name nocodb-test \ |
| 57 | + -p 8080:8080 \ |
| 58 | + -e NC_DB="sqlite3://data/nc.db" \ |
| 59 | + -e NC_AUTH_JWT_SECRET="test-jwt-secret-$(date +%s)" \ |
| 60 | + -e NC_DISABLE_TELE=true \ |
| 61 | + nocodb/nocodb:latest |
| 62 | + ``` |
| 63 | + |
| 64 | +2. **Creates Admin User**: |
| 65 | + ```bash |
| 66 | + curl -X POST /api/v1/auth/user/signup \ |
| 67 | + -d '{"email":"test@example.com","password":"TestPassword123!"}' |
| 68 | + ``` |
| 69 | + |
| 70 | +3. **Gets API Token**: |
| 71 | + ```bash |
| 72 | + curl -X POST /api/v1/auth/user/signin \ |
| 73 | + -d '{"email":"test@example.com","password":"TestPassword123!"}' |
| 74 | + ``` |
| 75 | + |
| 76 | +4. **Configures Environment**: |
| 77 | + ```bash |
| 78 | + NOCODB_BASE_URL=http://localhost:8080 |
| 79 | + NOCODB_TOKEN=$TOKEN |
| 80 | + TEST_TABLE_PREFIX=gh_test_ |
| 81 | + MAX_FILE_SIZE_MB=1 |
| 82 | + ``` |
| 83 | + |
| 84 | +## Environment Configuration |
| 85 | + |
| 86 | +### Automatic Environment Variables |
| 87 | +The workflow automatically configures: |
| 88 | + |
| 89 | +| Variable | Value | Description | |
| 90 | +|----------|-------|-------------| |
| 91 | +| `NOCODB_BASE_URL` | `http://localhost:8080` | NocoDB instance URL | |
| 92 | +| `NOCODB_TOKEN` | `${{ steps.setup-nocodb.outputs.token }}` | Dynamic API token | |
| 93 | +| `TEST_TABLE_PREFIX` | `gh_test_` | Prefix for test tables | |
| 94 | +| `CLEANUP_TEST_DATA` | `true` | Auto-cleanup enabled | |
| 95 | +| `RUN_INTEGRATION_TESTS` | `true` | Enable integration tests | |
| 96 | +| `TEST_TIMEOUT` | `60` | Extended timeout for CI | |
| 97 | +| `MAX_FILE_SIZE_MB` | `1` | File upload limit | |
| 98 | +| `PERFORMANCE_TEST_RECORDS` | `50` | Reduced for CI speed | |
| 99 | +| `BULK_TEST_BATCH_SIZE` | `10` | Small batches for CI | |
| 100 | + |
| 101 | +### Error Handling & Debugging |
| 102 | + |
| 103 | +#### Automatic Debugging on Failure: |
| 104 | +```bash |
| 105 | +# Show NocoDB logs |
| 106 | +docker logs nocodb-test |
| 107 | + |
| 108 | +# Show container status |
| 109 | +docker ps -a |
| 110 | + |
| 111 | +# Test API connectivity |
| 112 | +curl -v http://localhost:8080/api/v1/health |
| 113 | +``` |
| 114 | + |
| 115 | +#### Cleanup on Success/Failure: |
| 116 | +```bash |
| 117 | +docker stop nocodb-test || true |
| 118 | +docker rm nocodb-test || true |
| 119 | +rm -rf ./nocodb-data || true |
| 120 | +``` |
| 121 | + |
| 122 | +## Usage Examples |
| 123 | + |
| 124 | +### Triggering Feature Tests |
| 125 | +```bash |
| 126 | +# Push to feature branch triggers automatic testing |
| 127 | +git checkout -b feature/new-functionality |
| 128 | +git push origin feature/new-functionality |
| 129 | +``` |
| 130 | + |
| 131 | +### Adding Performance Tests |
| 132 | +```bash |
| 133 | +# Add label to PR to trigger performance tests |
| 134 | +gh pr edit --add-label "test-performance" |
| 135 | +``` |
| 136 | + |
| 137 | +### Local Testing Equivalent |
| 138 | +```bash |
| 139 | +# Same tests locally |
| 140 | +python scripts/run-all.py --integration # Integration tests |
| 141 | +python scripts/run-all.py --performance # Performance tests |
| 142 | +python scripts/run-all.py --all-tests # Everything |
| 143 | +``` |
| 144 | + |
| 145 | +## Troubleshooting |
| 146 | + |
| 147 | +### Common Issues |
| 148 | + |
| 149 | +1. **NocoDB startup timeout**: |
| 150 | + - Increased timeout to 120s |
| 151 | + - Multiple health check methods |
| 152 | + - Fallback token generation |
| 153 | + |
| 154 | +2. **API token extraction failure**: |
| 155 | + - Multiple extraction methods |
| 156 | + - Fallback token generation |
| 157 | + - Graceful error handling |
| 158 | + |
| 159 | +3. **Test data conflicts**: |
| 160 | + - Unique table prefixes (`gh_test_`, `perf_test_`) |
| 161 | + - Automatic cleanup |
| 162 | + - Isolated containers per job |
| 163 | + |
| 164 | +### Debug Steps |
| 165 | + |
| 166 | +1. **Check workflow logs** in GitHub Actions |
| 167 | +2. **Review NocoDB container logs** (shown on failure) |
| 168 | +3. **Test API endpoints manually** using curl commands |
| 169 | +4. **Run locally** with same environment variables |
| 170 | + |
| 171 | +## Performance Considerations |
| 172 | + |
| 173 | +### Optimizations Applied: |
| 174 | +- **Reduced Python matrix** for feature tests (3 versions vs 5) |
| 175 | +- **SQLite database** (faster than PostgreSQL/MySQL) |
| 176 | +- **Disabled telemetry** (`NC_DISABLE_TELE=true`) |
| 177 | +- **Reduced test datasets** for CI environment |
| 178 | +- **Parallel job execution** where possible |
| 179 | +- **Efficient cleanup** to minimize resource usage |
| 180 | + |
| 181 | +### Expected Durations: |
| 182 | +- **Unit tests**: 2-4 minutes per Python version |
| 183 | +- **Integration tests**: 8-12 minutes total |
| 184 | +- **Performance tests**: 10-15 minutes (when enabled) |
| 185 | +- **Total feature workflow**: ~15-20 minutes |
0 commit comments