chore(typegen): add canary python types runtime #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate Python Type Generation | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| validate-python-types: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Python dependencies | |
| run: | | |
| pip install pydantic typing-extensions | |
| - name: Start test database | |
| working-directory: test/db | |
| run: | | |
| docker compose up -d --wait | |
| - name: Wait for database to be ready | |
| run: | | |
| # Install PostgreSQL client for health check | |
| sudo apt-get update && sudo apt-get install -y postgresql-client | |
| until pg_isready -h localhost -p 5432 -U postgres; do | |
| echo "Waiting for database..." | |
| sleep 1 | |
| done | |
| echo "Database is ready!" | |
| - name: Generate Python types | |
| id: generate-types | |
| run: | | |
| node --loader ts-node/esm scripts/generate-python-types-test.ts > generated_types.py | |
| echo "Generated Python types (first 30 lines):" | |
| head -30 generated_types.py | |
| - name: Validate Python types syntax | |
| run: | | |
| python -m py_compile generated_types.py | |
| echo "✓ Python syntax is valid" | |
| - name: Validate Python types imports | |
| run: | | |
| python << 'EOF' | |
| import sys | |
| import importlib.util | |
| try: | |
| # Load the module from file | |
| spec = importlib.util.spec_from_file_location("generated_types", "generated_types.py") | |
| if spec is None or spec.loader is None: | |
| print("✗ Failed to create module spec") | |
| sys.exit(1) | |
| module = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(module) | |
| print("✓ All imports are valid") | |
| print("✓ Generated types can be imported successfully") | |
| print(f"✓ Module loaded: {module.__name__}") | |
| except ImportError as e: | |
| print(f"✗ Import error: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| sys.exit(1) | |
| except SyntaxError as e: | |
| print(f"✗ Syntax error: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| sys.exit(1) | |
| except Exception as e: | |
| print(f"✗ Unexpected error: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| sys.exit(1) | |
| EOF | |
| - name: Cleanup | |
| if: always() | |
| working-directory: test/db | |
| run: docker compose down |