Skip to content

Commit 26054b4

Browse files
authored
Fix detection of which tests to run when "quick" tests are requested. (#539)
Also in this PR: change to print_matrix_configuration to allow us to treat certain files as being within a given subdirectory when looking through the file list in auto-diff mode. For example, cmake/external/firestore.cmake should be considered under the "firestore" directory.
1 parent 0010b72 commit 26054b4

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

.github/workflows/integration_tests.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,18 @@ jobs:
166166
run: |
167167
echo "Autodetecting which tests to run."
168168
if [[ -n "${{github.event.inputs.test_pull_request}}" ]]; then
169-
# If running this manually, diff against main.
170-
echo "AUTO_DIFF_PARAM=--auto_diff main" >> $GITHUB_ENV
169+
# If running this manually, diff against our common ancestor with main.
170+
MERGE_BASE=$(git merge-base HEAD origin/main)
171+
echo "::warning ::Auto-diff HEAD..${MERGE_BASE}"
172+
git diff --name-only HEAD..${MERGE_BASE}
173+
echo "AUTO_DIFF_PARAM=--auto_diff HEAD..${MERGE_BASE}" >> $GITHUB_ENV
171174
else
172175
# If running in a PR, diff against the PR's base.
173-
echo "AUTO_DIFF_PARAM=--auto_diff ${{github.event.pull_request.base.sha}}" >> $GITHUB_ENV
176+
# "git merge-base main branch_name" will give the common ancestor of both branches.
177+
MERGE_BASE=$(git merge-base origin/${{github.event.pull_request.head.ref}} origin/${{github.event.pull_request.base.ref}})
178+
echo "::warning ::Auto-diff origin/${{github.event.pull_request.head.ref}}..${MERGE_BASE}"
179+
git diff --name-only origin/${{github.event.pull_request.head.ref}}..${MERGE_BASE}
180+
echo "AUTO_DIFF_PARAM=--auto_diff origin/${{github.event.pull_request.head.ref}}..${MERGE_BASE}" >> $GITHUB_ENV
174181
fi
175182
- id: export-result
176183
# e.g. 'ubuntu-latest,macos-latest' -> '["ubuntu-latest","macos-latest"]'

scripts/gha/print_matrix_configuration.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,32 @@ def filter_values_on_diff(parm_key, value, auto_diff):
243243
# Any top-level directories set to None are completely ignored.
244244
"external": None,
245245
"release_build_files": None,
246+
# Uncomment the two below lines when debugging this script, or GitHub
247+
# actions related to auto-diff mode.
248+
# ".github": None,
249+
# "scripts": None,
246250
# Top-level directories listed below trigger additional APIs being tested.
247251
# For example, if auth is touched by a PR, we also need to test functions,
248252
# database, firestore, and storage.
249253
"auth": "auth,functions,database,firestore,storage",
250254
}
255+
file_redirects = {
256+
# Custom handling for specific files, to be treated as a different path or
257+
# ignored completely (set to None).
258+
"cmake/external/firestore.cmake": "firestore",
259+
"cmake/external/libuv.cmake": "database",
260+
"cmake/external/uWebSockets.cmake": "database",
261+
}
251262
requested_api_list = set(value.split(','))
252263
filtered_api_list = set()
253264

254265
for path in file_list:
255266
if len(path) == 0: continue
267+
if path in file_redirects:
268+
if file_redirects[path] is None:
269+
continue
270+
else:
271+
path = os.path.join(file_redirects[path], path)
256272
topdir = path.split(os.path.sep)[0]
257273
if topdir in custom_triggers:
258274
if not custom_triggers[topdir]: continue # Skip ones set to None.
@@ -263,7 +279,7 @@ def filter_values_on_diff(parm_key, value, auto_diff):
263279
else:
264280
# Something was modified that's not a known subdirectory.
265281
# Abort this whole process and just return the original api list.
266-
sys.stderr.write("Defaulting to all APIs: %s\n" % value)
282+
sys.stderr.write("Path '%s' is outside known directories, defaulting to all APIs: %s\n" % (path, value))
267283
return value
268284
sys.stderr.write("::warning::Autodetected APIs: %s\n" % ','.join(sorted(filtered_api_list)))
269285
return ','.join(sorted(filtered_api_list))

0 commit comments

Comments
 (0)