Skip to content

Commit

Permalink
Merge pull request #4671 from storybooks/cli-teamcity-report
Browse files Browse the repository at this point in the history
Report CLI tests to teamcity
  • Loading branch information
shilman authored Nov 2, 2018
2 parents 48b2b51 + 22c6c38 commit edcff0e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object OpenSourceProjects_Storybook_CliTest : BuildType({
set -e -x
yarn
yarn test --cli
yarn test --cli --teamcity
""".trimIndent()
dockerImage = "node:%docker.node.version%"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object OpenSourceProjects_Storybook_CliTestLatestCra : BuildType({
set -e -x
yarn
yarn test-latest-cra
yarn test-latest-cra -t
""".trimIndent()
dockerImage = "node:%docker.node.version%"
}
Expand Down
29 changes: 27 additions & 2 deletions lib/cli/test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ function cleanup {
trap cleanup EXIT

fixtures_dir='fixtures'
teamcity=0

# parse command-line options
# '-f' sets fixtures directory
while getopts ":uosf:" opt; do
# '-t' adds teamcity reporting
while getopts ":tf:" opt; do
case $opt in
f)
fixtures_dir=$OPTARG
;;
t)
teamcity=1
;;
esac
done

Expand Down Expand Up @@ -49,7 +54,27 @@ for dir in *
do
# check that storybook starts without errors
cd $dir

if [ $teamcity -eq 1 ]
then
echo "##teamcity[testStarted name='$dir' captureStandardOutput='true']"
fi

echo "Running smoke test in $dir"
yarn storybook --smoke-test
failed=0
yarn storybook --smoke-test || failed=1

if [ $teamcity -eq 1 ]
then
if [ $failed -eq 1 ]
then
echo "##teamcity[testFailed name='$dir']"
fi
echo "##teamcity[testFinished name='$dir']"
elif [ $failed -eq 1 ]
then
exit 1
fi

cd ..
done
2 changes: 1 addition & 1 deletion lib/cli/test/test_latest_cra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ cd cra-fixtures
npx create-react-app react-scripts-latest-fixture

cd ..
./run_tests.sh -f cra-fixtures
./run_tests.sh -f cra-fixtures $@
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"repo-dirty-check": "node ./scripts/repo-dirty-check",
"start": "yarn --cwd examples/official-storybook storybook",
"test": "node ./scripts/test.js",
"test-latest-cra": "npm --prefix lib/cli run test-latest-cra"
"test-latest-cra": "yarn --cwd lib/cli run test-latest-cra"
},
"devDependencies": {
"@angular/common": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const tasks = {
name: `Use TeamCity reporter`,
defaultValue: false,
option: '--teamcity',
extraParam: '--testResultsProcessor=jest-teamcity-reporter',
extraParam: '-t --testResultsProcessor=jest-teamcity-reporter',
}),
};

Expand Down

0 comments on commit edcff0e

Please sign in to comment.