Integrate Ruff support for Python code formatting in Pyright LSP Bridge #3
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: Build with Ruff Support | |
| on: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| NODE_VERSION: 'v20.11.0' | |
| RUFF_VERSION: '0.14.3' | |
| jobs: | |
| linux: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| arch: [x64] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build for linux-${{ matrix.arch }} with Ruff | |
| run: | | |
| PLATFORM="linux-${{ matrix.arch }}" | |
| NODE_ARCH="linux-${{ matrix.arch }}" | |
| mkdir -p output/${PLATFORM} | |
| # Bundle TypeScript with esbuild | |
| npx esbuild index.ts \ | |
| --bundle \ | |
| --platform=node \ | |
| --target=node18 \ | |
| --format=esm \ | |
| --outfile=output/${PLATFORM}/bundle.js \ | |
| --external:ws \ | |
| --external:vscode-ws-jsonrpc \ | |
| --external:vscode-jsonrpc \ | |
| --external:dotenv | |
| # Download Node.js runtime | |
| NODE_PKG="node-${NODE_VERSION}-${NODE_ARCH}" | |
| NODE_URL="https://nodejs.org/dist/${NODE_VERSION}/${NODE_PKG}.tar.gz" | |
| curl -L "${NODE_URL}" -o /tmp/${NODE_PKG}.tar.gz | |
| tar -xzf /tmp/${NODE_PKG}.tar.gz -C /tmp/ | |
| mv /tmp/${NODE_PKG} output/${PLATFORM}/node | |
| # Strip unnecessary files from Node.js | |
| cd output/${PLATFORM}/node | |
| rm -rf lib/node_modules/npm lib/node_modules/corepack | |
| rm -f bin/npm bin/npx bin/corepack | |
| rm -rf share/doc share/man share/systemtap include | |
| rm -f README.md CHANGELOG.md LICENSE *.md | |
| strip bin/node 2>/dev/null || true | |
| cd ../../.. | |
| # Download Ruff for Linux | |
| echo "Downloading Ruff ${RUFF_VERSION} for linux-x64..." | |
| RUFF_URL="https://github.com/astral-sh/ruff/releases/download/${RUFF_VERSION}/ruff-x86_64-unknown-linux-gnu.tar.gz" | |
| mkdir -p output/${PLATFORM}/bin | |
| curl -L -A "Mozilla/5.0" "${RUFF_URL}" -o /tmp/ruff.tar.gz | |
| tar -xzf /tmp/ruff.tar.gz -C /tmp/ | |
| cp /tmp/ruff-x86_64-unknown-linux-gnu/ruff output/${PLATFORM}/bin/ruff | |
| chmod +x output/${PLATFORM}/bin/ruff | |
| # Install production dependencies | |
| cp package.json output/${PLATFORM}/ | |
| cd output/${PLATFORM} | |
| npm install --production --no-optional | |
| rm package-lock.json | |
| echo '{"type":"module"}' > package.json | |
| # Prune unnecessary files from node_modules | |
| find node_modules -type d -name "test" -exec rm -rf {} + 2>/dev/null || true | |
| find node_modules -type d -name "tests" -exec rm -rf {} + 2>/dev/null || true | |
| find node_modules -type d -name "docs" -exec rm -rf {} + 2>/dev/null || true | |
| find node_modules -type f -name "*.md" -delete 2>/dev/null || true | |
| find node_modules -type f -name "*.ts" ! -name "*.d.ts" -delete 2>/dev/null || true | |
| find node_modules -type f -name "*.map" -delete 2>/dev/null || true | |
| cd ../.. | |
| # Copy config template | |
| cp pyrightconfig.json output/${PLATFORM}/ | |
| # Create start script with RUFF_PATH | |
| cat > output/${PLATFORM}/start.sh << 'EOF' | |
| #!/bin/bash | |
| DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| export RUFF_PATH="${DIR}/bin/ruff" | |
| "${DIR}/node/bin/node" "${DIR}/bundle.js" "$@" | |
| EOF | |
| chmod +x output/${PLATFORM}/start.sh | |
| # Create compressed archive | |
| cd output | |
| tar -czf ${PLATFORM}.tar.gz ${PLATFORM}/ | |
| cd .. | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-${{ matrix.arch }} | |
| path: output/linux-${{ matrix.arch }}.tar.gz | |
| macos: | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| arch: [x64, arm64] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build for darwin-${{ matrix.arch }} with Ruff | |
| run: | | |
| PLATFORM="darwin-${{ matrix.arch }}" | |
| NODE_ARCH="darwin-${{ matrix.arch }}" | |
| mkdir -p output/${PLATFORM} | |
| # Bundle TypeScript with esbuild | |
| npx esbuild index.ts \ | |
| --bundle \ | |
| --platform=node \ | |
| --target=node18 \ | |
| --format=esm \ | |
| --outfile=output/${PLATFORM}/bundle.js \ | |
| --external:ws \ | |
| --external:vscode-ws-jsonrpc \ | |
| --external:vscode-jsonrpc \ | |
| --external:dotenv | |
| # Download Node.js runtime | |
| NODE_PKG="node-${NODE_VERSION}-${NODE_ARCH}" | |
| NODE_URL="https://nodejs.org/dist/${NODE_VERSION}/${NODE_PKG}.tar.gz" | |
| curl -L "${NODE_URL}" -o /tmp/${NODE_PKG}.tar.gz | |
| tar -xzf /tmp/${NODE_PKG}.tar.gz -C /tmp/ | |
| mv /tmp/${NODE_PKG} output/${PLATFORM}/node | |
| # Strip unnecessary files from Node.js (no strip on macOS binaries) | |
| cd output/${PLATFORM}/node | |
| rm -rf lib/node_modules/npm lib/node_modules/corepack | |
| rm -f bin/npm bin/npx bin/corepack | |
| rm -rf share/doc share/man share/systemtap include | |
| rm -f README.md CHANGELOG.md LICENSE *.md | |
| cd ../../.. | |
| # Download Ruff for macOS | |
| echo "Downloading Ruff ${RUFF_VERSION} for darwin-${{ matrix.arch }}..." | |
| if [ "${{ matrix.arch }}" = "x64" ]; then | |
| RUFF_ARCH="x86_64" | |
| else | |
| RUFF_ARCH="aarch64" | |
| fi | |
| RUFF_URL="https://github.com/astral-sh/ruff/releases/download/${RUFF_VERSION}/ruff-${RUFF_ARCH}-apple-darwin.tar.gz" | |
| mkdir -p output/${PLATFORM}/bin | |
| curl -L -A "Mozilla/5.0" "${RUFF_URL}" -o /tmp/ruff.tar.gz | |
| tar -xzf /tmp/ruff.tar.gz -C /tmp/ | |
| cp /tmp/ruff-${RUFF_ARCH}-apple-darwin/ruff output/${PLATFORM}/bin/ruff | |
| chmod +x output/${PLATFORM}/bin/ruff | |
| # Install production dependencies | |
| cp package.json output/${PLATFORM}/ | |
| cd output/${PLATFORM} | |
| npm install --production --no-optional | |
| rm package-lock.json | |
| echo '{"type":"module"}' > package.json | |
| # Prune unnecessary files from node_modules | |
| find node_modules -type d -name "test" -exec rm -rf {} + 2>/dev/null || true | |
| find node_modules -type d -name "tests" -exec rm -rf {} + 2>/dev/null || true | |
| find node_modules -type d -name "docs" -exec rm -rf {} + 2>/dev/null || true | |
| find node_modules -type f -name "*.md" -delete 2>/dev/null || true | |
| find node_modules -type f -name "*.ts" ! -name "*.d.ts" -delete 2>/dev/null || true | |
| find node_modules -type f -name "*.map" -delete 2>/dev/null || true | |
| cd ../.. | |
| # Copy config template | |
| cp pyrightconfig.json output/${PLATFORM}/ | |
| # Create start script with RUFF_PATH | |
| cat > output/${PLATFORM}/start.sh << 'EOF' | |
| #!/bin/bash | |
| DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| export RUFF_PATH="${DIR}/bin/ruff" | |
| "${DIR}/node/bin/node" "${DIR}/bundle.js" "$@" | |
| EOF | |
| chmod +x output/${PLATFORM}/start.sh | |
| # Create compressed archive | |
| cd output | |
| tar -czf ${PLATFORM}.tar.gz ${PLATFORM}/ | |
| cd .. | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: darwin-${{ matrix.arch }} | |
| path: output/darwin-${{ matrix.arch }}.tar.gz | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [linux, macos] | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: artifacts/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| body: | | |
| ## Pyright LSP Bridge with Ruff Formatting Support | |
| This release includes Ruff formatter bundled with the language server. | |
| ### Platform Support | |
| - ✅ Linux x64 with Ruff | |
| - ✅ macOS Intel (x64) with Ruff | |
| - ✅ macOS Apple Silicon (arm64) with Ruff | |
| ### Features | |
| - Python language server (Pyright) | |
| - Code formatting (Ruff) | |
| - Cross-platform support | |
| - Bundled Node.js runtime | |
| ### Installation | |
| **Linux:** | |
| ```bash | |
| tar -xzf linux-x64-with-ruff.tar.gz | |
| cd linux-x64 | |
| ./start.sh --port 9011 --bot-root /path/to/bot --jesse-root /path/to/jesse | |
| ``` | |
| **macOS:** | |
| ```bash | |
| tar -xzf darwin-arm64-with-ruff.tar.gz # or darwin-x64-with-ruff.tar.gz | |
| cd darwin-arm64 # or darwin-x64 | |
| ./start.sh --port 9011 --bot-root /path/to/bot --jesse-root /path/to/jesse | |
| ``` | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |