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

Update Heroku generator for JHipster 8 #23971

Merged
merged 46 commits into from
Oct 28, 2023
Merged

Update Heroku generator for JHipster 8 #23971

merged 46 commits into from
Oct 28, 2023

Conversation

mraible
Copy link
Contributor

@mraible mraible commented Oct 24, 2023

Fixes #23686.


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (below reviewers) and adding skip-ci label, you can still see CI build result at your branch.

@mraible mraible marked this pull request as draft October 24, 2023 03:53
@mraible mraible mentioned this pull request Oct 24, 2023
1 task
mraible and others added 3 commits October 23, 2023 22:39
Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
@mraible
Copy link
Contributor Author

mraible commented Oct 24, 2023

@mshima Do you have advice for making this work?

@mraible
Copy link
Contributor Author

mraible commented Oct 25, 2023

@mshima I'm not sure I'm mocking spawnCommand correctly. The first error is:

  1) generator - Heroku
       microservice application
         with JAR deployment
           "before each" hook for "should match files snapshot":
     TypeError: stub expected to yield, but no callback was passed. Received [spawnCommand, heroku --version, [object Object]]

@github-actions github-actions bot added the theme: dependencies Pull requests that update a dependency file label Oct 25, 2023
@mshima
Copy link
Member

mshima commented Oct 25, 2023

@mraible I did some adjusts.
Not going to continue right now.

@github-actions github-actions bot removed the theme: dependencies Pull requests that update a dependency file label Oct 26, 2023
@mraible mraible marked this pull request as ready for review October 26, 2023 03:47
@mshima
Copy link
Member

mshima commented Oct 27, 2023

I hope random name is fixed now.

@mraible
Copy link
Contributor Author

mraible commented Oct 27, 2023

I hope random name is fixed now.

It almost works:

? The Heroku application "foobar" already exists! Use it anyways? No, generate a random name
INFO! Creating app...
INFO!  done, sleepy-falls-26483
INFO!
INFO! https://sleepy-falls-26483-e4a894bcc786.herokuapp.com/ | https://git.heroku.com/sleepy-falls-26483.git
INFO!
INFO!  ›   Error: Couldn't find that app.
INFO!  ›
INFO!  ›   Error ID: not_found
INFO!

Provisioning addons

Provisioning database addon heroku-postgresql
Creating heroku-postgresql on ⬢ sleepy-falls-26483-e4a894bcc786... !
 ▸    Couldn't find that app.
ERROR! An error occured while running jhipster:heroku#herokuAddonsCreate
ERROR! ERROR! Command failed with exit code 1: heroku addons:create heroku-postgresql --as DATABASE --app sleepy-falls-26483-e4a894bcc786
Error: Command failed with exit code 1: heroku addons:create heroku-postgresql --as DATABASE --app sleepy-falls-26483-e4a894bcc786
    at makeError (file:///Users/mraible/dev/generator-jhipster/node_modules/execa/lib/error.js:60:11)
    at handlePromise (file:///Users/mraible/dev/generator-jhipster/node_modules/execa/index.js:124:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HerokuGenerator.herokuAddonsCreate (file:///Users/mraible/dev/generator-jhipster/dist/generators/heroku/generator.mjs:299:48)
    at async HerokuGenerator.executeTask (file:///Users/mraible/dev/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:241:13)
    at async runLoop.add.once (file:///Users/mraible/dev/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:381:17) {
  shortMessage: 'Command failed with exit code 1: heroku addons:create heroku-postgresql --as DATABASE --app sleepy-falls-26483-e4a894bcc786',
  command: 'heroku addons:create heroku-postgresql --as DATABASE --app sleepy-falls-26483-e4a894bcc786',
  escapedCommand: 'heroku "addons:create" heroku-postgresql --as DATABASE --app sleepy-falls-26483-e4a894bcc786',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  cwd: '/Users/mraible/Downloads/21p',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

I was able to reproduce it a couple of times. If I try again and use sleepy-falls-26483, it says it already exists. If I say I have access to it, it works to deploy to it.

@mshima
Copy link
Member

mshima commented Oct 27, 2023

Do we need to remove -e4a894bcc786.
Or add a timeout for the app to settle.

@mraible
Copy link
Contributor Author

mraible commented Oct 27, 2023

I think it's a timeout issue. Can we wait a few seconds for the command to complete?

@mraible
Copy link
Contributor Author

mraible commented Oct 28, 2023

@mshima I was able to fix the random name issue. I also added checks for the config (e.g. GRADLE_TASK) and buildpacks already being set. This is necessary because you can't add buildpacks twice so jhipster heroku can't be run multiple times without this check.

Other minor issues:

  1. When the configuring is processing, the checks print blank lines:
Configuring Heroku
INFO!
INFO!
INFO! Setting GRADLE_TASK and restarting

If the app already exists and you're deploying again, it prints the output from the checks. It'd be nice if the blank lines and output from the check commands could be suppressed.

Configuring Heroku
INFO! stage -Pprod -PnodeInstall
INFO!
INFO! === windycity Buildpack URL
INFO!
INFO! heroku/gradle
INFO!
  1. When deploying a new app, true is printed to the console after specifying the Java version.
? Which Java version would you like to use to build and run your app? 21
WARNING! Ignoring 'Preferences' definitions as it is using a built-in Entity 'user': 'otherEntityRelationshipName' is set with value 'undefined' at relationship 'user' but no back-reference was found
INFO! true
INFO!

If you update an existing app, true is still printed. It'd be nice to remove this.

INFO! Deploying as existing application: windycity
INFO! true
INFO!
  1. For the git repository, it prints java and a version for some reason. It'd be nice if it just printed the first line without lines 2 and 3.
Using existing Git repository
INFO! java 3.1.1
INFO!
  1. If the app already exists, it runs the following command, which spews a bunch of JSON to the console. It'd be nice if it was possible to read this JSON without printing it to the console.
const { stdout, exitCode } = await this.spawnHeroku(['apps:info', '--json', this.jhipsterConfig.herokuAppName]);

@mshima
Copy link
Member

mshima commented Oct 28, 2023

To stop printing to console, add a { verboseInfo: false } to the command like here:

const { exitCode } = await this.spawnHerokuCommand('--version', { verboseInfo: false });

@mshima
Copy link
Member

mshima commented Oct 28, 2023

Blank lines like INFO! are printed by the command, we could ignore blank lines, but I think it will be ugly.

this.log.verboseInfo(`No new ${addon} addon created`);
const { stdout } = await this.spawnHeroku(['create', ...regionParams]);
// Extract from "Created random-app-name-1234... done"
this.herokuAppName = stdout.substring(stdout.lastIndexOf('/') + 1, stdout.indexOf('.git'));
Copy link
Member

Choose a reason for hiding this comment

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

If it’s not a git deployment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It still seems to work OK for this part.

? The Heroku application "play-more" already exists! Use it anyways? No, generate a random name
INFO! Creating app...
INFO!  done, evening-escarpment-92393
INFO!
INFO! https://evening-escarpment-92393-39f845122a90.herokuapp.com/ | https://git.heroku.com/evening-escarpment-92393.git
INFO!
INFO! set git remote heroku to https://git.heroku.com/evening-escarpment-92393.git
INFO!

Provisioning addons

However, there is a stacktrace further down:

Building application
ERROR! An error occured while running jhipster:heroku#productionBuild
ERROR! ERROR! Cannot read properties of null (reading 'on')
TypeError: Cannot read properties of null (reading 'on')
    at HerokuGenerator.printChildOutput (file:///Users/mraible/dev/generator-jhipster/dist/generators/heroku/generator.mjs:521:16)
    at HerokuGenerator.productionBuild (file:///Users/mraible/dev/generator-jhipster/dist/generators/heroku/generator.mjs:409:28)
    at HerokuGenerator.executeTask (file:///Users/mraible/dev/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:241:26)
    at env.queueTask.once (file:///Users/mraible/dev/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:215:56)
    at runLoop.add.once (file:///Users/mraible/dev/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:381:23)
    at Immediate.<anonymous> (/Users/mraible/dev/generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:48:34)
    at process.processImmediate (node:internal/timers:476:21)

> health-points@0.0.1-SNAPSHOT java:jar:prod
> npm run java:jar -- -Pprod

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The build finishes, but there's no deployment to Heroku that happens.

@mshima
Copy link
Member

mshima commented Oct 28, 2023

Let’s merge and we can handle any remaining adjusts later.

@mshima mshima enabled auto-merge (squash) October 28, 2023 13:05
mshima and others added 5 commits October 28, 2023 13:57
Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
@mraible
Copy link
Contributor Author

mraible commented Oct 28, 2023

@mshima I'm OK to merge. Some tests are failing though.

@mshima mshima merged commit e8f6e35 into main Oct 28, 2023
57 of 58 checks passed
@mshima mshima deleted the heroku-update branch October 28, 2023 22:13
@deepu105 deepu105 added this to the 8.0.0 milestone Nov 2, 2023
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.

Heroku generator update.
3 participants