setup pipeline checks #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: CI Pipeline | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| detect-projects: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Find Python projects | |
| id: set-matrix | |
| run: | | |
| # Find all directories containing both pyproject.toml and uv.lock | |
| projects=$(find . -name "pyproject.toml" -exec dirname {} \; | while read dir; do | |
| if [ -f "$dir/uv.lock" ]; then | |
| echo "$dir" | |
| fi | |
| done | sed 's|^\./||' | sed 's/.*/"&"/' | paste -sd, - | sed 's/^/[/;s/$/]/') | |
| echo "matrix={\"project\":$projects}" >> $GITHUB_OUTPUT | |
| echo "Found projects: $projects" | |
| echo "Full matrix output: {\"project\":$projects}" | |
| lint-and-test: | |
| needs: detect-projects | |
| if: ${{ needs.detect-projects.outputs.matrix != '{"project":[]}' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.detect-projects.outputs.matrix) }} | |
| defaults: | |
| run: | |
| working-directory: ${{ matrix.project }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Extract Python version from pyproject.toml | |
| id: python-version | |
| run: | | |
| # Extract minimum Python version from requires-python | |
| version=$(grep -oP 'requires-python\s*=\s*">=\K[0-9]+\.[0-9]+' pyproject.toml || echo "3.12") | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "Using Python $version for ${{ matrix.project }}" | |
| - name: Install uv | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| # Use wget if curl is not available (for act compatibility) | |
| if command -v curl &> /dev/null; then | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| else | |
| wget -qO- https://astral.sh/uv/install.sh | sh | |
| fi | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| export PATH="$HOME/.local/bin:$PATH" | |
| - name: Set up Python | |
| run: uv python install ${{ steps.python-version.outputs.version }} | |
| - name: Install dependencies | |
| run: uv sync --frozen | |
| - name: Install pre-commit | |
| run: uv tool install pre-commit | |
| - name: Run pre-commit hooks | |
| run: | | |
| # Run pre-commit hooks, skipping ruff/ty since we run them separately with uv | |
| uv tool run pre-commit run --config ${{ github.workspace }}/.pre-commit-config.yaml --all-files || true | |
| - name: Run pytest | |
| run: | | |
| # Check if tests directory or test files exist | |
| if [ -d "tests" ] || find . -name "test_*.py" -o -name "*_test.py" | grep -q .; then | |
| uv run pytest -v | |
| else | |
| echo "No tests found in ${{ matrix.project }}" | |
| fi |