Move bindata to static package. Clean up coverage script (#149)

This commit is contained in:
Luke Kysow
2017-09-22 17:58:30 -07:00
committed by Anubhav Mishra
parent c8df67a457
commit cbbd59d09c
4 changed files with 19 additions and 80 deletions

View File

@@ -29,13 +29,14 @@ test: ## Run tests, coverage reports, and clean (coverage taints the compiled co
go test $(PKG)
test-coverage:
./scripts/coverage.sh
./scripts/coverage.sh $(PKG)
test-coverage-html:
./scripts/coverage.sh --html
./scripts/coverage.sh $(PKG)
go tool cover -html .cover/cover.out
dist: ## Package up everything in static/ using go-bindata-assetfs so it can be served by a single binary
go-bindata-assetfs -pkg server static/... && mv bindata_assetfs.go server
go-bindata-assetfs -pkg static static/... && mv bindata_assetfs.go static
release: ## Create packages for a release
./scripts/binary-release.sh

View File

@@ -1,13 +1,12 @@
#!/bin/sh
# From https://github.com/mlafeldt/chef-runner/blob/v0.7.0/script/coverage
# Taken and modified from https://github.com/mlafeldt/chef-runner/blob/v0.7.0/script/coverage
# Generate test coverage statistics for Go packages.
#
# Works around the fact that `go test -coverprofile` currently does not work
# with multiple packages, see https://code.google.com/p/go/issues/detail?id=6909
#
# Usage: script/coverage [--html]
#
# --html Additionally create HTML report and open it in browser
# Usage: coverage.sh packages...
# Example: coverage.sh github.com/hootsuite/atlantis github.com/hootsuite/atlantis/bootstrap
#
set -e
@@ -20,7 +19,7 @@ generate_cover_data() {
rm -rf "$workdir"
mkdir "$workdir"
pkgs=$(go list ./... | grep -v e2e | grep -v vendor | grep -v static)
pkgs=$@
for pkg in $pkgs; do
f="$workdir/$(echo $pkg | tr / -).cover"
go test -covermode="$mode" -coverprofile="$f" "$pkg"
@@ -30,17 +29,4 @@ generate_cover_data() {
grep -h -v "^mode:" "$workdir"/*.cover >>"$profile"
}
show_cover_report() {
go tool cover -${1}="$profile"
}
generate_cover_data $(go list ./...)
show_cover_report func
case "$1" in
"")
;;
--html)
show_cover_report html ;;
*)
echo >&2 "error: invalid option: $1"; exit 1 ;;
esac
generate_cover_data $@

View File

@@ -26,6 +26,7 @@ import (
"github.com/pkg/errors"
"github.com/urfave/cli"
"github.com/urfave/negroni"
"github.com/hootsuite/atlantis/static"
)
const (
@@ -165,7 +166,7 @@ func (s *Server) Start() error {
s.router.HandleFunc("/", s.index).Methods("GET").MatcherFunc(func(r *http.Request, rm *mux.RouteMatch) bool {
return r.URL.Path == "/" || r.URL.Path == "/index.html"
})
s.router.PathPrefix("/static/").Handler(http.FileServer(&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo}))
s.router.PathPrefix("/static/").Handler(http.FileServer(&assetfs.AssetFS{Asset: static.Asset, AssetDir: static.AssetDir, AssetInfo: static.AssetInfo}))
s.router.HandleFunc("/events", s.postEvents).Methods("POST")
s.router.HandleFunc("/locks", s.deleteLock).Methods("DELETE").Queries("id", "{id:.*}")
lockRoute := s.router.HandleFunc("/lock", s.getLock).Methods("GET").Queries("id", "{id}").Name(lockRoute)

File diff suppressed because one or more lines are too long