Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 完成通知域基础功能 #1

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
tags: [ "v*.*.*" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
31 changes: 31 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI
on:
push:
branches: [ "main" ]
tags: [ "v*.*.*" ]
pull_request:
branches: [ "main" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- linux-amd64-fmt
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v4
with:
go-version: "stable"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: go test
run: go test ./...
84 changes: 84 additions & 0 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Upgrade

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
REGISTRY: docker.io
USERNAME: lansongxx
IMAGE_NAME: cloudmind-system

jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Bump Version
id: version
run: curl -s https://raw.githubusercontent.com/xh-polaris/chore/main/bump_version.sh | bash -s -- ${{ env.USERNAME }}/${{ env.IMAGE_NAME }}

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name == 'push'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
steps:
- name: Setup Kubectl
uses: azure/setup-kubectl@v3
with:
version: ${{ vars.KUBE_VERSION }}

- name: Deploy
run: |
mkdir $HOME/.kube
echo "${{ secrets.KUBE_CONFIG }}" > $HOME/.kube/config
kubectl get deployment ${{ env.IMAGE_NAME }} -n ${{ vars.BASE_TEST_NAMESPACE }} -o yaml |\
sed 's/^\( - image: lansongxx\/${{ env.IMAGE_NAME }}:\).*$/\1${{ needs.build.outputs.version }}/' |\
kubectl apply -f -
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*.dll
*.so
*.dylib

etc
output
# Test binary, built with `go test -c`
*.test

Expand Down
32 changes: 32 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
run:
go: '1.18'
timeout: 30m

linters:
disable-all: true
enable: # please keep this alphabetized
# Don't use soon to deprecated[1] linters that lead to false
# https://github.com/golangci/golangci-lint/issues/1841
# - deadcode
# - structcheck
# - varcheck
- ineffassign
- staticcheck
- stylecheck
- unused
- revive

linters-settings: # please keep this alphabetized
staticcheck:
checks:
- "all"
- "-SA1019" # TODO(fix) Using a deprecated function, variable, constant or field
- "-SA2002" # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isn’t allowed
stylecheck:
checks:
- "ST1019" # Importing the same package multiple times.
revive:
rules:
- name: var-naming
disabled: true
arguments: [["ID", "URL", "RPC"]]
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM golang:1.20-alpine AS builder

LABEL stage=gobuilder

ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

RUN apk update --no-cache && apk add --no-cache tzdata

WORKDIR /build

ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
RUN sh ./build.sh

FROM alpine

COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai

ENV TZ Asia/Shanghai

WORKDIR /app
COPY --from=builder /build/output /app

CMD ["sh", "./bootstrap.sh"]
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.PHONY: start build wire clean

run:
sh ./output/bootstrap.sh
build:
sh ./build.sh
build_and_run:
sh ./build.sh && sh ./output/bootstrap.sh
wire:
wire ./provider
clean:
rm -r ./output
38 changes: 38 additions & 0 deletions biz/adaptor/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package adaptor

import (
"context"
"github.com/CloudStriver/service-idl-gen-go/kitex_gen/cloudmind/system"

"github.com/CloudStriver/cloudmind-system/biz/application/service"
"github.com/CloudStriver/cloudmind-system/biz/infrastructure/config"
)

type SystemServerImpl struct {
*config.Config
SystemService service.SystemService
}

func (s *SystemServerImpl) ReadNotifications(ctx context.Context, req *system.ReadNotificationsReq) (res *system.ReadNotificationsResp, err error) {
return s.SystemService.ReadNotifications(ctx, req)
}

func (s *SystemServerImpl) GetNotifications(ctx context.Context, req *system.GetNotificationsReq) (res *system.GetNotificationsResp, err error) {
return s.SystemService.GetNotifications(ctx, req)
}

func (s *SystemServerImpl) CleanNotification(ctx context.Context, req *system.CleanNotificationReq) (res *system.CleanNotificationResp, err error) {
return s.SystemService.CleanNotification(ctx, req)
}

func (s *SystemServerImpl) GetNotificationCount(ctx context.Context, req *system.GetNotificationCountReq) (res *system.GetNotificationCountResp, err error) {
return s.SystemService.GetNotificationCount(ctx, req)
}

func (s *SystemServerImpl) ReadNotification(ctx context.Context, req *system.ReadNotificationReq) (res *system.ReadNotificationResp, err error) {
return s.SystemService.ReadNotification(ctx, req)
}

func (s *SystemServerImpl) CreateNotification(ctx context.Context, req *system.CreateNotificationReq) (res *system.CreateNotificationResp, err error) {
return s.SystemService.CreateNotification(ctx, req)
}
Loading
Loading