mirror of
https://github.com/hustcer/deepseek-review.git
synced 2026-05-13 05:16:05 +08:00
chore: Add basic code skeleton
This commit is contained in:
62
.github/workflows/basic.yml
vendored
62
.github/workflows/basic.yml
vendored
@@ -3,71 +3,27 @@
|
|||||||
# REF:
|
# REF:
|
||||||
# - https://github.com/marketplace/actions/checkout
|
# - https://github.com/marketplace/actions/checkout
|
||||||
|
|
||||||
name: Setup-Moonbit@Dev
|
name: Code Review@Dev
|
||||||
on:
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened]
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- develop
|
- main
|
||||||
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
setup-moonbit:
|
setup-deepseek-review:
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
name: Setup MoonBit@${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Moonbit
|
|
||||||
uses: hustcer/setup-moonbit@develop
|
|
||||||
|
|
||||||
- name: Check Moonbit Version
|
|
||||||
run: |
|
|
||||||
moon version --all
|
|
||||||
|
|
||||||
setup-moonbit-of-version:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
name: Setup MoonBit with Version@${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Moonbit with Version
|
|
||||||
uses: hustcer/setup-moonbit@develop
|
|
||||||
with:
|
|
||||||
setup-core: false
|
|
||||||
version: 0.1.20250108+7a6b9ab0e
|
|
||||||
|
|
||||||
- name: Check Moonbit Version
|
|
||||||
run: |
|
|
||||||
moon version --all
|
|
||||||
|
|
||||||
setup-moonbit-bleeding:
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest]
|
os: [macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
name: Setup MoonBit Bleeding@${{ matrix.os }}
|
name: Deepseek Code Review@${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Moonbit Bleeding
|
- name: Setup Deepseek Code Review
|
||||||
uses: hustcer/setup-moonbit@develop
|
uses: hustcer/deepseek-review@main
|
||||||
with:
|
with:
|
||||||
version: bleeding
|
deepseek-token: ${{ secrets.DEEPSEEK_TOKEN }}
|
||||||
|
|
||||||
- name: Check Moonbit Version
|
|
||||||
run: |
|
|
||||||
moon version --all
|
|
||||||
|
|||||||
11
Justfile
11
Justfile
@@ -1,7 +1,7 @@
|
|||||||
# Author: hustcer
|
# Author: hustcer
|
||||||
# Create: 2023/10/29 18:05:20
|
# Create: 2025/01/29 13:05:20
|
||||||
# Description:
|
# Description:
|
||||||
# Some helper task for setup-moonbit
|
# Some helper task for deepseek-review
|
||||||
# Ref:
|
# Ref:
|
||||||
# 1. https://github.com/casey/just
|
# 1. https://github.com/casey/just
|
||||||
# 2. https://www.nushell.sh/book/
|
# 2. https://www.nushell.sh/book/
|
||||||
@@ -21,7 +21,7 @@ set dotenv-load := true
|
|||||||
set positional-arguments := true
|
set positional-arguments := true
|
||||||
|
|
||||||
# Just commands aliases
|
# Just commands aliases
|
||||||
alias f := fetch
|
alias cr := code-review
|
||||||
|
|
||||||
# Use `just --evaluate` to show env vars
|
# Use `just --evaluate` to show env vars
|
||||||
|
|
||||||
@@ -43,6 +43,11 @@ release *OPTIONS:
|
|||||||
@overlay use {{ join(DEEPSEEK_REIVEW_PATH, 'nu', 'release.nu') }}; \
|
@overlay use {{ join(DEEPSEEK_REIVEW_PATH, 'nu', 'release.nu') }}; \
|
||||||
make-release {{OPTIONS}}
|
make-release {{OPTIONS}}
|
||||||
|
|
||||||
|
# Code review for GitHub PRs or local changes
|
||||||
|
code-review *OPTIONS:
|
||||||
|
@overlay use {{ join(DEEPSEEK_REIVEW_PATH, 'nu', 'review.nu') }}; \
|
||||||
|
deepseek-review {{OPTIONS}}
|
||||||
|
|
||||||
# Plugins need to be registered only once after nu v0.61
|
# Plugins need to be registered only once after nu v0.61
|
||||||
_setup:
|
_setup:
|
||||||
@register -e json {{ join(NU_DIR, _query_plugin) }}
|
@register -e json {{ join(NU_DIR, _query_plugin) }}
|
||||||
|
|||||||
42
README.md
42
README.md
@@ -1,47 +1,7 @@
|
|||||||
# Setup MoonBit Action
|
# Deepseek Code Review
|
||||||
|
|
||||||
[中文说明](README.zh-CN.md)
|
[中文说明](README.zh-CN.md)
|
||||||
|
|
||||||
[](https://github.com/hustcer/setup-moonbit/actions/workflows/basic.yml)
|
|
||||||
[](https://github.com/hustcer/setup-moonbit/actions/workflows/daily.yml)
|
|
||||||
|
|
||||||
This GitHub Action will setup a [MoonBit](https://www.moonbitlang.com/) environment for you. It should work on Github `macOS` , `Ubuntu` , and `Windows` runners.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Basic
|
|
||||||
|
|
||||||
It's quite simple to use `hustcer/setup-moonbit` , just follow the example below:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Moonbit
|
|
||||||
uses: hustcer/setup-moonbit@v1
|
|
||||||
|
|
||||||
- name: Check Moonbit Version
|
|
||||||
run: |
|
|
||||||
moon version --all
|
|
||||||
```
|
|
||||||
|
|
||||||
Or, check the [test.yaml](https://github.com/hustcer/setup-moonbit/blob/main/.github/workflows/test.yml) example.
|
|
||||||
|
|
||||||
In rare circumstances you might get rate limiting errors, if this happens you can set the `GITHUB_TOKEN` environment variable.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: hustcer/setup-moonbit@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Inputs
|
|
||||||
|
|
||||||
| Name | Required | Description | Type | Default |
|
|
||||||
| ------------ | -------- | ------------ | ------ | --------- |
|
|
||||||
| `version` | no | A valid moonbit tool chain version, such as `0.1.20250108+7a6b9ab0e`, `nightly`, `latest`, etc. or even `bleeding` | string | `latest`|
|
|
||||||
| `setup-core` | no | `true` to download and bundle Moonbit Core, `false` to ignore it | bool | `true` |
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +1,5 @@
|
|||||||
# Setup MoonBit Action
|
# Deepseek Code Review
|
||||||
|
|
||||||
[](https://github.com/hustcer/setup-moonbit/actions/workflows/basic.yml)
|
|
||||||
|
|
||||||
本 GitHub Action 将为你配置一个 [MoonBit](https://www.moonbitlang.com/) 开发环境。适用于 Github `macOS` , `Ubuntu` 和 `Windows` 工作流运行时镜像。
|
|
||||||
|
|
||||||
## 使用
|
|
||||||
|
|
||||||
### 基础使用
|
|
||||||
|
|
||||||
使用 `hustcer/setup-moonbit` 非常简单,只需要按照下面示例即可:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Moonbit
|
|
||||||
uses: hustcer/setup-moonbit@v1
|
|
||||||
|
|
||||||
- name: Check Moonbit Version
|
|
||||||
run: |
|
|
||||||
moon version --all
|
|
||||||
```
|
|
||||||
|
|
||||||
或者也可以参考下本仓库的 [test.yaml](https://github.com/hustcer/setup-moonbit/blob/main/.github/workflows/test.yml) 例子。
|
|
||||||
|
|
||||||
在极少数情况下,你可能会看到速率限制之类的错误。如果发生这种情况,你可以通过设置 `GITHUB_TOKEN` 环境变量来避免该问题:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: hustcer/setup-moonbit@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 输入
|
|
||||||
|
|
||||||
| 参数名 | 必填 | 描述 | 类型 | 默认值 |
|
|
||||||
| ---------------- | -------- | --- | ------ | --------- |
|
|
||||||
| `version` | 否 | 合法的 Moonbit 工具链版本,比如: `0.1.20250108+7a6b9ab0e`, `nightly`, `latest` 或者 `bleeding` | string | `latest` |
|
|
||||||
| `setup-core` | 否 | 设置为 `true` 则下载并打包 Moonbit Core, `false` 则忽略 | bool | `true` |
|
|
||||||
|
|
||||||
## 许可
|
## 许可
|
||||||
|
|
||||||
|
|||||||
39
action.yaml
39
action.yaml
@@ -15,14 +15,25 @@ branding:
|
|||||||
color: 'purple'
|
color: 'purple'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
deepseek-token:
|
||||||
|
required: true
|
||||||
|
description: 'Your deepseek API token.'
|
||||||
|
model:
|
||||||
required: false
|
required: false
|
||||||
default: 'latest'
|
default: 'deepseek-chat'
|
||||||
description: 'The moonbit toolchain version to setup.'
|
description: 'The deepseek model to choose for code review.'
|
||||||
setup-core:
|
base-url:
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: 'https://api.deepseek.com'
|
||||||
description: 'Set to `true` if you want to setup moonbit core.'
|
description: 'The base url of deepseek API.'
|
||||||
|
sys-prompt:
|
||||||
|
required: false
|
||||||
|
default: '你是一个专业的代码审查助手,负责分析GitHub Pull Request的代码变更,指出潜在的问题,如代码风格、逻辑错误、安全漏洞,并提供改进建议。请用简洁明了的语言列出问题及建议。'
|
||||||
|
description: 'The system prompt for deepseek API.'
|
||||||
|
user-prompt:
|
||||||
|
required: false
|
||||||
|
default: '请分析以下代码变更:'
|
||||||
|
description: 'The user prompt for deepseek API.'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
@@ -36,7 +47,17 @@ runs:
|
|||||||
shell: nu {0}
|
shell: nu {0}
|
||||||
run: |
|
run: |
|
||||||
use ${{ github.action_path }}/nu/review.nu *
|
use ${{ github.action_path }}/nu/review.nu *
|
||||||
let version = '${{inputs.version}}'
|
let model = '${{inputs.model}}'
|
||||||
let setupCore = '${{inputs.setup-core}}' | into bool
|
let baseUrl = '${{inputs.base-url}}'
|
||||||
deepseek-review $version --setup-core=$setupCore
|
let token = '${{inputs.deepseek-token}}'
|
||||||
|
let sysPrompt = '${{inputs.sys-prompt}}'
|
||||||
|
let ghToken = '${{secrets.GITHUB_TOKEN}}'
|
||||||
|
let userPrompt = '${{inputs.user-prompt}}'
|
||||||
|
(deepseek-review $token
|
||||||
|
--model $model
|
||||||
|
--base-url $baseUrl
|
||||||
|
--gh-token $ghToken
|
||||||
|
--sys-prompt $sysPrompt
|
||||||
|
--user-prompt $userPrompt
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
# tags: backend security
|
# tags: backend security
|
||||||
# run: bundle audit
|
# run: bundle audit
|
||||||
#
|
#
|
||||||
min_version: 1.8.0
|
min_version: 1.10.0
|
||||||
no_tty: false
|
no_tty: false
|
||||||
skip_output:
|
skip_output:
|
||||||
- meta # Skips lefthook version printing
|
- meta # Skips lefthook version printing
|
||||||
|
|||||||
16
nu/review.nu
16
nu/review.nu
@@ -8,7 +8,21 @@
|
|||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
|
|
||||||
export def deepseek-review [] {
|
const DEFAULT_OPTIONS = {
|
||||||
|
MODEL: 'deepseek-chat',
|
||||||
|
BASE_URL: 'https://api.deepseek.com',
|
||||||
|
USER_PROMPT: '请分析以下代码变更:',
|
||||||
|
SYS_PROMPT: '你是一个专业的代码审查助手,负责分析GitHub Pull Request的代码变更,指出潜在的问题,如代码风格、逻辑错误、安全漏洞,并提供改进建议。请用简洁明了的语言列出问题及建议。',
|
||||||
|
}
|
||||||
|
|
||||||
|
export def deepseek-review [
|
||||||
|
token: string, # Your Deepseek API token
|
||||||
|
--gh-token: string, # Your Github token, GITHUB_TOKEN by default
|
||||||
|
--model: string = $DEFAULT_OPTIONS.MODEL, # Model name, deepseek-chat by default
|
||||||
|
--base-url: string = $DEFAULT_OPTIONS.BASE_URL,
|
||||||
|
--sys-prompt: string = $DEFAULT_OPTIONS.SYS_PROMPT,
|
||||||
|
--user-prompt: string = $DEFAULT_OPTIONS.USER_PROMPT,
|
||||||
|
] {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user