Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: report "npm WARN deprecated" #4229

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions buildspec/linuxTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,11 @@ phases:
fi
- |
{
set -e
set -o pipefail
_PROMISE_REJ_MSG='rejected promise not handled'
mkfifo testout
(cat testout &)
xvfb-run npm test --silent | tee testout \
| grep -v 'undefined..reading..range' \
| grep -v CODEWHISPERER_INLINE_UPDATE_LOCK_KEY \
| { >testout-rej grep --line-buffered "$_PROMISE_REJ_MSG" || true; }
if [ -s testout-rej ] ; then
echo ''
cat testout-rej | sort
printf '\n\nERROR: Found %s "%s" in test output (see above).\n%s\n\n' \
"$(cat testout-rej | wc -l | tr -d ' ')" \
"$_PROMISE_REJ_MSG" \
' This typically indicates a bug. Read https://developer.mozilla.org/docs/Web/JavaScript/Guide/Using_promises#error_handling'
# TODO: fail the CI job
# exit 1;
fi
. buildspec/shared/common.sh
2>&1 xvfb-run npm test --silent | run_and_report \
'rejected promise not handled' \
'This typically indicates a bug. Read https://developer.mozilla.org/docs/Web/JavaScript/Guide/Using_promises#error_handling' \
|| true # TODO: fail the CI job
}
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g') # Encode `#` in the URL because otherwise the url is clipped in the Codecov.io site
Expand Down
30 changes: 30 additions & 0 deletions buildspec/shared/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Common functions used by other CI scripts.
# "Include" this file by sourcing (not executing) it:
# . buildspec/shared/common.sh

# Expects stdin + two args:
# 1: grep pattern
# 2: message shown at end of report, if pattern was found in stdin.
# Usage:
# echo foo | run_and_report '.*' 'You must fix this. See https://example.com'
run_and_report() {
set -o pipefail
local pat="${1}"
local msg="${2}"
local r=0
mkfifo testout
(cat testout &)
# Capture messages that we may want to fail (or report) later.
tee testout \
| { grep > testout-err --line-buffered -E "$pat" || true; }
echo ''
if grep "$pat" testout-err | sort; then
printf '\nERROR: Found %s "%s" in test output (see above).\n%s\n\n' \
"$(grep "${pat}" testout-err | wc -l | tr -d ' ')" \
"$pat" \
" ${msg}"
r=1
fi
rm -f testout testout-err
return "$r"
}
11 changes: 9 additions & 2 deletions buildspec/shared/linux-pre_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# Common code for "pre_build" phase of linux codebuild CI job.

set -e
set -o pipefail

_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Include common functions.
. "${_SCRIPT_DIR}/common.sh"

# If present, log into CodeArtifact. Provides a fallback in case NPM is down.
# Should only affect tests run through Toolkits-hosted CodeBuild.
Expand All @@ -14,5 +20,6 @@ if [ "$TOOLKITS_CODEARTIFACT_DOMAIN" ] && [ "$TOOLKITS_CODEARTIFACT_REPO" ] && [
fi
fi

# TODO: do this in the "install" phase?
npm ci
# TODO: move this to the "install" phase?
npm 2>&1 ci | run_and_report 'npm WARN deprecated' 'Deprecated dependencies must be updated.' \
|| true # TODO: fail the CI job