-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devops: start uploading test reports to flakiness dashboard (#4239)
- Loading branch information
1 parent
4b2a29e
commit d5fbe3a
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) Microsoft Corporation. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
set +x | ||
|
||
if [[ ($1 == '--help') || ($1 == '-h') ]]; then | ||
echo "usage: $(basename $0) <report.json>" | ||
echo | ||
echo "Upload report to the flakiness dashboard." | ||
echo | ||
echo "NOTE: the following env variables are required:" | ||
echo " FLAKINESS_CONNECTION_STRING connection for the azure blob storage to upload report" | ||
exit 0 | ||
fi | ||
|
||
if [[ -z "${FLAKINESS_CONNECTION_STRING}" ]]; then | ||
echo "ERROR: \$FLAKINESS_CONNECTION_STRING environment variable is missing." | ||
echo " 'Azure Account Name' and 'Azure Account Key' secrets are required" | ||
echo " to upload flakiness results to Azure blob storage." | ||
exit 1 | ||
fi | ||
|
||
if [[ $# == 0 ]]; then | ||
echo "ERROR: missing report name!" | ||
echo "try './$(basename $0) --help' for more information" | ||
exit 1 | ||
fi | ||
|
||
export BUILD_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | ||
export COMMIT_SHA=$(git rev-parse HEAD) | ||
export COMMIT_TIMESTAMP=$(git show -s --format=%ct HEAD) | ||
|
||
EMBED_METADATA_SCRIPT=$(cat <<EOF | ||
const json = require('./' + process.argv[1]); | ||
json.metadata = { | ||
runURL: process.env.BUILD_URL, | ||
commitSHA: process.env.COMMIT_SHA, | ||
commitTimestamp: process.env.COMMIT_TIMESTAMP, | ||
}; | ||
console.log(JSON.stringify(json)); | ||
EOF | ||
) | ||
|
||
REPORT_NAME=$(node -e "console.log(require('crypto').randomBytes(20).toString('hex'))") | ||
node -e "${EMBED_METADATA_SCRIPT}" "$1" > "${REPORT_NAME}" | ||
|
||
gzip "${REPORT_NAME}" | ||
|
||
az storage blob upload --connection-string "${FLAKINESS_CONNECTION_STRING}" -c uploads -f "${REPORT_NAME}.gz" -n "${REPORT_NAME}.gz" | ||
rm -rf "${REPORT_NAME}.gz" | ||
|