-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: init project with
hedon-go-road/template
and finish the demo
- Loading branch information
0 parents
commit e91263a
Showing
17 changed files
with
1,052 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,106 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build-go: | ||
strategy: | ||
matrix: | ||
platform: [ubuntu-latest] | ||
go-version: ['1.22'] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 | ||
- name: Cache Go modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-${{ matrix.go-version }}- | ||
- name: Display Go version | ||
run: go version | ||
- name: Install dependencies | ||
run: go get ./... | ||
- name: Check code format | ||
run: gofmt -l . | ||
- name: Check the package for errors | ||
run: go build ./... | ||
- name: Run tests with coverage and race detector | ||
run: | | ||
go test -v -race -covermode=atomic -coverpkg=./... -coverprofile=coverage.out ./... | ||
go tool cover -func=coverage.out | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4.0.1 | ||
with: | ||
files: coverage.out | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
flags: unittests | ||
name: codecov-umbrella | ||
fail_ci_if_error: false | ||
continue_on_error: true | ||
verbose: true | ||
# - name: Check test coverage | ||
# run: bash ./scripts/ci/check_test_coverage.sh | ||
- name: Get tags info | ||
id: get_tag_message | ||
run: git fetch origin +refs/tags/*:refs/tags/* | ||
if: startsWith(github.ref, 'refs/tags/') | ||
- name: Generate a changelog | ||
uses: orhun/git-cliff-action@v3 | ||
id: git-cliff | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
config: cliff.toml | ||
args: -vv --latest --strip header | ||
env: | ||
OUTPUT: NEW_CHANGELOG.md | ||
- name: Prepend tag message and new changelog to existing CHANGELOG.md | ||
run: | | ||
cat NEW_CHANGELOG.md | ||
git fetch origin main:main | ||
git checkout main | ||
if [ -f "CHANGELOG.md" ]; then | ||
head -n 1 CHANGELOG.md > TEMP_CHANGELOG.md | ||
echo "" >> TEMP_CHANGELOG.md | ||
cat NEW_CHANGELOG.md >> TEMP_CHANGELOG.md | ||
tail -n +2 CHANGELOG.md >> TEMP_CHANGELOG.md | ||
mv TEMP_CHANGELOG.md CHANGELOG.md | ||
else | ||
mv NEW_CHANGELOG.md CHANGELOG.md | ||
fi | ||
rm -f NEW_CHANGELOG.md | ||
git config --global user.name 'GitHub Actions' | ||
git config --global user.email 'actions@github.com' | ||
git add CHANGELOG.md | ||
git commit -m "[skip] Update CHANGELOG.md with new changes" | ||
git push origin main --force | ||
if: startsWith(github.ref, 'refs/tags/') && steps.git-cliff.outputs.content != '' | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
body: ${{ steps.git-cliff.outputs.content }} |
This file contains 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,33 @@ | ||
# name: gen-plantuml | ||
|
||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
# tags: | ||
# - v* | ||
# pull_request: | ||
# branches: | ||
# - main | ||
|
||
# permissions: | ||
# contents: write | ||
|
||
# jobs: | ||
# generate_plantuml: | ||
# runs-on: ubuntu-latest | ||
# name: plantuml | ||
# steps: | ||
# - name: checkout | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# fetch-depth: 0 | ||
# - name: plantuml | ||
# id: plantuml | ||
# uses: grassedge/generate-plantuml-action@v1.5 | ||
# with: | ||
# path: "assets/uml" | ||
# message: "[skip] auto generate plant uml svgs" | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} | ||
|
This file contains 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,10 @@ | ||
.idea | ||
.vscode/** | ||
main | ||
**coverage.out* | ||
*groups-*.json | ||
.DS_Store | ||
|
||
# binary files | ||
|
||
# config file |
This file contains 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,113 @@ | ||
linters-settings: | ||
dupl: | ||
threshold: 100 | ||
funlen: | ||
lines: 100 | ||
statements: 50 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- whyNoLint | ||
- wrapperFunc | ||
- exposedSyncMutex | ||
gocyclo: | ||
# Minimal code complexity to report. | ||
# Default: 30 (but we recommend 10-20) | ||
min-complexity: 15 | ||
goimports: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
lll: | ||
line-length: 140 | ||
misspell: | ||
locale: US | ||
mnd: | ||
checks: # "argument", "case", "condition", "operation", "return", "assign" | ||
- case | ||
- return | ||
- assign | ||
- condition | ||
- operation | ||
stylecheck: | ||
checks: | ||
- ST1000 | ||
- ST1001 | ||
- ST1002 | ||
# 不要启用 ST1003 | ||
- ST1004 | ||
- ST1005 | ||
- ST1006 | ||
- ST1008 | ||
- ST1010 | ||
- ST1011 | ||
- ST1012 | ||
- ST1013 | ||
- ST1015 | ||
- ST1016 | ||
- ST1017 | ||
- ST1018 | ||
|
||
linters: | ||
# please, do not use `enable-all`: it's deprecated and will be removed soon. | ||
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
# - depguard # what is the usage of it? | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- funlen | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- mnd | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- rowserrcheck | ||
- exportloopref | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
|
||
# don't enable: | ||
# - gochecknoglobals | ||
# - gocognit | ||
# - godox | ||
# - maligned | ||
# - prealloc | ||
|
||
issues: | ||
# Excluding configuration per-path, per-linter, per-text and per-source | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- gomnd | ||
- funlen | ||
exclude-dirs: | ||
- vendor | ||
new: true | ||
new-from-rev: "HEAD~1" | ||
whole-files: false |
This file contains 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,36 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: trailing-whitespace # handle any whitespace of the end of line and the new line. | ||
- id: end-of-file-fixer # remove EOF of your whole files project. | ||
files: \.go$ | ||
- id: check-yaml # fix yaml format file. | ||
- id: check-added-large-files # let you know which file has large file size. | ||
- repo: https://github.com/dnephin/pre-commit-golang | ||
rev: v0.5.1 | ||
hooks: | ||
- id: go-mod-tidy # run go mod tidy -v. | ||
- repo: local | ||
hooks: | ||
- id: golangci-lint | ||
name: golangci-lint | ||
description: run golangci-lint | ||
entry: golangci-lint run -v ./... | ||
language: golang | ||
files: \.*$ | ||
pass_filenames: false | ||
- id: go-unit-tests | ||
name: go-unit-tests | ||
description: run go tests with race detector | ||
entry: bash -c 'go test -race ./...' | ||
language: golang | ||
files: \.*$ | ||
pass_filenames: false | ||
- id: typos | ||
name: typos | ||
description: check typo | ||
entry: bash -c 'typos' | ||
language: golang | ||
files: \.*$ | ||
pass_filenames: false |
This file contains 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,2 @@ | ||
docs/** | ||
fixtures/** |
This file contains 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 @@ | ||
# Changelog |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Hedon | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,5 @@ | ||
main: | ||
go run main.go | ||
|
||
genpb: | ||
protoc --go_out=. ./protos/* |
This file contains 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,3 @@ | ||
# gmm(go-mysql-mocker) | ||
|
||
`gmm(go-mysql-mocker)` is a simple but useful tool to mock mysql server in Go project, it is especially useful in unit testing. This tool uses dolthub/go-mysql-server as memory server and gorm to auto create table and init data. |
This file contains 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,5 @@ | ||
[default.extend-words] | ||
configer = "configer" | ||
|
||
[files] | ||
extend-exclude = ["CHANGELOG.md", "notebooks/*", ".gitignore", "assets/*"] |
Oops, something went wrong.