| #!/usr/bin/env bash |
| |
| # Copyright 2022 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| |
| set -eo pipefail |
| |
| ci_dir="$(dirname -- "${BASH_SOURCE[0]}")" |
| source ${ci_dir:?unable to figure out script dir}/common.sh |
| cd ${root_dir:?unable to find root dir} |
| |
| # run tests & lints |
| |
| # run tests & lint & typecheck separately for better output |
| echo "running typecheck..." >&2 |
| node ${ci_dir}/ci-tsc.mjs &>${TYPECHECK_LOG_OUTPUT} |
| echo " (done with typechecking)" |
| |
| echo "running lints..." >&2 |
| # run this, but continue on because we almost never want to stop from running |
| # the tests if we fail lints |
| lint_res=$(npm run --silent lint -- --format=${ci_dir}/eslint-formatter.js >${LINT_XML_OUTPUT} 2>${LINT_LOG_OUTPUT} || echo "fail") |
| echo " (done with lints: ${lint_res:-"success"})" >&2 |
| |
| echo "running node tests..." >&2 |
| xvfb-run -a npm run test:ci &>${TEST_LOG_OUTPUT} |
| echo " (done with tests)" >&2 |
| |
| # fail later if we fail the lints |
| if [[ ${lint_res} == "fail" ]]; then |
| echo "(failed on lints)" |
| exit 1; |
| fi |
| |
| echo "...done testing!" >&2 |