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

Make sure shellcheck exist #14872

Merged
merged 1 commit into from
Dec 5, 2022
Merged

Make sure shellcheck exist #14872

merged 1 commit into from
Dec 5, 2022

Conversation

HeavenTonight
Copy link
Contributor

@Bhargav-InfraCloud
Copy link
Contributor

I don't think staticcheck will cover for shellcheck. Need to check for shellcheck installation or an alternative.

@ahrtr
Copy link
Member

ahrtr commented Nov 30, 2022

Thanks @Bhargav-InfraCloud for pointing this out. I mis-read the shellcheck as staticcheck. It seems that the shellcheck has never worked in the github workflow? @serathius @ptabor

@ahrtr
Copy link
Member

ahrtr commented Nov 30, 2022

Based on the guide https://github.com/koalaman/shellcheck#installing, it seems that we should install the tool using command sudo apt install shellcheck, but we should install a specified version so as to make the workflow stable. WDYT? @serathius @ptabor

@HeavenTonight
Copy link
Contributor Author

HeavenTonight commented Nov 30, 2022

.PHONY: install-shellcheck install-shellcheck: if ! command -v shellcheck > /dev/null 2>&1; then sudo apt install shellcheck fi

like this,check first,is that ok? @ahrtr

@ahrtr
Copy link
Member

ahrtr commented Nov 30, 2022

We need to install a specific version of shellcheck. sudo apt install shellcheck somehow can only specify version 0.3.7-5. Probably we can download the tool directly something like below,

VERSION=v0.8.0

wget https://github.com/koalaman/shellcheck/releases/download/${VERSION}/shellcheck-${VERSION}.linux.x86_64.tar.xz

Makefile Outdated Show resolved Hide resolved
@ahrtr
Copy link
Member

ahrtr commented Dec 1, 2022

Please squash the commits into one commit.

Makefile Outdated Show resolved Hide resolved
@lowryxiao
Copy link

lowryxiao commented Dec 1, 2022

If you don't mind, I'd like to share my 2 cents here:
If it's better to add check and download shellcheck logic here if it doesn't exist? that we needn't check twice.
https://github.com/etcd-io/etcd/blob/main/scripts/test.sh#L393
Since the original error comes from the function tool_exists:
https://github.com/etcd-io/etcd/blob/main/scripts/test_lib.sh#L351

As what I can image is like this:

function shellcheck_pass {
  # make sure shellcheck is there, if not, install it first
  if ! tool_exists "shellcheck" "https://github.com/koalaman/shellcheck#installing"; then
    # if shellcheck is not there, we need to install it first
  fi
  # run shellcheck
  generic_checker run shellcheck -fgcc scripts/*.sh
  # return $? of above command
  return $?
}

It's better to return corresponding error code of shellcheck to the caller then the caller will take care if there error happens.

scripts/test.sh Outdated Show resolved Hide resolved
@ahrtr
Copy link
Member

ahrtr commented Dec 4, 2022

I agree that we shouldn't change anything of system-wide or user-wide settings. The proposal #14872 (comment) seems like a valid solution to me.

If the command shellcheck already exists, then use it directly, and set SHELLCHECK="shellcheck". Otherwise, download and install it in $(pwd)/bin, and set SHELLCHECK="$(pwd)/bin/shellcheck". Eventually execute command ${SHELLCHECK} something like below,

generic_checker run ${SHELLCHECK}  -fgcc scripts/*.sh

scripts/test.sh Outdated Show resolved Hide resolved
scripts/test.sh Outdated Show resolved Hide resolved
@ahrtr
Copy link
Member

ahrtr commented Dec 5, 2022

Please also add an item rm -rf ./bin/shellcheck* into the target clean in Makefile.

Signed-off-by: guiyong.ou <[email protected]>
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM

Thank you @HeavenTonight

Copy link
Member

@serathius serathius left a comment

Choose a reason for hiding this comment

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

Looks reasonable. Personally I would prefer we simplify dev scripting enough to migrate most commands to Makefile.

@ahrtr ahrtr merged commit b851eac into etcd-io:main Dec 5, 2022
thedtripp added a commit to thedtripp/etcd that referenced this pull request Jun 27, 2024
Include conditional logic to install shellcheck with correct architecture.

This is based on commit 4f23883 and pull request etcd-io#14872.

Signed-off-by: D Tripp <[email protected]>
thedtripp added a commit to thedtripp/etcd that referenced this pull request Jun 27, 2024
Include conditional logic to install shellcheck with correct architecture.

This is based on commit 4f23883 and pull request etcd-io#14872.

Signed-off-by: D Tripp <[email protected]>
thedtripp added a commit to thedtripp/etcd that referenced this pull request Jun 28, 2024
Include conditional logic to install shellcheck with correct architecture.

This is based on commit 4f23883 and pull request etcd-io#14872.

Signed-off-by: D Tripp <[email protected]>
thedtripp added a commit to thedtripp/etcd that referenced this pull request Jun 28, 2024
Include conditional logic to install shellcheck with correct architecture.

This is based on commit 4f23883 and pull request etcd-io#14872.

Signed-off-by: D Tripp <[email protected]>
thedtripp added a commit to thedtripp/etcd that referenced this pull request Jul 3, 2024
This is based on commit 4f23883 and pull request etcd-io#14872.

Signed-off-by: D Tripp <[email protected]>
thedtripp added a commit to thedtripp/etcd that referenced this pull request Jul 3, 2024
This is based on commit 4f23883 and pull request etcd-io#14872.

Signed-off-by: D Tripp <[email protected]>
aneesh1 pushed a commit to DataDog/etcd that referenced this pull request Sep 24, 2024
Include conditional logic to install shellcheck with correct architecture.

This is based on commit 4f23883 and pull request etcd-io#14872.

Signed-off-by: D Tripp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

make verify-shellcheck only warns, doesn't fail when tool doesn't exist
6 participants