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

Halt execution when invalid options are provided #76

Merged
merged 5 commits into from Dec 8, 2020
Merged

Conversation

alfredodeza
Copy link
Contributor

Closes #67

  • Prevents execution from continuing when invalid input is given
  • Prevents execution from continuing when no input (neither path or image) is given
  • Adds a Makefile with targets for functional testing with act
  • Adds a test harness to validate output and functional tests of the actions
  • Adds a github action validation for PRs that calls make check which in turn runs all the new test harness

Signed-off-by: Alfredo Deza <adeza@anchore.com>
@alfredodeza alfredodeza force-pushed the issue-74 branch 2 times, most recently from 9724466 to 3d88dea Compare December 8, 2020 12:28
Alfredo Deza added 4 commits December 8, 2020 07:38
Signed-off-by: Alfredo Deza <adeza@anchore.com>
Signed-off-by: Alfredo Deza <adeza@anchore.com>
Signed-off-by: Alfredo Deza <adeza@anchore.com>
Signed-off-by: Alfredo Deza <adeza@anchore.com>
JOB=$1

# ensure this is at the root
cd "$SCRIPTPATH/.."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit / clarifying question: if this script is only meant to run in the root of the repo, would $(pwd) be alright instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, yes, I think that would work. I did it this way to ensure that regardless of where it runs it is always correct. Do you think that assurance is overkill?

Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great, really like the direction you took!

core.setFailed(
"At least one source for scanning needs to be provided. Available options are: image, and path"
);
throw new Error("At least one source for scanning needs to be provided. Available options are: image, and path");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(no change needed) I took another look at this (re our Zoom chat the other day) and it makes sense why this was needed. Throwing an error accomplishes failing the job and skipping the remainder code, only because of the try/catch setup here. Another option is to control the flow via an early return, which lets you control the execution separately from deciding the job status if you ever need to. That might be of interest if we want to move away from large try blocks one day 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point. I will open a ticket to track this improvement

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

Successfully merging this pull request may close these issues.

When options are invalid an immediate halt of execution should happen
3 participants