From 21ee2a94ef4631e468edc5c9b66816c39c7244ac Mon Sep 17 00:00:00 2001 From: BohuTANG Date: Wed, 11 Mar 2020 11:43:27 +0800 Subject: [PATCH] github: add workflows --- .github/workflows/mydumper-build.yml | 22 ++++++++++++++++++++++ .github/workflows/mydumper-coverage.yml | 23 +++++++++++++++++++++++ .github/workflows/mydumper-test.yml | 22 ++++++++++++++++++++++ README.md | 5 ++++- conf/mydumper.ini.sample | 15 ++++++++------- makefile | 9 ++++++++- 6 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/mydumper-build.yml create mode 100644 .github/workflows/mydumper-coverage.yml create mode 100644 .github/workflows/mydumper-test.yml diff --git a/.github/workflows/mydumper-build.yml b/.github/workflows/mydumper-build.yml new file mode 100644 index 0000000..f8819c1 --- /dev/null +++ b/.github/workflows/mydumper-build.yml @@ -0,0 +1,22 @@ +name: mydumper Build +on: [push, pull_request] +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Build + run: | + export PATH=$PATH:$(go env GOPATH)/bin + make build diff --git a/.github/workflows/mydumper-coverage.yml b/.github/workflows/mydumper-coverage.yml new file mode 100644 index 0000000..f8513b6 --- /dev/null +++ b/.github/workflows/mydumper-coverage.yml @@ -0,0 +1,23 @@ +name: mydumper Coverage +on: [push, pull_request] +jobs: + + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Coverage + run: | + export PATH=$PATH:$(go env GOPATH)/bin + make coverage + bash <(curl -s https://codecov.io/bash) -f "!mock.go" -t 139cd284-7f04-4e98-9e4b-4c697f007b59 diff --git a/.github/workflows/mydumper-test.yml b/.github/workflows/mydumper-test.yml new file mode 100644 index 0000000..1666487 --- /dev/null +++ b/.github/workflows/mydumper-test.yml @@ -0,0 +1,22 @@ +name: mydumper Test +on: [push, pull_request] +jobs: + + test: + name: Test + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Test + run: | + export PATH=$PATH:$(go env GOPATH)/bin + make test diff --git a/README.md b/README.md index b8c2742..c270c1b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -[![Build Status](https://travis-ci.org/xelabs/go-mydumper.png)](https://travis-ci.org/xelabs/go-mydumper) [![Go Report Card](https://goreportcard.com/badge/github.com/xelabs/go-mydumper)](https://goreportcard.com/report/github.com/xelabs/go-mydumper) [![codecov.io](https://codecov.io/gh/xelabs/go-mydumper/graphs/badge.svg)](https://codecov.io/gh/xelabs/go-mydumper/branch/master) +[![Github Actions Status](https://github.com/xelabs/go-mydumper/workflows/mydumper%20Build/badge.svg)](https://github.com/xelabs/go-mydumper/actions?query=workflow%3A%22mydumper+Build%22) +[![Github Actions Status](https://github.com/xelabs/go-mydumper/workflows/mydumper%20Test/badge.svg)](https://github.com/xelabs/go-mydumper/actions?query=workflow%3A%22mydumper+Test%22) +[![Github Actions Status](https://github.com/xelabs/go-mydumper/workflows/mydumper%20Coverage/badge.svg)](https://github.com/xelabs/go-mydumper/actions?query=workflow%3A%22mydumper+Coverage%22) +[![Go Report Card](https://goreportcard.com/badge/github.com/xelabs/go-mydumper)](https://goreportcard.com/report/github.com/xelabs/go-mydumper) [![codecov.io](https://codecov.io/gh/xelabs/go-mydumper/graphs/badge.svg)](https://codecov.io/gh/xelabs/go-mydumper/branch/master) # go-mydumper diff --git a/conf/mydumper.ini.sample b/conf/mydumper.ini.sample index 4f9e6a4..ff4234a 100644 --- a/conf/mydumper.ini.sample +++ b/conf/mydumper.ini.sample @@ -14,17 +14,18 @@ outdir = ./dumper-sql # Split tables into chunks of this output file size. This value is in MB chunksize = 128 # Session variables, split by ; -vars= "xx=xx;xx=xx;" +# vars= "xx=xx;xx=xx;" +vars= "" # Use this to restrict exported data. These are optional [where] -sample_table1 = created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) -sample_table2 = created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) +# sample_table1 = created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) +# sample_table2 = created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) # Use this to override value returned from tables. These are optional [select] -user.salt = 'reset salt of all system users' -user.password = 'reset password of all system users' +# user.salt = 'reset salt of all system users' +# user.password = 'reset password of all system users' -customer.first_name = CONCAT('Bohu', id) -customer.last_name = 'Last' +# customer.first_name = CONCAT('Bohu', id) +# customer.last_name = 'Last' diff --git a/makefile b/makefile index bc54888..c30d405 100644 --- a/makefile +++ b/makefile @@ -7,6 +7,9 @@ get: @echo "--> go get..." go get github.com/xelabs/go-mysqlstack/driver go get github.com/dlintw/goconf + +gettest: + @echo "--> go get..." go get github.com/stretchr/testify/assert go get github.com/pierrre/gotestcover @@ -28,6 +31,8 @@ fmt: go vet ./... test: + @$(MAKE) get + @$(MAKE) gettest @echo "--> Testing..." @$(MAKE) testcommon @@ -37,8 +42,10 @@ testcommon: # code coverage COVPKGS = common coverage: + @$(MAKE) get + @$(MAKE) gettest go build -v -o bin/gotestcover \ src/github.com/pierrre/gotestcover/*.go; - gotestcover -coverprofile=coverage.out -v $(COVPKGS) + bin/gotestcover -coverprofile=coverage.out -v $(COVPKGS) go tool cover -html=coverage.out .PHONY: get build clean fmt test coverage