|
| 1 | +name: Python Type Checking |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'src/Fable.Transforms/Python/**' |
| 8 | + - 'src/fable-library-py/**' |
| 9 | + - 'tests/Python/**' |
| 10 | + - 'pyrightconfig.ci.json' |
| 11 | + - 'pyproject.toml' |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + pyright: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + env: |
| 21 | + UV_LINK_MODE: copy |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v5 |
| 25 | + |
| 26 | + - name: Setup .NET |
| 27 | + uses: actions/setup-dotnet@v5 |
| 28 | + with: |
| 29 | + dotnet-version: "10.0.x" |
| 30 | + |
| 31 | + - name: Setup dotnet tools |
| 32 | + run: dotnet tool restore |
| 33 | + |
| 34 | + - name: Set up Python 3.12 |
| 35 | + uses: actions/setup-python@v6 |
| 36 | + with: |
| 37 | + python-version: "3.12" |
| 38 | + |
| 39 | + - name: Install uv |
| 40 | + run: | |
| 41 | + pipx install uv |
| 42 | + pipx install maturin |
| 43 | +
|
| 44 | + - name: Build Python (compile only) |
| 45 | + run: ./build.sh test python --compile-only |
| 46 | + |
| 47 | + - name: Run Pyright (standard mode) |
| 48 | + id: pyright |
| 49 | + continue-on-error: true |
| 50 | + run: | |
| 51 | + if uv run pyright --project pyrightconfig.ci.json temp/tests/Python/ temp/fable-library-py/; then |
| 52 | + echo "result=:white_check_mark: All non-excluded files pass" >> $GITHUB_OUTPUT |
| 53 | + echo "passed=true" >> $GITHUB_OUTPUT |
| 54 | + else |
| 55 | + echo "result=:x: Type errors found in non-excluded files" >> $GITHUB_OUTPUT |
| 56 | + echo "passed=false" >> $GITHUB_OUTPUT |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Get excluded files |
| 60 | + id: excluded |
| 61 | + run: | |
| 62 | + COUNT=$(grep -c '"temp/' pyrightconfig.ci.json || echo "0") |
| 63 | + echo "count=$COUNT" >> $GITHUB_OUTPUT |
| 64 | + FILES=$(grep '"temp/' pyrightconfig.ci.json | sed 's/.*"temp/temp/' | sed 's/".*//' | sort) |
| 65 | + echo "files<<EOF" >> $GITHUB_OUTPUT |
| 66 | + echo "$FILES" >> $GITHUB_OUTPUT |
| 67 | + echo "EOF" >> $GITHUB_OUTPUT |
| 68 | +
|
| 69 | + - name: Find existing comment |
| 70 | + uses: peter-evans/find-comment@v3 |
| 71 | + id: find-comment |
| 72 | + with: |
| 73 | + issue-number: ${{ github.event.pull_request.number }} |
| 74 | + comment-author: 'github-actions[bot]' |
| 75 | + body-includes: Python Type Checking |
| 76 | + |
| 77 | + - name: Create or update PR comment |
| 78 | + uses: peter-evans/create-or-update-comment@v4 |
| 79 | + with: |
| 80 | + comment-id: ${{ steps.find-comment.outputs.comment-id }} |
| 81 | + issue-number: ${{ github.event.pull_request.number }} |
| 82 | + edit-mode: replace |
| 83 | + body: | |
| 84 | + ## Python Type Checking (Pyright) Results |
| 85 | +
|
| 86 | + ${{ steps.pyright.outputs.result }} |
| 87 | +
|
| 88 | + | Metric | Value | |
| 89 | + | -------------- | ----------------------------------- | |
| 90 | + | Excluded files | ${{ steps.excluded.outputs.count }} | |
| 91 | +
|
| 92 | + <details> |
| 93 | + <summary>Files excluded from type checking</summary> |
| 94 | +
|
| 95 | + These files have known type errors and are excluded from CI. Remove from `pyrightconfig.ci.json` as errors are fixed. |
| 96 | +
|
| 97 | + ``` |
| 98 | + ${{ steps.excluded.outputs.files }} |
| 99 | + ``` |
| 100 | +
|
| 101 | + </details> |
| 102 | +
|
| 103 | + - name: Fail if type errors |
| 104 | + if: false # Temporarily disabled |
| 105 | + # if: steps.pyright.outputs.passed == 'false' |
| 106 | + run: exit 1 |
0 commit comments