diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14fdf72..3f3ec52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,45 +20,71 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python + - name: Detect Python project + id: pyproject + run: | + if [ -f backend/pyproject.toml ]; then + echo "exists=true" >> "$GITHUB_OUTPUT" + echo "path=backend" >> "$GITHUB_OUTPUT" + elif [ -f pyproject.toml ]; then + echo "exists=true" >> "$GITHUB_OUTPUT" + echo "path=." >> "$GITHUB_OUTPUT" + else + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + + - name: Set up Python (with cache) + if: steps.pyproject.outputs.exists == 'true' uses: actions/setup-python@v5 with: python-version: "3.12" cache: pip + cache-dependency-path: ${{ steps.pyproject.outputs.path }}/pyproject.toml + + - name: Set up Python (without cache, no pyproject.toml yet) + if: steps.pyproject.outputs.exists != 'true' + uses: actions/setup-python@v5 + with: + python-version: "3.12" - name: Install dependencies + if: steps.pyproject.outputs.exists == 'true' + working-directory: ${{ steps.pyproject.outputs.path }} run: | python -m pip install --upgrade pip - if [ -f pyproject.toml ]; then - pip install -e ".[dev]" || true - else - echo "Skipping — no pyproject.toml yet" - exit 0 - fi + pip install -e ".[dev]" - name: Ruff lint - if: hashFiles('pyproject.toml') != '' + if: steps.pyproject.outputs.exists == 'true' + working-directory: ${{ steps.pyproject.outputs.path }} run: ruff check . - name: Ruff format check - if: hashFiles('pyproject.toml') != '' + if: steps.pyproject.outputs.exists == 'true' + working-directory: ${{ steps.pyproject.outputs.path }} run: ruff format --check . - name: Mypy - if: hashFiles('pyproject.toml') != '' - run: mypy app/ || true # warn-only until app/ has content + if: steps.pyproject.outputs.exists == 'true' + working-directory: ${{ steps.pyproject.outputs.path }} + run: mypy app/ - name: Tests - if: hashFiles('pyproject.toml') != '' + if: steps.pyproject.outputs.exists == 'true' + working-directory: ${{ steps.pyproject.outputs.path }} run: pytest --cov=app --cov-report=xml -v - name: Upload coverage - if: always() && hashFiles('coverage.xml') != '' + if: always() && hashFiles('backend/coverage.xml', 'coverage.xml') != '' uses: codecov/codecov-action@v4 with: - files: coverage.xml + files: backend/coverage.xml,coverage.xml fail_ci_if_error: false + - name: No-op (no Python project yet — skipped) + if: steps.pyproject.outputs.exists != 'true' + run: echo "No pyproject.toml found — skipping Python checks for this branch" + go: name: Go — vet, test runs-on: ubuntu-24.04