From a016ca92e78389c781accfac0d5758f436851ca9 Mon Sep 17 00:00:00 2001 From: fanlv Date: Fri, 25 Jul 2025 19:00:14 +0800 Subject: [PATCH] chore(.github): add github ci --- .github/.licenserc.yaml | 25 +++++++ .github/ISSUE_TEMPLATE/bug_report.md | 40 +++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 24 +++++++ .github/PULL_REQUEST_TEMPLATE.md | 44 ++++++++++++ .github/workflows/idl.yaml | 67 ++++++++++++++++++ .github/workflows/license-check.yaml | 35 ++++++++++ .github/workflows/semantic-pull-request.yaml | 69 +++++++++++++++++++ .../api/handler/coze/workflow_service_test.go | 15 ++-- backend/application/base/appinfra/modelmgr.go | 2 +- .../internal/canvas/adaptor/canvas_test.go | 3 +- .../internal/canvas/adaptor/type_convert.go | 1 + .../workflow/internal/nodes/code/code.go | 3 +- .../workflow/internal/nodes/code/code_test.go | 3 +- docker/docker-compose.yml | 6 ++ 14 files changed, 326 insertions(+), 11 deletions(-) create mode 100644 .github/.licenserc.yaml create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/idl.yaml create mode 100644 .github/workflows/license-check.yaml create mode 100644 .github/workflows/semantic-pull-request.yaml diff --git a/.github/.licenserc.yaml b/.github/.licenserc.yaml new file mode 100644 index 00000000..7ffea2f5 --- /dev/null +++ b/.github/.licenserc.yaml @@ -0,0 +1,25 @@ +header: + license: + spdx-id: Apache-2.0 + copyright-owner: coze-dev + + paths: + - '**/*.go' + - frontend/apps/**/*.{ts,tsx} + - frontend/packages/**/*.{ts,tsx} + paths-ignore: + - 'dist' + - 'licenses' + - '**/*.md' + - '**/testdata/**' + - '**/go.mod' + - '**/go.sum' + - 'LICENSE' + - 'NOTICE' + - '**/assets/languages.yaml' + - '**/assets/assets.gen.go' + - '**/gorm_gen/**' + - '**/kitex_gen/**' + - '**/*.gen.go' + files: + - ../backend/go.mod \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..28bb0672 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,40 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** + +A clear and concise description of what the bug is. + +**To Reproduce** + +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** + +A clear and concise description of what you expected to happen. + +**Screenshots** + +If applicable, add screenshots to help explain your problem. + +**Version:** + +Please provide the version of {project_name} you are using. + +**Environment:** + +The output of `go env`. + +**Additional context** + +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..f0291e05 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** + +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** + +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** + +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** + +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..6f8b1a38 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,44 @@ +#### What type of PR is this? + + +#### Check the PR title. + +- [ ] This PR title match the format: \(optional scope): \ +- [ ] The description of this PR title is user-oriented and clear enough for others to understand. +- [ ] Add documentation if the current PR requires user awareness at the usage level. + + +#### (Optional) Translate the PR title into Chinese. + + +#### (Optional) More detailed description for this PR(en: English/zh: Chinese). + +en: +zh(optional): + + +#### (Optional) Which issue(s) this PR fixes: + diff --git a/.github/workflows/idl.yaml b/.github/workflows/idl.yaml new file mode 100644 index 00000000..807ce93b --- /dev/null +++ b/.github/workflows/idl.yaml @@ -0,0 +1,67 @@ +name: Thrift Syntax Validation + +on: + push: + branches: ['main'] + paths: + - 'idl/**' + - '.github/workflows/idl.yaml' + pull_request: + branches: ['main'] + paths: + - 'idl/**' + - '.github/workflows/idl.yaml' + +jobs: + validate-thrift: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + + - name: Install kitex tools + run: | + go install github.com/cloudwego/thriftgo@v0.4.1 + go install github.com/cloudwego/kitex/tool/cmd/kitex@v0.13.1 + go install github.com/cloudwego/thrift-gen-validator@v0.2.6 + + - name: Validate Thrift Files via kitex + run: | + # Initialize error flag + ERROR_FOUND=0 + + # Create temporary working directory + TEMP_DIR=$(mktemp -d) + echo "Created temporary working directory: $TEMP_DIR" + + # Initialize go mod in temp directory + cd "$TEMP_DIR" + go mod init dummy + + # Find all thrift files and validate them + while IFS= read -r -d '' thrift_file; do + echo "Validating $thrift_file..." + if ! kitex -streamx -thrift ignore_initialisms=false -module=dummy "$thrift_file" 2>&1; then + echo "IDL gen code error in file: $thrift_file" + ERROR_FOUND=1 + fi + done < <(find "$GITHUB_WORKSPACE/idl" -name '*.thrift' -print0) + + # Clean up temporary directory + cd "$GITHUB_WORKSPACE" + rm -rf "$TEMP_DIR" + echo "Cleaned up temporary working directory" + + # Exit with appropriate status + if [ $ERROR_FOUND -eq 1 ]; then + echo "Thrift validation failed. Please check the errors above." + exit 1 + else + echo "All Thrift files validated successfully!" + exit 0 + fi diff --git a/.github/workflows/license-check.yaml b/.github/workflows/license-check.yaml new file mode 100644 index 00000000..c88c689a --- /dev/null +++ b/.github/workflows/license-check.yaml @@ -0,0 +1,35 @@ +name: License Check + +on: + push: + branches: ['main'] + pull_request: + + workflow_dispatch: + +jobs: + license-check: + name: License Check + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: 1.23 + + - name: Install license-eye + run: | + go install github.com/apache/skywalking-eyes/cmd/license-eye@v0.4.0 + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: License Header Check + run: | + license-eye header check -c .github/.licenserc.yaml + + - name: License Dependency Check + run: | + license-eye dependency check -c .github/.licenserc.yaml diff --git a/.github/workflows/semantic-pull-request.yaml b/.github/workflows/semantic-pull-request.yaml new file mode 100644 index 00000000..42876d38 --- /dev/null +++ b/.github/workflows/semantic-pull-request.yaml @@ -0,0 +1,69 @@ +name: Semantic Pull Request + +on: + pull_request: + types: + - opened + - reopened + - edited + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.number }} + cancel-in-progress: true + +jobs: + main: + name: Check Pull Request Title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5.5.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # see https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#type + types: | + build + ci + docs + feat + fix + perf + refactor + style + test + chore + # idl: idl + # infra: + # - go version update, lint, database, etc + # - rush update, {eslint,ts,vitest}-config, prettier etc + # frontend + # backend + # workflow: gh workflow + # prompt, evaluation, trace, model, dataset, foundation + scopes: | + idl + frontend + backend + infra + app + singleagent + memory + search + workflow + prompt + knowledge + plugin + middleware + model + database + foundation + + # The pull request's title should be fulfilled the following pattern: + # + # [][] + # + # ... where valid types and scopes can be found above; for example: + # + # [fix][test] flaky test V1_ProxyAuthenticationTest.anonymousSocketTest + headerPattern: '^\[(\w*?)\](?:\[(.*?)\])?(?:\s*)(.*)$' + headerPatternCorrespondence: type, scope, subject diff --git a/backend/api/handler/coze/workflow_service_test.go b/backend/api/handler/coze/workflow_service_test.go index fb66d106..f8678bca 100644 --- a/backend/api/handler/coze/workflow_service_test.go +++ b/backend/api/handler/coze/workflow_service_test.go @@ -40,6 +40,13 @@ import ( "github.com/cloudwego/hertz/pkg/common/ut" "github.com/cloudwego/hertz/pkg/protocol" "github.com/cloudwego/hertz/pkg/protocol/sse" + "github.com/redis/go-redis/v9" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" + "gorm.io/driver/mysql" + "gorm.io/gorm" + modelknowledge "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge" plugin2 "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin" pluginmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin" @@ -76,8 +83,8 @@ import ( "github.com/coze-dev/coze-studio/backend/domain/workflow/entity" "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo" "github.com/coze-dev/coze-studio/backend/domain/workflow/service" - "github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr" "github.com/coze-dev/coze-studio/backend/infra/contract/coderunner" + "github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr" "github.com/coze-dev/coze-studio/backend/infra/impl/checkpoint" "github.com/coze-dev/coze-studio/backend/infra/impl/coderunner/direct" mockCrossUser "github.com/coze-dev/coze-studio/backend/internal/mock/crossdomain/crossuser" @@ -93,12 +100,6 @@ import ( "github.com/coze-dev/coze-studio/backend/pkg/sonic" "github.com/coze-dev/coze-studio/backend/types/consts" "github.com/coze-dev/coze-studio/backend/types/errno" - "github.com/redis/go-redis/v9" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.uber.org/mock/gomock" - "gorm.io/driver/mysql" - "gorm.io/gorm" ) type wfTestRunner struct { diff --git a/backend/application/base/appinfra/modelmgr.go b/backend/application/base/appinfra/modelmgr.go index 00853ba3..41b71f84 100644 --- a/backend/application/base/appinfra/modelmgr.go +++ b/backend/application/base/appinfra/modelmgr.go @@ -100,7 +100,7 @@ func initModelByEnv(wd, templatePath string) (modelEntities []*modelmgr.Model, e modelEntity.Meta.ConnConfig.Model = info.modelID modelEntity.Meta.ConnConfig.APIKey = info.apiKey modelEntity.Meta.ConnConfig.BaseURL = info.baseURL - + modelEntities = append(modelEntities, modelEntity) default: diff --git a/backend/domain/workflow/internal/canvas/adaptor/canvas_test.go b/backend/domain/workflow/internal/canvas/adaptor/canvas_test.go index 9722ed19..21e03390 100644 --- a/backend/domain/workflow/internal/canvas/adaptor/canvas_test.go +++ b/backend/domain/workflow/internal/canvas/adaptor/canvas_test.go @@ -29,10 +29,11 @@ import ( "github.com/bytedance/mockey" "github.com/cloudwego/eino/schema" - "github.com/coze-dev/coze-studio/backend/infra/contract/coderunner" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" + "github.com/coze-dev/coze-studio/backend/infra/contract/coderunner" + userentity "github.com/coze-dev/coze-studio/backend/domain/user/entity" "github.com/coze-dev/coze-studio/backend/domain/workflow" "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/code" diff --git a/backend/domain/workflow/internal/canvas/adaptor/type_convert.go b/backend/domain/workflow/internal/canvas/adaptor/type_convert.go index 4d87a864..c2f539fd 100644 --- a/backend/domain/workflow/internal/canvas/adaptor/type_convert.go +++ b/backend/domain/workflow/internal/canvas/adaptor/type_convert.go @@ -23,6 +23,7 @@ import ( "strings" einoCompose "github.com/cloudwego/eino/compose" + "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/database" "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/knowledge" "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/model" diff --git a/backend/domain/workflow/internal/nodes/code/code.go b/backend/domain/workflow/internal/nodes/code/code.go index 69844f50..ff05837e 100644 --- a/backend/domain/workflow/internal/nodes/code/code.go +++ b/backend/domain/workflow/internal/nodes/code/code.go @@ -23,9 +23,10 @@ import ( "regexp" "strings" - "github.com/coze-dev/coze-studio/backend/infra/contract/coderunner" "golang.org/x/exp/maps" + "github.com/coze-dev/coze-studio/backend/infra/contract/coderunner" + "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes" "github.com/coze-dev/coze-studio/backend/pkg/ctxcache" diff --git a/backend/domain/workflow/internal/nodes/code/code_test.go b/backend/domain/workflow/internal/nodes/code/code_test.go index ef3754f0..69ffb762 100644 --- a/backend/domain/workflow/internal/nodes/code/code_test.go +++ b/backend/domain/workflow/internal/nodes/code/code_test.go @@ -21,10 +21,11 @@ import ( "fmt" "testing" - "github.com/coze-dev/coze-studio/backend/infra/contract/coderunner" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" + "github.com/coze-dev/coze-studio/backend/infra/contract/coderunner" + "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes" mockcode "github.com/coze-dev/coze-studio/backend/internal/mock/domain/workflow/crossdomain/code" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0042be4d..2e66105f 100755 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -458,6 +458,9 @@ services: container_name: coze-mysql-setup-schema profiles: ['middleware', 'mysql-setup', 'run-server'] env_file: *env_file + depends_on: + mysql: + condition: service_healthy volumes: - ./atlas/opencoze_latest_schema.hcl:/opencoze_latest_schema.hcl entrypoint: @@ -493,6 +496,9 @@ services: container_name: coze-mysql-setup-init-sql profiles: ['middleware', 'mysql-setup', 'run-server', 'volcano-setup'] env_file: *env_file + depends_on: + mysql: + condition: service_healthy command: - /bin/sh - -c