2015-07-27 09:48:35 -04:00
.PHONY : all test clean build install run stop cover dist cleandb travis docker
2015-06-14 23:53:32 -08:00
GOPATH ?= $( GOPATH:)
GOFLAGS ?= $( GOFLAGS:)
BUILD_NUMBER ?= $( BUILD_NUMBER:)
2015-09-16 17:45:00 -07:00
BUILD_DATE = $( shell date -u)
2015-09-17 13:01:40 -07:00
BUILD_HASH = $( shell git rev-parse HEAD)
2015-06-14 23:53:32 -08:00
2015-07-24 12:37:11 -04:00
GO = $( GOPATH) /bin/godep go
2015-09-03 08:49:58 -04:00
ESLINT = node_modules/eslint/bin/eslint.js
2015-07-20 15:13:12 -04:00
2015-06-14 23:53:32 -08:00
i f e q ( $( BUILD_NUMBER ) , )
BUILD_NUMBER := dev
e n d i f
2015-07-29 23:55:45 -08:00
i f e q ( $( TRAVIS_BUILD_NUMBER ) , )
BUILD_NUMBER := dev
e l s e
BUILD_NUMBER := $( TRAVIS_BUILD_NUMBER)
e n d i f
2015-06-14 23:53:32 -08:00
DIST_ROOT = dist
DIST_PATH = $( DIST_ROOT) /mattermost
DIST_RESULTS = $( DIST_ROOT) /results
BENCH = .
TESTS = .
2015-07-27 09:48:35 -04:00
DOCKERNAME ?= mm-dev
DOCKER_CONTAINER_NAME ?= mm-test
2015-06-25 12:21:47 -04:00
all : travis
travis :
@echo building for travis
2015-07-05 08:28:22 -08:00
2015-09-17 16:27:25 -04:00
if [ " $( TRAVIS_DB) " = "postgres" ] ; then \
sed -i'.bak' 's|mysql|postgres|g' config/config.json; \
sed -i'.bak' 's|mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8|postgres://mmuser:mostest@dockerhost:5432/mattermost_test?sslmode=disable\&connect_timeout=10|g' config/config.json; \
fi
2015-07-05 08:28:22 -08:00
rm -Rf $( DIST_ROOT)
2015-07-20 15:13:12 -04:00
@$( GO) clean $( GOFLAGS) -i ./...
2015-06-25 15:33:39 -04:00
@cd web/react/ && npm install
2015-10-07 09:09:48 -04:00
cd web/react/ && npm run build-libs
2015-06-25 15:33:39 -04:00
2015-09-03 08:49:58 -04:00
@echo Checking for style guide compliance
2015-09-03 15:13:02 -04:00
cd web/react && $( ESLINT) --quiet components/* dispatcher/* pages/* stores/* utils/*
2015-09-17 09:01:33 -04:00
@echo Running gofmt
$( eval GOFMT_OUTPUT := $( shell gofmt -d -s api/ model/ store/ utils/ manualtesting/ mattermost.go 2>& 1) )
@echo " $( GOFMT_OUTPUT) "
@if [ ! " $( GOFMT_OUTPUT) " ] ; then \
echo "gofmt sucess" ; \
else \
echo "gofmt failure" ; \
exit 1; \
fi
2015-09-03 08:49:58 -04:00
2015-09-16 17:37:11 -07:00
@sed -i'.bak' 's|_BUILD_NUMBER_|$(BUILD_NUMBER)|g' ./model/version.go
@sed -i'.bak' 's|_BUILD_DATE_|$(BUILD_DATE)|g' ./model/version.go
2015-09-17 13:01:40 -07:00
@sed -i'.bak' 's|_BUILD_HASH_|$(BUILD_HASH)|g' ./model/version.go
2015-09-16 17:37:11 -07:00
2015-07-20 15:13:12 -04:00
@$( GO) build $( GOFLAGS) ./...
2015-09-16 09:50:20 -07:00
@$( GO) install $( GOFLAGS) ./...
2015-06-14 23:53:32 -08:00
2015-06-25 15:33:39 -04:00
@mkdir -p logs
2015-07-20 15:13:12 -04:00
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 180s ./api || exit 1
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 12s ./model || exit 1
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 120s ./store || exit 1
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 120s ./utils || exit 1
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 120s ./web || exit 1
2015-06-25 15:33:39 -04:00
2015-07-29 23:55:45 -08:00
mkdir -p $( DIST_PATH) /bin
cp $( GOPATH) /bin/platform $( DIST_PATH) /bin
cp -RL config $( DIST_PATH) /config
touch $( DIST_PATH) /config/build.txt
echo $( BUILD_NUMBER) | tee -a $( DIST_PATH) /config/build.txt
mkdir -p $( DIST_PATH) /logs
mkdir -p web/static/js
cd web/react && npm run build
2015-10-07 09:09:48 -04:00
cd web/sass-files && compass compile -e production --force
2015-07-29 23:55:45 -08:00
2015-10-07 09:09:48 -04:00
mkdir -p $( DIST_PATH) /web/static/js
cp -L web/static/js/*.min.js $( DIST_PATH) /web/static/js/
2015-10-08 16:46:45 -04:00
cp -RL web/static/config $( DIST_PATH) /web/static
cp -RL web/static/css $( DIST_PATH) /web/static
cp -RL web/static/fonts $( DIST_PATH) /web/static
cp -RL web/static/help $( DIST_PATH) /web/static
cp -RL web/static/images $( DIST_PATH) /web/static
2015-10-07 09:09:48 -04:00
cp -RL web/static/js/jquery-dragster $( DIST_PATH) /web/static/js/
2015-07-29 23:55:45 -08:00
cp -RL web/templates $( DIST_PATH) /web
mkdir -p $( DIST_PATH) /api
cp -RL api/templates $( DIST_PATH) /api
2015-09-30 14:16:03 -04:00
cp build/MIT-COMPILED-LICENSE.md $( DIST_PATH)
2015-08-03 08:16:10 -08:00
cp NOTICE.txt $( DIST_PATH)
cp README.md $( DIST_PATH)
2015-07-29 23:55:45 -08:00
mv $( DIST_PATH) /web/static/js/bundle.min.js $( DIST_PATH) /web/static/js/bundle-$( BUILD_NUMBER) .min.js
2015-10-07 09:09:48 -04:00
mv $( DIST_PATH) /web/static/js/libs.min.js $( DIST_PATH) /web/static/js/libs-$( BUILD_NUMBER) .min.js
2015-07-29 23:55:45 -08:00
2015-09-14 13:56:58 -04:00
@sed -i'.bak' 's|react-with-addons-0.13.3.js|react-with-addons-0.13.3.min.js|g' $( DIST_PATH) /web/templates/head.html
2015-07-29 23:55:45 -08:00
@sed -i'.bak' 's|jquery-1.11.1.js|jquery-1.11.1.min.js|g' $( DIST_PATH) /web/templates/head.html
2015-09-14 13:56:58 -04:00
@sed -i'.bak' 's|bootstrap-3.3.5.js|bootstrap-3.3.5.min.js|g' $( DIST_PATH) /web/templates/head.html
@sed -i'.bak' 's|react-bootstrap-0.25.1.js|react-bootstrap-0.25.1.min.js|g' $( DIST_PATH) /web/templates/head.html
2015-07-29 23:55:45 -08:00
@sed -i'.bak' 's|perfect-scrollbar.js|perfect-scrollbar.min.js|g' $( DIST_PATH) /web/templates/head.html
@sed -i'.bak' 's|bundle.js|bundle-$(BUILD_NUMBER).min.js|g' $( DIST_PATH) /web/templates/head.html
2015-10-07 09:09:48 -04:00
@sed -i'.bak' 's|libs.min.js|libs-$(BUILD_NUMBER).min.js|g' $( DIST_PATH) /web/templates/head.html
2015-07-29 23:55:45 -08:00
rm $( DIST_PATH) /web/templates/*.bak
2015-10-02 14:48:50 -04:00
mv doc/README.md doc/index.md
2015-10-09 11:58:19 -04:00
mkdocs build --strict
2015-10-02 14:48:50 -04:00
cp -r documentation-html $( DIST_PATH) /documentation-html
2015-07-29 23:55:45 -08:00
tar -C dist -czf $( DIST_PATH) .tar.gz mattermost
2015-10-02 14:48:50 -04:00
rm -r $( DIST_PATH)
2015-07-29 23:55:45 -08:00
2015-06-14 23:53:32 -08:00
build :
2015-07-20 15:13:12 -04:00
@$( GO) build $( GOFLAGS) ./...
2015-06-14 23:53:32 -08:00
install :
@go get $( GOFLAGS) github.com/tools/godep
2015-07-24 13:50:02 -04:00
@if [ $( shell docker ps -a | grep -ci mattermost-mysql) -eq 0 ] ; then \
2015-06-14 23:53:32 -08:00
echo starting mattermost-mysql; \
docker run --name mattermost-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD = mostest \
-e MYSQL_USER = mmuser -e MYSQL_PASSWORD = mostest -e MYSQL_DATABASE = mattermost_test -d mysql > /dev/null; \
2015-07-20 09:52:25 -04:00
elif [ $( shell docker ps | grep -ci mattermost-mysql) -eq 0 ] ; then \
echo restarting mattermost-mysql; \
docker start mattermost-mysql > /dev/null; \
2015-06-14 23:53:32 -08:00
fi
@cd web/react/ && npm install
2015-10-07 09:09:48 -04:00
@cd web/react/ && npm run build-libs
2015-06-14 23:53:32 -08:00
2015-07-28 10:24:24 -04:00
check : install
@echo Running ESLint...
2015-09-03 08:49:58 -04:00
-cd web/react && $( ESLINT) components/* dispatcher/* pages/* stores/* utils/*
2015-09-17 09:01:33 -04:00
@echo Running gofmt
$( eval GOFMT_OUTPUT := $( shell gofmt -d -s api/ model/ store/ utils/ manualtesting/ mattermost.go 2>& 1) )
@echo " $( GOFMT_OUTPUT) "
@if [ [ ! " $( GOFMT_OUTPUT) " ] ] ; then \
echo "gofmt sucess" ; \
else \
echo "gofmt failure" ; \
exit 1; \
fi
2015-07-28 10:24:24 -04:00
2015-06-14 23:53:32 -08:00
test : install
@mkdir -p logs
2015-10-02 14:05:25 +10:00
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 600s ./api || exit 1
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 60s ./model || exit 1
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 600s ./store || exit 1
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 600s ./utils || exit 1
@$( GO) test $( GOFLAGS) -run= $( TESTS) -test.v -test.timeout= 600s ./web || exit 1
2015-06-14 23:53:32 -08:00
benchmark : install
@mkdir -p logs
2015-07-20 15:13:12 -04:00
@$( GO) test $( GOFLAGS) -test.v -run= NO_TESTS -bench= $( BENCH) ./api || exit 1
2015-06-14 23:53:32 -08:00
cover : install
rm -Rf $( DIST_RESULTS)
mkdir -p $( DIST_RESULTS)
2015-07-24 12:17:48 -04:00
@$( GO) test $( GOFLAGS) -coverprofile= $( DIST_RESULTS) /api.cover.out github.com/mattermost/platform/api
@$( GO) test $( GOFLAGS) -coverprofile= $( DIST_RESULTS) /model.cover.out github.com/mattermost/platform/model
@$( GO) test $( GOFLAGS) -coverprofile= $( DIST_RESULTS) /store.cover.out github.com/mattermost/platform/store
@$( GO) test $( GOFLAGS) -coverprofile= $( DIST_RESULTS) /utils.cover.out github.com/mattermost/platform/utils
@$( GO) test $( GOFLAGS) -coverprofile= $( DIST_RESULTS) /web.cover.out github.com/mattermost/platform/web
2015-06-14 23:53:32 -08:00
cd $( DIST_RESULTS) && \
echo "mode: set" > coverage.out && cat *.cover.out | grep -v mode: | sort -r | \
awk '{if($$1 != last) {print $$0;last=$$1}}' >> coverage.out
2015-07-24 12:17:48 -04:00
cd $( DIST_RESULTS) && $( GO) tool cover -html= coverage.out -o= coverage.html
2015-06-14 23:53:32 -08:00
rm -f $( DIST_RESULTS) /*.cover.out
clean :
rm -Rf $( DIST_ROOT)
2015-07-20 15:13:12 -04:00
@$( GO) clean $( GOFLAGS) -i ./...
2015-06-14 23:53:32 -08:00
@if [ $( shell docker ps -a | grep -ci mattermost-mysql) -eq 1 ] ; then \
echo stopping mattermost-mysql; \
docker stop mattermost-mysql > /dev/null; \
docker rm -v mattermost-mysql > /dev/null; \
fi
rm -rf web/react/node_modules
rm -f web/static/js/bundle*.js
2015-10-07 09:09:48 -04:00
rm -f web/static/js/libs*.js
2015-06-14 23:53:32 -08:00
rm -f web/static/css/styles.css
2015-07-20 08:06:55 -04:00
rm -rf data/*
rm -rf api/data/*
2015-06-14 23:53:32 -08:00
rm -rf logs/*
2015-09-14 15:30:51 +03:00
rm -rf Godeps/_workspace/pkg/
2015-06-14 23:53:32 -08:00
run : install
mkdir -p web/static/js
@echo starting react processor
@cd web/react && npm start &
@echo starting go web server
2015-07-20 15:13:12 -04:00
@$( GO) run $( GOFLAGS) mattermost.go -config= config.json &
2015-06-14 23:53:32 -08:00
@echo starting compass watch
@cd web/sass-files && compass watch &
stop :
@for PID in $$ ( ps -ef | grep [ c] ompass | awk '{ print $$2 }' ) ; do \
echo stopping css watch $$ PID; \
kill $$ PID; \
done
@for PID in $$ ( ps -ef | grep [ n] pm | awk '{ print $$2 }' ) ; do \
echo stopping watchify $$ PID; \
kill $$ PID; \
done
@for PID in $$ ( ps -ef | grep [ m] atterm | awk '{ print $$2 }' ) ; do \
echo stopping go web $$ PID; \
kill $$ PID; \
done
2015-07-27 09:48:35 -04:00
@if [ $( shell docker ps -a | grep -ci ${ DOCKER_CONTAINER_NAME } ) -eq 1 ] ; then \
echo removing dev docker container; \
docker stop ${ DOCKER_CONTAINER_NAME } > /dev/null; \
docker rm -v ${ DOCKER_CONTAINER_NAME } > /dev/null; \
fi
2015-06-14 23:53:32 -08:00
setup-mac :
echo $$ ( boot2docker ip 2> /dev/null) dockerhost | sudo tee -a /etc/hosts
cleandb :
@if [ $( shell docker ps -a | grep -ci mattermost-mysql) -eq 1 ] ; then \
docker stop mattermost-mysql > /dev/null; \
docker rm -v mattermost-mysql > /dev/null; \
fi
dist : install
2015-09-16 17:37:11 -07:00
@sed -i'.bak' 's|_BUILD_NUMBER_|$(BUILD_NUMBER)|g' ./model/version.go
@sed -i'.bak' 's|_BUILD_DATE_|$(BUILD_DATE)|g' ./model/version.go
2015-09-17 13:01:40 -07:00
@sed -i'.bak' 's|_BUILD_HASH_|$(BUILD_HASH)|g' ./model/version.go
2015-09-16 17:37:11 -07:00
2015-09-16 09:50:20 -07:00
@$( GO) build $( GOFLAGS) -i ./...
@$( GO) install $( GOFLAGS) ./...
2015-06-14 23:53:32 -08:00
mkdir -p $( DIST_PATH) /bin
cp $( GOPATH) /bin/platform $( DIST_PATH) /bin
cp -RL config $( DIST_PATH) /config
touch $( DIST_PATH) /config/build.txt
echo $( BUILD_NUMBER) | tee -a $( DIST_PATH) /config/build.txt
mkdir -p $( DIST_PATH) /logs
mkdir -p web/static/js
cd web/react && npm run build
2015-10-07 09:09:48 -04:00
cd web/sass-files && compass compile -e production --force
2015-06-14 23:53:32 -08:00
2015-10-08 16:46:45 -04:00
mkdir -p $( DIST_PATH) /web/static/js
cp -L web/static/js/*.min.js $( DIST_PATH) /web/static/js/
cp -RL web/static/config $( DIST_PATH) /web/static
cp -RL web/static/css $( DIST_PATH) /web/static
cp -RL web/static/fonts $( DIST_PATH) /web/static
cp -RL web/static/help $( DIST_PATH) /web/static
cp -RL web/static/images $( DIST_PATH) /web/static
cp -RL web/static/js/jquery-dragster $( DIST_PATH) /web/static/js/
2015-06-14 23:53:32 -08:00
cp -RL web/templates $( DIST_PATH) /web
mkdir -p $( DIST_PATH) /api
cp -RL api/templates $( DIST_PATH) /api
2015-09-30 14:16:03 -04:00
cp build/MIT-COMPILED-LICENSE.md $( DIST_PATH)
2015-08-03 08:16:10 -08:00
cp NOTICE.txt $( DIST_PATH)
cp README.md $( DIST_PATH)
2015-06-14 23:53:32 -08:00
mv $( DIST_PATH) /web/static/js/bundle.min.js $( DIST_PATH) /web/static/js/bundle-$( BUILD_NUMBER) .min.js
2015-10-07 09:09:48 -04:00
mv $( DIST_PATH) /web/static/js/libs.min.js $( DIST_PATH) /web/static/js/libs-$( BUILD_NUMBER) .min.js
2015-06-14 23:53:32 -08:00
2015-09-14 13:56:58 -04:00
@sed -i'.bak' 's|react-with-addons-0.13.3.js|react-with-addons-0.13.3.min.js|g' $( DIST_PATH) /web/templates/head.html
2015-07-06 10:13:38 -04:00
@sed -i'.bak' 's|jquery-1.11.1.js|jquery-1.11.1.min.js|g' $( DIST_PATH) /web/templates/head.html
2015-09-14 13:56:58 -04:00
@sed -i'.bak' 's|bootstrap-3.3.5.js|bootstrap-3.3.5.min.js|g' $( DIST_PATH) /web/templates/head.html
@sed -i'.bak' 's|react-bootstrap-0.25.1.js|react-bootstrap-0.25.1.min.js|g' $( DIST_PATH) /web/templates/head.html
2015-07-06 10:13:38 -04:00
@sed -i'.bak' 's|perfect-scrollbar.js|perfect-scrollbar.min.js|g' $( DIST_PATH) /web/templates/head.html
2015-06-14 23:53:32 -08:00
@sed -i'.bak' 's|bundle.js|bundle-$(BUILD_NUMBER).min.js|g' $( DIST_PATH) /web/templates/head.html
2015-10-07 09:09:48 -04:00
@sed -i'.bak' 's|libs.min.js|libs-$(BUILD_NUMBER).min.js|g' $( DIST_PATH) /web/templates/head.html
2015-06-14 23:53:32 -08:00
rm $( DIST_PATH) /web/templates/*.bak
2015-07-06 10:13:38 -04:00
tar -C dist -czf $( DIST_PATH) .tar.gz mattermost
2015-07-27 09:48:35 -04:00
2015-08-11 14:07:35 -04:00
docker-build : stop
docker build -t ${ DOCKERNAME } -f docker/local/Dockerfile .
2015-07-27 09:48:35 -04:00
docker-run : docker -build
docker run --name ${ DOCKER_CONTAINER_NAME } -d --publish 8065:80 ${ DOCKERNAME }