Skip to content
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

Add github action CI #26

Merged
merged 2 commits into from
Mar 9, 2020
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
20 changes: 20 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "workflow"
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.13.x
- uses: actions/checkout@v2

- name: "format"
run: make format

- name: "test"
run: make test

- name: "build"
run: make build
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
bin
bin
.idea/
go-tpc
23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@ GO=GO15VENDOREXPERIMENT="1" CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GO111MOD

PACKAGE_LIST := go list ./...| grep -vE "cmd"
PACKAGES := $$($(PACKAGE_LIST))
FILES := $$(find . -name "*.go" | grep -vE "vendor")
GOFILTER := grep -vE 'vendor|render.Delims|bindata_assetfs|testutil|\.pb\.go'
GOCHECKER := $(GOFILTER) | awk '{ print } END { if (NR > 0) { exit 1 } }'
FILES_TO_FMT := $(shell find . -path -prune -o -name '*.go' -print)

all: build
all: format test build

format: vet fmt

fmt:
@echo "gofmt"
@gofmt -s -l -w $(FILES) 2>&1 | $(GOCHECKER)
@gofmt -w ${FILES_TO_FMT}
@git diff --exit-code .

test:
go test ./... -cover $(PACKAGES)

build:
go build -o ./bin/go-tpc cmd/go-tpc/*
build: mod
go build -o ./bin/go-tpc cmd/go-tpc/*

vet:
go vet ./...

mod:
@echo "go mod tidy"
GO111MODULE=on go mod tidy
@git diff --exit-code -- go.sum go.mod
6 changes: 3 additions & 3 deletions cmd/go-tpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ var (
)

const (
unknownDB = "Unknown database"
createDBDDL = "CREATE DATABASE "
mysqlDriver = "mysql"
unknownDB = "Unknown database"
createDBDDL = "CREATE DATABASE "
mysqlDriver = "mysql"
)

func closeDB() {
Expand Down
2 changes: 1 addition & 1 deletion tpcc/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (w *Workloader) loadItem(ctx context.Context) error {

var v []string
if isDataGen {
v = []string{strconv.Itoa(i+1), strconv.Itoa(iImID), iName, fmt.Sprintf("%f", iPrice), iData}
v = []string{strconv.Itoa(i + 1), strconv.Itoa(iImID), iName, fmt.Sprintf("%f", iPrice), iData}
} else {
v = []string{fmt.Sprintf(`(%d, %d, '%s', %f, '%s')`, i+1, iImID, iName, iPrice, iData)}
}
Expand Down