Skip to content

Commit d35c813

Browse files
committed
Add build script and status badge of tests
1 parent 388db7d commit d35c813

File tree

5 files changed

+154
-1
lines changed

5 files changed

+154
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ _test
1313
*.exe
1414
*.test
1515
*.prof
16-
16+
*.out
1717
*.swp
1818

19+
vendor/*
20+
!vendor/vendor.json

.travis.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
language: go
2+
3+
matrix:
4+
fast_finish: true
5+
include:
6+
- go: 1.10.x
7+
- go: 1.11.x
8+
env: GO111MODULE=on
9+
- go: 1.12.x
10+
env: GO111MODULE=on
11+
- go: 1.13.x
12+
- go: master
13+
14+
git:
15+
depth: 10
16+
17+
before_install:
18+
- if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi
19+
20+
install:
21+
- if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make install; fi
22+
- if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi
23+
- if [[ "${GO111MODULE}" = "on" ]]; then make tools; fi
24+
25+
go_import_path: github.com/soongo/path-to-regexp
26+
27+
script:
28+
- make vet
29+
- make fmt-check
30+
- make misspell-check
31+
- make test
32+
33+
after_success:
34+
- bash <(curl -s https://codecov.io/bash)
35+
36+
notifications:
37+
email:
38+
recipients:
39+
- guoyao.dev@gmail.com
40+
on_success: change
41+
on_failure: always
42+
on_cancel: never

Makefile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
GO ?= go
2+
GOFMT ?= gofmt "-s"
3+
PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
4+
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/ | grep -v /examples/)
5+
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
6+
TESTFOLDER := $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
7+
8+
all: install
9+
10+
install: deps
11+
govendor sync
12+
13+
.PHONY: test
14+
test:
15+
echo "mode: atomic" > coverage.out
16+
for d in $(TESTFOLDER); do \
17+
$(GO) test -v -covermode=atomic -coverprofile=profile.out $$d > tmp.out; \
18+
cat tmp.out; \
19+
if grep -q "^--- FAIL" tmp.out; then \
20+
rm tmp.out; \
21+
exit 1; \
22+
elif grep -q "build failed" tmp.out; then \
23+
rm tmp.out; \
24+
exit 1; \
25+
elif grep -q "setup failed" tmp.out; then \
26+
rm tmp.out; \
27+
exit 1; \
28+
fi; \
29+
if [ -f profile.out ]; then \
30+
cat profile.out | grep -v "mode:" >> coverage.out; \
31+
rm profile.out; \
32+
fi; \
33+
done
34+
35+
.PHONY: fmt
36+
fmt:
37+
$(GOFMT) -w $(GOFILES)
38+
39+
.PHONY: fmt-check
40+
fmt-check:
41+
@diff=$$($(GOFMT) -d $(GOFILES)); \
42+
if [ -n "$$diff" ]; then \
43+
echo "Please run 'make fmt' and commit the result:"; \
44+
echo "$${diff}"; \
45+
exit 1; \
46+
fi;
47+
48+
vet:
49+
$(GO) vet $(VETPACKAGES)
50+
51+
deps:
52+
@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
53+
$(GO) get -u github.com/kardianos/govendor; \
54+
fi
55+
56+
.PHONY: lint
57+
lint:
58+
@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
59+
$(GO) get -u golang.org/x/lint/golint; \
60+
fi
61+
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
62+
63+
.PHONY: misspell-check
64+
misspell-check:
65+
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
66+
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
67+
fi
68+
misspell -error $(GOFILES)
69+
70+
.PHONY: misspell
71+
misspell:
72+
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
73+
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
74+
fi
75+
misspell -w $(GOFILES)
76+
77+
.PHONY: tools
78+
tools:
79+
go install golang.org/x/lint/golint; \
80+
go install github.com/client9/misspell/cmd/misspell;

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Path-to-RegExp
22

3+
[![Build Status](https://travis-ci.org/soongo/path-to-regexp.svg)](https://travis-ci.org/soongo/path-to-regexp)
4+
[![codecov](https://codecov.io/gh/soongo/path-to-regexp/branch/master/graph/badge.svg)](https://codecov.io/gh/soongo/path-to-regexp)
5+
[![Go Report Card](https://goreportcard.com/badge/github.com/soongo/path-to-regexp)](https://goreportcard.com/report/github.com/soongo/path-to-regexp)
6+
[![GoDoc](https://godoc.org/github.com/soongo/path-to-regexp?status.svg)](https://godoc.org/github.com/soongo/path-to-regexp)
7+
[![License](https://img.shields.io/badge/MIT-green.svg)](https://opensource.org/licenses/MIT)
8+
39
> Turn a path string such as `/user/:name` into a regular expression.
410
511
Thanks to [path-to-regexp](https://github.com/pillarjs/path-to-regexp).

vendor/vendor.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"comment": "v0.1.0",
3+
"ignore": "test",
4+
"package": [
5+
{
6+
"checksumSHA1": "2oe1uUXbqNYrm1N7Zy2XA02fFRY=",
7+
"path": "github.com/dlclark/regexp2",
8+
"revision": "92c702aa5812963ef9193a9624191932d44073d7",
9+
"revisionTime": "2019-08-06T04:29:31Z",
10+
"version": "v1.2.0",
11+
"versionExact": "v1.2.0"
12+
},
13+
{
14+
"checksumSHA1": "Y1AUMxG1q6+9I4Wp7h0c5ESZU84=",
15+
"path": "github.com/dlclark/regexp2/syntax",
16+
"revision": "92c702aa5812963ef9193a9624191932d44073d7",
17+
"revisionTime": "2019-08-06T04:29:31Z",
18+
"version": "v1.2.0",
19+
"versionExact": "v1.2.0"
20+
}
21+
],
22+
"rootPath": "github.com/soongo/path-to-regexp"
23+
}

0 commit comments

Comments
 (0)