pytest-language-server 0.22.0

A blazingly fast Language Server Protocol implementation for pytest
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
name: Release

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:

permissions:
  contents: write
  id-token: write

jobs:
  linux:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: 3.x
          allow-prereleases: true
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --interpreter python3.10 python3.11 python3.12 python3.13 python3.14 python3.14t pypy3.10 pypy3.11
          sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
          manylinux: auto
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-linux-${{ matrix.target }}
          path: dist

  musllinux:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        target: [x86_64, x86, aarch64, armv7]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: 3.x
          allow-prereleases: true
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --interpreter python3.10 python3.11 python3.12 python3.13 python3.14 python3.14t pypy3.10 pypy3.11
          sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
          manylinux: musllinux_1_2
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-musllinux-${{ matrix.target }}
          path: dist

  windows:
    runs-on: windows-latest
    strategy:
      matrix:
        target: [x64, x86]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: |
            3.10
            3.11
            3.12
            3.13
            3.14
          architecture: ${{ matrix.target }}
          allow-prereleases: true
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --interpreter 3.10 3.11 3.12 3.13 3.14
          sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-windows-${{ matrix.target }}
          path: dist

  windows-freethreaded:
    runs-on: windows-latest
    strategy:
      matrix:
        target: [x64, x86]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: '3.14t'
          architecture: ${{ matrix.target }}
          allow-prereleases: true
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --interpreter 3.14t
          sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-windows-${{ matrix.target }}-freethreaded
          path: dist

  macos:
    runs-on: ${{ matrix.runner }}
    strategy:
      matrix:
        include:
          - runner: macos-15
            target: x86_64
          - runner: macos-14
            target: aarch64
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: 3.x
          allow-prereleases: true
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --interpreter 3.10 3.11 3.12 3.13 3.14 3.14t pypy3.10 pypy3.11
          sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-macos-${{ matrix.target }}
          path: dist

  sdist:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Build sdist
        uses: PyO3/maturin-action@v1
        with:
          command: sdist
          args: --out dist
      - name: Upload sdist
        uses: actions/upload-artifact@v7
        with:
          name: wheels-sdist
          path: dist

  update-homebrew-formula:
    name: Update Homebrew formula
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: [build-binaries]
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6
        with:
          ref: ${{ github.event.repository.default_branch }}
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Download binaries
        uses: actions/download-artifact@v8
        with:
          pattern: binary-*
          path: binaries

      - name: Compute checksums and update formula
        shell: bash
        run: |
          VERSION="${GITHUB_REF#refs/tags/v}"
          echo "Updating formula to version $VERSION"

          # Flatten binaries
          mkdir -p binaries-flat
          find binaries -type f -name "pytest-language-server*" -exec cp {} binaries-flat/ \;
          ls -la binaries-flat/

          # Verify all required binaries exist
          for binary in aarch64-apple-darwin x86_64-apple-darwin aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do
            if [ ! -f "binaries-flat/pytest-language-server-$binary" ]; then
              echo "Missing required binary: pytest-language-server-$binary"
              exit 1
            fi
          done
          echo "All required binaries present"

          # Compute SHA256 checksums
          SHA_MACOS_ARM64=$(sha256sum binaries-flat/pytest-language-server-aarch64-apple-darwin | cut -d' ' -f1)
          SHA_MACOS_X86=$(sha256sum binaries-flat/pytest-language-server-x86_64-apple-darwin | cut -d' ' -f1)
          SHA_LINUX_ARM64=$(sha256sum binaries-flat/pytest-language-server-aarch64-unknown-linux-gnu | cut -d' ' -f1)
          SHA_LINUX_X86=$(sha256sum binaries-flat/pytest-language-server-x86_64-unknown-linux-gnu | cut -d' ' -f1)

          echo "SHA256 checksums:"
          echo "  macOS ARM64: $SHA_MACOS_ARM64"
          echo "  macOS x86_64: $SHA_MACOS_X86"
          echo "  Linux ARM64: $SHA_LINUX_ARM64"
          echo "  Linux x86_64: $SHA_LINUX_X86"

          # Update formula using sed replacements
          sed -i \
            -e "s/version \".*\"/version \"$VERSION\"/" \
            -e "s|download/v[^/]*/pytest-language-server|download/v$VERSION/pytest-language-server|g" \
            -e "/aarch64-apple-darwin/{ n; s/sha256 \".*\"/sha256 \"$SHA_MACOS_ARM64\"/; }" \
            -e "/x86_64-apple-darwin/{ n; s/sha256 \".*\"/sha256 \"$SHA_MACOS_X86\"/; }" \
            -e "/aarch64-unknown-linux-gnu/{ n; s/sha256 \".*\"/sha256 \"$SHA_LINUX_ARM64\"/; }" \
            -e "/x86_64-unknown-linux-gnu/{ n; s/sha256 \".*\"/sha256 \"$SHA_LINUX_X86\"/; }" \
            Formula/pytest-language-server.rb

          echo "Updated formula:"
          cat Formula/pytest-language-server.rb

      - name: Commit and push formula update
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add Formula/pytest-language-server.rb
          if git diff --staged --quiet; then
            echo "No changes to commit"
          else
            git commit -m "chore: update Homebrew formula to ${GITHUB_REF#refs/tags/}"
            # Retry push with rebase if there's a race condition
            git push || {
              echo "Push failed, retrying with rebase..."
              git pull --rebase
              git push
            }
          fi

  release:
    name: Release
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: [linux, musllinux, windows, windows-freethreaded, macos, sdist, build-binaries, update-homebrew-formula]
    permissions:
      id-token: write
      contents: write
      attestations: write
    steps:
      - uses: actions/checkout@v6

      - name: Download wheel artifacts
        uses: actions/download-artifact@v8
        with:
          pattern: wheels-*
          path: wheels

      - name: Download standalone binaries
        uses: actions/download-artifact@v8
        with:
          pattern: binary-*
          path: binaries

      - name: Generate artifact attestation
        uses: actions/attest-build-provenance@v4
        with:
          subject-path: "wheels/*/*.whl"

      - name: Flatten wheels directory
        run: |
          mkdir -p dist
          find wheels -name "*.whl" -exec cp {} dist/ \;
          find wheels -name "*.tar.gz" -exec cp {} dist/ \;
          ls -lh dist/

      - name: Flatten binaries directory
        run: |
          mkdir -p binaries-dist
          find binaries -type f -name "pytest-language-server*" -exec cp {} binaries-dist/ \;
          chmod +x binaries-dist/* || true
          ls -lh binaries-dist/

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: |
            dist/*.whl
            dist/*.tar.gz
            binaries-dist/*
          generate_release_notes: true
          fail_on_unmatched_files: true

      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          skip-existing: true
          verbose: true

  publish-crates:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: "publish-crates"
      - name: Publish to crates.io
        run: cargo publish --allow-dirty --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

  build-binaries:
    name: Build standalone binaries for extensions
    runs-on: ${{ matrix.os }}
    if: startsWith(github.ref, 'refs/tags/')
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            binary_name: pytest-language-server-x86_64-unknown-linux-gnu
          - os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            binary_name: pytest-language-server-aarch64-unknown-linux-gnu
          - os: macos-15
            target: x86_64-apple-darwin
            binary_name: pytest-language-server-x86_64-apple-darwin
          - os: macos-14
            target: aarch64-apple-darwin
            binary_name: pytest-language-server-aarch64-apple-darwin
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            binary_name: pytest-language-server.exe
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: "build-binaries-${{ matrix.target }}"
      - name: Install cross-compilation tools (Linux ARM64)
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu
      - name: Build binary
        env:
          CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
        run: |
          cargo build --release --target ${{ matrix.target }}
      - name: Rename binary (Unix)
        if: runner.os != 'Windows'
        run: |
          mv target/${{ matrix.target }}/release/pytest-language-server target/${{ matrix.target }}/release/${{ matrix.binary_name }}
      - name: Rename binary (Windows)
        if: runner.os == 'Windows'
        run: |
          move target\${{ matrix.target }}\release\pytest-language-server.exe target\${{ matrix.target }}\release\${{ matrix.binary_name }}
      - name: Upload binary
        uses: actions/upload-artifact@v7
        with:
          name: binary-${{ matrix.target }}
          path: target/${{ matrix.target }}/release/${{ matrix.binary_name }}

  publish-vscode:
    name: Publish VSCode extension
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: [build-binaries]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: '20'
      - name: Download all binaries
        uses: actions/download-artifact@v8
        with:
          pattern: binary-*
          path: extensions/vscode-extension/bin
      - name: Flatten binaries
        run: |
          cd extensions/vscode-extension/bin
          find . -type f -name "pytest-language-server*" -exec mv {} . \;
          find . -type d -empty -delete
          chmod +x pytest-language-server-* || true
          ls -lh
      - name: Install dependencies
        run: |
          cd extensions/vscode-extension
          npm install
          npm install -g @vscode/vsce
      - name: Package extension
        run: |
          cd extensions/vscode-extension
          vsce package
      - name: Publish to VSCode Marketplace
        run: |
          cd extensions/vscode-extension
          vsce publish -p ${{ secrets.VSCE_TOKEN }}

  publish-intellij:
    name: Publish IntelliJ/PyCharm plugin
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    needs: [build-binaries]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-java@v5
        with:
          distribution: 'temurin'
          java-version: '21'
      - name: Download all binaries
        uses: actions/download-artifact@v8
        with:
          pattern: binary-*
          path: extensions/intellij-plugin/src/main/resources/bin
      - name: Flatten binaries
        run: |
          cd extensions/intellij-plugin/src/main/resources/bin
          find . -type f -name "pytest-language-server*" -exec mv {} . \;
          find . -type d -empty -delete
          chmod +x pytest-language-server-* || true
          ls -lh
      - name: Build plugin
        run: |
          cd extensions/intellij-plugin
          chmod +x build.sh gradlew
          ./build.sh
      - name: Upload plugin to GitHub release
        uses: softprops/action-gh-release@v2
        with:
          files: extensions/intellij-plugin/build/distributions/pytest-language-server-*.zip
      - name: Verify plugin compatibility
        run: |
          # Download plugin verifier
          curl -L https://github.com/JetBrains/intellij-plugin-verifier/releases/download/1.307/plugin-verifier-1.307-all.jar -o plugin-verifier.jar
          # Run verification (informational only)
          PLUGIN_ZIP=$(ls extensions/intellij-plugin/build/distributions/pytest-language-server-*.zip | head -1)
          java -jar plugin-verifier.jar check-plugin "$PLUGIN_ZIP" || true
        continue-on-error: true
      - name: Publish to JetBrains Marketplace
        env:
          JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_TOKEN }}
          JETBRAINS_PLUGIN_ID: ${{ secrets.JETBRAINS_PLUGIN_ID }}
        run: |
          PLUGIN_ZIP=$(ls extensions/intellij-plugin/build/distributions/pytest-language-server-*.zip | head -1)

          if [ -z "$JETBRAINS_TOKEN" ] || [ -z "$JETBRAINS_PLUGIN_ID" ]; then
            echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
            echo "⚠️  JetBrains Marketplace publishing skipped"
            echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
            echo ""
            echo "✅ Plugin built successfully: $PLUGIN_ZIP"
            echo "✅ Plugin uploaded to GitHub release"
            echo ""
            echo "📦 To publish to JetBrains Marketplace:"
            echo ""
            echo "   Option 1 - Manual upload (first time):"
            echo "   1. Visit https://plugins.jetbrains.com/plugin/add"
            echo "   2. Download the plugin ZIP from GitHub releases"
            echo "   3. Upload and complete the listing"
            echo "   4. Note the plugin ID for automated future releases"
            echo ""
            echo "   Option 2 - Automated (after first publish):"
            echo "   1. Get permanent token: https://plugins.jetbrains.com/author/me/tokens"
            echo "   2. Add secrets to repository settings:"
            echo "      - JETBRAINS_TOKEN: your permanent token"
            echo "      - JETBRAINS_PLUGIN_ID: plugin ID from marketplace"
            echo "   3. Future releases will auto-publish"
            echo ""
            echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
          else
            echo "🚀 Publishing to JetBrains Marketplace (Plugin ID: $JETBRAINS_PLUGIN_ID)..."

            RESPONSE=$(curl -s -w "\n%{http_code}" \
              --header "Authorization: Bearer $JETBRAINS_TOKEN" \
              -F pluginId="$JETBRAINS_PLUGIN_ID" \
              -F file=@"$PLUGIN_ZIP" \
              https://plugins.jetbrains.com/plugin/uploadPlugin)

            HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
            BODY=$(echo "$RESPONSE" | head -n-1)

            if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "201" ]; then
              echo "✅ Successfully published to JetBrains Marketplace!"
            else
              echo "❌ Failed to publish to JetBrains Marketplace"
              echo "HTTP Status: $HTTP_CODE"
              echo "Response: $BODY"
              exit 1
            fi
          fi

  publish-zed:
    name: Publish Zed extension
    runs-on: ubuntu-latest
    # Disabled due to bug in huacnlee/zed-extension-action - regex doesn't handle multiline TOML
    # Manually update version in bellini666/extensions repository after each release
    if: false
    steps:
      - name: Bump Zed extension version
        uses: huacnlee/zed-extension-action@82920ff0876879f65ffbcfa3403589114a8919c6
        with:
          extension-name: pytest-language-server
          extension-path: extensions/zed-extension
          push-to: bellini666/extensions
        env:
          # Personal access token with "repo" & "workflow" scopes
          # Create at: https://github.com/settings/tokens
          COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}