Skip to content

Commit

Permalink
ci: 调整ci
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Sep 19, 2024
1 parent be78fc5 commit cce434e
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 27 deletions.
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

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

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

.idea
.vscode
.docker

/configs/config.yaml

/docs
/runtime
/bin
30 changes: 14 additions & 16 deletions deploy/gitea/.gitea/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4.2.0
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'

- name: Lint
# uses: golangci/golangci-lint-action@v3
uses: actions/golangci-lint-action@v3
# uses: golangci/golangci-lint-action@v6
uses: actions/golangci-lint-action@v6
with:
version: latest
install-mode: goinstall
args: --timeout=30m

- name: Tests
Expand All @@ -59,7 +57,7 @@ jobs:
- name: Login to Docker Hub
# uses: docker/login-action@v3
uses: actions/login-action@v1
uses: actions/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
Expand All @@ -71,8 +69,8 @@ jobs:
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Docker build and push
# use: docker/build-push-action@v5
uses: actions/build-push-action@v5
# use: docker/build-push-action@v6
uses: actions/build-push-action@v6
with:
push: true
file: deploy/docker/Dockerfile
Expand All @@ -83,25 +81,25 @@ jobs:
BASEIMAGE=${{ env.BASEIMAGE }}/debian:12-slim
- name: Set up kubeconfig
# uses: azure/k8s-set-context@v3
uses: actions/k8s-set-context@v3
# uses: azure/k8s-set-context@v4
uses: actions/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
context: k8s-context

- name: Set up Helm
# uses: azure/setup-helm@v3
uses: actions/setup-helm@v3.6
# uses: azure/setup-helm@v4
uses: actions/setup-helm@v4
with:
version: 'v3.13.1' # default is latest (stable)

- name: Deploy ${{ env.ENV }}
env:
APP_NAME: ${{ env.ENV=='prod' && env.APP_NAME || format('{0}-{1}', env.APP_NAME, env.ENV) }}
DOMAIN: ${{ env.ENV=='prod' && env.DOMAIN || format('{0}.{1}', env.ENV, env.DOMAIN) }}
RESOURCE_CPU: ${{ env.ENV=='prod' && '500m' || '100m' }}
RESOURCE_MEMORY: ${{ env.ENV=='prod' && '512Mi' || '128Mi' }}
RESOURCE_CPU: ${{ env.ENV=='prod' && '200m' || '100m' }}
RESOURCE_MEMORY: ${{ env.ENV=='prod' && '256Mi' || '128Mi' }}
AUTO_SCALING: ${{ env.ENV=='prod' && 'true' || 'false' }}
AUTO_SCALING_MIN_REPLICAS: ${{ env.ENV=='prod' && '2' || '1' }}
run: |
Expand All @@ -116,4 +114,4 @@ jobs:
--set resources.requests.cpu=$RESOURCE_CPU \
--set resources.requests.memory=$RESOURCE_MEMORY \
--set autoscaling.enabled=$AUTO_SCALING \
--set autoscaling.minReplicas=$AUTO_SCALING_MIN_REPLICAS
--set autoscaling.minReplicas=$AUTO_SCALING_MIN_REPLICAS
8 changes: 3 additions & 5 deletions deploy/gitea/.gitea/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4.2.0
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Lint
# uses: golangci/golangci-lint-action@v3
uses: actions/golangci-lint-action@v3
# uses: golangci/golangci-lint-action@v6
uses: actions/golangci-lint-action@v6
with:
version: latest
install-mode: goinstall
args: --timeout=30m

- name: Tests
Expand Down
8 changes: 4 additions & 4 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ resources:
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 500m
memory: 512Mi
memory: 521Mi
requests:
cpu: 200m
memory: 256Mi

autoscaling:
enabled: true
Expand Down
25 changes: 25 additions & 0 deletions examples/simple/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

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

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

.idea
.vscode
.docker

/configs/config.yaml

/docs
/runtime
/bin
5 changes: 3 additions & 2 deletions examples/simple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ GOOS=linux
GOARCH=amd64
APP_NAME=simple
APP_VERSION=1.0.0
LD_FLAGS=-w -s -X github.com/codfrm/cago/configs.Version=${APP_VERSION}

SUFFIX=
ifeq ($(GOOS),windows)
SUFFIX=.exe
endif

build:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o bin/$(APP_NAME)_v$(APP_VERSION)$(SUFFIX) ./cmd/app

GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o bin/$(APP_NAME)_v$(APP_VERSION)$(SUFFIX) \
-trimpath -ldflags "${LD_FLAGS}" ./cmd/app
1 change: 1 addition & 0 deletions examples/simple/internal/task/queue/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func PublishExample(ctx context.Context, msg *message.ExampleMsg) error {
})
}

// SubscribeExample 订阅示例消息
func SubscribeExample(ctx context.Context, fn func(ctx context.Context, msg *message.ExampleMsg) error) error {
_, err := broker.Default().Subscribe(ctx, ExampleTopic, func(ctx context.Context, event broker2.Event) error {
msg := &message.ExampleMsg{}
Expand Down

0 comments on commit cce434e

Please sign in to comment.