Skip to content
This repository was archived by the owner on Feb 16, 2020. It is now read-only.

Commit 94f2288

Browse files
committed
#5: Adds VERSION and BUILD instead of just VERSION made of both
1 parent bb7bd35 commit 94f2288

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env sh
22

3-
echo "Setting VERSION='${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}' in src/constants.py"
4-
echo "VERSION = '${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}'" >> src/constants.py
3+
echo "Setting VERSION"
4+
find . -name .git -type d -prune -o -type f -name constants.py -exec sed -i s/^VERSION.*/VERSION\ =\ \'${CI_COMMIT_REF_NAME}\'/g {} + -exec grep VERSION {} +
5+
echo "Setting BUILD"
6+
find . -name .git -type d -prune -o -type f -name constants.py -exec sed -i s/^BUILD.*/BUILD\ =\ \'${CI_COMMIT_SHORT_SHA}\'/g {} + -exec grep BUILD {} +

src/etherscan-exporter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pygelf
1111
from prometheus_client import start_http_server
1212
from prometheus_client.core import REGISTRY, GaugeMetricFamily
13-
import constants
13+
from .lib import constants
1414

1515
LOG = logging.getLogger(__name__)
1616
logging.basicConfig(
@@ -21,6 +21,7 @@
2121
)
2222

2323
FILENAME = os.path.splitext(sys.modules['__main__'].__file__)[0]
24+
version = f'{constants.VERSION}-{constants.BUILD}'
2425

2526

2627
def configure_logging():
@@ -166,8 +167,7 @@ def collect(self):
166167
if __name__ == '__main__':
167168
configure_logging()
168169
PORT = int(os.environ.get('PORT', 9308))
169-
# pylint: disable=no-member
170-
LOG.info("Starting {} {} on port {}".format(FILENAME, constants.VERSION, PORT))
170+
LOG.info("Starting {} {} on port {}".format(FILENAME, version, PORT))
171171
REGISTRY.register(EtherscanCollector())
172172
start_http_server(PORT)
173173
while True:

src/lib/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
# -*- coding: utf-8 -*-
33
""" Constants declarations """
44

5+
# These get set at build time
56
VERSION = None
7+
BUILD = None

0 commit comments

Comments
 (0)