Fix Python dependency management in CI workflows #13
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: CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| echo "Python dependencies installed successfully" | |
| # Verify key packages are installed | |
| python -c "import pytest; print('pytest version:', pytest.__version__)" | |
| python -c "import numpy; print('numpy version:', numpy.__version__)" | |
| python -c "import flake8; print('flake8 installed successfully')" | |
| - name: Lint with flake8 | |
| run: | | |
| # stop the build if there are Python syntax errors or undefined names | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Test with unittest | |
| run: | | |
| cd tests | |
| python run_tests.py | |
| - name: Test component system | |
| run: | | |
| cd tests | |
| python test_components.py | |
| - name: Run interface demo | |
| run: | | |
| python interface_demo.py | |
| - name: Run combined demo | |
| run: | | |
| python combined_demo.py | |
| - name: Generate coverage report | |
| run: | | |
| coverage run -m pytest tests/ | |
| coverage xml | |
| - name: Upload coverage to Codecov | |
| if: matrix.python-version == '3.11' | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Check package | |
| run: | | |
| twine check dist/* | |
| integration-test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ['3.10', '3.11'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run core tests | |
| run: | | |
| cd tests | |
| python test_components.py | |
| - name: Test import | |
| run: | | |
| python -c " | |
| import zlayout | |
| print('ZLayout version:', zlayout.__version__) | |
| print('Available modules:', zlayout.__all__) | |
| # Test component creation | |
| from zlayout import ComponentManager, create_resistor | |
| manager = ComponentManager(':memory:') | |
| resistor = create_resistor('test_r', 1000) | |
| print('Successfully created resistor:', resistor.name) | |
| manager.close() | |
| print('Integration test passed!') | |
| " |