Skip to content

Commit

Permalink
Move bindata to static package. Clean up coverage script (runatlantis…
Browse files Browse the repository at this point in the history
  • Loading branch information
lkysow authored and anubhavmishra committed Sep 23, 2017
1 parent c8df67a commit cbbd59d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 80 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 5 additions & 19 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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 $@
3 changes: 2 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/pkg/errors"
"github.com/urfave/cli"
"github.com/urfave/negroni"
"github.com/hootsuite/atlantis/static"
)

const (
Expand Down Expand Up @@ -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)
Expand Down
65 changes: 8 additions & 57 deletions server/bindata_assetfs.go → static/bindata_assetfs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cbbd59d

Please sign in to comment.