-
Notifications
You must be signed in to change notification settings - Fork 4
feat: 提交workflow配置 #13
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
Open
junwense
wants to merge
13
commits into
ecodeclub:main
Choose a base branch
from
junwense:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
99f784a
feat: 提交workflow配置
junwense 2da3918
feat: 修改docker-compose,license配置
junwense 3a1b8fe
feat: 修改license配置
junwense ba57e0c
feat:
junwense 3c31380
feat:
junwense 9712449
feat:
junwense 76d6cd3
feat:
junwense 3236129
feat:
junwense a3de613
feat:
junwense 929ef3b
feat:
junwense fb6c0ee
feat:
junwense cdfcf6d
feat:
junwense e9cd6bb
feat:
junwense File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
# Copyright 2021 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. | ||
# | ||
# To use, store as .git/hooks/pre-commit inside your repository and make sure | ||
# it has execute permissions. | ||
# | ||
# This script does not handle file names that contain spaces. | ||
|
||
# Pre-commit configuration | ||
|
||
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/sh | ||
# Copyright 2021 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. | ||
# git test pre-push hook | ||
# | ||
# To use, store as .git/hooks/pre-push inside your repository and make sure | ||
# it has execute permissions. | ||
# | ||
# This script does not handle file names that contain spaces. | ||
|
||
# Pre-push configuration | ||
remote=$1 | ||
url=$2 | ||
echo >&2 "Try pushing $2 to $1" | ||
|
||
TEST="go test ./... -race -cover -failfast" | ||
LINTER="golangci-lint run -c .golangci.yml" | ||
|
||
# Run test and return if failed | ||
printf "Running go test..." | ||
$TEST | ||
RESULT=$? | ||
if [ $RESULT -ne 0 ]; then | ||
echo >&2 "$TEST" | ||
echo >&2 "Check code to pass test." | ||
exit 1 | ||
fi | ||
|
||
# Run linter and return if failed | ||
printf "Running go linter..." | ||
$LINTER | ||
RESULT=$? | ||
if [ $RESULT -ne 0 ]; then | ||
echo >&2 "$LINTER" | ||
echo >&2 "Check code to pass linter." | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Copyright 2021 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: Post Coverage by Codecov | ||
|
||
on: | ||
push: | ||
branches: [ main,dev ] | ||
paths-ignore: | ||
- 'docs/**' | ||
- '**.md' | ||
|
||
pull_request: | ||
branches: [ main,dev ] | ||
paths-ignore: | ||
- 'docs/**' | ||
- '**.md' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.24.2" | ||
|
||
- name: Start Docker Compose | ||
run: | | ||
docker compose -f ./.script/docker-compose.yaml up -d | ||
|
||
- name: Test for MySQL | ||
run: | | ||
# 等待MySQL服务就绪(最多尝试30次,每次等待2秒) | ||
timeout=60 | ||
elapsed=0 | ||
until docker exec script-mysql8-1 mysqladmin -uroot -proot -h127.0.0.1 ping; do | ||
sleep 2 | ||
elapsed=$((elapsed + 2)) | ||
if [ $elapsed -ge $timeout ]; then | ||
echo "MySQL未在${timeout}秒内启动!" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# MySQL就绪后执行命令 | ||
docker exec script-mysql8-1 mysql -uroot -proot -h127.0.0.1 -e "SHOW DATABASES;" | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -race -coverprofile=cover.out -v ./... | ||
|
||
- name: Stop Docker Compose | ||
run: docker compose -f ./.script/docker-compose.yaml down | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v5 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2021 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@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.24.2" | ||
|
||
- name: Install goimports | ||
run: | | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest && \ | ||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2021 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: | ||
tags: | ||
- v* | ||
branches: [main,dev] | ||
pull_request: | ||
branches: [main,dev] | ||
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.24.2" | ||
- uses: actions/checkout@v4 | ||
- 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 | ||
|
||
args: --timeout=10m | ||
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2021 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: | ||
- main | ||
- dev | ||
jobs: | ||
check-license-lines: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Check License Lines | ||
uses: kt3k/[email protected] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2021 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.24.2' | ||
skip-dirs: | ||
- .idea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"**/*.go": "// Copyright 2021 ecodeclub", | ||
"**/*.{yml,yaml,sql}": "# Copyright 2021 ecodeclub", | ||
"**/*.sh": "# Copyright 2021 ecodeclub", | ||
|
||
"ignore": [ | ||
"mocks","*.pb.go", "*.pb.gw.go" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
version: '3.0' | ||
services: | ||
|
||
mysql8: | ||
image: mysql:8.0.29 | ||
restart: always | ||
command: --default-authentication-plugin=mysql_native_password | ||
command: --default-authentication-plugin=mysql_native_password --bind-address=0.0.0.0 | ||
environment: | ||
# 数据库密码 | ||
MYSQL_ROOT_PASSWORD: root | ||
volumes: | ||
# 设置初始化脚本 | ||
# 设置初始化脚本 | ||
- ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql | ||
ports: | ||
# 端口映射 | ||
# 注意这里我映射为了 13316 端口 | ||
- "13316:3306" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.PHONY: bench | ||
bench: | ||
@go test -bench=. -benchmem ./... | ||
|
||
#.PHONY: ut | ||
#ut: | ||
# @go test -race -v ./... -failfast | ||
|
||
.PHONY: e2e | ||
e2e: | ||
@docker compose -f docker-compose.yaml up -d | ||
@go test -race -v -failfast ./... | ||
@docker compose -f docker-compose.yaml down | ||
|
||
.PHONY: fmt | ||
fmt: | ||
@goimports -l -w $$(find . -type f -name '*.go' -not -path "./.idea/*") | ||
|
||
.PHONY: lint | ||
lint: | ||
@golangci-lint run -c .golangci.yml | ||
|
||
.PHONY: tidy | ||
tidy: | ||
@go mod tidy -v | ||
|
||
.PHONY: check | ||
check: | ||
@$(MAKE) fmt | ||
@$(MAKE) tidy | ||
@$(MAKE) lint |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.