2013-06-15 12:10:11 +04:00
PYTHON = python
SITELIB = $( shell $( PYTHON) -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" )
2014-04-29 19:19:14 +04:00
OFFICIAL ?= no
2014-01-07 23:14:07 +04:00
PACKER ?= packer
2014-03-19 19:29:02 +04:00
GRUNT ?= $( shell [ -t 0 ] && echo "grunt" || echo "grunt --no-color" )
2013-06-24 21:03:33 +04:00
# Get the branch information from git
GIT_DATE := $( shell git log -n 1 --format= "%ai" )
2013-06-26 03:46:12 +04:00
DATE := $( shell date -u +%Y%m%d%H%M)
2013-06-24 21:03:33 +04:00
2014-10-17 17:01:45 +04:00
NAME = ansible-tower
VERSION = $( shell $( PYTHON) -c "from awx import __version__; print(__version__.split('-')[0])" )
RELEASE ?= 1
GIT_REMOTE_URL = $( shell git config --get remote.origin.url)
BUILD ?= 0.git$( DATE)
2014-01-28 18:58:44 +04:00
2014-02-03 22:22:58 +04:00
# Allow AMI license customization
2014-10-17 17:01:45 +04:00
AWS_INSTANCE_COUNT ?= 100
2014-01-28 18:58:44 +04:00
2014-10-17 17:01:45 +04:00
# TAR build parameters
2013-06-24 21:03:33 +04:00
i f n e q ( $( OFFICIAL ) , y e s )
2014-10-17 17:01:45 +04:00
SETUP_TAR_NAME = $( NAME) -setup-$( VERSION) -$( BUILD)
SDIST_TAR_NAME = $( NAME) -$( VERSION) -$( BUILD)
PACKER_BUILD_OPTS = -var-file= vars-aws-keys.json -var-file= vars-nightly.json
2013-06-24 21:03:33 +04:00
e l s e
2014-10-17 17:01:45 +04:00
SETUP_TAR_NAME = $( NAME) -setup-$( VERSION)
SDIST_TAR_NAME = $( NAME) -$( VERSION)
PACKER_BUILD_OPTS = -var-file= vars-aws-keys.json -var-file= vars-release.json
2013-06-24 21:03:33 +04:00
e n d i f
2014-10-17 17:01:45 +04:00
SDIST_TAR_FILE = $( SDIST_TAR_NAME) .tar.gz
# DEB build parameters
DEBUILD_BIN ?= debuild
DEBUILD_OPTS = --source-option= "-I"
DPUT_BIN ?= dput
DPUT_OPTS ?=
i f e q ( $( OFFICIAL ) , y e s )
DEB_DIST ?= stable
DEB_RELEASE = $( RELEASE)
# Sign OFFICIAL builds using 'DEBSIGN_KEYID'
# DEBSIGN_KEYID is required when signing
ifneq ( $( DEBSIGN_KEYID) ,)
DEBUILD_OPTS += -k$( DEBSIGN_KEYID)
endif
e l s e
DEB_DIST ?= unstable
DEB_RELEASE = $( BUILD)
# Do not sign development builds
DEBUILD_OPTS += -uc -us
DPUT_OPTS += -u
e n d i f
DEBUILD = $( DEBUILD_BIN) $( DEBUILD_OPTS)
DEB_PPA ?= reprepro
# RPM build parameters
RPM_SPECDIR = packaging/rpm
RPM_SPEC = $( RPM_SPECDIR) /$( NAME) .spec
RPM_DIST = $( shell rpm --eval '%{?dist}' )
i f e q ( $( OFFICIAL ) , y e s )
RPM_RELEASE = $( RELEASE)
e l s e
RPM_RELEASE = $( BUILD)
e n d i f
RPM_NVR = $( NAME) -$( VERSION) -$( RPM_RELEASE) $( RPM_DIST)
2014-05-09 16:59:02 +04:00
MOCK_BIN ?= mock
MOCK_CFG ?=
2014-10-02 21:26:32 +04:00
.PHONY : clean rebase push requirements requirements_pypi requirements_jenkins \
develop refresh adduser syncdb migrate dbchange dbshell runserver celeryd \
receiver test test_coverage coverage_html test_ui test_jenkins dev_build \
2014-10-17 17:01:45 +04:00
release_build release_clean sdist rpmtar mock-rpm mock-srpm \
deb deb-src debian reprepro
2013-06-20 23:53:10 +04:00
# Remove temporary build files, compiled Python files.
2013-03-13 21:09:36 +04:00
clean :
2013-06-23 23:40:07 +04:00
rm -rf dist/*
2014-10-17 17:01:45 +04:00
rm -rf build rpm-build $( NAME) -$( VERSION) *.egg-info
rm -rf debian deb-build reprepro
2014-05-12 22:21:51 +04:00
rm -f awx/ui/static/{ js,css} /awx*.{ js,css}
2014-08-28 20:12:04 +04:00
rm -rf awx/ui/static/docs
2014-07-08 23:59:42 +04:00
rm -rf node_modules package.json Gruntfile.js bower.json
2013-03-13 21:09:36 +04:00
find . -type f -regex " .*\.py[co] $$ " -delete
2013-06-20 23:53:10 +04:00
# Fetch from origin, rebase local commits on top of origin commits.
2013-03-13 23:28:30 +04:00
rebase :
git pull --rebase origin master
2013-06-20 23:53:10 +04:00
# Push changes to origin.
2013-03-14 00:06:19 +04:00
push :
2013-06-20 23:53:10 +04:00
git push origin master
2013-03-13 23:15:35 +04:00
2013-06-20 23:53:10 +04:00
# Install third-party requirements needed for development environment (using
# locally downloaded packages).
requirements :
2013-09-25 05:40:53 +04:00
@if [ " $( VIRTUAL_ENV) " ] ; then \
2014-03-31 22:08:03 +04:00
( cd requirements && pip install --no-index setuptools-2.2.tar.gz) ; \
2014-09-10 22:35:53 +04:00
( cd requirements && pip install --no-index Django-1.6.7.tar.gz) ; \
2013-09-25 05:40:53 +04:00
( cd requirements && pip install --no-index -r dev_local.txt) ; \
2013-09-30 04:36:46 +04:00
$( PYTHON) fix_virtualenv_setuptools.py; \
2013-09-25 05:40:53 +04:00
else \
( cd requirements && sudo pip install --no-index -r dev_local.txt) ; \
fi
2013-06-20 23:53:10 +04:00
# Install third-party requirements needed for development environment
# (downloading from PyPI if necessary).
requirements_pypi :
2013-09-25 05:40:53 +04:00
@if [ " $( VIRTUAL_ENV) " ] ; then \
2014-03-31 22:08:03 +04:00
pip install setuptools = = 2.2; \
2014-09-10 22:35:53 +04:00
pip install Django\> = 1.6.7,\< 1.7; \
2013-09-25 05:40:53 +04:00
pip install -r requirements/dev.txt; \
2013-09-30 04:36:46 +04:00
$( PYTHON) fix_virtualenv_setuptools.py; \
2013-09-25 05:40:53 +04:00
else \
sudo pip install -r requirements/dev.txt; \
fi
2013-06-20 23:53:10 +04:00
2014-09-10 23:25:29 +04:00
# Install third-party requirements needed for running unittests in jenkins
# (using locally downloaded packages).
2014-10-02 23:19:33 +04:00
requirements_jenkins :
2014-09-10 23:25:29 +04:00
@if [ " $( VIRTUAL_ENV) " ] ; then \
2014-10-02 23:19:33 +04:00
( cd requirements && pip install --no-index distribute-0.7.3.zip || true ) ; \
( cd requirements && pip install --no-index pip-1.5.4.tar.gz || true ) ; \
else \
( cd requirements && sudo pip install --no-index distribute-0.7.3.zip || true ) ; \
( cd requirements && sudo pip install --no-index pip-1.5.4.tar.gz || true ) ; \
fi
$( MAKE) requirements
@if [ " $( VIRTUAL_ENV) " ] ; then \
2014-10-03 00:16:27 +04:00
( cd requirements && pip install -U -r jenkins.txt) ; \
2014-09-10 23:25:29 +04:00
$( PYTHON) fix_virtualenv_setuptools.py; \
else \
2014-10-03 00:16:27 +04:00
( cd requirements && sudo pip install -U -r jenkins.txt) ; \
2014-09-10 23:25:29 +04:00
fi
npm install -g csslint jshint
2014-01-29 22:49:29 +04:00
# "Install" ansible-tower package in development mode. Creates link to working
2013-06-23 21:21:02 +04:00
# copy in site-packages and installs awx-manage command.
2013-05-25 01:55:03 +04:00
develop :
2013-09-25 05:40:53 +04:00
@if [ " $( VIRTUAL_ENV) " ] ; then \
2014-01-29 22:49:29 +04:00
pip uninstall -y awx; \
2013-09-25 05:40:53 +04:00
$( PYTHON) setup.py develop; \
else \
2014-01-29 22:49:29 +04:00
sudo pip uninstall -y awx; \
2013-09-25 05:40:53 +04:00
sudo $( PYTHON) setup.py develop; \
fi
2013-05-25 01:55:03 +04:00
2013-06-20 23:53:10 +04:00
# Refresh development environment after pulling new code.
refresh : clean requirements develop migrate
2013-05-22 01:39:34 +04:00
2013-06-20 23:53:10 +04:00
# Create Django superuser.
2013-03-14 01:20:50 +04:00
adduser :
2013-09-25 05:40:53 +04:00
$( PYTHON) manage.py createsuperuser
2013-03-14 01:20:50 +04:00
2013-06-20 23:53:10 +04:00
# Create initial database tables (excluding migrations).
2013-03-01 04:52:14 +04:00
syncdb :
2013-09-25 05:40:53 +04:00
$( PYTHON) manage.py syncdb --noinput
2013-03-01 04:52:14 +04:00
2013-06-20 23:53:10 +04:00
# Create database tables and apply any new migrations.
2013-05-22 01:39:34 +04:00
migrate : syncdb
2013-09-25 05:40:53 +04:00
$( PYTHON) manage.py migrate --noinput
2013-03-13 23:15:35 +04:00
2013-06-20 23:53:10 +04:00
# Run after making changes to the models to create a new migration.
dbchange :
2013-09-25 05:40:53 +04:00
$( PYTHON) manage.py schemamigration main v14_changes --auto
2013-06-20 23:53:10 +04:00
2013-06-23 21:21:02 +04:00
# access database shell, asks for password
2013-03-13 23:15:35 +04:00
dbshell :
2013-12-21 03:16:52 +04:00
sudo -u postgres psql -d awx-dev
2013-03-01 04:52:14 +04:00
2014-05-02 23:26:05 +04:00
server_noattach :
2014-03-19 21:51:48 +04:00
tmux new-session -d -s tower 'exec make runserver'
tmux rename-window 'Tower'
tmux select -window -t tower:0
tmux split-window -v 'exec make celeryd'
2014-04-16 23:26:52 +04:00
tmux split-window -h 'exec make socketservice'
2014-04-16 23:30:49 +04:00
tmux select -pane -U
2014-03-19 21:51:48 +04:00
tmux split-window -v 'exec make receiver'
tmux split-window -h 'exec make taskmanager'
2014-05-02 23:26:05 +04:00
server : server_noattach
2014-03-19 21:51:48 +04:00
tmux -2 attach-session -t tower
2013-06-20 23:53:10 +04:00
# Run the built-in development webserver (by default on http://localhost:8013).
runserver :
2013-09-25 05:40:53 +04:00
$( PYTHON) manage.py runserver
2013-06-20 23:53:10 +04:00
# Run to start the background celery worker for development.
celeryd :
2014-02-04 02:04:56 +04:00
$( PYTHON) manage.py celeryd -l DEBUG -B --autoscale= 20,2 -Ofair
2013-06-20 23:53:10 +04:00
2014-02-19 00:16:39 +04:00
# Run to start the zeromq callback receiver
receiver :
$( PYTHON) manage.py run_callback_receiver
2014-03-12 22:09:00 +04:00
taskmanager :
$( PYTHON) manage.py run_task_system
2014-04-16 23:26:52 +04:00
socketservice :
$( PYTHON) manage.py run_socketio_service
2014-04-23 21:55:09 +04:00
pep8 :
2014-06-05 19:17:16 +04:00
pep8 -r awx/
2014-04-23 21:55:09 +04:00
pyflakes :
pyflakes awx/
2013-09-25 05:40:53 +04:00
# Run all API unit tests.
2013-03-01 04:52:14 +04:00
test :
2014-09-10 21:17:35 +04:00
$( PYTHON) manage.py test -v2 awx.main.tests
2013-05-22 01:39:34 +04:00
2013-09-25 05:40:53 +04:00
# Run all API unit tests with coverage enabled.
2013-05-22 03:08:46 +04:00
test_coverage :
2014-09-10 21:17:35 +04:00
coverage run manage.py test -v2 awx.main.tests
2013-05-22 03:08:46 +04:00
2013-06-20 23:53:10 +04:00
# Output test coverage as HTML (into htmlcov directory).
2013-05-22 03:08:46 +04:00
coverage_html :
coverage html
2013-09-25 05:40:53 +04:00
# Run UI unit tests using Selenium.
test_ui :
2014-09-10 21:17:35 +04:00
$( PYTHON) manage.py test -v2 awx.ui.tests
2013-09-25 05:40:53 +04:00
# Run API unit tests across multiple Python/Django versions with Tox.
test_tox :
tox -v
# Run unit tests to produce output for Jenkins.
test_jenkins :
2014-10-02 21:26:32 +04:00
$( PYTHON) manage.py jenkins -v2 --enable-coverage --project-apps-tests
2013-09-25 05:40:53 +04:00
2014-07-08 23:59:42 +04:00
Gruntfile.js :
2014-07-07 17:41:44 +04:00
cp packaging/grunt/$@ $@
bower.json :
cp packaging/grunt/$@ $@
2014-02-26 17:36:32 +04:00
package.json :
2014-07-07 17:30:27 +04:00
sed -e 's#%NAME%#$(NAME)#;s#%VERSION%#$(VERSION)#;s#%GIT_REMOTE_URL%#$(GIT_REMOTE_URL)#;' packaging/grunt/package.template > $@
2014-02-26 17:36:32 +04:00
2014-02-17 19:18:33 +04:00
# Update local npm install
2014-07-08 23:59:42 +04:00
node_modules : Gruntfile .js bower .json package .json
2014-02-17 19:18:33 +04:00
npm install
2013-09-25 05:40:53 +04:00
# Build minified JS/CSS.
2014-02-17 19:18:33 +04:00
minjs : node_modules
2014-03-06 17:56:02 +04:00
$( GRUNT)
2014-02-13 02:19:30 +04:00
2014-02-17 19:18:33 +04:00
# Check .js files for errors and lint
2014-08-28 20:01:35 +04:00
jshint : node_modules
$( GRUNT) $@
ngdocs : node_modules
$( GRUNT) $@
2013-09-25 05:40:53 +04:00
2013-06-20 23:53:10 +04:00
# Build a pip-installable package into dist/ with a timestamped version number.
2014-02-17 19:18:33 +04:00
dev_build :
2013-09-25 05:40:53 +04:00
$( PYTHON) setup.py dev_build
2013-05-22 01:39:34 +04:00
2013-06-20 23:53:10 +04:00
# Build a pip-installable package into dist/ with the release version number.
2013-05-22 01:39:34 +04:00
release_build :
2013-09-25 05:40:53 +04:00
$( PYTHON) setup.py release_build
# Build AWX setup tarball.
2014-10-17 17:01:45 +04:00
$(SETUP_TAR_NAME).tar.gz :
2013-09-25 05:40:53 +04:00
@cp -a setup $( SETUP_TAR_NAME)
@tar czf $( SETUP_TAR_NAME) .tar.gz $( SETUP_TAR_NAME) /
@rm -rf $( SETUP_TAR_NAME)
2014-10-17 17:01:45 +04:00
@echo "#############################################"
@echo "Setup artifacts:"
@echo $( SETUP_TAR_NAME) .tar.gz
@echo "#############################################"
setup_tarball : $( SETUP_TAR_NAME ) .tar .gz
2013-05-26 19:01:00 +04:00
2013-06-11 01:21:04 +04:00
release_clean :
2013-05-26 19:01:00 +04:00
-( rm *.tar)
2013-06-11 01:21:04 +04:00
-( rm -rf ( $RELEASE ) )
2013-06-15 12:10:11 +04:00
2014-10-17 17:01:45 +04:00
dist/$(SDIST_TAR_FILE) :
BYTE_COMPLE = $( BYTE_COMPILE) BUILD = " $( BUILD) " $( PYTHON) setup.py sdist
2014-05-22 19:25:50 +04:00
2014-10-17 17:01:45 +04:00
sdist : minjs dist /$( SDIST_TAR_FILE )
2013-06-15 12:10:11 +04:00
2014-10-17 17:01:45 +04:00
rpm-build/$(SDIST_TAR_FILE) : dist /$( SDIST_TAR_FILE )
2014-04-23 21:52:08 +04:00
mkdir -p rpm-build
2014-10-17 17:01:45 +04:00
cp packaging/rpm/$( NAME) .spec rpm-build/
2014-04-23 21:52:08 +04:00
cp packaging/rpm/$( NAME) .te rpm-build/
2013-06-26 16:10:17 +04:00
if [ " $( OFFICIAL) " != "yes" ] ; then \
2014-10-17 17:01:45 +04:00
( cd dist/ && tar zxf $( SDIST_TAR_FILE) ) ; \
( cd dist/ && mv $( NAME) -$( VERSION) -$( BUILD) $( NAME) -$( VERSION) ) ; \
( cd dist/ && tar czf ../rpm-build/$( SDIST_TAR_FILE) $( NAME) -$( VERSION) ) ; \
ln -sf $( SDIST_TAR_FILE) rpm-build/$( NAME) -$( VERSION) .tar.gz ; \
else \
ln -sf ../dist/$( SDIST_TAR_FILE) rpm-build/ ; \
2013-06-26 16:10:17 +04:00
fi
2014-10-17 17:01:45 +04:00
rpmtar : rpm -build /$( SDIST_TAR_FILE )
rpm-build/$(RPM_NVR).src.rpm : /etc /mock /$( MOCK_CFG ) .cfg
$( MOCK_BIN) -r $( MOCK_CFG) --resultdir rpm-build --buildsrpm --spec rpm-build/$( NAME) .spec --sources rpm-build \
--define " tower_version $( VERSION) " --define " tower_release $( RPM_RELEASE) "
@echo "#############################################"
@echo "SRPM artifacts:"
@echo rpm-build/$( RPM_NVR) .src.rpm
@echo "#############################################"
mock-srpm : rpmtar rpm -build /$( RPM_NVR ) .src .rpm
rpm-build/$(RPM_NVR).noarch.rpm : rpm -build /$( RPM_NVR ) .src .rpm
$( MOCK_BIN) -r $( MOCK_CFG) --resultdir rpm-build --rebuild rpm-build/$( RPM_NVR) .src.rpm \
--define " tower_version $( VERSION) " --define " tower_release $( RPM_RELEASE) "
@echo "#############################################"
@echo "RPM artifacts:"
@echo rpm-build/$( RPM_NVR) .noarch.rpm
@echo "#############################################"
2014-10-17 23:46:25 +04:00
mock-rpm : rpmtar rpm -build /$( RPM_NVR ) .noarch .rpm
2014-10-17 17:01:45 +04:00
deb-build/$(SDIST_TAR_NAME) : BYTE_COMPILE = 1
deb-build/$(SDIST_TAR_NAME) :
mkdir -p deb-build
tar -C deb-build/ -xvf dist/$( SDIST_TAR_FILE)
cp -a packaging/debian deb-build/$( SDIST_TAR_NAME) /
sed -ie " s#^ $( NAME) (\([^)]*\)) \([^;]*\);# $( NAME) ( $( VERSION) - $( DEB_RELEASE) ) $( DEB_DIST) ;# " deb-build/$( SDIST_TAR_NAME) /debian/changelog
debian : sdist deb -build /$( SDIST_TAR_NAME )
deb-build/$(NAME)_$(VERSION)-$(DEB_RELEASE)_all.deb :
cd deb-build/$( SDIST_TAR_NAME) && $( DEBUILD) -b
@echo "#############################################"
@echo "DEB artifacts:"
@echo deb-build/$( NAME) _$( VERSION) -$( DEB_RELEASE) _all.deb
@echo "#############################################"
deb : debian deb -build /$( NAME ) _ $( VERSION ) -$( DEB_RELEASE ) _all .deb
deb-build/$(NAME)_$(VERSION)-$(DEB_RELEASE)_source.changes :
cd deb-build/$( SDIST_TAR_NAME) && $( DEBUILD) -S
@echo "#############################################"
@echo "DEB artifacts:"
@echo deb-build/$( NAME) _$( VERSION) -$( DEB_RELEASE) _source.changes
@echo "#############################################"
deb-src : debian deb -build /$( NAME ) _ $( VERSION ) -$( DEB_RELEASE ) _source .changes
deb-upload : deb
$( DPUT_BIN) $( DPUT_OPTS) $( DEB_PPA) deb-build/$( NAME) _$( VERSION) -$( DEB_RELEASE) _amd64.changes ; \
deb-src-upload : deb -src
$( DPUT_BIN) $( DPUT_OPTS) $( DEB_PPA) deb-build/$( NAME) _$( VERSION) -$( DEB_RELEASE) _source.changes ; \
reprepro : deb
mkdir -p reprepro/conf
cp -a packaging/reprepro/* reprepro/conf/
@DEB= deb-build/$( NAME) _$( VERSION) -$( DEB_RELEASE) _all.deb ; \
for DIST in trusty precise ; do \
echo " Removing ' $( NAME) ' from the $$ {DIST} apt repo " ; \
echo reprepro --export= force -b reprepro remove $$ { DIST} $( NAME) ; \
done ; \
reprepro --export= force -b reprepro clearvanished; \
for DIST in trusty precise ; do \
echo " Adding $$ {DEB} to the $$ {DIST} apt repo " ; \
reprepro --keepunreferencedfiles --export= force -b reprepro --ignore= brokenold includedeb $$ { DIST} $$ { DEB} ; \
done ; \
2013-06-23 23:40:07 +04:00
2014-02-03 22:22:58 +04:00
ami :
2014-04-29 19:19:14 +04:00
( cd packaging/ami && $( PACKER) build $( PACKER_BUILD_OPTS) -var " aws_instance_count= $( AWS_INSTANCE_COUNT) " -var " product_version= $( VERSION) " -var " official= $( OFFICIAL) " $( NAME) .json)
2014-01-07 21:04:25 +04:00
2013-06-23 23:40:07 +04:00
install :
$( PYTHON) setup.py install egg_info -b ""