From b835baf013d428cc41709c672dc92379e11e88b8 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 2 Oct 2019 15:41:14 +0300 Subject: [PATCH] *(global): CI scripts --- .gitignore | 3 ++- .golangci.yml | 3 +++ .travis.yml | 9 ++------- ci.sh | 32 ++++++++++++++++++++++++++++++++ querylog/querylog_file.go | 4 ++-- 5 files changed, 41 insertions(+), 10 deletions(-) create mode 100755 ci.sh diff --git a/.gitignore b/.gitignore index f8564fd9..7ed45af2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,8 @@ /querylog.json /querylog.json.1 /a_main-packr.go +coverage.txt # Test output dnsfilter/tests/top-1m.csv -dnsfilter/tests/dnsfilter.TestLotsOfRules*.pprof \ No newline at end of file +dnsfilter/tests/dnsfilter.TestLotsOfRules*.pprof diff --git a/.golangci.yml b/.golangci.yml index ee952d7b..013b9000 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -38,6 +38,9 @@ linters: - gochecknoinits - prealloc - maligned + - godox + - funlen + - whitespace - goconst # disabled until it's possible to configure fast: true diff --git a/.travis.yml b/.travis.yml index 972fabd3..df2714e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ os: before_install: - nvm install node - npm install -g npm + - go install github.com/golangci/golangci-lint/cmd/golangci-lint install: - npm --prefix client install @@ -22,13 +23,7 @@ cache: - $HOME/Library/Caches/go-build script: - - node -v - - npm -v - # Run tests - - go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./... - # Make - - make build/static/index.html - - make + - /bin/bash ci.sh after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/ci.sh b/ci.sh new file mode 100755 index 00000000..63e5c0c5 --- /dev/null +++ b/ci.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e +set -x + +# Check versions and current directory +node -v +npm -v +go version +golangci-lint --version + +# Print the current directory contents +ls -la + +# Run linter +golangci-lint run + +# Run tests +go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./... + +# Make +make clean +make build/static/index.html +make + +if [[ -z "$(git status --porcelain)" ]]; then + # Working directory clean + echo "Git status is clean" +else + echo "Git status is not clean and contains uncommited changes" + echo "Please make sure there are no changes" + exit 1 +fi diff --git a/querylog/querylog_file.go b/querylog/querylog_file.go index 4f63a247..8f613012 100644 --- a/querylog/querylog_file.go +++ b/querylog/querylog_file.go @@ -271,7 +271,7 @@ func (r *Reader) BeginReadPrev(olderThan time.Time, count uint64) { if int64(off) < maxEntrySize { off = 0 } - r.fpos = uint64(off) + r.fpos = off log.Debug("QueryLog: seek: %x", off) _, err := r.f.Seek(int64(off), io.SeekStart) if err != nil { @@ -376,7 +376,7 @@ func (r *Reader) prepareRead() bool { if int64(off) < maxEntrySize { off = 0 } - r.fpos = uint64(off) + r.fpos = off log.Debug("QueryLog: seek: %x", off) _, err = r.f.Seek(int64(off), io.SeekStart) if err != nil {