Unverified Commit bc532006 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Add warning for the upcoming run build change (#616)

* Add warning for the upcoming run build change
parent 3c3db2ed
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
## master ## master
- Add warning for the upcoming run build change (#616)
## v135 (2018-02-06)
- Fix bug where failing builds on CI would not fail CI (#613)
- Internal logging changes (#596, #600)
## v134 (2018-12-20) ## v134 (2018-12-20)
- Internal changes (#593, #591) - Internal changes (#593, #591)
......
...@@ -97,8 +97,7 @@ warn_missing_package_json "$BUILD_DIR" ...@@ -97,8 +97,7 @@ warn_missing_package_json "$BUILD_DIR"
### Behavior flags ### Behavior flags
[ ! "$NEW_BUILD_SCRIPT_BEHAVIOR" ] && NEW_BUILD_SCRIPT_BEHAVIOR=$(read_json "$BUILD_DIR/package.json" ".[\"heroku-run-build-script\"]") [ ! "$NEW_BUILD_SCRIPT_BEHAVIOR" ] && NEW_BUILD_SCRIPT_BEHAVIOR=$(read_json "$BUILD_DIR/package.json" ".[\"heroku-run-build-script\"]")
warn_build_script_behavior_opt_in "$NEW_BUILD_SCRIPT_BEHAVIOR" | output "$LOG_FILE"
log_build_script_opt_in "$NEW_BUILD_SCRIPT_BEHAVIOR"
### Compile ### Compile
...@@ -318,4 +317,8 @@ warn_no_start "$BUILD_DIR" ...@@ -318,4 +317,8 @@ warn_no_start "$BUILD_DIR"
warn_unmet_dep "$LOG_FILE" warn_unmet_dep "$LOG_FILE"
warn_old_npm_lockfile $NPM_LOCK warn_old_npm_lockfile $NPM_LOCK
warn_build_script_behavior_change "$NEW_BUILD_SCRIPT_BEHAVIOR" "$BUILD_DIR" | output "$LOG_FILE"
warn_build_script_behavior_opt_in "$NEW_BUILD_SCRIPT_BEHAVIOR" | output "$LOG_FILE"
log_build_script_opt_in "$NEW_BUILD_SCRIPT_BEHAVIOR" "$BUILD_DIR"
log_build_data >> "$BUILDPACK_LOG_FILE" log_build_data >> "$BUILDPACK_LOG_FILE"
...@@ -43,7 +43,7 @@ run_build_script() { ...@@ -43,7 +43,7 @@ run_build_script() {
has_heroku_build_script=$(read_json "$build_dir/package.json" ".scripts[\"heroku-postbuild\"]") has_heroku_build_script=$(read_json "$build_dir/package.json" ".scripts[\"heroku-postbuild\"]")
if [[ -n "$has_heroku_build_script" ]] && [[ -n "$has_build_script" ]]; then if [[ -n "$has_heroku_build_script" ]] && [[ -n "$has_build_script" ]]; then
echo "Detected both 'build' and 'heroku-postbuild' scripts" echo "Detected both \"build\" and \"heroku-postbuild\" scripts"
mcount "scripts.heroku-postbuild-and-build" mcount "scripts.heroku-postbuild-and-build"
run_if_present "$build_dir" 'heroku-postbuild' run_if_present "$build_dir" 'heroku-postbuild'
elif [[ -n "$has_heroku_build_script" ]]; then elif [[ -n "$has_heroku_build_script" ]]; then
...@@ -59,10 +59,33 @@ warn_build_script_behavior_opt_in() { ...@@ -59,10 +59,33 @@ warn_build_script_behavior_opt_in() {
local opted_in="$1" local opted_in="$1"
if [[ "$opted_in" = true ]]; then if [[ "$opted_in" = true ]]; then
header "Opting in to new default build script behavior" header "Opting in to new default build script behavior"
echo "You have set \"heroku-run-build-script\" = true in your package.json" echo "You have set \"heroku-run-build-script\"=true in your package.json"
echo "Your app will be unaffected by the change on March 11, 2019"
echo ""
fi
}
warn_build_script_behavior_change() {
local opted_in="$1"
local build_dir="$2"
local has_build_script has_heroku_build_script
has_build_script=$(read_json "$build_dir/package.json" ".scripts.build")
has_heroku_build_script=$(read_json "$build_dir/package.json" ".scripts[\"heroku-postbuild\"]")
if [[ -z "$has_heroku_build_script" ]] && [[ -n "$has_build_script" ]] && [[ "$opted_in" != "true" ]]; then
header "Change to Node.js build process"
echo "On March 11, 2019 Heroku will begin executing the \"build\" script defined in package.json"
echo "by default. This application may be affected by this change."
echo ""
echo "To make this transition easier, we've published a tool that will automatically"
echo "update your app for you. You can run it with one command in your app's"
echo "root directory:"
echo ""
echo "$ npx @heroku/update-node-build-script"
echo ""
echo "Please see https://help.heroku.com/P5IMU3MP/heroku-node-js-build-script-change-faq for more information"
echo "" echo ""
echo "- If a \"build\" script is defined in package.json it will be executed by default"
echo "- The \"heroku-postbuild\" script will be executed instead if present"
fi fi
} }
......
...@@ -16,6 +16,25 @@ log_initial_state() { ...@@ -16,6 +16,25 @@ log_initial_state() {
log_build_script_opt_in() { log_build_script_opt_in() {
local opted_in="$1" local opted_in="$1"
local build_dir="$2"
local has_build_script has_heroku_build_script
has_build_script=$(read_json "$build_dir/package.json" ".scripts.build")
has_heroku_build_script=$(read_json "$build_dir/package.json" ".scripts[\"heroku-postbuild\"]")
# if this app will be affected by the change
if [[ -z "$has_heroku_build_script" ]] && [[ -n "$has_build_script" ]]; then
mcount "affected-by-build-change"
if [[ "$opted_in" = "true" ]]; then
mcount "affected-by-build-change-opted-in"
bd_set "affected-but-opted-in" "true"
else
bd_set "affected-but-opted-in" "false"
fi
fi
if [[ "$opted_in" = true ]]; then if [[ "$opted_in" = true ]]; then
bd_set "build-script-opt-in" "true" bd_set "build-script-opt-in" "true"
else else
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
"url": "http://github.com/example/example.git" "url": "http://github.com/example/example.git"
}, },
"engines": { "engines": {
"node": "~0.10.0" "node": "10.x"
}, },
"scripts" : { "scripts" : {
"build": "echo build hook message", "build": "echo build hook message",
"heroku-postbuild": "echo heroku-postbuild hook message" "heroku-postbuild": "echo heroku-postbuild hook message"
} },
"heroku-run-build-script": true
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"url" : "http://github.com/example/example.git" "url" : "http://github.com/example/example.git"
}, },
"engines": { "engines": {
"node": "~0.10.0" "node": "10.x"
}, },
"scripts" : { "scripts" : {
"build" : "echo build hook message" "build" : "echo build hook message"
......
...@@ -15,6 +15,26 @@ testFlatmapStream() { ...@@ -15,6 +15,26 @@ testFlatmapStream() {
assertCapturedError assertCapturedError
} }
testBuildScriptWarning() {
local env_dir=$(mktmpdir)
local metrics_log=$(mktemp)
echo "$metrics_log" > $env_dir/BUILDPACK_LOG_FILE
compile "build-script" "$(mktmpdir)" $env_dir
# Without opting in, having a build script will display a warning
assertCaptured "On March 11, 2019 Heroku will begin executing the \"build\" script defined in package.json"
assertCaptured "https://help.heroku.com/P5IMU3MP/heroku-node-js-build-script-change-faq"
# make sure metrics are being captured as we expect
assertFileContains "count#buildpack.nodejs.affected-by-build-change=1" "$metrics_log"
assertFileNotContains "affected-by-build-change-opted-in" "$metrics_log"
# We shouldn't see the opt-in success message
assertNotCaptured "Opting in to new default build script behavior"
assertCapturedSuccess
}
testBuildScriptBehavior() { testBuildScriptBehavior() {
# opt in to new build script behavior # opt in to new build script behavior
cache=$(mktmpdir) cache=$(mktmpdir)
...@@ -27,16 +47,28 @@ testBuildScriptBehavior() { ...@@ -27,16 +47,28 @@ testBuildScriptBehavior() {
assertCapturedSuccess assertCapturedSuccess
# the 'heroku-postbuild' script takes precedence over the 'build' script # the 'heroku-postbuild' script takes precedence over the 'build' script
compile "build-script-override" $cache $env_dir compile "build-script-override"
assertCaptured "Detected both 'build' and 'heroku-postbuild' scripts" assertCaptured "Detected both \"build\" and \"heroku-postbuild\" scripts"
assertCaptured "Running heroku-postbuild" assertCaptured "Running heroku-postbuild"
assertCapturedSuccess assertCapturedSuccess
} }
testBuildScriptOptIn() { testBuildScriptOptIn() {
compile "build-script-opt-in" local env_dir=$(mktmpdir)
local metrics_log=$(mktemp)
echo "$metrics_log" > $env_dir/BUILDPACK_LOG_FILE
compile "build-script-opt-in" "$(mktmpdir)" $env_dir
assertCaptured "Running build" assertCaptured "Running build"
assertCaptured "Opting in to new default build script behavior" assertCaptured "Opting in to new default build script behavior"
# We shouldn't see this warning once they opt-in
assertNotCaptured "Warning: On March 11, 2019 Heroku will begin executing the \"build\" script defined in package.json by default"
assertNotCaptured "https://help.heroku.com/P5IMU3MP/heroku-node-js-build-script-change-faq"
# make sure metrics are being captured as we expect
assertFileContains "count#buildpack.nodejs.affected-by-build-change=1" "$metrics_log"
assertFileContains "count#buildpack.nodejs.affected-by-build-change-opted-in=1" "$metrics_log"
assertCapturedSuccess assertCapturedSuccess
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment