diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..c76e8ff --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,64 @@ +name: quality + +on: + pull_request: + paths: + - '**/*.py' + - '.pyscn.toml' + - 'pyproject.toml' + push: + branches: + - main + paths: + - '**/*.py' + - '.pyscn.toml' + - 'pyproject.toml' + +jobs: + pyscn: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + make init-uv + make install + + - name: Quality check with pyscn + run: make lint-quality + + - name: Generate pyscn report + if: always() + run: make lint-quality-report + + - name: Upload pyscn report + if: always() + uses: actions/upload-artifact@v4 + with: + name: pyscn-report + path: .pyscn/reports/*.html + + - name: Comment pyscn summary on PR + if: >- + always() && + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + env: + GH_TOKEN: ${{ github.token }} + run: | + uv run pyscn analyze --json --output - . | jq -r ' + "## pyscn report\n" + + "- **Health Score:** " + (.summary.health_score | tostring) + " / 100 (" + .summary.grade + ")\n" + + "- Complexity: " + (.summary.complexity_score | tostring) + "\n" + + "- Dead code: " + (.summary.dead_code_score | tostring) + "\n" + ' > comment.md + gh pr comment "${{ github.event.pull_request.number }}" --body-file comment.md diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8304a8f..4da3050 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -47,9 +47,6 @@ jobs: - name: Lint with Sqlfluff run: make lint-sql - - name: Quality check with pyscn - run: make lint-quality - type-check: runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index f81de20..a3fcf34 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,9 @@ lint-docstrings: lint-quality: uv run pyscn check . +lint-quality-report: + uv run pyscn analyze --no-open --html . + type: uv run pyrefly check