devops: collect host os name and version (#4244)

Our test annotations don't provide (and don't require) a fine-grained
information regarding ubuntu version, so we collect it separately.
This commit is contained in:
Andrey Lushnikov 2020-10-26 16:44:32 -07:00 committed by GitHub
parent 7fc4b797eb
commit 86e1e3f3fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,10 +44,22 @@ export BUILD_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_
export COMMIT_SHA=$(git rev-parse HEAD)
export COMMIT_TIMESTAMP=$(git show -s --format=%ct HEAD)
export HOST_OS_NAME="$(uname)"
export HOST_OS_VERSION=""
if [[ "$HOST_OS_NAME" == "Darwin" ]]; then
HOST_OS_VERSION=$(sw_vers -productVersion | grep -o '^\d\+.\d\+')
elif [[ "$HOST_OS_NAME" == "Linux" ]]; then
HOST_OS_NAME="$(bash -c 'source /etc/os-release && echo $NAME')"
HOST_OS_VERSION="$(bash -c 'source /etc/os-release && echo $VERSION_ID')"
fi
EMBED_METADATA_SCRIPT=$(cat <<EOF
const json = require('./' + process.argv[1]);
json.metadata = {
runURL: process.env.BUILD_URL,
osName: process.env.HOST_OS_NAME,
osVersion: process.env.HOST_OS_VERSION,
commitSHA: process.env.COMMIT_SHA,
commitTimestamp: process.env.COMMIT_TIMESTAMP,
};