From e9361125bcc1c12ebe6abd023a85f52e1bcd5f8d Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Fri, 31 Jan 2025 09:51:51 +0800 Subject: [PATCH] doc: Update CLI help output (#53) * doc: Update CLI help output * doc: Update CLI help output * doc: Update CLI help output * fix: Fix max-length not work issue * fix: Fix max-length not work issue * fix: Fix max-length not work issue * fix: Fix max-length not work issue * fix: Fix max-length not work issue * fix: Fix max-length not work issue * fix: Fix max-length not work issue * fix: Fix max-length not work issue * fix: Fix max-length not work issue --- .github/workflows/basic.yml | 1 + README.md | 7 ++++--- README.zh-CN.md | 7 ++++--- action.yaml | 14 +++++++------- nu/review.nu | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index 7814e63..9c50ba2 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -20,4 +20,5 @@ jobs: - name: Deepseek Code Review uses: hustcer/deepseek-review@develop with: + max-length: 10 chat-token: ${{ secrets.CHAT_TOKEN }} diff --git a/README.md b/README.md index 05e519c..e4aec22 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ To perform code reviews locally, you need to install the following tools: - Once the tools are installed, simply clone this repository to your local machine, navigate to the repository directory, and run `just code-review -h` or `just cr -h`. You should see an output similar to the following: ```console -Use Deepseek AI to review code changes +Use Deepseek AI to review code changes locally or in GitHub Actions Usage: > deepseek-review {flags} (token) @@ -90,9 +90,10 @@ Flags: -d, --debug: Debug mode -r, --repo : GitHub repository name, e.g. hustcer/deepseek-review -n, --pr-number : GitHub PR number - --gh-token : Your GitHub token, GITHUB_TOKEN by default + --gh-token : Your GitHub token, fallback to GITHUB_TOKEN env var -t, --diff-to : Diff to git REF -f, --diff-from : Diff from git REF + -l, --max-length : Maximum length of the content for review, 0 means no limit. -m, --model : Model name, deepseek-chat by default (default: 'deepseek-chat') --base-url (default: 'https://api.deepseek.com') -s, --sys-prompt (default: 'You are a professional code review assistant responsible for analyzing code changes in GitHub Pull Requests. Identify potential issues such as code style violations, logical errors, security vulnerabilities, and provide improvement suggestions. Clearly list the problems and recommendations in a concise manner.') @@ -100,7 +101,7 @@ Flags: -h, --help: Display the help message for this command Parameters: - token : Your Deepseek API token, fallback to CHAT_TOKEN (optional) + token : Your Deepseek API token, fallback to CHAT_TOKEN env var (optional) ``` diff --git a/README.zh-CN.md b/README.zh-CN.md index 723b8e8..1cb4c57 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -79,7 +79,7 @@ Deepseek 接口调用入参: - 接下来只需要把本仓库代码克隆到本地,然后进入仓库目录执行 `just code-review -h` 或者 `just cr -h` 即可看到类似如下输出: ```console -Use Deepseek AI to review code changes +Use Deepseek AI to review code changes locally or in GitHub Actions Usage: > deepseek-review {flags} (token) @@ -88,9 +88,10 @@ Flags: -d, --debug: Debug mode -r, --repo : GitHub repository name, e.g. hustcer/deepseek-review -n, --pr-number : GitHub PR number - --gh-token : Your GitHub token, GITHUB_TOKEN by default + --gh-token : Your GitHub token, fallback to GITHUB_TOKEN env var -t, --diff-to : Diff to git REF -f, --diff-from : Diff from git REF + -l, --max-length : Maximum length of the content for review, 0 means no limit. -m, --model : Model name, deepseek-chat by default (default: 'deepseek-chat') --base-url (default: 'https://api.deepseek.com') -s, --sys-prompt (default: 'You are a professional code review assistant responsible for analyzing code changes in GitHub Pull Requests. Identify potential issues such as code style violations, logical errors, security vulnerabilities, and provide improvement suggestions. Clearly list the problems and recommendations in a concise manner.') @@ -98,7 +99,7 @@ Flags: -h, --help: Display the help message for this command Parameters: - token : Your Deepseek API token, fallback to CHAT_TOKEN (optional) + token : Your Deepseek API token, fallback to CHAT_TOKEN env var (optional) ``` diff --git a/action.yaml b/action.yaml index 071012c..0a9acd2 100644 --- a/action.yaml +++ b/action.yaml @@ -19,8 +19,8 @@ inputs: required: true description: 'Your deepseek API token.' max-length: - required: false default: 0 + required: false description: 'The maximum length of the content for review, 0 means no limit.' model: required: false @@ -52,15 +52,15 @@ runs: run: | const NU_LIB_DIRS = [ ${{ github.action_path }}/nu ] use review.nu * - let model = '${{inputs.model}}' + let model = '${{ inputs.model }}' let ghToken = '${{ github.token }}' - let baseUrl = '${{inputs.base-url}}' + let baseUrl = '${{ inputs.base-url }}' let repo = '${{ github.repository }}' - let token = '${{inputs.chat-token}}' - let sysPrompt = '${{inputs.sys-prompt}}' - let userPrompt = '${{inputs.user-prompt}}' - let maxLength = ${{inputs.max-length}} | into int + let token = '${{ inputs.chat-token }}' + let sysPrompt = '${{ inputs.sys-prompt }}' + let userPrompt = '${{ inputs.user-prompt }}' let pr = '${{ github.event.pull_request.number }}' + let maxLength = try { '${{ inputs.max-length }}' | into int } catch { 0 } (deepseek-review $token --model $model --repo $repo diff --git a/nu/review.nu b/nu/review.nu index 4e1ba48..002151b 100644 --- a/nu/review.nu +++ b/nu/review.nu @@ -92,7 +92,7 @@ export def --env deepseek-review [ print $'(char nl)(ansi r)The content length ($length) exceeds the maximum limit ($max_length), review skipped.(ansi reset)' exit $ECODE.SUCCESS } - print $'Review content length: (ansi g)($length)(ansi reset)' + print $'Review content length: (ansi g)($length)(ansi reset), current max length: (ansi g)($max_length)(ansi reset)' let payload = { model: $model, stream: false,