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

Hooks should be completely orderable #532

Closed
alessandro-fazzi opened this issue Jun 20, 2019 · 1 comment
Closed

Hooks should be completely orderable #532

alessandro-fazzi opened this issue Jun 20, 2019 · 1 comment

Comments

@alessandro-fazzi
Copy link
Member

Scenario: At the moment we have 4 predefined hooks locations per action: 4 on pull and 4 on push. While we can order commands inside each location, we cannot change the order used to fire the locations.

Problem: we cannot coordinate operations. E.g.: if I want to receive a chat notification when a deploy is finished, I must use a hook inside after.femote location, because it's the last to be fired.

Solution: hooks definition in the movefile shuold be refactored to something like

hooks:
  - command: 'rm -rf /*'
    action: push
    when: before
    where: remove
    
  - command: 'wp spam test'
    action: pull
    when: after
    where: remote

this way Wordmove will

  • group hooks by action; previous order must be honored in each group. Will ignore the group which is not for the current action.
  • group hooks by when; previous order must be honored in each group
  • run the resulting groups at the right time in order

Expected result: we'll be able to run hooks locally ore remotely using an arbitrary order. E.g: we'll be able to send a Ryver chat message after push using our local machine as the very last command.

Alternate YAML structure (more expressive?):

hooks:
  push:
    before:
      - command: 'bash ./send_ryver_message.sh'
        where: local
      - command: 'wp do something'
        where: remote
    after:
      - command: 'wp do something'
        where: remote
      - command: 'bash ./send_ryver_message.sh'
        where: local
  pull:
    before:
    after:

The goal of the alternative syntax is to have a more intuitive structure: with a flat structure is harder to understand what will be executed where and when, this way the only flat structure will be used where actually we want to have an arbitrary order.

@alessandro-fazzi
Copy link
Member Author

Here we are. With a new (terrific!) feature added 🎉 #557

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

No branches or pull requests

1 participant