Skip to content

[BLD] Add script that fails build if git tags do not exist #27770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:

git:
# for cloning
depth: 2000
depth: false

matrix:
fast_finish: true
Expand Down Expand Up @@ -63,7 +63,7 @@ before_install:
- pwd
- uname -a
- git --version
- git tag
- ./ci/check_git_tags.sh
# Because travis runs on Google Cloud and has a /etc/boto.cfg,
# it breaks moto import, see:
# https://github.com/spulec/moto/issues/1771
Expand Down
28 changes: 28 additions & 0 deletions ci/check_git_tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set -e

if [[ ! $(git tag) ]]; then
echo "No git tags in clone, please sync your git tags with upstream using:"
echo " git fetch --tags upstream"
echo " git push --tags origin"
echo ""
echo "If the issue persists, the clone depth needs to be increased in .travis.yml"
exit 1
fi

# This will error if there are no tags and we omit --always
DESCRIPTION=$(git describe --long --tags)
echo "$DESCRIPTION"

if [[ "$DESCRIPTION" == *"untagged"* ]]; then
echo "Unable to determine most recent tag, aborting build"
exit 1
else
if [[ "$DESCRIPTION" != *"g"* ]]; then
# A good description will have the hash prefixed by g, a bad one will be
# just the hash
echo "Unable to determine most recent tag, aborting build"
exit 1
else
echo "$(git tag)"
fi
fi
11 changes: 11 additions & 0 deletions pandas/tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections
from distutils.version import LooseVersion
from functools import partial
import string

Expand Down Expand Up @@ -117,3 +118,13 @@ def test_git_version():
git_version = pd.__git_version__
assert len(git_version) == 40
assert all(c in string.hexdigits for c in git_version)


def test_version_tag():
version = pd.__version__
try:
version > LooseVersion("0.0.1")
except TypeError:
raise ValueError(
"No git tags exist, please sync tags between upstream and your repo"
)