File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,3 +24,10 @@ env_vars: {
2424 key: " REPORT_TO_BUILD_COP_BOT"
2525 value: " true"
2626}
27+
28+ # Run DRIFT test result injection
29+ # (only for Python 3.7 builds)
30+ env_vars: {
31+ key: " INJECT_REGION_TAGS"
32+ value: " true"
33+ }
Original file line number Diff line number Diff line change 4141nox -s " $RUN_TESTS_SESSION "
4242EXIT=$?
4343
44+ echo " PWD: ${PWD} "
45+
46+ # Inject region tag data into the test log
47+ set +e # Don't fail the entire test if this step fails
48+ if [[ " ${INJECT_REGION_TAGS:- } " == " true" ]]; then
49+
50+ export XUNIT_PATH=" $PWD /sponge_log.xml"
51+ export XUNIT_TMP_PATH=" $( mktemp) "
52+
53+ if [[ -f " $XUNIT_PATH " ]]; then
54+ echo " === Injecting region tags into XUnit output ==="
55+ echo " Processing XUnit output file: $XUNIT_PATH (saving output to $XUNIT_TMP_PATH )"
56+
57+ # We use `python3` because it will work even if we remove old
58+ # python versions from the docker image.
59+ echo " Calling python3 ${PARSER_PATH} inject-snippet-mapping --output_file ${XUNIT_TMP_PATH} ${PWD} "
60+ cat " $XUNIT_PATH " | \
61+ python3 " $PARSER_PATH " inject-snippet-mapping --output_file " $XUNIT_TMP_PATH " " $PWD "
62+ if [[ $? -eq 0 ]] && [[ -s " $XUNIT_PATH " ]]; then
63+ mv $XUNIT_TMP_PATH $XUNIT_PATH
64+ else
65+ echo " Region tag injection FAILED; XUnit file not modified."
66+ fi
67+ else
68+ echo " No XUnit output file found!"
69+ fi
70+ echo " === Region tag injection complete! ==="
71+ fi
72+ set -e
73+
4474# If REPORT_TO_BUILD_COP_BOT is set to "true", send the test log
4575# to the Build Cop Bot.
4676# See:
Original file line number Diff line number Diff line change @@ -121,6 +121,27 @@ set +e
121121RTN=0
122122ROOT=$( pwd)
123123
124+ # Setup DRIFT region tag injector
125+ # (only run on *some* builds)
126+ if [[ " ${INJECT_REGION_TAGS:- } " == " true" ]]; then
127+ echo " === Setting up DRIFT region tag injector ==="
128+ # install PyYaml (used by the DRIFT region tag parsing system)
129+ echo " --- Installing PyYaml ---"
130+ python3 -m pip install --user pyyaml
131+
132+ # Use ${HOME} because trampoline will automatically clean up this
133+ # directory.
134+ export REGION_TAG_PARSER_DIR=" ${HOME} /region-tag-parser"
135+ export PARSER_PATH=" ${REGION_TAG_PARSER_DIR} /wizard-py/cli.py"
136+
137+ if [[ ! -f $PARSER_PATH ]]; then
138+ echo " --- Fetching injection script from HEAD (via GitHub) ---"
139+ git clone https://github.com/GoogleCloudPlatform/repo-automation-playground " $REGION_TAG_PARSER_DIR " --single-branch
140+ chmod +x $PARSER_PATH
141+ fi
142+ echo " === Region tag injector setup complete ==="
143+ fi
144+
124145test_prog=" ${PROJECT_ROOT} /.kokoro/tests/run_single_test.sh"
125146
126147btlr_args=(
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ required_envvars+=(
2525pass_down_envvars+=(
2626 "BUILD_SPECIFIC_GCLOUD_PROJECT"
2727 "REPORT_TO_BUILD_COP_BOT"
28+ "INJECT_REGION_TAGS"
2829 # Target directories.
2930 "RUN_TESTS_DIRS"
3031 # The nox session to run.
You can’t perform that action at this time.
0 commit comments