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-01-07 23:14:07 +04:00
PACKER ?= packer
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
2013-06-24 09:16:00 +04:00
VERSION = $( shell $( PYTHON) -c "from awx import __version__; print(__version__.split('-')[0])" )
2013-06-24 21:03:33 +04:00
RELEASE = $( shell $( PYTHON) -c "from awx import __version__; print(__version__.split('-')[1])" )
2014-01-28 18:58:44 +04:00
2014-02-03 22:22:58 +04:00
# Allow AMI license customization
2014-02-03 22:52:00 +04:00
LICENSE_TIER ?= 10.json
2014-01-28 18:58:44 +04:00
2013-06-24 21:03:33 +04:00
i f n e q ( $( OFFICIAL ) , y e s )
2013-06-26 15:33:09 +04:00
BUILD = dev$( DATE)
2014-01-29 21:30:12 +04:00
SDIST_TAR_FILE = ansible-tower-$( VERSION) -$( BUILD) .tar.gz
SETUP_TAR_NAME = ansible-tower-setup-$( VERSION) -$( BUILD)
2013-06-26 15:33:09 +04:00
RPM_PKG_RELEASE = $( BUILD)
2014-01-29 21:30:12 +04:00
DEB_BUILD_DIR = deb-build/ansible-tower-$( VERSION) -$( BUILD)
2013-06-26 15:33:09 +04:00
DEB_PKG_RELEASE = $( VERSION) -$( BUILD)
2014-01-29 21:30:12 +04:00
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
BUILD =
2014-01-29 21:30:12 +04:00
SDIST_TAR_FILE = ansible-tower-$( VERSION) .tar.gz
SETUP_TAR_NAME = ansible-tower-setup-$( VERSION)
2013-06-26 16:10:17 +04:00
RPM_PKG_RELEASE = $( RELEASE)
2014-01-29 21:30:12 +04:00
DEB_BUILD_DIR = deb-build/ansible-tower-$( VERSION)
2013-06-24 21:03:33 +04:00
DEB_PKG_RELEASE = $( VERSION) -$( RELEASE)
2014-01-29 21:30:12 +04:00
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
2013-05-26 19:01:00 +04:00
2013-09-25 05:40:53 +04:00
.PHONY : clean rebase push requirements requirements_pypi develop refresh \
2014-02-19 00:16:39 +04:00
adduser syncdb migrate dbchange dbshell runserver celeryd receiver test \
2013-09-25 05:40:53 +04:00
test_coverage coverage_html test_ui test_jenkins dev_build \
release_build release_clean sdist rpm
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/*
2013-06-15 12:10:11 +04:00
rm -rf build rpm-build *.egg-info
2013-06-23 23:40:07 +04:00
rm -rf debian deb-build
2014-02-17 19:18:33 +04:00
rm -f awx/ui/static/css/awx*.js awx/ui/static/css/awx*.css
rm -rf node_modules
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 \
( 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 \
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-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
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
2013-09-25 05:40:53 +04:00
# Run all API unit tests.
2013-03-01 04:52:14 +04:00
test :
2013-09-25 05:40:53 +04:00
$( PYTHON) manage.py test -v2 main
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 :
2013-09-25 05:40:53 +04:00
coverage run manage.py test -v2 main
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 :
$( PYTHON) manage.py test -v2 ui
# 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 :
$( PYTHON) manage.py jenkins -v2
2014-02-17 19:18:33 +04:00
# Update local npm install
node_modules :
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-02-13 02:19:30 +04:00
grunt
2014-02-17 19:18:33 +04:00
# Check .js files for errors and lint
lintjs : node_modules
2014-02-13 02:19:30 +04:00
grunt jshint
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.
setup_tarball :
@cp -a setup $( SETUP_TAR_NAME)
@tar czf $( SETUP_TAR_NAME) .tar.gz $( SETUP_TAR_NAME) /
@rm -rf $( SETUP_TAR_NAME)
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
2013-07-16 21:19:18 +04:00
sdist : clean minjs
2013-06-24 21:03:33 +04:00
if [ " $( OFFICIAL) " = "yes" ] ; then \
$( PYTHON) setup.py release_build; \
else \
2013-06-26 03:46:12 +04:00
BUILD = $( BUILD) $( PYTHON) setup.py sdist_awx; \
2013-06-24 21:03:33 +04:00
fi
2013-06-15 12:10:11 +04:00
2013-06-26 15:33:09 +04:00
rpmtar : sdist
2013-06-26 16:10:17 +04:00
if [ " $( OFFICIAL) " != "yes" ] ; then \
( cd dist/ && tar zxf $( SDIST_TAR_FILE) ) ; \
2014-01-29 21:30:12 +04:00
( cd dist/ && mv ansible-tower-$( VERSION) -$( BUILD) ansible-tower-$( VERSION) ) ; \
( cd dist/ && tar czf ansible-tower-$( VERSION) .tar.gz ansible-tower-$( VERSION) ) ; \
2013-06-26 16:10:17 +04:00
fi
2013-06-25 22:30:40 +04:00
2013-06-26 15:33:09 +04:00
rpm : rpmtar
2013-06-15 12:10:11 +04:00
@mkdir -p rpm-build
2014-01-29 21:30:12 +04:00
@cp dist/ansible-tower-$( VERSION) .tar.gz rpm-build/
2013-06-15 12:10:11 +04:00
@rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir %{_topdir}" \
--define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \
--define "_sourcedir %{_topdir}" \
2013-06-26 16:10:17 +04:00
--define " _pkgrelease $( RPM_PKG_RELEASE) " \
2014-01-29 21:30:12 +04:00
-ba packaging/rpm/ansible-tower.spec
2013-06-23 23:40:07 +04:00
2013-06-26 15:33:09 +04:00
deb : sdist
2013-06-24 09:16:00 +04:00
@mkdir -p deb-build
2013-06-24 21:03:33 +04:00
@cp dist/$( SDIST_TAR_FILE) deb-build/
( cd deb-build && tar zxf $( SDIST_TAR_FILE) )
2014-01-29 21:30:12 +04:00
( cd $( DEB_BUILD_DIR) && dh_make --indep --yes -f ../$( SDIST_TAR_FILE) -p ansible-tower-$( VERSION) )
2013-06-24 21:03:33 +04:00
@rm -rf $( DEB_BUILD_DIR) /debian
@cp -a packaging/debian $( DEB_BUILD_DIR) /
2014-01-29 22:10:21 +04:00
@echo " ansible-tower- $( DEB_PKG_RELEASE) .deb admin optional " > $( DEB_BUILD_DIR) /debian/realfiles
2013-06-24 21:03:33 +04:00
( cd $( DEB_BUILD_DIR) && PKG_RELEASE = $( DEB_PKG_RELEASE) dpkg-buildpackage -nc -us -uc -b --changes-option= "-fdebian/realfiles" )
2013-06-23 23:40:07 +04:00
2014-02-03 22:22:58 +04:00
ami :
2014-02-03 22:52:00 +04:00
( cd packaging/ami && $( PACKER) build $( PACKER_BUILD_OPTS) -var " aws_license= $( LICENSE_TIER) " ansible-tower.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 ""