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

init --forcePush runs pre-push hooks before init #12664

Open
2 tasks done
joekiller opened this issue May 22, 2023 · 1 comment
Open
2 tasks done

init --forcePush runs pre-push hooks before init #12664

joekiller opened this issue May 22, 2023 · 1 comment
Labels
bug Something isn't working p2 platform-hooks Issue is related to CLI command hooks

Comments

@joekiller
Copy link
Contributor

joekiller commented May 22, 2023

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v16.20.0

Amplify CLI Version

12.0.0

What operating system are you using?

Linux

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made.

Describe the bug

When amplify init is run with --forcePush the pre-push hook is run before init instead of before push.

Expected behavior

I expect the pre-push hook to run consistently before a push to an initialized environment.

Reproduction steps

  1. Run the steps in This environment is missing some parameter values. [appId,type] do not have values. in PR Preview envs, auto-detected branch envs #12644
  2. Note during the branch build that the pre-push hook will run prior to a forced init/add of the environment.

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

I thought downgrading to <12 should fix the issue thinking it runs the hooks during the init and the push of a --forcePush per #12512 but that only applies to post-push hook.

The hooks might be somewhat correct/somewhat bugged in the instance of a init --forcePush because it's really two different actions: amplify env add + amplify push. init creates all the resources that normally would come with an amplify env add. I've seen that the CLI populates different push parameters in a clean init --forcePush. It wouldn't matter as much for people if the pre-push would run twice but it doesn't I guess. Moving the pre-push to post init would avoided situations where stuff like #12640 occurs, ie on the forcePush --init, the cloudformation name isn't know for the hook.

Now with #12512 in, I think pre-push hooks running during the adding of the env is a bug and they should run after the init/add of the env.

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@joekiller joekiller added the pending-triage Issue is pending triage label May 22, 2023
@josefaidt
Copy link
Contributor

Hey @joekiller thanks for raising this! As promised, lifting my note from the linked issue this appears to be unique to init --forcePush in that the CLI is verifying environment variables and executing the pre-push hook https://github.com/aws-amplify/amplify-cli/blob/dev/packages/amplify-cli/src/commands/init.ts#L37

In this specific case I can see how this affects the chosen functionality for your pre-push hook, and will mark this as a bug to reevaluate the order of execution.

@josefaidt josefaidt added bug Something isn't working platform-hooks Issue is related to CLI command hooks p2 and removed pending-triage Issue is pending triage labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2 platform-hooks Issue is related to CLI command hooks
Projects
None yet
Development

No branches or pull requests

2 participants