Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ pnpm-lock.yaml merge=ours
shrinkwrap.yaml merge=binary
npm-shrinkwrap.json merge=binary
yarn.lock merge=binary
# 不做自动解决冲突,暴露冲突后由开发者自行 rush pull-idl 做更新
# packages/arch/idl/bam.log.json merge=ours

# Rush's JSON config files use JavaScript-style code comments. The rule below prevents pedantic
# syntax highlighters such as GitHub's from highlighting these comments as errors. Your text editor
Expand Down
File renamed without changes.
13 changes: 10 additions & 3 deletions .golangci.yaml → .github/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
version: "2"

run:
timeout: 5m
skip-dirs:
- kitex_gen
- loop_gen
- gorm_gen

linters: # https://golangci-lint.run/usage/linters/
disable-all: true
enable:
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- unconvert

formatters:
enable:
- goimports
- gofmt
- gofumpt
Expand All @@ -19,5 +27,4 @@ linters-settings:
gofumpt:
# Choose whether to use the extra rules.
extra-rules: true
goimports:
local-prefixes: github.com/coze-dev/cozeloop
goimports:
26 changes: 22 additions & 4 deletions .licenserc.yaml → .github/.licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ header:

paths:
- '**/*.go'
- '**/*.ts'
- '**/*.tsx'
- frontend/apps/**/*.{ts,tsx,less,css}
- frontend/packages/cozeloop/**/*.{ts,tsx,less,css}

paths-ignore:
- 'node_modules'
- 'dist'
- 'licenses'
- '**/*.md'
- '**/*.hz'
- '**/*.yaml'
- 'LICENSE'
- 'NOTICE'
- "**/mocks/**"
- "**/gorm_gen/**"
- "**/kitex_gen/**"
Expand All @@ -22,10 +30,20 @@ header:
- "backend/api/router/coze/loop/apis/coze.loop.apis.go"
- "backend/modules/observability/domain/trace/entity/collector/**/*.go"
- "backend/modules/observability/domain/trace/service/collector/processor/queueprocessor/queue_processor.go"
- 'frontend/packages/cozeloop/api-schema/src/api/idl'

comment: on-failure

dependency:
files:
- go.mod
- package.json
- ../backend/go.mod
licenses:
- name: github.com/cloudwego/eino-ext/*/*/*
license: Apache-2.0
excludes:
- name: github.com/alicebob/gopher-json
license: Unlicense
- name: github.com/hashicorp/*
license: MPL-2.0
- name: github.com/go-sql-driver/mysql
license: MPL-2.0
33 changes: 33 additions & 0 deletions .github/scripts/branch-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# 如果未提供目标分支,使用 main 分支
if [ -z "$1" ]; then
target_branch="origin/main"
else
target_branch=$1
fi

diff_list=$(git diff --name-only "$target_branch" -- 'common/*' 'frontend/*')
convert_to_json_array() {
local input_string="$1"
local output_array="["

# 使用 IFS 变量临时更改字段分隔符为换行符
old_ifs=$IFS
IFS=$'\n'

# 将字符串分割为单词并添加到数组中
for word in $input_string; do
output_array+="\"$word\","
done

# 移除最后一个逗号并关闭数组
output_array=${output_array%,}"]"

# 恢复原始 IFS 值
IFS=$old_ifs

echo "$output_array"
}

echo "$(convert_to_json_array "$diff_list")"
44 changes: 29 additions & 15 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
name: CI@backend

on:
push:
branches:
- main
branches: ["main"]
paths:
- 'backend/**'
- '.github/workflows/backend-ci.yaml'
pull_request:
branches:
- main
branches: ["main"]
paths:
- 'backend/**'
- '.github/workflows/backend-ci.yaml'

jobs:
golangci-lint:
golang-lint:
name: Golang CI Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- name: Set up Go
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.23.4"
- name: Golangci Lint

- name: Golang Lint
# https://golangci-lint.run/
uses: golangci/golangci-lint-action@v6
with:
version: latest
only-new-issues: true
run: |
# Install golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.2.1

# Add golangci-lint to PATH
export PATH=$PATH:$(go env GOPATH)/bin

# Run golangci-lint
golangci-lint run --config ../.github/.golangci.yaml

build-and-unittest:
name: Build and Unit Test
Expand All @@ -41,19 +49,25 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.23.4"

- name: Build
run: go build -v ./...

- name: Run Unit Tests
run: go test -gcflags="all=-N -l" -race -v -coverprofile=coverage.out -coverpkg=./... ./...
run: |
go test -gcflags="all=-N -l" -race -v -coverprofile=coverage.out -coverpkg=./... ./...

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./coverage.out
files: ./coverage.out
flags: unittests
slug: coze-dev/cozeloop
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
73 changes: 73 additions & 0 deletions .github/workflows/frontend-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI@frontend - Main

on:
push:
branches: ["main"]
paths:
- 'frontend/**'
- '.github/workflows/frontend-ci.yaml'
pull_request:
branches: ["main"]
paths:
- 'frontend/**'
- '.github/workflows/frontend-ci.yaml'
workflow_dispatch:

jobs:
setup:
name: Setup jobs
runs-on: ubuntu-latest
env:
NODE_VERSION: '18'
# should be ci trigger user
GIT_USER_NAME: 'mocayo'
GIT_USER_EMAIL: '[email protected]'
BUILD_BRANCH: ${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Config Git User
run: |
git config --local user.name ${{ env.GIT_USER_NAME }}
git config --local user.email ${{ env.GIT_USER_EMAIL }}

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache
uses: actions/cache@v4
with:
path: |
common/temp/pnpm-local
common/temp/pnpm-store
common/temp/install-run
key: ${{ runner.os }}-rush-store-${{ hashFiles('common/config/subspaces/default/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-rush-store-main
${{ runner.os }}-rush-store

- name: Branch Diff
id: branch-diff
run: |
TARGET_BRANCH="${GITHUB_BASE_REF:-main}"
git fetch origin $TARGET_BRANCH
sh .github/scripts/branch-diff.sh origin/$TARGET_BRANCH > changed.json
echo "file=changed.json" >> "$GITHUB_OUTPUT"

- name: Install Dependencies
run: |
node common/scripts/install-run-rush.js install

- name: Build All
run: |
node common/scripts/install-run-rush.js rebuild --verbose --timeline

- name: Lint & Style
run: |
node common/scripts/install-run-rush.js increment --action lint -p ${{ steps.branch-diff.outputs.file }}
node common/scripts/install-run-rush.js increment --action style -p ${{ steps.branch-diff.outputs.file }}
71 changes: 71 additions & 0 deletions .github/workflows/frontend-tsc-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI@frontend - TS Check

on:
push:
branches: ["main"]
paths:
- 'frontend/**'
- '.github/workflows/frontend-tsc-ci.yaml'
pull_request:
branches: ["main"]
paths:
- 'frontend/**'
- '.github/workflows/frontend-tsc-ci.yaml'
workflow_dispatch:

jobs:
setup:
name: Setup jobs
runs-on: ubuntu-latest
env:
NODE_VERSION: '18'
# should be ci trigger user
GIT_USER_NAME: 'mocayo'
GIT_USER_EMAIL: '[email protected]'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Config Git User
run: |
git config --local user.name ${{ env.GIT_USER_NAME }}
git config --local user.email ${{ env.GIT_USER_EMAIL }}

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache
uses: actions/cache@v4
with:
path: |
common/temp/pnpm-local
common/temp/pnpm-store
common/temp/install-run
key: ${{ runner.os }}-rush-store-${{ hashFiles('common/config/subspaces/default/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-rush-store-main
${{ runner.os }}-rush-store

- name: Branch Diff
id: branch-diff
run: |
TARGET_BRANCH="${GITHUB_BASE_REF:-main}"
git fetch origin $TARGET_BRANCH
sh .github/scripts/branch-diff.sh origin/$TARGET_BRANCH > changed.json
echo "file=changed.json" >> "$GITHUB_OUTPUT"

- name: Install Dependencies
run: |
node common/scripts/install-run-rush.js increment --action install -p ${{ steps.branch-diff.outputs.file }}

- name: Prepare Basic Packages
run: |
node common/scripts/install-run-rush.js pre-build -v

- name: TS Check
run: |
node common/scripts/install-run-rush.js increment --action ts-check -p ${{ steps.branch-diff.outputs.file }}
Loading
Loading