Skip to content

Commit

Permalink
Add github action CI (pingcap#26)
Browse files Browse the repository at this point in the history
* add basic github action workflow

Signed-off-by: yeya24 <yb532204897@gmail.com>
  • Loading branch information
yeya24 authored Mar 9, 2020
1 parent 76be84b commit 3dabf96
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
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

0 comments on commit 3dabf96

Please sign in to comment.