CI #2
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 ] | |
| schedule: | |
| # Run daily at 3 AM UTC to catch dependency issues | |
| - cron: '0 3 * * *' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| # Quick quality checks that should pass before running expensive tests | |
| pre-check: | |
| name: Pre-checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check commit message | |
| if: github.event_name == 'pull_request' | |
| uses: wagoid/commitlint-github-action@v5 | |
| - name: Check for large files | |
| uses: ActionsDesk/lfs-warning@v2.0 | |
| with: | |
| filesizelimit: 10485760 # 10MB | |
| # Code quality and linting | |
| quality: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| needs: pre-check | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run Black | |
| run: black --check --diff . | |
| - name: Run isort | |
| run: isort --check-only --diff . | |
| - name: Run Ruff | |
| run: ruff check . | |
| - name: Run mypy | |
| run: mypy tenets --strict | |
| - name: Run Bandit security linting | |
| run: bandit -r tenets -ll | |
| - name: Check dependencies with Safety | |
| run: safety check | |
| continue-on-error: true # Don't fail on advisories | |
| # Run tests across multiple Python versions and OS | |
| test: | |
| name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| needs: pre-check | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
| exclude: | |
| # macOS runners are expensive, only test min/max Python | |
| - os: macos-latest | |
| python-version: '3.10' | |
| - os: macos-latest | |
| python-version: '3.11' | |
| - os: macos-latest | |
| python-version: '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: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev,test]" | |
| - name: Run pytest with coverage | |
| run: | | |
| pytest -v --cov=tenets --cov-report=xml --cov-report=term | |
| - name: Upload coverage to Codecov | |
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: true | |
| verbose: true | |
| # Test with optional dependencies | |
| test-optional: | |
| name: Test with optional dependencies | |
| runs-on: ubuntu-latest | |
| needs: pre-check | |
| strategy: | |
| matrix: | |
| extras: ['light', 'ml', 'viz', 'all'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install with extras | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[${{ matrix.extras }},test]" | |
| - name: Run tests | |
| run: pytest -v -m "not slow" | |
| # Build and test installation | |
| build: | |
| name: Build distribution | |
| runs-on: ubuntu-latest | |
| needs: [quality, test] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: python -m build | |
| - name: Check package | |
| run: twine check --strict dist/* | |
| - name: Test installation | |
| run: | | |
| pip install dist/*.whl | |
| tenets --version | |
| tenets --help | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: dist | |
| path: dist/ | |
| # Build documentation | |
| docs: | |
| name: Build documentation | |
| runs-on: ubuntu-latest | |
| needs: pre-check | |
| 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 -e ".[docs]" | |
| - name: Build docs | |
| run: | | |
| mkdocs build --strict | |
| - name: Check for broken links | |
| run: | | |
| pip install linkchecker | |
| linkchecker site/ | |
| continue-on-error: true | |
| # Docker build test | |
| docker: | |
| name: Docker build | |
| runs-on: ubuntu-latest | |
| needs: pre-check | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| tags: tenets:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Test Docker image | |
| run: | | |
| docker run --rm tenets:test --version | |
| docker run --rm tenets:test --help | |
| # All tests passed | |
| all-checks: | |
| name: All checks passed | |
| runs-on: ubuntu-latest | |
| needs: [quality, test, test-optional, build, docs, docker] | |
| steps: | |
| - name: All checks passed | |
| run: echo "All checks passed successfully!" |