Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b86a0f

Browse files
authored
Use 'git merge-base --fork-point' to try to find common ancestor. (googleapis#5487)
* Use 'git merge-base --fork-point' to try to find common ancestor. * Revive whole-line search for target packages from googleapis#5482. * Add head ref hash, name to debugging output. * Add name of current branch to debugging output. * Try using 'baseline/master' as the comparison point.
1 parent 71a0c9c commit 2b86a0f

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

.circleci/config.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,151 +43,151 @@ jobs:
4343
- run:
4444
name: Run tests - google.api_core
4545
command: |
46-
if [[ -n $(grep api_core ~/target_packages) ]]; then
46+
if [[ -n $(grep -x api_core ~/target_packages) ]]; then
4747
nox -f api_core/nox.py
4848
fi
4949
- run:
5050
name: Run tests - google.cloud.core
5151
command: |
52-
if [[ -n $(grep core ~/target_packages) ]]; then
52+
if [[ -n $(grep -x core ~/target_packages) ]]; then
5353
nox -f core/nox.py
5454
fi
5555
- run:
5656
name: Run tests - google.cloud.bigquery
5757
command: |
58-
if [[ -n $(grep bigquery ~/target_packages) ]]; then
58+
if [[ -n $(grep -x bigquery ~/target_packages) ]]; then
5959
nox -f bigquery/nox.py
6060
fi
6161
- run:
6262
name: Run tests - google.cloud.bigquery_datatransfer
6363
command: |
64-
if [[ -n $(grep bigquery_datatransfer ~/target_packages) ]]; then
64+
if [[ -n $(grep -x bigquery_datatransfer ~/target_packages) ]]; then
6565
nox -f bigquery_datatransfer/nox.py
6666
fi
6767
- run:
6868
name: Run tests - google.cloud.bigtable
6969
command: |
70-
if [[ -n $(grep bigtable ~/target_packages) ]]; then
70+
if [[ -n $(grep -x bigtable ~/target_packages) ]]; then
7171
nox -f bigtable/nox.py
7272
fi
7373
- run:
7474
name: Run tests - google.cloud.container
7575
command: |
76-
if [[ -n $(grep container ~/target_packages) ]]; then
76+
if [[ -n $(grep -x container ~/target_packages) ]]; then
7777
nox -f container/nox.py
7878
fi
7979
- run:
8080
name: Run tests - google.cloud.datastore
8181
command: |
82-
if [[ -n $(grep datastore ~/target_packages) ]]; then
82+
if [[ -n $(grep -x datastore ~/target_packages) ]]; then
8383
nox -f datastore/nox.py
8484
fi
8585
- run:
8686
name: Run tests - google.cloud.dataproc
8787
command: |
88-
if [[ -n $(grep dataproc ~/target_packages) ]]; then
88+
if [[ -n $(grep -x dataproc ~/target_packages) ]]; then
8989
nox -f dataproc/nox.py
9090
fi
9191
- run:
9292
name: Run tests - google.cloud.dlp
9393
command: |
94-
if [[ -n $(grep dlp ~/target_packages) ]]; then
94+
if [[ -n $(grep -x dlp ~/target_packages) ]]; then
9595
nox -f dlp/nox.py
9696
fi
9797
- run:
9898
name: Run tests - google.cloud.dns
9999
command: |
100-
if [[ -n $(grep dns ~/target_packages) ]]; then
100+
if [[ -n $(grep -x dns ~/target_packages) ]]; then
101101
nox -f dns/nox.py
102102
fi
103103
- run:
104104
name: Run tests - google.cloud.error_reporting
105105
command: |
106-
if [[ -n $(grep error_reporting ~/target_packages) ]]; then
106+
if [[ -n $(grep -x error_reporting ~/target_packages) ]]; then
107107
nox -f error_reporting/nox.py
108108
fi
109109
- run:
110110
name: Run tests - google.cloud.firestore
111111
command: |
112-
if [[ -n $(grep firestore ~/target_packages) ]]; then
112+
if [[ -n $(grep -x firestore ~/target_packages) ]]; then
113113
nox -f firestore/nox.py
114114
fi
115115
- run:
116116
name: Run tests - google.cloud.language
117117
command: |
118-
if [[ -n $(grep language ~/target_packages) ]]; then
118+
if [[ -n $(grep -x language ~/target_packages) ]]; then
119119
nox -f language/nox.py
120120
fi
121121
- run:
122122
name: Run tests - google.cloud.logging
123123
command: |
124-
if [[ -n $(grep logging ~/target_packages) ]]; then
124+
if [[ -n $(grep -x logging ~/target_packages) ]]; then
125125
nox -f logging/nox.py
126126
fi
127127
- run:
128128
name: Run tests - google.cloud.monitoring
129129
command: |
130-
if [[ -n $(grep monitoring ~/target_packages) ]]; then
130+
if [[ -n $(grep -x monitoring ~/target_packages) ]]; then
131131
nox -f monitoring/nox.py
132132
fi
133133
- run:
134134
name: Run tests - google.cloud.pubsub
135135
command: |
136-
if [[ -n $(grep pubsub ~/target_packages) ]]; then
136+
if [[ -n $(grep -x pubsub ~/target_packages) ]]; then
137137
nox -f pubsub/nox.py
138138
fi
139139
- run:
140140
name: Run tests - google.cloud.resource_manager
141141
command: |
142-
if [[ -n $(grep resource_manager ~/target_packages) ]]; then
142+
if [[ -n $(grep -x resource_manager ~/target_packages) ]]; then
143143
nox -f resource_manager/nox.py
144144
fi
145145
- run:
146146
name: Run tests - google.cloud.runtimeconfig
147147
command: |
148-
if [[ -n $(grep runtimeconfig ~/target_packages) ]]; then
148+
if [[ -n $(grep -x runtimeconfig ~/target_packages) ]]; then
149149
nox -f runtimeconfig/nox.py
150150
fi
151151
- run:
152152
name: Run tests - google.cloud.spanner
153153
command: |
154-
if [[ -n $(grep spanner ~/target_packages) ]]; then
154+
if [[ -n $(grep -x spanner ~/target_packages) ]]; then
155155
nox -f spanner/nox.py
156156
fi
157157
- run:
158158
name: Run tests - google.cloud.speech
159159
command: |
160-
if [[ -n $(grep speech ~/target_packages) ]]; then
160+
if [[ -n $(grep -x speech ~/target_packages) ]]; then
161161
nox -f speech/nox.py
162162
fi
163163
- run:
164164
name: Run tests - google.cloud.storage
165165
command: |
166-
if [[ -n $(grep storage ~/target_packages) ]]; then
166+
if [[ -n $(grep -x storage ~/target_packages) ]]; then
167167
nox -f storage/nox.py
168168
fi
169169
- run:
170170
name: Run tests - google.cloud.trace
171171
command: |
172-
if [[ -n $(grep trace ~/target_packages) ]]; then
172+
if [[ -n $(grep -x trace ~/target_packages) ]]; then
173173
nox -f trace/nox.py
174174
fi
175175
- run:
176176
name: Run tests - google.cloud.translate
177177
command: |
178-
if [[ -n $(grep translate ~/target_packages) ]]; then
178+
if [[ -n $(grep -x translate ~/target_packages) ]]; then
179179
nox -f translate/nox.py
180180
fi
181181
- run:
182182
name: Run tests - google.cloud.vision
183183
command: |
184-
if [[ -n $(grep vision ~/target_packages) ]]; then
184+
if [[ -n $(grep -x vision ~/target_packages) ]]; then
185185
nox -f vision/nox.py
186186
fi
187187
- run:
188188
name: Run tests - google.cloud.videointelligence
189189
command: |
190-
if [[ -n $(grep videointelligence ~/target_packages) ]]; then
190+
if [[ -n $(grep -x videointelligence ~/target_packages) ]]; then
191191
nox -f videointelligence/nox.py
192192
fi
193193
- run:

test_utils/scripts/get_target_packages.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
CI_BRANCH = os.environ.get('CIRCLE_BRANCH')
2828
CI_PR = os.environ.get('CIRCLE_PR_NUMBER')
2929
CIRCLE_TAG = os.environ.get('CIRCLE_TAG')
30+
head_hash, head_name = subprocess.check_output(['git', 'show-ref', 'HEAD']
31+
).strip().decode('ascii').split()
32+
rev_parse = subprocess.check_output(
33+
['git', 'rev-parse', '--abbrev-ref', 'HEAD']
34+
).strip().decode('ascii')
3035
MAJOR_DIV = '#' * 78
3136
MINOR_DIV = '#' + '-' * 77
3237

@@ -66,16 +71,18 @@ def get_baseline():
6671
ci_non_master = (CI == 'true') and any([CI_BRANCH != 'master', CI_PR])
6772

6873
if ci_non_master:
69-
if CI_PR is None and CI_BRANCH is not None:
70-
output = subprocess.check_output(
71-
['git', 'merge-base', 'master', CI_BRANCH])
72-
return output.strip().decode('ascii')
7374

7475
repo_url = '[email protected]:GoogleCloudPlatform/{}'.format(GITHUB_REPO)
7576
subprocess.run(['git', 'remote', 'add', 'baseline', repo_url],
7677
stderr=subprocess.DEVNULL)
7778
subprocess.run(['git', 'pull', 'baseline'], stderr=subprocess.DEVNULL)
78-
# Can we have a PR but not a branch?
79+
80+
if CI_PR is None and CI_BRANCH is not None:
81+
output = subprocess.check_output([
82+
'git', 'merge-base', '--fork-point',
83+
'baseline/master', CI_BRANCH])
84+
return output.strip().decode('ascii')
85+
7986
return 'baseline/master'
8087

8188
# If environment variables are set identifying what the master tip is,
@@ -243,6 +250,9 @@ def main():
243250
print('# CircleCI branch: {}'.format(CI_BRANCH))
244251
print('# CircleCI pr: {}'.format(CI_PR))
245252
print('# CircleCI tag: {}'.format(CIRCLE_TAG))
253+
print('# HEAD ref: {}'.format(head_hash))
254+
print('# {}'.format(head_name))
255+
print('# Git branch: {}'.format(rev_parse))
246256
print(MAJOR_DIV)
247257

248258
packages = list(get_target_packages())

0 commit comments

Comments
 (0)