Skip to content

Commit

Permalink
chore: re-enable using current pkg versions for api compat checks (aw…
Browse files Browse the repository at this point in the history
…s#8427)

This was originally added in commit
aws@3dd21b9.

However, the script fails during a bump build when the package version
in lerna.json is ahead of the latest published in NPM. This was worked
around by turning this feature off -
aws@09a1f33.

Re-enable this feature and handle version in lerna.json may be ahead of
NPM.

### Testing

Manually tested three cases -
* When version in `lerna.json` is <= package published in NPM
* When version in `lerna.json` is > package published in NPM
* When `DOWNLOAD_LATEST` is set to `true`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Niranjan Jayakar authored Jun 9, 2020
1 parent f6fe36a commit ae90cba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ echo "==========================================================================
echo "building..."
time lerna run $bail --stream $runtarget || fail

DOWNLOAD_LATEST=true /bin/bash scripts/check-api-compatibility.sh
/bin/bash scripts/check-api-compatibility.sh

touch $BUILD_INDICATOR
11 changes: 8 additions & 3 deletions scripts/check-api-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ package_name() {
#
# Doesn't use 'npm view' as that is slow. Direct curl'ing npmjs is better
package_exists_on_npm() {
curl -I 2>/dev/null https://registry.npmjs.org/$1 | head -n 1 | grep 200 >/dev/null
pkg=$1
ver=$2 # optional
curl -I 2>/dev/null https://registry.npmjs.org/$pkg/$ver | head -n 1 | grep 200 >/dev/null
}


Expand Down Expand Up @@ -53,10 +55,13 @@ if ! ${SKIP_DOWNLOAD:-false}; then
existing_names=$(echo "$jsii_package_dirs" | xargs -n1 -P4 -I {} bash -c 'dirs_to_existing_names "$@"' _ {})
echo " Done." >&2

if ! ${DOWNLOAD_LATEST:-false}; then
current_version=$(node -p 'require("./lerna.json").version')
current_version=$(node -p 'require("./lerna.json").version')
echo "Current version in lerna.json is $current_version"
if ! ${DOWNLOAD_LATEST:-false} && package_exists_on_npm aws-cdk $current_version; then
echo "Using package version ${current_version} as baseline"
existing_names=$(echo "$existing_names" | sed -e "s/$/@$current_version/")
else
echo "However, using the latest version from NPM as the baseline"
fi

rm -rf $tmpdir
Expand Down

0 comments on commit ae90cba

Please sign in to comment.