Skip to content

Commit

Permalink
feat: include project in mocha xunit report (#1665)
Browse files Browse the repository at this point in the history
  • Loading branch information
fhinkel committed Mar 30, 2020
1 parent b8f394b commit 40e3345
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 14 deletions.
32 changes: 32 additions & 0 deletions .kokoro/.mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2020 Google LLC
//
// 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.
const config = {};

if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
delete config['throw-deprecation'];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}

const reporterOptions = [];
if (process.env.MOCHA_REPORTER_OUTPUT) {
reporterOptions.push(`output=${process.env.MOCHA_REPORTER_OUTPUT}`);
}
if (process.env.MOCHA_REPORTER_SUITENAME) {
reporterOptions.push(`suiteName=${process.env.MOCHA_REPORTER_SUITENAME}`);
}
config['reporter-option'] = reporterOptions;

module.exports = config
3 changes: 0 additions & 3 deletions .kokoro/.mocharc.yml

This file was deleted.

7 changes: 4 additions & 3 deletions .kokoro/build-with-appengine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ set -e;
export GCLOUD_PROJECT=nodejs-docs-samples-tests

# Activate mocha config
export MOCHA_REPORTER_OUTPUT=sponge_log.xml
export MOCHA_REPORTER=xunit
pushd github/nodejs-docs-samples
mv .kokoro/.mocharc.yml .
mv .kokoro/.mocharc.js .
popd

# Update gcloud
Expand Down Expand Up @@ -66,8 +68,7 @@ npm install
# If tests are running against master, configure Build Cop
# to open issues on failures:
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"release"* ]]; then
export MOCHA_REPORTER_OUTPUT=sponge_log.xml
export MOCHA_REPORTER=xunit
export MOCHA_REPORTER_SUITENAME=${PROJECT}
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
$KOKORO_GFILE_DIR/linux_amd64/buildcop
Expand Down
7 changes: 4 additions & 3 deletions .kokoro/build-with-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
set -eo pipefail

# Activate mocha config
export MOCHA_REPORTER_OUTPUT=sponge_log.xml
export MOCHA_REPORTER=xunit
pushd github/nodejs-docs-samples
mv .kokoro/.mocharc.yml .
mv .kokoro/.mocharc.js .
popd

export GOOGLE_CLOUD_PROJECT=nodejs-docs-samples-tests
Expand Down Expand Up @@ -62,8 +64,7 @@ npm install
# If tests are running against master, configure Build Cop
# to open issues on failures:
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"release"* ]]; then
export MOCHA_REPORTER_OUTPUT=sponge_log.xml
export MOCHA_REPORTER=xunit
export MOCHA_REPORTER_SUITENAME=${PROJECT}
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
$KOKORO_GFILE_DIR/linux_amd64/buildcop
Expand Down
7 changes: 4 additions & 3 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ export BOT_ACCESS_TOKEN=${KOKORO_GFILE_DIR}/secrets-slack-bot-access-token.txt
export CHANNEL=${KOKORO_GFILE_DIR}/secrets-slack-channel-id.txt

# Activate mocha config
export MOCHA_REPORTER_OUTPUT=sponge_log.xml
export MOCHA_REPORTER=xunit
pushd github/nodejs-docs-samples
mv .kokoro/.mocharc.yml .
mv .kokoro/.mocharc.js .
popd

cd github/nodejs-docs-samples/${PROJECT}
Expand All @@ -89,8 +91,7 @@ gcloud config set project $GCLOUD_PROJECT
# If tests are running against master, configure Build Cop
# to open issues on failures:
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"release"* ]]; then
export MOCHA_REPORTER_OUTPUT=sponge_log.xml
export MOCHA_REPORTER=xunit
export MOCHA_REPORTER_SUITENAME=${PROJECT}
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
$KOKORO_GFILE_DIR/linux_amd64/buildcop
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ env_vars: {
# Export XUnit test results for further analysis
action {
define_artifacts {
regex: "**/sponge_log.xml"
regex: "**/*sponge_log.xml"
}
}
1 change: 0 additions & 1 deletion iot/http_example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "nodejs-docs-samples-iot-http-example",
"version": "0.0.1",
"description": "HTTP Example for Google Cloud IoT Core using NodeJS.",
"license": "Apache-2.0",
"author": "Google Inc.",
Expand Down

0 comments on commit 40e3345

Please sign in to comment.