Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0eee65a
feat(rpc): use standard respone
fdkevin0 May 26, 2022
a36c472
fix(health): rpc model error
fdkevin0 May 26, 2022
9d40401
fix(staff): rpc dorm model error
fdkevin0 May 26, 2022
377da1a
updates
fdkevin0 Jun 1, 2022
adb4891
updates
fdkevin0 Jun 1, 2022
03132e1
updates
fdkevin0 Jun 1, 2022
f13107f
Merge branch 'main' into dev-standard-rpc
setcy Jun 25, 2022
2558667
Merge branch 'main' into dev-standard-rpc
setcy Jun 28, 2022
c3d1ac9
update(campus): buf generate up to date
setcy Jun 28, 2022
0ffd101
update(aggregatingapis): update
setcy Jun 28, 2022
0831807
ci(gen): buf generate up to date
fdkevin0 Jun 28, 2022
f201531
update: require_unimplemented_servers
setcy Jun 28, 2022
65c1811
ci(gen): buf generate up to date
fdkevin0 Jun 28, 2022
6963b2d
updates
fdkevin0 Jun 29, 2022
5d0eb4b
Merge branch 'main' into dev-standard-rpc
setcy Jun 29, 2022
da72ea4
updates
setcy Jun 29, 2022
0a1e757
Merge remote-tracking branch 'origin/main' into dev-standard-rpc
fdkevin0 Jun 29, 2022
3bb32b9
Merge branch 'dev-standard-rpc' of github.com:hduhelp/api_open_sdk in…
fdkevin0 Jun 29, 2022
df8d9dc
feat: warm go proxy if main branch
fdkevin0 Jun 29, 2022
56fdbbe
update buf lint ci
fdkevin0 Jun 29, 2022
9f95bb5
update protos
fdkevin0 Jun 29, 2022
fd2126c
update protos
fdkevin0 Jun 29, 2022
d6b2024
update ci
fdkevin0 Jun 29, 2022
d615735
update protos
fdkevin0 Jun 29, 2022
0babf1c
update: lint
setcy Jun 29, 2022
f98b1cf
update ci
fdkevin0 Jun 29, 2022
0aa39af
remove unused code
fdkevin0 Jun 29, 2022
1509e43
buf gen
fdkevin0 Jun 29, 2022
adcdacd
Merge branch 'main' into dev-standard-rpc
setcy Jul 5, 2022
132fbb4
update(campusapis): GetStudentSchoolRollStatus
setcy Jul 5, 2022
e1e04e4
update actions
setcy Jul 8, 2022
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
20 changes: 20 additions & 0 deletions .github/workflows/buf-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: check buf lint
on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- "**.proto"
- "buf.yaml"
- ".github/workflows/buf-lint.yml"

jobs:
lint-protos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1
- uses: bufbuild/buf-lint-action@v1
68 changes: 68 additions & 0 deletions .github/workflows/buf-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: check buf generate up to date
on:
pull_request:
branches:
- main
paths:
- "**.go"
- "**.proto"
- "**.go.json"
- "go.mod"
- "go.sum"
- ".github/workflows/buf-pr.yml"

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: load Go 1.18 env
uses: actions/setup-go@v3
with:
go-version: 1.18
id: go

- name: checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}

- uses: actions/cache@v3
id: cache-golang
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/go/bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- run: echo ${{ steps.cache-golang.outputs.cache-hit }}

- name: init dependance
if: steps.cache-golang.outputs.cache-hit != 'true'
run: make install-tools

- name: generate proto
run: make generate-proto

- name: check if files up to date
run: |
if [[ `git status --porcelain` ]]; then
echo "buf gen code not up to date"
exit 1
fi

- name: warming go proxy
if: github.ref == 'refs/heads/main'
run: |
hash=$(git show -s --format=%h)
echo $hash
mkdir ~/warm
cd ~/warm
go mod init warm
go get github.com/hduhelp/api_open_sdk@$hash
GOPROXY=https://goproxy.io,direct go get github.com/hduhelp/api_open_sdk@$hash
GOPROXY=https://goproxy.cn,direct go get github.com/hduhelp/api_open_sdk@$hash

8 changes: 3 additions & 5 deletions .github/workflows/buf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- run: echo ${{ steps.cache-golang.outputs.cache-hit }}

- name: init dependance
if: steps.cache-golang.outputs.cache-hit != 'true'
run: make install-tools
Expand All @@ -48,7 +47,7 @@ jobs:
git commit -m "ci(gen): buf generate up to date"
git push
fi

- name: warming go proxy
run: |
hash=$(git show -s --format=%h)
Expand All @@ -58,5 +57,4 @@ jobs:
go mod init warm
go get github.com/hduhelp/api_open_sdk@$hash
GOPROXY=https://goproxy.io,direct go get github.com/hduhelp/api_open_sdk@$hash
GOPROXY=https://goproxy.cn,direct go get github.com/hduhelp/api_open_sdk@$hash

GOPROXY=https://goproxy.cn,direct go get github.com/hduhelp/api_open_sdk@$hash
46 changes: 46 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: check code lint
on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- "**.go"
- "**.go.json"
- "go.mod"
- "go.sum"
- ".golangci.yml"
- ".github/workflows/lint.yml"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Go Build Cache (lint)
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg
key: go-cache-${{ hashFiles('**/go.sum') }}-lint
restore-keys: |
go-cache-${{ hashFiles('**/go.sum') }}-
go-cache-

- run: go get -t ./...

- name: Run linters
uses: golangci/golangci-lint-action@v3
with:
version: v1.46.0
skip-pkg-cache: true
skip-build-cache: true
21 changes: 21 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Options for analysis running.
run:
# See the dedicated "run" documentation section.
option: value
# output configuration options
output:
# See the dedicated "output" documentation section.
option: value
# All available settings of specific linters.
linters-settings:
# See the dedicated "linters-settings" documentation section.
option: value
linters:
# See the dedicated "linters" documentation section.
option: value
issues:
# See the dedicated "issues" documentation section.
option: value
severity:
# See the dedicated "severity" documentation section.
option: value
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ install-tools: download
cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %

generate-proto:
buf generate -v
buf generate -v

lint:
golangci-lint run --fix
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,25 @@
make install-tools
```

## 依赖

- [go-task](https://taskfile.dev/installation/)
- [golangci-lint](https://golangci-lint.run/)

## 开发流程

1. 修改 proto 文件
2. 运行 `buf generate`
3. 开启 swagger-ui 实时预览

## 预览 swagger 效果 (多数情况下没必要预览) (感觉还有更简单的)

### 公开文档

在 https://github.com/hduhelp/api/config.json 中添加对应 OpenAPI 文件,提交后会自动拉取api_open_sdk最新文档

可在 https://hduhelp.github.io/api/ 页面查看接口文档

1. 安装 swagger-ui
```shell
# 新建目录
Expand All @@ -42,7 +54,11 @@ http://localhost:8080/campusapis/staff/v1/freshman.swagger.json

4. 每次改动 proto 后需要重新运行 `buf generate`,并且「清空缓存并进行硬刷新」网页

## Code Lint



## 接口注释

有效:rpc 方法前,Response message 前,message内部字段前
无效(不会显示到 swagger 中):Request message 前
- 有效:rpc 方法前,Response message 前,message内部字段前
- 无效(不会显示到 swagger 中):Request message 前
Loading