Skip to content

Commit 38a8838

Browse files
authored
Merge branch 'main' into sync_3abd28d
2 parents 53f86af + f73903c commit 38a8838

File tree

81 files changed

+2834
-685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2834
-685
lines changed

.gitlab/ci/.build-ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
## Building Images ##############################################
2+
.build:
3+
image: ${ALI_ACR_REGISTRY}/docker:27.3
4+
stage: build
5+
variables:
6+
DOCKER_HOST: "tcp://docker:2375"
7+
DOCKER_TLS_CERTDIR: ""
8+
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
9+
DOCKERCACHE: "${CI_PROJECT_DIR}/.cache/docker"
10+
services:
11+
- name: ${ALI_ACR_REGISTRY}/docker:27.3-dind
12+
command: ["--feature=containerd-snapshotter", "--experimental"]
13+
alias: docker
14+
before_script:
15+
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
16+
- echo "$ALI_ACR_PASSWORD" | docker login -u $ALI_ACR_USER $ALI_ACR_REGISTRY --password-stdin
17+
- |
18+
if [ "$BUILD_TAG" != "saas" ]; then
19+
echo "$DOCKER_REGISTRY_PASSWORD" | docker login -u $DOCKER_REGISTRY_USER --password-stdin
20+
fi
21+
- docker run --privileged --rm ${ALI_ACR_REGISTRY}/tonistiigi/binfmt --install all
22+
- sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
23+
- apk add bash jq
24+
- rm -rf .git
25+
script:
26+
- |
27+
cat <<'EOF' | bash -s
28+
# Generate full image
29+
echo "IMAGE_TAG=$IMAGE_TAG" >> build.env
30+
export IMAGE=${IMAGE_PREFIX}:${IMAGE_TAG}
31+
echo "Building ${IMAGE} for platform ${BUILD_PLATFORMS}."
32+
33+
if [[ $BUILD_TAG == "saas" ]]; then
34+
FLAG=${IMAGE_TAG#*-}
35+
BUILD_TAG=$(cat build_saas_version.json | jq -r \
36+
--arg flag "$FLAG" \
37+
--arg buildTag "saas" \
38+
'.[$flag] + [$buildTag] | join(",")')
39+
fi
40+
41+
BUILD_ARGS=(
42+
--provenance false
43+
--platform ${BUILD_PLATFORMS}
44+
--cache-from type=local,src="$DOCKERCACHE"
45+
--cache-to type=local,dest="$DOCKERCACHE"
46+
--build-arg CSGHUB_TAGS="$BUILD_TAG"
47+
--build-arg IMAGE_TAG="$IMAGE_TAG"
48+
--build-arg CI_COMMIT_SHORT_SHA="$CI_COMMIT_SHORT_SHA"
49+
--file ${DOCKERFILE}
50+
)
51+
52+
BUILD_TAGS=(
53+
--tag ${IMAGE}
54+
)
55+
56+
if [[ $BUILD_OUTPUT == "false" ]]; then
57+
BUILD_TAGS+=(
58+
--tag ${IMAGE#*/}
59+
)
60+
fi
61+
62+
# If building framework images context should be changed
63+
if [[ ! -z $DOCKER_CONTEXT ]]; then
64+
cd $DOCKER_CONTEXT
65+
fi
66+
67+
# Build & Push to ACR default
68+
docker buildx build \
69+
${BUILD_ARGS[@]} \
70+
${BUILD_TAGS[@]} \
71+
--push .
72+
73+
# If ee with tag, output artifacts for pushing to DockerHub
74+
if [[ $BUILD_OUTPUT == "true" ]] && [[ ! -z $IMAGE_TAG ]]; then
75+
docker buildx build \
76+
${BUILD_ARGS[@]} \
77+
--tag ${IMAGE#*/} \
78+
--output type=oci,dest=csghub-server-${IMAGE_TAG}.tar .
79+
fi
80+
EOF
81+
artifacts:
82+
reports:
83+
dotenv: build.env
84+
cache:
85+
key: build-cache
86+
paths:
87+
- .cache
88+
tags:
89+
- docker

.gitlab/ci/.lint-ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## Golang Lint ############################################
2+
.go-lint:
3+
image: ${ALI_ACR_REGISTRY}/golangci/golangci-lint:latest
4+
stage: test
5+
variables:
6+
DOCKER_HOST: "tcp://docker:2375"
7+
DOCKER_TLS_CERTDIR: ""
8+
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
9+
services:
10+
- name: ${ALI_ACR_REGISTRY}/docker:27.3-dind
11+
command: ["--feature=containerd-snapshotter", "--experimental"]
12+
alias: docker
13+
needs: []
14+
before_script:
15+
- go install gotest.tools/gotestsum@latest
16+
- go install github.com/axw/gocov/gocov@latest
17+
- go install github.com/AlekSi/gocov-xml@latest
18+
script:
19+
- gotestsum --junitfile report.xml --format testname -- -tags="$BUILD_TAG" -coverprofile=coverage.out -covermode=atomic ./...
20+
- go tool cover -func=coverage.out
21+
- gocov convert coverage.out | gocov-xml > coverage.xml
22+
interruptible: true
23+
coverage: '/total:\s+\(statements\)\s+\d+.\d+%/'
24+
artifacts:
25+
reports:
26+
coverage_report:
27+
coverage_format: cobertura
28+
path: coverage.xml
29+
junit: report.xml
30+
cache:
31+
key: lint-cache
32+
paths:
33+
- .cache
34+
rules:
35+
- if: $CI_PIPELINE_SOURCE == "schedule"
36+
when: never
37+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
38+
- if: $CI_COMMIT_BRANCH == "main"
39+
tags:
40+
- docker
41+
42+
test-ce:
43+
extends: .go-lint
44+
variables:
45+
BUILD_TAG: ""
46+
47+
test-ee:
48+
extends: .go-lint
49+
variables:
50+
BUILD_TAG: "ee"
51+
52+
test-saas:
53+
extends: .go-lint
54+
variables:
55+
BUILD_TAG: "saas"

.mockery.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ packages:
4747
MirrorNamespaceMappingComponent:
4848
NotebookComponent:
4949
LicenseComponent:
50+
XnetComponent:
5051
opencsg.com/csghub-server/component/reporter:
5152
config:
5253
interfaces:
@@ -79,6 +80,7 @@ packages:
7980
UserSvcClient:
8081
ModerationSvcClient:
8182
NotificationSvcClient:
83+
XnetSvcClient:
8284
opencsg.com/csghub-server/builder/sensitive:
8385
config:
8486
interfaces:

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@ db_rollback:
4444
error_doc:
4545
@go run cmd/csghub-server/main.go errorx doc-gen
4646

47+
error_scan:
48+
@go run cmd/csghub-server/main.go errorx scan --dir $(dir) -v
49+
4750
notify_gen:
4851
@go run cmd/csghub-server/main.go notification notify-gen -l Info

_mocks/opencsg.com/csghub-server/aigateway/component/mock_Moderation.go

Lines changed: 144 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)