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

Incorrect exit code on failure #72

Closed
chingor13 opened this issue Aug 10, 2020 · 1 comment · Fixed by #81
Closed

Incorrect exit code on failure #72

chingor13 opened this issue Aug 10, 2020 · 1 comment · Fixed by #81
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@chingor13
Copy link
Contributor

Not sure if this is from the CLI or the GitHub action, but a rejected promise is not causing the build step to fail.

Example: https://github.com/chingor13/actions-test/runs/968409994?check_suite_focus=true - the "Open Pull Request" step should have failed.

@chingor13 chingor13 added bug priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed bug labels Aug 10, 2020
@TomKristie
Copy link
Contributor

Yup. It looks like we never wrote an exit code: https://docs.github.com/en/actions/creating-actions/setting-exit-codes-for-actions

gcf-merge-on-green bot pushed a commit that referenced this issue Aug 13, 2020
**Assumptions**: To my knowledge, in order to get a step to fail, the process exit code has to be 1: https://docs.github.com/en/actions/creating-actions/setting-exit-codes-for-actions

**Scenario:**

Currently when the node process fails, it always exits with code 0.

Tested by running local script:
```
if code-suggester pr \
--upstream-repo="dne" \
--upstream-owner="TomKristie" \
--description="describe" \
--title="title" \
--branch="something" \
--primary="master" \
--message="some message" \
--git-dir="./kubernetes"; then
    exit 0
else
    echo "failure exit code non-zero"
    exit 1
fi
```

which tries to fork a non-existent repo.

The output is
```
{"level":30,"time":1597342089072,"pid":8411,"hostname":"penguin","msg":"Starting GitHub PR workflow..."}
{"level":50,"time":1597342089474,"pid":8411,"hostname":"penguin","msg":"Error when forking"}
{"level":50,"time":1597342089474,"pid":8411,"hostname":"penguin","msg":"Workflow failed"}
{"level":50,"time":1597342089474,"pid":8411,"hostname":"penguin","stack":"Error: HttpError: Not Found\n    at Object.fork (/home/kristietom/code-suggester/build/src/github-handler/fork-handler.js:44:15)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)\n    at async Object.createPullRequest (/home/kristietom/code-suggester/build/src/index.js:59:20)\n    at async Object.main (/home/kristietom/code-suggester/build/src/bin/workflow.js:42:17)","type":"Error","msg":"HttpError: Not Found"}
failure exit code non-zero
```
Fixes #72 🦕
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants