Skip to content

Commit

Permalink
Improve release.sh script and prerequisites (#606)
Browse files Browse the repository at this point in the history
Added a check for CHANGELOG.md generation and a Mac OS specific check
for GPG setting to enable git to sign commits. Modified how changelog.py
is called so that
release.sh blocks if there are any errors. Updated Makefile to create
venv and activate venv with install and other targets depending on it.
Added a new prereq target to install required python versions.
  • Loading branch information
ebadyano authored Dec 20, 2018
1 parent be6336c commit 7175a27
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 27 deletions.
95 changes: 69 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
SHELL = /bin/bash
# We assume an active virtualenv for development
install:
-@python3 setup.py -q develop --upgrade
include requirements.txt
PYENV_REGEX = .pyenv/shims
VENV_NAME ?= .venv
VENV_ACTIVATE_FILE = $(VENV_NAME)/bin/activate
VENV_ACTIVATE = . $(VENV_ACTIVATE_FILE)
VEPYTHON = $(VENV_NAME)/bin/python3
PYENV_ERROR = "\033[0;31mIMPORTANT\033[0m: Please install pyenv.\n"
PYENV_PATH_ERROR = "\033[0;31mIMPORTANT\033[0m: Please add $(HOME)/$(PYENV_REGEX) to your PATH env.\n"
PYENV_PREREQ_HELP = "\033[0;31mIMPORTANT\033[0m: please add \033[0;31meval \"\$$(pyenv init -)\"\033[0m to your bash profile and restart your terminal before proceeding any further.\n"
VE_MISSING_HELP = "\033[0;31mIMPORTANT\033[0m: Couldn't find $(PWD)/$(VENV_NAME); have you executed make venv-create?\033[0m\n"

prereq: requirements.txt
pyenv install $(PY34)
pyenv install $(PY35)
pyenv install $(PY36)
pyenv install $(PY37)
pyenv global system $(PY34) $(PY35) $(PY36) $(PY37)
-@ printf $(PYENV_PREREQ_HELP)

venv-create:
@if [[ ! -x $$(command -v pyenv) ]]; then \
printf $(PYENV_ERROR); \
exit 1; \
fi;
@if [[ ! $(PATH) =~ $(PYENV_REGEX) ]]; then \
printf $(PYENV_PATH_ERROR); \
exit 1; \
fi;
@if [[ ! -f $(VENV_ACTIVATE_FILE) ]]; then \
eval "$$(pyenv init -)" && python3 -mvenv $(VENV_NAME); \
printf "Created python3 venv under $(PWD)/$(VENV_NAME).\n"; \
fi;

check-venv:
@if [[ ! -f $(VENV_ACTIVATE_FILE) ]]; then \
printf $(VE_MISSING_HELP); \
fi

install: venv-create
. $(VENV_ACTIVATE_FILE); pip3 install -e .
# install tox for it tests
. $(VENV_ACTIVATE_FILE); pip3 install tox
# install coverage
. $(VENV_ACTIVATE_FILE); pip3 install coverage
# also install development dependencies
# workaround for https://github.com/elastic/rally/issues/439
-@pip3 install -q sphinx sphinx_rtd_theme
. $(VENV_ACTIVATE_FILE); pip3 install -q sphinx sphinx_rtd_theme

clean: nondocs-clean docs-clean

Expand All @@ -18,40 +61,40 @@ python-caches-clean:
-@find . -name "__pycache__" -exec rm -rf -- \{\} \;
-@find . -name ".pyc" -exec rm -rf -- \{\} \;

docs:
docs: check-venv
cd docs && $(MAKE) html

test:
python3 setup.py test
test: check-venv
$(VEPYTHON) setup.py test

it: python-caches-clean
tox
it: check-venv python-caches-clean
. $(VENV_ACTIVATE_FILE); tox

it34: python-caches-clean
tox -e py34
it34: check-venv python-caches-clean
. $(VENV_ACTIVATE_FILE); tox -e py34

it35: python-caches-clean
tox -e py35
it35: check-venv python-caches-clean
. $(VENV_ACTIVATE_FILE); tox -e py35

it36: python-caches-clean
tox -e py36
it36: check-venv python-caches-clean
. $(VENV_ACTIVATE_FILE); tox -e py36

it37: python-caches-clean
tox -e py37
it37: check-venv python-caches-clean
. $(VENV_ACTIVATE_FILE); tox -e py37

benchmark:
python3 setup.py pytest --addopts="-s benchmarks"
benchmark: check-venv
$(VEPYTHON) setup.py pytest --addopts="-s benchmarks"

coverage:
coverage run setup.py test
coverage html
coverage: check-venv
. $(VENV_ACTIVATE_FILE); coverage run setup.py test
. $(VENV_ACTIVATE_FILE); coverage html

release-checks:
./release-checks.sh $(release_version) $(next_version)
release-checks: check-venv
. $(VENV_ACTIVATE_FILE); ./release-checks.sh $(release_version) $(next_version)

# usage: e.g. make release release_version=0.9.2 next_version=0.9.3
release: release-checks clean docs it
./release.sh $(release_version) $(next_version)
release: check-venv release-checks clean docs it
. $(VENV_ACTIVATE_FILE); ./release.sh $(release_version) $(next_version)

docker-it: nondocs-clean python-caches-clean
@if ! export | grep UID; then export UID=$(shell id -u) >/dev/null 2>&1 || export UID; fi ; \
Expand All @@ -60,4 +103,4 @@ docker-it: nondocs-clean python-caches-clean
docker-compose build --pull; `# add --pull here to rebuild a fresh image` \
docker-compose run --rm rally-tests /bin/bash -c "make docs-clean && make it"

.PHONY: install clean nondocs-clean docs-clean python-caches-clean docs test docker-it it it34 it35 it36 benchmark coverage release release-checks
.PHONY: install clean nondocs-clean docs-clean python-caches-clean docs test docker-it it it34 it35 it36 benchmark coverage release release-checks prereq venv-create check-env
11 changes: 11 additions & 0 deletions release-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# fail this script immediately if any command fails with a non-zero exit code
set -eu
RELEASE_VERSION=$1

# test number of parameters
if [[ $# != 2 ]]
Expand All @@ -25,3 +26,13 @@ then
echo "The release process requires a valid GitHub token. See RELEASE.md for details."
exit 1
fi

if [[ $(uname) == "Darwin" && -z "${GPG_TTY+set}" ]]
then
echo "Error: to allow git to create signed commits on Mac OS you need to set \"export GPG_TTY=\$(tty)\"."
exit 1
fi

# Check if there will be any errors during CHANGELOG.md generation
CHANGELOG="$(python3 changelog.py ${RELEASE_VERSION})"

6 changes: 5 additions & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ then
fi

echo "Updating changelog"
echo -e "$(python3 changelog.py ${RELEASE_VERSION})\n\n$(cat CHANGELOG.md)" > CHANGELOG.md
# For exit on error to work we have to separate
# CHANGELOG.md generation into two steps.
CHANGELOG="$(python3 changelog.py ${RELEASE_VERSION})"
printf "$CHANGELOG\n\n$(cat CHANGELOG.md)" > CHANGELOG.md
git commit -a -m "Update changelog for Rally release $RELEASE_VERSION"

# * Update version in `setup.py` and `docs/conf.py`
Expand All @@ -50,6 +53,7 @@ fi
# Build new version
python3 setup.py bdist_wheel
# Upload to PyPI
printf "\033[0;31mUploading to PyPI. Please enter your credentials ...\033[0m\n"
twine upload dist/esrally-${RELEASE_VERSION}-*.whl

# Create (signed) release tag
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PY34=3.4.9
PY35=3.5.6
PY36=3.6.7
PY37=3.7.1

0 comments on commit 7175a27

Please sign in to comment.