Skip to content

Commit 8c03ec7

Browse files
committed
feat: Modernize project infrastructure and documentation
This commit includes several improvements to modernize the project: - Update Go version from 1.13 to 1.22 - Enhance GitHub Actions workflows: - Use latest action versions (checkout@v4, setup-go@v4, etc.) - Configure MySQL 8.0 with proper health checks - Add code coverage reporting and upload to Codecov - Improve CodeQL analysis with proper permissions - Update reviewdog with additional checks - Extend Makefile with new commands: - make test, test-race, test-cover for different test scenarios - make build for building binaries in ./bin/ directory - make install for installing to $GOPATH/bin - make clean for cleanup - Update documentation: - Rewrite README with comprehensive English documentation - Add detailed architecture explanation and usage examples - Update status badges and build instructions - Add bin/ directory to .gitignore These changes improve developer experience, ensure better code quality, and make the project more accessible to new contributors.
1 parent 857f3f8 commit 8c03ec7

File tree

19 files changed

+657
-296
lines changed

19 files changed

+657
-296
lines changed
Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,46 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
61
name: "CodeQL"
72

83
on:
94
push:
10-
branches: [master]
5+
branches: [ main, master ]
116
pull_request:
12-
# The branches below must be a subset of the branches above
13-
branches: [master]
7+
branches: [ main, master ]
148
schedule:
15-
- cron: '0 1 * * 6'
9+
- cron: '0 1 * * 6' # Run every Saturday at 1 AM
1610

1711
jobs:
1812
analyze:
1913
name: Analyze
2014
runs-on: ubuntu-latest
15+
permissions:
16+
security-events: write
17+
actions: read
18+
contents: read
2119

2220
strategy:
2321
fail-fast: false
2422
matrix:
25-
# Override automatic language detection by changing the below list
26-
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
27-
language: ['go']
28-
# Learn more...
29-
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
23+
language: [ 'go' ]
3024

3125
steps:
3226
- name: Checkout repository
33-
uses: actions/checkout@v2
34-
with:
35-
# We must fetch at least the immediate parents so that if this is
36-
# a pull request then we can checkout the head.
37-
fetch-depth: 2
38-
39-
# If this run was triggered by a pull request event, then checkout
40-
# the head of the pull request instead of the merge commit.
41-
- run: git checkout HEAD^2
42-
if: ${{ github.event_name == 'pull_request' }}
27+
uses: actions/checkout@v4
4328

44-
# Initializes the CodeQL tools for scanning.
4529
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
30+
uses: github/codeql-action/init@v2
4731
with:
4832
languages: ${{ matrix.language }}
49-
# If you wish to specify custom queries, you can do so here or in a config file.
50-
# By default, queries listed here will override any specified in a config file.
51-
# Prefix the list here with "+" to use these queries and those in the config file.
52-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53-
54-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55-
# If this step fails, then you should remove it and run the build manually (see below)
56-
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
5833

59-
# ℹ️ Command-line programs to run using the OS shell.
60-
# 📚 https://git.io/JvXDl
61-
62-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63-
# and modify them (or add more) to build your code if your project
64-
# uses a compiled language
34+
- name: Set up Go
35+
uses: actions/setup-go@v4
36+
with:
37+
go-version: '1.22'
38+
cache: true
6539

66-
#- run: |
67-
# make bootstrap
68-
# make release
40+
- name: Build
41+
run: go build ./...
6942

7043
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v1
44+
uses: github/codeql-action/analyze@v2
45+
with:
46+
category: "/language:${{matrix.language}}"

.github/workflows/reviewdog.yml

Lines changed: 61 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,74 @@
11
name: reviewdog
2-
on: [push,pull_request]
3-
jobs:
4-
# NOTE: golangci-lint doesn't report multiple errors on the same line from
5-
# different linters and just report one of the errors?
2+
on:
3+
push:
4+
branches: [main, master]
5+
pull_request:
6+
branches: [main, master]
67

8+
jobs:
79
golangci-lint:
810
name: runner / golangci-lint
911
runs-on: ubuntu-latest
1012
steps:
11-
- name: Check out code into the Go module directory
12-
uses: actions/checkout@v1
13-
- name: golangci-lint
14-
uses: docker://reviewdog/action-golangci-lint:v1.0.4 # Pre-built image
15-
# uses: reviewdog/action-golangci-lint@v1 # Build with Dockerfile
16-
# uses: docker://reviewdog/action-golangci-lint:v1.0.2 # Can use specific version.
17-
# uses: reviewdog/[email protected] # Can use specific version.
13+
- name: Check out code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v4
1818
with:
19-
github_token: ${{ secrets.github_token }}
20-
# Can pass --config flag to change golangci-lint behavior and target
21-
# directory.
22-
golangci_lint_flags: "--config=.github/.golangci.yml ./testdata"
23-
24-
# Use golint via golangci-lint binary with "warning" level.
25-
golint:
26-
name: runner / golint
19+
go-version: '1.22'
20+
cache: true
21+
22+
- name: Install golangci-lint
23+
run: |
24+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
25+
26+
- name: Install reviewdog
27+
run: |
28+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
29+
30+
- name: Run golangci-lint with reviewdog
31+
env:
32+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.github_token }}
33+
run: |
34+
$(go env GOPATH)/bin/golangci-lint run --no-config --disable-all --enable=gofmt,govet,errcheck | reviewdog -f=golangci-lint -reporter=github-pr-review -level=info
35+
36+
go-test:
37+
name: runner / go test
2738
runs-on: ubuntu-latest
2839
steps:
29-
- name: Check out code into the Go module directory
30-
uses: actions/checkout@v1
31-
- name: golint
32-
uses: docker://reviewdog/action-golangci-lint:v1.0.4 # Pre-built image
40+
- name: Check out code
41+
uses: actions/checkout@v4
42+
43+
- name: Set up Go
44+
uses: actions/setup-go@v4
3345
with:
34-
github_token: ${{ secrets.github_token }}
35-
golangci_lint_flags: "--disable-all -E golint --exclude-use-default=false"
36-
tool_name: golint # Change reporter name.
37-
level: warning # GitHub Status Check won't become failure with this level.
38-
39-
# You can add more and more supported linters with different config.
40-
errcheck:
41-
name: runner / errcheck
46+
go-version: "1.22"
47+
cache: true
48+
49+
- name: Run tests
50+
run: go test -v ./...
51+
52+
misspell:
53+
name: runner / misspell
4254
runs-on: ubuntu-latest
4355
steps:
44-
- name: Check out code into the Go module directory
45-
uses: actions/checkout@v1
46-
- name: errcheck
47-
uses: docker://reviewdog/action-golangci-lint:v1.0.4 # Pre-built image
56+
- name: Check out code
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Go
60+
uses: actions/setup-go@v4
4861
with:
49-
github_token: ${{ secrets.github_token }}
50-
golangci_lint_flags: "--disable-all -E errcheck"
51-
tool_name: errcheck
52-
level: info
62+
go-version: '1.22'
63+
cache: true
64+
65+
- name: Install reviewdog and misspell
66+
run: |
67+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
68+
go install github.com/client9/misspell/cmd/misspell@latest
69+
70+
- name: Run misspell with reviewdog
71+
env:
72+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.github_token }}
73+
run: |
74+
$(go env GOPATH)/bin/misspell -locale US . | $(go env GOPATH)/bin/reviewdog -f=misspell -reporter=github-pr-review -level=info

.github/workflows/test.yml

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,59 @@
11
name: sql-dog
2-
on: [push]
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
37

48
jobs:
59
test:
10+
name: Build and Test
611
runs-on: ubuntu-latest
712
services:
813
mysql:
9-
image: mysql:5.7
14+
image: mysql:8.0
1015
env:
11-
MYSQL_USER: root
1216
MYSQL_ROOT_PASSWORD: admin
1317
MYSQL_DATABASE: sql-dog
1418
ports:
15-
- 3306
19+
- 3306:3306
20+
options: >-
21+
--health-cmd "mysqladmin ping -h localhost"
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
1625
1726
steps:
18-
- name: Set up Go 1.13
19-
uses: actions/setup-go@v1
27+
- name: Set up Go
28+
uses: actions/setup-go@v4
2029
with:
21-
go-version: 1.13.4
22-
id: go
23-
- name: Check out code into the Go module directory
24-
uses: actions/checkout@v2
25-
- name: Get dependencies
30+
go-version: '1.22'
31+
cache: true
32+
33+
- name: Check out code
34+
uses: actions/checkout@v4
35+
36+
- name: Install dependencies
2637
run: go mod download
27-
- name: Test
28-
run: go test ./...
38+
39+
- name: Run linter
40+
run: |
41+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
42+
$(go env GOPATH)/bin/golangci-lint run --timeout=5m --no-config --disable-all --enable=gofmt,govet,errcheck
43+
44+
- name: Run tests
45+
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
46+
env:
47+
DB_HOST: localhost
48+
DB_PORT: 3306
49+
DB_USER: root
50+
DB_PASSWORD: admin
51+
DB_NAME: sql-dog
52+
53+
- name: Upload coverage report
54+
uses: codecov/codecov-action@v3
55+
with:
56+
files: ./coverage.txt
57+
flags: unittests
58+
name: codecov-umbrella
59+
fail_ci_if_error: false

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea/
22
config.yaml
3-
linter.yaml
3+
linter.yaml
4+
/bin/
5+
coverage.txt

.golangci.yml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
linters-settings:
2-
# depguard:
3-
# list-type: blacklist
4-
# packages:
5-
# - github.com/sirupsen/logrus
6-
# packages-with-error-message:
7-
# - {github.com/sirupsen/logrus: 'logging is allowed only by logutils.Log'}
8-
# dupl:
9-
# threshold: 100
10-
funlen:
11-
lines: 500
12-
statements: 80
2+
depguard:
3+
list-type: denylist
4+
include-go-root: false
5+
packages:
6+
# 特定の禁止したいパッケージがあればここに記述
7+
packages-with-error-message:
8+
# メッセージ付きで禁止したいパッケージがあればここに記述
9+
funlen:
10+
lines: 500
11+
statements: 80
1312
# goconst:
1413
# min-len: 2
1514
# min-occurrences: 2
@@ -52,7 +51,6 @@ linters:
5251
disable-all: true
5352
enable:
5453
- bodyclose
55-
- deadcode
5654
- depguard
5755
- dogsled
5856
- dupl
@@ -64,28 +62,22 @@ linters:
6462
- gocyclo
6563
- gofmt
6664
- goimports
67-
- golint
68-
- gomnd
6965
- goprintffuncname
7066
- gosec
7167
- gosimple
7268
- govet
7369
- ineffassign
74-
- interfacer
75-
# - lll
7670
- misspell
7771
- nakedret
7872
- rowserrcheck
79-
- scopelint
8073
- staticcheck
81-
- structcheck
8274
- stylecheck
8375
- typecheck
8476
- unconvert
8577
- unparam
8678
- unused
87-
- varcheck
8879
- whitespace
80+
- revive # replaces golint
8981

9082
# issues:
9183
# exclude-rules:

Makefile

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
1+
# Linting tasks
12
lint:
2-
golangci-lint run
3+
$(HOME)/go/bin/golangci-lint run --no-config --disable-all --enable=gofmt,govet,errcheck
4+
5+
# Testing tasks
6+
test:
7+
go test -v ./...
8+
9+
test-race:
10+
go test -v -race ./...
11+
12+
test-cover:
13+
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
14+
15+
# Build tasks
16+
build:
17+
go build -o bin/sql-dog-lint ./cmd/lint/main.go
18+
go build -o bin/sql-dog-clean ./cmd/clean/main.go
19+
@echo "Binaries built in ./bin/"
20+
21+
# Installation task
22+
install:
23+
go install ./cmd/lint
24+
go install ./cmd/clean
25+
26+
# Clean up tasks
27+
clean:
28+
rm -rf bin/
29+
30+
.PHONY: lint test test-race test-cover build install clean

0 commit comments

Comments
 (0)