From 8ba2bb511c2edc368880b479e410767ae10cbdaf Mon Sep 17 00:00:00 2001 From: StarHeartHunt Date: Sun, 16 Feb 2025 10:09:24 +0800 Subject: [PATCH] :construction_worker: add lint ci --- .github/actions/setup-python/action.yml | 20 ++++++++++++++++ .github/workflows/pyright.yml | 31 +++++++++++++++++++++++++ .github/workflows/ruff.yml | 26 +++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 .github/actions/setup-python/action.yml create mode 100644 .github/workflows/pyright.yml create mode 100644 .github/workflows/ruff.yml diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml new file mode 100644 index 0000000..8a85cc4 --- /dev/null +++ b/.github/actions/setup-python/action.yml @@ -0,0 +1,20 @@ +name: Setup Python +description: Setup Python + +inputs: + python-version: + description: Python version + required: false + default: "3.9" + +runs: + using: "composite" + steps: + - name: Install poetry + run: pipx install poetry + shell: bash + + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + cache: "poetry" diff --git a/.github/workflows/pyright.yml b/.github/workflows/pyright.yml new file mode 100644 index 0000000..6c1c2cb --- /dev/null +++ b/.github/workflows/pyright.yml @@ -0,0 +1,31 @@ +name: Pyright Lint + +on: + push: + branches: + - main + pull_request: + paths: + - "nonebot_plugin_llmchat/**" + - ".github/workflows/pyright.yml" + - "pyproject.toml" + - "poetry.lock" + +jobs: + pyright: + name: Pyright Lint + runs-on: ubuntu-latest + concurrency: + group: lint-${{ github.ref }}-${{ matrix.env }} + cancel-in-progress: true + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python environment + uses: ./.github/actions/setup-python + + - name: Run Pyright + uses: jakebailey/pyright-action@v2 + with: + pylance-version: latest-release diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..b0f1edd --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,26 @@ +name: Ruff Lint + +on: + push: + branches: + - main + pull_request: + paths: + - "nonebot_plugin_llmchat/**" + - ".github/workflows/ruff.yml" + - "pyproject.toml" + - "poetry.lock" + +jobs: + ruff: + name: Ruff Lint + runs-on: ubuntu-latest + concurrency: + group: lint-${{ github.ref }} + cancel-in-progress: true + + steps: + - uses: actions/checkout@v4 + + - name: Run Ruff Lint + uses: astral-sh/ruff-action@v3