Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b3fd0d5
Add DRIFT region tag parser to CI
Jul 31, 2020
a23d664
Merge branch 'master' into drift-parser-2
Aug 15, 2020
27a1f1c
Merge branch 'master' into drift-parser-2
Aug 18, 2020
6fbf850
Address comments
Aug 18, 2020
d699285
Address comments, take 2
Aug 18, 2020
65599ff
Address comments, take 2.1 (yaml)
Aug 19, 2020
01f28d8
Merge branch 'master' into drift-parser-2
Aug 19, 2020
b92b20e
Address feedback, take 3
Aug 19, 2020
c0d2629
Merge branch 'drift-parser-2' of http://github.com/GoogleCloudPlatfor…
Aug 19, 2020
55281f3
Address comments, take 4
Aug 19, 2020
231a7e4
Fix missing bracket
Aug 19, 2020
9b4d428
Address comments, take 5
Aug 20, 2020
a6b821b
Address comments, take 6
Aug 20, 2020
7d51e03
Move pip install to run_tests.sh
Aug 20, 2020
744990f
Merge branch 'master' into drift-parser-2
Aug 21, 2020
611044e
Use uuid in temp file + python write instead of stdout
Aug 21, 2020
802d8b7
DBG foo
Aug 21, 2020
18dc556
Address comments + get things working locally
Aug 22, 2020
09e19ee
Merge branch 'drift-parser-2' of http://github.com/GoogleCloudPlatfor…
Aug 22, 2020
487712d
Revert "DBG foo"
Aug 24, 2020
01d2896
uuid -> mktemp
Aug 25, 2020
2c3d822
Merge branch 'drift-parser-2' of http://github.com/GoogleCloudPlatfor…
Aug 25, 2020
d1cf339
Merge branch 'master' into drift-parser-2
Aug 25, 2020
085ada5
Use set e for error handling + check file existence
Aug 25, 2020
00a2d3b
Merge branch 'drift-parser-2' of http://github.com/GoogleCloudPlatfor…
Aug 25, 2020
a723d33
Merge branch 'master' into drift-parser-2
Aug 25, 2020
d653e3e
use `python3 -m pip install`
Aug 26, 2020
18358aa
remove env vars from run_single_test.sh
Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .kokoro/python3.7/periodic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ env_vars: {
key: "REPORT_TO_BUILD_COP_BOT"
value: "true"
}

# Run DRIFT test result injection
# (only for Python 3.7 builds)
env_vars: {
key: "INJECT_REGION_TAGS"
value: "true"
}
30 changes: 30 additions & 0 deletions .kokoro/tests/run_single_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@ fi
nox -s "$RUN_TESTS_SESSION"
EXIT=$?

echo "PWD: ${PWD}"

# Inject region tag data into the test log
set +e # Don't fail the entire test if this step fails
if [[ "${INJECT_REGION_TAGS:-}" == "true" ]]; then

export XUNIT_PATH="$PWD/sponge_log.xml"
export XUNIT_TMP_PATH="$(mktemp)"

if [[ -f "$XUNIT_PATH" ]]; then
echo "=== Injecting region tags into XUnit output ==="
echo "Processing XUnit output file: $XUNIT_PATH (saving output to $XUNIT_TMP_PATH)"

# We use `python3` because it will work even if we remove old
# python versions from the docker image.
echo "Calling python3 ${PARSER_PATH} inject-snippet-mapping --output_file ${XUNIT_TMP_PATH} ${PWD}"
cat "$XUNIT_PATH" | \
python3 "$PARSER_PATH" inject-snippet-mapping --output_file "$XUNIT_TMP_PATH" "$PWD"
if [[ $? -eq 0 ]] && [[ -s "$XUNIT_PATH" ]]; then
mv $XUNIT_TMP_PATH $XUNIT_PATH
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you 100% sure that there is a file when the script exit with 0?
If not, please check the file existance.

Also, does it make sense to log something here as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file at $XUNIT_TMP_PATH doesn't exist, then the mv command should fail.

IMO, logging something here would be overkill. 🙂

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if mv fails, the test is marked as failed even if just the injection here failed?
I don't like it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, actually, there's no -e flag set in this file. So it may keep running.
I still like the explicit check, but I think I can live with the current code.

else
echo "Region tag injection FAILED; XUnit file not modified."
fi
else
echo "No XUnit output file found!"
fi
echo "=== Region tag injection complete! ==="
fi
set -e

Comment thread
ace-n marked this conversation as resolved.
# If REPORT_TO_BUILD_COP_BOT is set to "true", send the test log
# to the Build Cop Bot.
# See:
Expand Down
21 changes: 21 additions & 0 deletions .kokoro/tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,27 @@ set +e
RTN=0
ROOT=$(pwd)

# Setup DRIFT region tag injector
# (only run on *some* builds)
if [[ "${INJECT_REGION_TAGS:-}" == "true" ]]; then
echo "=== Setting up DRIFT region tag injector ==="
# install PyYaml (used by the DRIFT region tag parsing system)
echo "--- Installing PyYaml ---"
python3 -m pip install --user pyyaml

# Use ${HOME} because trampoline will automatically clean up this
# directory.
export REGION_TAG_PARSER_DIR="${HOME}/region-tag-parser"
export PARSER_PATH="${REGION_TAG_PARSER_DIR}/wizard-py/cli.py"

if [[ ! -f $PARSER_PATH ]]; then
echo "--- Fetching injection script from HEAD (via GitHub) ---"
git clone https://github.com/GoogleCloudPlatform/repo-automation-playground "$REGION_TAG_PARSER_DIR" --single-branch
chmod +x $PARSER_PATH
fi
echo "=== Region tag injector setup complete ==="
fi

test_prog="${PROJECT_ROOT}/.kokoro/tests/run_single_test.sh"

btlr_args=(
Expand Down
1 change: 1 addition & 0 deletions .trampolinerc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ required_envvars+=(
pass_down_envvars+=(
"BUILD_SPECIFIC_GCLOUD_PROJECT"
"REPORT_TO_BUILD_COP_BOT"
"INJECT_REGION_TAGS"
# Target directories.
"RUN_TESTS_DIRS"
# The nox session to run.
Expand Down