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

Use unified Heroku buildpack output style #745

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Use unified Heroku buildpack output style #745

wants to merge 17 commits into from

Conversation

Malax
Copy link
Member

@Malax Malax commented Nov 22, 2024

This PR introduces a new shared library for all JVM buildpacks that implements the unified Heroku buildpack output style. All buildpacks in the repository have been modified to use this new shared library over the log module from libherokubuildpack.

In some cases, the buildpacks changes their output a little bit more to output more detailed information about the process. For example, the jvm buildpack now tells the user where the OpenJDK version is defined.

Example

# Heroku OpenJDK Buildpack

- OpenJDK version resolution
  - Using version string provided in `system.properties`
  - Selected major version `11` resolves to `11.0.25`
- OpenJDK Installation
  - Downloading and unpacking OpenJDK distribution
  - Done (50.5s)
- Applying JDK overlay
  - Skipping (directory `.jdk_overlay` not present)
- Linking base image certificates as OpenJDK keystore
  - Done.

# Heroku Maven Buildpack

- Installing Maven
  - Skipping (Maven wrapper detected)
- Running Maven build
  - Running `./mvnw -DskipTests clean install`
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    [INFO] Scanning for projects...
    [INFO]
    [INFO] -------------------< com.heroku:simple-http-service >-------------------
    [INFO] Building simple-http-service 1.0-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------

Closes:
W-17215812
W-17215820
W-17215822
W-17215818

@schneems
Copy link
Contributor

schneems commented Dec 3, 2024

Not a blocker, but would help for QA-ing the output as a whole to print the getting started guide in CI. https://github.com/heroku/buildpacks-ruby/blob/187770e700a433cf9e6af678cb3eb5735b89eec5/.github/workflows/ci.yml#L62-L97

Copy link
Contributor

@schneems schneems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge #761, put this back in draft state and make changes until you're happy with the output (removal of newlines, using the correct style for a "value" etc.) Then we can iterate on the output style. Happy to iterate/pair too.

@schneems
Copy link
Contributor

@runesoerensen I told him to do it. I opened heroku-buildpacks/bullet_stream#23 to bring that to the larger group.

@schneems
Copy link
Contributor

Here's my take on this PR. It's implemented on top of this branch. #767

image

Take anything that's useful...drop anything that's not. Doing that helped me find some missing changes such as left-over libherokubuildpack::log calls. It prints more command info to the logs, but IMHO that's fine unless there's strong reasons to hide one. I also refactored the command error handling which would close out #762.

schneems added a commit that referenced this pull request Jan 31, 2025
Uses the newly defined `output` interface that Manuel introduced for the JVM buildpack in #745 instead of the legacy libherokubuildpack::log::log_error. For all buildpacks except for jvm-function-invoker.
Copy link
Contributor

@schneems schneems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are things need to be done to migrate onto the new output format, there might be more, but all of these recommendations come from having implemented the migration twice already. These almost exclusively come from specific commits on this ready-to-merge PR #769:

Double check

While iterating, I originally made changes and looked at the print output and kept going. The above 🆙 list is based on the second time I implemented the build output for buildpacks-jvm and is more focused, however, it's important that the output be used while iterating or you might introduce different problems. Basically "it's not done until it looks okay."

  • Timing information isn't being emitted at the same time as commands are streaming
  • Command execution indentation and formatting is correct
  • Commands "Running: <cmd>" should be indented under an appropriate header
  • The "print" CI task's output looks okay in all three guides

Edit: Remove commenatary

@schneems
Copy link
Contributor

schneems commented Feb 5, 2025

To round back on the h2 issue, I went to send a PR to the dotnet buildpack and it looks like it is already using them https://github.com/heroku/buildpacks-dotnet/blame/f11d9b15c3ae79a2d364a68b42f4973b05ee90e8/buildpacks/dotnet/src/main.rs#L68.

@Malax Malax force-pushed the malax/output branch 2 times, most recently from 8580f7b to 3950aa1 Compare February 5, 2025 16:19
Copy link
Contributor

@schneems schneems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that the specific fixes I requested have been implemented. After reviewing the printed buildpack output, I found some issues, which are detailed below.

Required fixes

  • Maven dependency list is not indented,
- Running `./mvnw dependency:list` quietly
  - Done (4.0s)
- Done (finished in 10.7s)

should be

  - Running `./mvnw dependency:list` quietly
  - Done (4.0s)
- Done (finished in 10.7s)

Edit: Removed more detailed request

  • Gradle daemon command output needs to be formatted or hidden
## Heroku Gradle Buildpack

- Running Gradle build
  - Starting Gradle daemon
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Downloading https://services.gradle.org/distributions/gradle-8.12-bin.zip
.............10%.............20%.............30%.............40%.............50%.............60%.............70%.............80%.............90%.............100%
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :heroku_buildpack_start_daemon UP-TO-DATE

BUILD SUCCESSFUL in 31s
  - Done (31.6s)
  - Querying tasks
  - Done (1.4s)
  - Querying dependency report
  - Done (4.0s)

Given that it takes so long (31s), I recommend streaming it as a normal Running <cmd> output. That's different from what you're currently doing but less confusing. If you were using bullet_stream, I would suggest background dots here as an alternative, i.e., "Starting Gradle daemon ... "

  • Missing "done" timing on the command execution:
- Running Gradle build
  - Running `./gradlew build -x check`

      Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
      > Task :compileJava
      > Task :processResources
      > Task :classes
      > Task :resolveMainClassName
      > Task :bootJar
      > Task :jar
      > Task :assemble
      > Task :build
      
      BUILD SUCCESSFUL in 6s
      5 actionable tasks: 5 executed

- Done (finished in 44.5s)

Should be:

      BUILD SUCCESSFUL in 6s
      5 actionable tasks: 5 executed

  - Done (2s)
- Done (finished in 44.5s)

From an interface perspective, every time you need to run a streaming command, you also need to remember to emit "Done" with timing. My suggestion is to couple that behavior with your implementation. i.e. have run_command emit it by default so you don't forget it.

Edit: Removed commentary

@Malax
Copy link
Member Author

Malax commented Feb 6, 2025

The Maven output seems fine to me in the context of this PR. Let's stick to moving the output style to the new one before making fixes to the output/UX in general. Indentation also seems correct to me on CI. I left this as-is.

The other issues I have fixed. I found another one with duplicated Gradle headings that I've fixed too.

Everything optional I left out to be either broken out or discussed separately.

@Malax Malax requested a review from schneems February 6, 2025 17:57
Copy link
Contributor

@schneems schneems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated:

Re-requesting indenting this line:

- Running `./mvnw dependency:list` quietly

I see that I wasn't clear with what I was asking before.

),
})?;

output::print_section(BuildpackOutputText::new(vec![
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update output according to style guide please https://github.com/heroku-buildpacks/bullet_stream/blob/c24396edfa449e21c5ed9c4f36b618502887c8b5/examples/style_guide.rs#L22-L25

Suggested change
output::print_section(BuildpackOutputText::new(vec![
output::print_subsection(BuildpackOutputText::new(vec![

Copy link
Contributor

@schneems schneems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after bullet -> sub-bullet suggestion is accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants