From 8ba2bb511c2edc368880b479e410767ae10cbdaf Mon Sep 17 00:00:00 2001 From: StarHeartHunt Date: Sun, 16 Feb 2025 10:09:24 +0800 Subject: [PATCH 1/4] :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 From 980c272504d1cf8557172d11dcca2435b100ca83 Mon Sep 17 00:00:00 2001 From: StarHeartHunt Date: Sun, 16 Feb 2025 10:11:18 +0800 Subject: [PATCH 2/4] :construction_worker: add pre-commit config --- .pre-commit-config.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4450573 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +default_install_hook_types: [pre-commit, prepare-commit-msg] +ci: + autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks" + autofix_prs: true + autoupdate_branch: main + autoupdate_schedule: monthly + autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks" +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.4 + hooks: + - id: ruff + args: [--fix] + stages: [pre-commit] + - id: ruff-format + stages: [pre-commit] + + - repo: https://github.com/nonebot/nonemoji + rev: v0.1.4 + hooks: + - id: nonemoji + stages: [prepare-commit-msg] From a729d77d4e73df9b3e6d63bd123ea1654d216e8a Mon Sep 17 00:00:00 2001 From: StarHeartHunt Date: Sun, 16 Feb 2025 10:14:49 +0800 Subject: [PATCH 3/4] :green_heart: fix setup --- .github/actions/setup-python/action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml index 8a85cc4..382fd60 100644 --- a/.github/actions/setup-python/action.yml +++ b/.github/actions/setup-python/action.yml @@ -18,3 +18,6 @@ runs: with: python-version: ${{ inputs.python-version }} cache: "poetry" + + - run: poetry install --all-extras + shell: bash From e88ac6bcd57b0ab343e1f6576f36d09145d87274 Mon Sep 17 00:00:00 2001 From: StarHeartHunt Date: Sun, 16 Feb 2025 10:17:15 +0800 Subject: [PATCH 4/4] :green_heart: fix ci --- .github/workflows/pyright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pyright.yml b/.github/workflows/pyright.yml index 6c1c2cb..4cd27b0 100644 --- a/.github/workflows/pyright.yml +++ b/.github/workflows/pyright.yml @@ -25,6 +25,8 @@ jobs: - name: Setup Python environment uses: ./.github/actions/setup-python + - run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH + - name: Run Pyright uses: jakebailey/pyright-action@v2 with: