-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Prow: Add shellcheck.sh task #95
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
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: alejovicu If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @alejovicu. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
Maybe update |
|
Actually, your script has both the container form and the non-container form, so definitely update |
hack/shellcheck.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the newline guard? I don't expect us to have any files ending in .sh with shell-sensitive characters in the names. I expect we can also drop the tmp-search business and just paste in the:
for file in $(find /workdir/ -type f -name "*.sh"); dofrom .travis.yaml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, we can probably just do:
shellcheck --format=gcc $(find "${DIR}" -type f -name '*.sh')and skip the for loop entirely (although this diverges from .travis.yaml, so I'm fine punting it to follow-up work).
If we replace /workdir/ with "${DIR}" in the find (to allow folks to call this locally without spinning up a container), you'd want to adjust the container call to:
docker run -e IS_CONTAINER='TRUE' --rm -v "$(realpath "${DIR}")":/workdir:ro --entrypoint sh quay.io/coreos/shellcheck-alpine:v0.5.0 /workdir/hack/shellcheck.sh /workdir;and add a leading:
DIR="${1:-.}"or similar to the script (realpath is not in POSIX, but it is in coreutils).
hack/shellcheck.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs the executable bit set to avoid:
$ ./hack/shellcheck.sh
/home/travis/.travis/job_stages: line 78: ./hack/shellcheck.sh: Permission denied
|
Can you rebase this into a single commit on top of master? Also probably drop your yamllint whitespace fixes in |
hack/shellcheck.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to print a success message. Exiting zero and the lack of warnings should be sufficient feedback. We also want to exit nonzero of the find exits nonzero. How about:
find "${DIR}" -type f -name '*.sh' -exec shellcheck --format=gcc {} \+ || exit 1without the if? Even the || exit 1 may be optional, because with:
if [ "$IS_CONTAINER" != "" ]; then
find "${DIR}" -type f -name '*.sh' -exec shellcheck --format=gcc {} \+
else
docker run ...
fithe find command will be the last command in the script, so the scripts default exit handling will pass it back to the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This success message is to get an execution feedback from the pod log in Prow when it passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This success message is to get an execution feedback from the pod log in Prow when it passed.
If Prow needs something on stdout for success, you could always use:
./hack/shellcheck.sh && echo 'Shell Check Passed'or similar in openshift/release#1131.
Bug 1915959: Add missing exclude annotations for hosted control plane
* select the COS region (which is a 1:1 mapping of the IBM Cloud VPC region) from the Power VS Region Co-authored-by: wolf <[email protected]>
Add shell script to run the shell check task.
This task will be executed by Prow:
openshift/release#1131