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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli,action): when process fails, make exit code 1 #81

Merged

Conversation

TomKristie
Copy link
Contributor

@TomKristie TomKristie commented 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 馃

@TomKristie TomKristie requested a review from a team August 13, 2020 18:09
@TomKristie TomKristie requested a review from a team as a code owner August 13, 2020 18:09
@codecov
Copy link

codecov bot commented Aug 13, 2020

Codecov Report

Merging #81 into master will decrease coverage by 0.48%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
- Coverage   86.35%   85.86%   -0.49%     
==========================================
  Files          14       14              
  Lines        1231     1238       +7     
  Branches       81       81              
==========================================
  Hits         1063     1063              
- Misses        167      174       +7     
  Partials        1        1              
Impacted Files Coverage 螖
src/bin/code-suggester.ts 0.00% <0.00%> (酶)

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 326145f...b2adc70. Read the comment docs.

@TomKristie TomKristie requested a review from bcoe August 13, 2020 18:17
@TomKristie TomKristie changed the title fix(nonzero exit on error): when code fails, make exit code 1 fix(github action always passes): when process fails, make exit code 1 Aug 13, 2020
entrypoint.sh Outdated Show resolved Hide resolved
@chingor13 chingor13 changed the title fix(github action always passes): when process fails, make exit code 1 fix(cli,action): when process fails, make exit code 1 Aug 13, 2020
@chingor13 chingor13 added the automerge Merge the pull request once unit tests and other checks pass. label Aug 13, 2020
@gcf-merge-on-green gcf-merge-on-green bot merged commit c1495cb into googleapis:master Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge the pull request once unit tests and other checks pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect exit code on failure
2 participants