Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Travis build stages #199

Merged
merged 2 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 39 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
language: go

go:
- 1.9.x

go_import_path: github.com/cloudflare/unsee

cache:
directories:
- node_modules
- vendor
jobs:
include:
- stage: Test Go code
language: go
go: "1.9.2"
before_script:
- make mock-assets
cache:
directories:
- vendor
script: make test-go

- stage: Test JavaScript code
language: node_js
node_js: "8"
env:
- NODE_ENV=test
cache:
directories:
- node_modules
script: make test-js

env:
- NODE_ENV=test
- stage: Lint Go code
language: go
go: "1.9.2"
script: make lint-go

before_script:
- nvm install 8
- stage: Lint JavaScript code
language: node_js
node_js: "8"
cache:
directories:
- node_modules
script: make lint-js

script:
- make test
- stage: Build Docker image
sudo: true
addons:
apt:
packages:
- docker-ce
script: make docker-image
34 changes: 29 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ endif
touch $@

.build/npm.install: package.json package-lock.json
@mkdir -p .build
npm install
touch $@

Expand Down Expand Up @@ -89,16 +90,40 @@ run-docker: docker-image
-p $(PORT):$(PORT) \
$(NAME):$(VERSION)

.PHONY: lint
lint: .build/deps.ok
.PHONY: lint-go
lint-go: .build/golint
golint ./... | (egrep -v "^vendor/|^bindata_assetfs.go" || true)

.PHONY: lint-js
lint-js: .build/npm.install
$(CURDIR)/node_modules/.bin/eslint --quiet assets/static/*.js

.PHONY: test
test: lint bindata_assetfs.go
.PHONY: lint
lint: lint-go lint-js

# Creates mock bindata_assetfs.go with source assets rather than webpack generated ones
.PHONY: mock-assets
mock-assets: .build/go-bindata .build/go-bindata-assetfs
mkdir -p $(CURDIR)/assets/static/dist/templates
cp $(CURDIR)/assets/static/*.* $(CURDIR)/assets/static/dist/
touch $(CURDIR)/assets/static/dist/templates/loader_unsee.html
touch $(CURDIR)/assets/static/dist/templates/loader_shared.html
touch $(CURDIR)/assets/static/dist/templates/loader_help.html
go-bindata-assetfs -prefix assets -nometadata assets/templates/... assets/static/dist/...
# force assets rebuild on next make run
rm -f .build/bindata_assetfs.*

.PHONY: test-go
test-go: .build/vendor.ok
go test -bench=. -cover `go list ./... | grep -v /vendor/`

.PHONY: test-js
test-js:
npm test

.PHONY: test
test: lint test-go test-js

.build/dep.ok:
go get -u github.com/golang/dep/cmd/dep
@mkdir -p .build
Expand All @@ -114,7 +139,6 @@ vendor: .build/dep.ok
dep ensure
dep prune


.PHONY: vendor-update
vendor-update: .build/dep.ok
dep ensure -update
Expand Down