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
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**仅限中文**

在提之前请先查找[已有 issues](https://github.com/ecodeclub/ginx/issues),避免重复上报。

并且确保自己已经:
- [ ] 阅读过文档
- [ ] 阅读过代码注释
- [ ] 阅读过相关测试

### 问题简要描述

### 复现步骤
> 通过编写单元、集成及e2e测试来复现Bug

### 错误日志或者截图

### 你期望的结果

### 你排查的结果,或者你觉得可行的修复方案
> 可选。希望你能够尽量先排查问题,这对于你个人能力提升很有帮助。

### 你设置的的 Go 环境?
> 上传 `go env` 的结果
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: feature
assignees: ''

---

**仅限中文**

### 使用场景

### 行业分析
> 如果你知道有框架提供了类似功能,可以在这里描述,并且给出文档或者例子

### 可行方案
> 如果你有设计思路或者解决方案,请在这里提供。你可以提供多个方案,并且给出自己的选择

### 其它
> 任何你觉得有利于解决问题的补充说明

### 你设置的的 Go 环境?
> 上传 `go env` 的结果
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Question
about: Want to ask some questions
title: ''
labels: question
---

**仅限中文**

在提问之前请先查找[已有 issues](https://github.com/ecodeclub/ginx/issues),避免重复提问。

并且确保自己已经:
- [ ] 阅读过文档
- [ ] 阅读过代码注释
- [ ] 阅读过相关测试

### 你的问题

### 你设置的的 Go 环境?
> 上传 `go env` 的结果
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Refactor request
about: Refactor existing code
title: ''
labels: refactor
assignees: ''

---

**仅限中文**

### 当前实现缺陷

### 重构方案
> 描述可以如何重构,以及重构之后带来的效果,如可读性、性能等方面的提升

### 其它
> 任何你觉得有利于解决问题的补充说明
42 changes: 42 additions & 0 deletions .github/workflows/go-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2023 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Format Go code

on:
push:
branches: [ main,dev ]
pull_request:
branches: [ main,dev ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ">=1.20.0"

- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest

- name: Check
run: |
make check
if [ -n "$(git status --porcelain)" ]; then
echo >&2 "错误: 请在本地运行命令'make check'后再提交."
exit 1
fi
40 changes: 40 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2023 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Go

on:
push:
branches: [ dev,main ]
pull_request:
branches: [ dev,main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.0

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

- name: Test
run: go test -race -coverprofile=cover.out -v ./...

- name: Post Coverage
uses: codecov/codecov-action@v2
61 changes: 61 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2023 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: golangci-lint
on:
push:
branches:
- dev
- main
pull_request:
branches:
- dev
- main
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.20.0
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: -c .golangci.yml

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
29 changes: 29 additions & 0 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2023 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Check License Lines
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- develop
- main
- dev
jobs:
check-license-lines:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Check License Lines
uses: kt3k/license_checker@v1.0.6
33 changes: 33 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Mark stale issues and pull requests

on:
schedule:
- cron: "30 1 * * *"

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: actions/stale@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is inactive for a long time.'
stale-pr-message: 'This PR is inactive for a long time'
stale-issue-label: 'inactive-issue'
stale-pr-label: 'inactive-pr'
18 changes: 18 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 ecodeclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

run:
go: '1.21'
skip-dirs:
- .idea
8 changes: 8 additions & 0 deletions .licenserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"**/*.go": "// Copyright 2023 ecodeclub",
"**/*.{yml,toml}": "# Copyright 2023 ecodeclub",
"**/*.sh": "# Copyright 2023 ecodeclub",
"ignore": [
"*.mock.go"
]
}
32 changes: 28 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
.PHONY: mock
mock:
@mockgen -source=internal/ratelimit/types.go -package=limitmocks -destination=internal/ratelimit/mocks/ratelimit.mock.go
@go mod tidy
.PHONY: bench
bench:
@go test -bench=. -benchmem ./...

.PHONY: ut
ut:
@go test -tags=goexperiment.arenas -race ./...

.PHONY: setup
setup:
@sh ./script/setup.sh

.PHONY: fmt
fmt:
@sh ./script/goimports.sh

.PHONY: lint
lint:
@golangci-lint run -c .golangci.yml

.PHONY: tidy
tidy:
@go mod tidy -v

.PHONY: check
check:
@$(MAKE) fmt
@$(MAKE) tidy
14 changes: 14 additions & 0 deletions internal/integration/activelimit_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 ecodeclub
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build e2e

package integration
Expand Down
Loading