Skip to content

Commit

Permalink
Test windows
Browse files Browse the repository at this point in the history
* Run Go build and test on Ubuntu Linux and Windows

* Add lint
  • Loading branch information
blobbered authored Jan 25, 2021
1 parent 5b702c4 commit 2850189
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 56 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
go: ["1.14", "1.13", "1.12"]
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2-beta
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- run: go build -x -work ./cmds/...
Expand All @@ -19,14 +19,29 @@ jobs:
with:
node-version: "10.x"
- run: npm install
golangci:
name: lint
strategy:
matrix:
go: ["1.14"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- name: golangci-lint
uses: golangci/[email protected]
with:
# the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.35.2
go-test:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.14", "1.13", "1.12"]
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2-beta
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- run: go test -race ./...
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,12 @@ test:
go test github.com/hound-search/hound/...
npm test

lint:
export GO111MODULE=on
go get github.com/golangci/golangci-lint/cmd/golangci-lint
export GOPATH=/tmp/gopath
export PATH=$GOPATH/bin:$PATH
golangci-lint run ./...

clean:
rm -rf .build node_modules
2 changes: 1 addition & 1 deletion ansi/ansi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var (
printTests = false
)

func makeReal(s string) string {
func makeReal(s string) string { //nolint
return strings.Replace(s, "~", "\x1b", -1)
}

Expand Down
2 changes: 1 addition & 1 deletion ansi/tty_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ansi

const ioctlReadTermios = 0x5401 // syscall.TCGETS
const ioctlWriteTermios = 0x5402 // syscall.TCSETS
const ioctlWriteTermios = 0x5402 //nolint syscall.TCSETS
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func searchAll(
*filesOpened += r.res.FilesOpened
}

*duration = int(time.Now().Sub(startedAt).Seconds() * 1000)
*duration = int(time.Now().Sub(startedAt).Seconds() * 1000) //nolint

return res, nil
}
Expand Down
4 changes: 2 additions & 2 deletions client/coalesce.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ func matchToBlock(m *index.Match) *Block {

v[b] = true

for _, line := range m.Before {
for _, line := range m.Before { //nolint
l = append(l, line)
}

l = append(l, m.Line)

for _, line := range m.After {
for _, line := range m.After { //nolint
l = append(l, line)
}

Expand Down
6 changes: 3 additions & 3 deletions cmds/houndd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func makeSearchers(cfg *config.Config) (map[string]*searcher.Searcher, bool, err
if len(errs) > 0 {
// NOTE: This mutates the original config so the repos
// are not even seen by other code paths.
for name, _ := range errs {
for name, _ := range errs { //nolint
delete(cfg.Repos, name)
}

Expand Down Expand Up @@ -79,7 +79,7 @@ func registerShutdownSignal() <-chan os.Signal {
return shutdownCh
}

func makeTemplateData(cfg *config.Config) (interface{}, error) {
func makeTemplateData(cfg *config.Config) (interface{}, error) { //nolint
var data struct {
ReposAsJson string
}
Expand All @@ -98,7 +98,7 @@ func makeTemplateData(cfg *config.Config) (interface{}, error) {
return &data, nil
}

func runHttp(
func runHttp( //nolint
addr string,
dev bool,
cfg *config.Config,
Expand Down
12 changes: 6 additions & 6 deletions codesearch/index/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type idrange struct {
lo, hi, new uint32
}

type postIndex struct {
tri uint32
count uint32
offset uint32
type postIndex struct { //nolint
tri uint32 //nolint
count uint32 //nolint
offset uint32 //nolint
}

// Merge creates a new index in the file dst that corresponds to merging
Expand All @@ -70,7 +70,7 @@ func Merge(dst, src1, src2 string) {
for i1 < uint32(ix1.numName) && ix1.Name(i1) < limit {
i1++
}
hi := i1
hi := i1 //nolint

// Record range before the shadow.
if old < lo {
Expand Down Expand Up @@ -304,7 +304,7 @@ func (r *postMapReader) nextId() bool {
type postDataWriter struct {
out *bufWriter
postIndexFile *bufWriter
buf [10]byte
buf [10]byte //nolint
base uint32
count, offset uint32
last uint32
Expand Down
4 changes: 2 additions & 2 deletions codesearch/index/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (ix *Index) Close() error {
}

// uvarint returns the varint value at the given offset in the index data.
func (ix *Index) uvarint(off uint32) uint32 {
func (ix *Index) uvarint(off uint32) uint32 { //nolint
v, n := binary.Uvarint(ix.slice(off, -1))
if n <= 0 {
corrupt(ix.data.f)
Expand Down Expand Up @@ -185,7 +185,7 @@ func (ix *Index) listAt(off uint32) (trigram, count, offset uint32) {
return
}

func (ix *Index) dumpPosting() {
func (ix *Index) dumpPosting() { //nolint
d := ix.slice(ix.postIndex, postEntrySize*ix.numPost)
for i := 0; i < ix.numPost; i++ {
j := i * postEntrySize
Expand Down
8 changes: 4 additions & 4 deletions codesearch/index/regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func trigramsImply(t []string, q *Query) bool {
// maybeRewrite rewrites q to use op if it is possible to do so
// without changing the meaning. It also simplifies if the node
// is an empty OR or AND.
func (q *Query) maybeRewrite(op QueryOp) {
func (q *Query) maybeRewrite(op QueryOp) { //nolint
if q.Op != QAnd && q.Op != QOr {
return
}
Expand Down Expand Up @@ -736,7 +736,7 @@ func (s stringSet) have() bool {
}

// contains reports whether s contains str.
func (s stringSet) contains(str string) bool {
func (s stringSet) contains(str string) bool { //nolint
for _, ss := range s {
if ss == str {
return true
Expand Down Expand Up @@ -814,7 +814,7 @@ func (s stringSet) minLen() int {
}

// maxLen returns the length of the longest string in s.
func (s stringSet) maxLen() int {
func (s stringSet) maxLen() int { //nolint
if len(s) == 0 {
return 0
}
Expand Down Expand Up @@ -847,7 +847,7 @@ func (s stringSet) cross(t stringSet, isSuffix bool) stringSet {
}

// clear empties the set but preserves the storage.
func (s *stringSet) clear() {
func (s *stringSet) clear() { //nolint
*s = (*s)[:0]
}

Expand Down
20 changes: 10 additions & 10 deletions codesearch/index/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type IndexWriter struct {
paths []string

nameData *bufWriter // temp file holding list of names
nameLen uint32 // number of bytes written to nameData
nameLen uint32 //nolint number of bytes written to nameData
nameIndex *bufWriter // temp file holding name index
numName int // number of names written
totalBytes int64
Expand Down Expand Up @@ -123,15 +123,15 @@ func (ix *IndexWriter) AddFile(name string) {
func (ix *IndexWriter) Add(name string, f io.Reader) string {
ix.trigram.Reset()
var (
c = byte(0)
c = byte(0) //nolint
i = 0
buf = ix.inbuf[:0]
tv = uint32(0)
n = int64(0)
linelen = 0
numLines = 0
longLines = 0
skipReason = ""
skipReason = "" //nolint
)

for {
Expand Down Expand Up @@ -246,7 +246,7 @@ func (ix *IndexWriter) Flush() {

os.Remove(ix.nameData.name)
for _, d := range ix.postData {
unmmap(d)
unmmap(d) //nolint
}
for _, f := range ix.postFile {
f.Close()
Expand Down Expand Up @@ -310,7 +310,7 @@ func (ix *IndexWriter) flushPost() {
}

ix.post = ix.post[:0]
w.Seek(0, 0)
w.Seek(0, 0) //nolint
ix.postFile = append(ix.postFile, w)
}

Expand Down Expand Up @@ -368,7 +368,7 @@ type postChunk struct {
m []postEntry // remaining entries after e
}

const postBuf = 4096
const postBuf = 4096 //nolint

// A postHeap is a heap (priority queue) of postChunks.
type postHeap struct {
Expand All @@ -388,7 +388,7 @@ func (h *postHeap) addMem(x []postEntry) {

// step reads the next entry from ch and saves it in ch.e.
// It returns false if ch is over.
func (h *postHeap) step(ch *postChunk) bool {
func (h *postHeap) step(ch *postChunk) bool { //nolint
old := ch.e
m := ch.m
if len(m) == 0 {
Expand All @@ -414,7 +414,7 @@ func (h *postHeap) add(ch *postChunk) {
}

// empty reports whether the postHeap is empty.
func (h *postHeap) empty() bool {
func (h *postHeap) empty() bool { //nolint
return len(h.ch) == 0
}

Expand Down Expand Up @@ -492,7 +492,7 @@ type bufWriter struct {
name string
file *os.File
buf []byte
tmp [8]byte
tmp [8]byte //nolint
}

// bufCreate creates a new file with the given name and returns a
Expand Down Expand Up @@ -578,7 +578,7 @@ func (b *bufWriter) flush() {
func (b *bufWriter) finish() *os.File {
b.flush()
f := b.file
f.Seek(0, 0)
f.Seek(0, 0) //nolint
return f
}

Expand Down
16 changes: 8 additions & 8 deletions codesearch/regexp/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

// cleanClass sorts the ranges (pairs of elements of r),
// merges them, and eliminates duplicates.
func cleanClass(rp *[]rune) []rune {
func cleanClass(rp *[]rune) []rune { //nolint

// Sort by lo increasing, hi decreasing to break ties.
sort.Sort(ranges{rp})
Expand Down Expand Up @@ -119,7 +119,7 @@ func appendFoldedRange(r []rune, lo, hi rune) []rune {
// The choice of receiver type definition is strange
// but avoids an allocation since we already have
// a *[]rune.
type ranges struct {
type ranges struct { //nolint
p *[]rune
}

Expand All @@ -141,25 +141,25 @@ func (ra ranges) Swap(i, j int) {
p[i], p[i+1], p[j], p[j+1] = p[j], p[j+1], p[i], p[i+1]
}

func progString(p *syntax.Prog) string {
func progString(p *syntax.Prog) string { //nolint
var b bytes.Buffer
dumpProg(&b, p)
return b.String()
}

func instString(i *syntax.Inst) string {
func instString(i *syntax.Inst) string { //nolint
var b bytes.Buffer
dumpInst(&b, i)
return b.String()
}

func bw(b *bytes.Buffer, args ...string) {
func bw(b *bytes.Buffer, args ...string) { //nolint
for _, s := range args {
b.WriteString(s)
}
}

func dumpProg(b *bytes.Buffer, p *syntax.Prog) {
func dumpProg(b *bytes.Buffer, p *syntax.Prog) { //nolint
for j := range p.Inst {
i := &p.Inst[j]
pc := strconv.Itoa(j)
Expand All @@ -175,11 +175,11 @@ func dumpProg(b *bytes.Buffer, p *syntax.Prog) {
}
}

func u32(i uint32) string {
func u32(i uint32) string { //nolint
return strconv.FormatUint(uint64(i), 10)
}

func dumpInst(b *bytes.Buffer, i *syntax.Inst) {
func dumpInst(b *bytes.Buffer, i *syntax.Inst) { //nolint
switch i.Op {
case syntax.InstAlt:
bw(b, "alt -> ", u32(i.Out), ", ", u32(i.Arg))
Expand Down
4 changes: 2 additions & 2 deletions codesearch/regexp/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ type flags uint32

const (
flagBOL flags = 1 << iota // beginning of line
flagEOL // end of line
flagEOL //nolint end of line
flagBOT // beginning of text
flagEOT // end of text
flagEOT //nolint end of text
flagWord // last byte was word byte
)

Expand Down
2 changes: 1 addition & 1 deletion codesearch/regexp/utf.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (b *runeBuilder) addRange(lo, hi rune, fold bool) {
}

// TODO: Pick off 80-10FFFF for special handling?
if lo == 0x80 && hi == 0x10FFFF {
if lo == 0x80 && hi == 0x10FFFF { //nolint
}

// Split range into same-length sized ranges.
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ func TestExampleConfigsAreValid(t *testing.T) {
repo := cfg.Repos["SomeGitRepo"]
vcsConfigBytes := repo.VcsConfig()
var vcsConfigVals map[string]interface{}
json.Unmarshal(vcsConfigBytes, &vcsConfigVals)
json.Unmarshal(vcsConfigBytes, &vcsConfigVals) //nolint
if detectRef, ok := vcsConfigVals["detect-ref"]; !ok || !detectRef.(bool) {
t.Error("global detectRef vcs config setting not set for repo")
}

repo = cfg.Repos["GitRepoWithDetectRefDisabled"]
vcsConfigBytes = repo.VcsConfig()
json.Unmarshal(vcsConfigBytes, &vcsConfigVals)
json.Unmarshal(vcsConfigBytes, &vcsConfigVals) //nolint
if detectRef, ok := vcsConfigVals["detect-ref"]; !ok || detectRef.(bool) {
t.Error("global detectRef vcs config setting not overriden by repo-level setting")
}
Expand Down
Loading

0 comments on commit 2850189

Please sign in to comment.