kcmerrill / alfred

(v0.2) Even Batman needs a little help. Task runner. Automator. Build system.
MIT License
63 stars 14 forks source link

Failure in setup should prevent the rest of the pipiline from running #60

Closed iilyak closed 6 years ago

iilyak commented 6 years ago

I am testing the setup functionality in context of https://github.com/kcmerrill/alfred/issues/53#issuecomment-354180384. Here is my minimal alfred.yml file

ensure.ssh.keys:
  summary: Check that ssh keys exist
  command: test -f non_existent_file
  private: true

test:
  summary: Should fail due to setup
  setup: |
    ensure.ssh.keys
  command: >
    echo SUCCESS

Here is the output:

build/bin/darwin_amd64/alfred test
[    0s] (27 Dec 17 14:10 PST) test started [] Should fail due to setup
[    0s] (27 Dec 17 14:10 PST) test setup ensure.ssh.keys
[    0s] (27 Dec 17 14:10 PST) ensure.ssh.keys started [] Check that ssh keys exist
[    0s] (27 Dec 17 14:10 PST) ensure.ssh.keys command failed
[    0s] (27 Dec 17 14:10 PST) ensure.ssh.keys ✘ failed [] elapsed time '0s'
[    0s] (27 Dec 17 14:10 PST) SUCCESS
[    0s] (27 Dec 17 14:10 PST) test ✔ ok [] elapsed time '0s'
kcmerrill commented 6 years ago

So I wanted to make sure this wasn't a regression and I don't think it is. The TL;DR is you need to put an exit: 42 (or whatever non zero exit code you want) on your ensure.ssh.keys.

Here is the latest version:

03:40 PM ✔ kcmerrill  tmp ] alfred
 pipeline    | Echo the superhero name
 should.fail | failme
03:40 PM ✔ kcmerrill  tmp ] alfred pipeline
[    0s] (27 Dec 17 15:41 MST) pipeline started [] Echo the superhero name
[    0s] (27 Dec 17 15:41 MST) pipeline setup should.fail
[    0s] (27 Dec 17 15:41 MST) should.fail started [] failme
[    0s] (27 Dec 17 15:41 MST) ls: /tmp/idonotexistordoi: No such file or directory
[    0s] (27 Dec 17 15:41 MST) should.fail command failed
[    0s] (27 Dec 17 15:41 MST) should.fail ✘ failed [] elapsed time '0s'
[    0s] (27 Dec 17 15:41 MST) made it here
[    0s] (27 Dec 17 15:41 MST) pipeline ✔ ok [] elapsed time '0s'
03:41 PM ✔ kcmerrill  tmp ]

Here is the previous version:

03:40 PM ✔ kcmerrill  tmp ] alfred
[pipeline] Echo the superhero name
[should.fail] failme
03:40 PM ✔ kcmerrill  tmp ] alfred pipeline

[should.fail] failme (Args: [])
ls: /tmp/idonotexistordoi: No such file or directory

---
✘ should.fail FAILED

[pipeline] Echo the superhero name (Args: [])
made it here

---
✔ pipeline DONE
03:40 PM ✔ kcmerrill  tmp ] cat alfred.yml
should.fail:
    summary: failme
    command: |
        ls -alh /tmp/idonotexistordoi

pipeline:
    summary: Echo the superhero name
    setup: should.fail
    command: |
        echo "made it here"
03:40 PM ✔ kcmerrill  tmp ]

Both using the same pipeline.