Skip to content

Commit 95f5dd5

Browse files
committed
[BLD] Add script that fails build if git tags do not exist
1 parent 61819ab commit 95f5dd5

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ before_install:
6363
- pwd
6464
- uname -a
6565
- git --version
66-
- git tag
66+
- ./ci/check_git_tags.sh
6767
# Because travis runs on Google Cloud and has a /etc/boto.cfg,
6868
# it breaks moto import, see:
6969
# https://github.com/spulec/moto/issues/1771

ci/check_git_tags.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
set -e
2+
3+
if [[ ! $(git tag) ]]; then
4+
echo "No git tags in clone, please sync your git tags with upstream using:"
5+
echo " git fetch --tags upstream"
6+
echo " git push --tags origin"
7+
echo ""
8+
echo "If the issue persists, the clone depth needs to be increased in .travis.yml"
9+
exit 1
10+
fi
11+
12+
# This will error if there are no tags and we omit --always
13+
DESCRIPTION=$(git describe --long --tags)
14+
echo "$DESCRIPTION"
15+
16+
if [[ "$DESCRIPTION" == *"untagged"* ]]; then
17+
echo "Unable to determine most recent tag, aborting build"
18+
exit 1
19+
else
20+
if [[ "$DESCRIPTION" != *"g"* ]]; then
21+
# A good description will have the hash prefixed by g, a bad one will be
22+
# just the hash
23+
echo "Unable to determine most recent tag, aborting build"
24+
exit 1
25+
else
26+
echo "$(git tag)"
27+
fi
28+
fi

pandas/tests/test_common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import collections
2+
from distutils.version import LooseVersion
23
from functools import partial
34
import string
5+
from subprocess import check_output
46

57
import numpy as np
68
import pytest
@@ -117,3 +119,13 @@ def test_git_version():
117119
git_version = pd.__git_version__
118120
assert len(git_version) == 40
119121
assert all(c in string.hexdigits for c in git_version)
122+
123+
124+
def test_version_tag():
125+
version = pd.__version__
126+
try:
127+
version > LooseVersion("0.0.1")
128+
except TypeError:
129+
raise ValueError(
130+
"No git tags exist, please sync tags between upstream and your repo"
131+
)

0 commit comments

Comments
 (0)