Skip to content

Commit 7b63c4b

Browse files
committed
Only test changed Dockerfiles
1 parent df0b7fb commit 7b63c4b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

ci_test.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313

1414
from __future__ import absolute_import, print_function, unicode_literals
1515

16+
import urllib2
17+
import json
1618
import subprocess
1719
import sys
1820
import os
1921

22+
2023
def run_command(cmd, log_file=None):
2124
print("Running: {}".format(cmd))
2225
sys.stdout.flush()
@@ -32,12 +35,18 @@ def run_command(cmd, log_file=None):
3235

3336
def get_dockerfiles():
3437
dockerfiles = []
35-
docker_dir = os.path.dirname(os.path.realpath(__file__))
36-
for root, dirs, files in os.walk(docker_dir):
37-
for file in files:
38-
if file == "Dockerfile":
39-
dockerfiles.append(root)
40-
dockerfiles.sort(reverse=True)
38+
GITHUB_API_URL = "https://api.github.com"
39+
response = urllib2.urlopen("{}/repos/{}/pulls/{}/files".format(GITHUB_API_URL,
40+
os.environ['ghprbGhRepository'],
41+
os.environ['ghprbPullId']))
42+
data = json.load(response)
43+
44+
for file_info in data:
45+
filename = file_info['filename']
46+
print(filename)
47+
if "Dockerfile" in filename:
48+
file_dir = filename.replace("Dockerfile", "")
49+
dockerfiles.append(file_dir)
4150
return dockerfiles
4251

4352

0 commit comments

Comments
 (0)