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

Having preconditions without fail #275

Closed
soullivaneuh opened this issue Dec 11, 2019 · 5 comments
Closed

Having preconditions without fail #275

soullivaneuh opened this issue Dec 11, 2019 · 5 comments

Comments

@soullivaneuh
Copy link

soullivaneuh commented Dec 11, 2019

In order to make a project dependencies update tools, I'm interested by the preconditions options.

It allow me to run the different dependencies managers if the condition are met:

version: '2'

silent: true

tasks:
  default:
    deps:
      - composer
      - npm

  composer:
    preconditions:
      - test -f composer.lock
    cmds:
      - composer update

  npm:
    preconditions:
      - test -f package-lock.json
    cmds:
      - npm update

But the way this option is working does not fit my needs. It fail immediately if one of the task as unmet condition:

❯ task
task: `test -f package-lock.json` failed
task: `test -f composer.lock` failed
task: precondition not met
❯ touch composer.lock
❯ task
task: `test -f package-lock.json` failed
task: precondition not met

I didn't find any option to solve this issue, so I guess it was designed for.

Would you consider an evolution about this?

Regards

@soullivaneuh
Copy link
Author

I found a workaround using ignore_error:

composer:
  ignore_error: true
  cmds:
    - test -f composer.lock && composer update

npm:
  ignore_error: true
  cmds:
    - test -f package-lock.json && npm update

But this is not ideal, because I won't have any feedback if the task really fails.

@andreynering andreynering added the type: feature A new feature or functionality. label Dec 16, 2019
@andreynering
Copy link
Member

Hi @soullivaneuh, thanks for opening this issue!

I'd say preconditions was specifically designed to explicitly fail when the condition isn't met.

Perhaps if we introduced a new keywords called something like skip_if it'd be clearer?

@soullivaneuh
Copy link
Author

Hi @andreynering and sorry for the delay.

Yes, this is perfectly what I'm looking for! It would be a great addition, opening multiple possibilities to go-task.

Smart CI jobs can be written this way for example. 👍

If you want to learn more, here is the project I'm setting up : https://gitlab.com/nexylan/kmi/merge_requests/1

@ghostsquad
Copy link
Contributor

I like how ConcourseCI does this. It feels very natural and quite powerful:

https://concourse-ci.org/modifier-and-hook-steps.html

@andreynering
Copy link
Member

I think #608 would address this use case, so I'm closing this one. If anyone has thoughts, let me know.

@pd93 pd93 removed the type: feature A new feature or functionality. label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants