Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c7b3f4c

Browse files
author
Elad Aharon
committedJun 6, 2019
travis - check started time as well
1 parent 1d02756 commit c7b3f4c

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed
 

‎.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ if: commit_message =~ test_this_on_travis
22

33
env:
44
global:
5+
- BUILD_ID=$TRAVIS_BUILD_ID
56
- SHA=$TRAVIS_PULL_REQUEST_SHA
67
- PR_NUM=$TRAVIS_PULL_REQUEST
78
- IS_LAST=False

‎travis_files/google_drive_integration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def download_result(self, file_id, file_name):
5959
else:
6060
sys.exit('ERROR download file: %s with id: %s' % (file_id, file_name))
6161

62-
def find_file_id(self, sha):
62+
def find_file_id(self, sha, started_time):
6363
"""
6464
Looking for the commit id in google drive
6565
:param sha: the commit id to look for.
@@ -71,6 +71,6 @@ def find_file_id(self, sha):
7171
# looking for the file with that sha(file format: pr,sha,date,passed.html)
7272

7373
for file in files:
74-
if sha in file['name']:
74+
if sha in file['name'] and started_time in file['name']:
7575
return file
7676
return False

‎travis_files/wait_for_results.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
import os
22
import sys
33
import time
4+
import json
45

56
from google_drive_integration import GoogleDriveService
67

8+
slug = "cisco-system-traffic-generator/trex-core"
9+
10+
def get_started_time():
11+
build_id = os.environ['BUILD_ID']
12+
command = "curl https://api.travis-ci.org/repos/%s/builds/%s" % (slug, build_id)
13+
output = os.popen(command).read()
14+
build_json = json.loads(output)
15+
return build_json['started_at']
16+
17+
718
if __name__ == '__main__':
819

920
last_check = os.environ['IS_LAST'] == "True"
1021
pr_num, sha = int(os.environ['PR_NUM']), os.environ['SHA']
22+
started_time = get_started_time()
1123

1224
gd_service = GoogleDriveService()
1325
total_sleep, sleeping_between_download = 45, 1 # in min
@@ -16,7 +28,7 @@
1628
# check if there are new results in google drive
1729
print('-' * 42)
1830
print('looking for test results for pull request number %d, sha: %s' % (pr_num, sha))
19-
file_data = gd_service.find_file_id(sha)
31+
file_data = gd_service.find_file_id(sha, started_time)
2032

2133
if file_data:
2234
passed = file_data['name'].split(',')[3].strip('.html') == "True" # extract the boolean from file name

0 commit comments

Comments
 (0)
Please sign in to comment.