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

ci(action): add shellcheck linter #6340

Closed
wants to merge 1 commit into from

Conversation

kwanhur
Copy link
Contributor

@kwanhur kwanhur commented Feb 16, 2022

What this PR does / why we need it:

  1. shellcheck lint on action
  2. fix shebang missing

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

- action-shellcheck@1.1.0

Signed-off-by: kwanhur <huang_hua2012@163.com>
@@ -7,3 +7,6 @@
[submodule "t/grpc_server_example"]
path = t/grpc_server_example
url = https://github.com/api7/grpc_server_example
[submodule ".github/actions/action-shellcheck"]
path = .github/actions/action-shellcheck
url = https://github.com/ludeeus/action-shellcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, Why do you add this into the submodule?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's due to policy of ASF? Actions not from Github or ASF are forbidden.

@kwanhur
Copy link
Contributor Author

kwanhur commented Feb 16, 2022 via email

@starsz
Copy link
Contributor

starsz commented Feb 17, 2022

Refers to PR#5364, only actions from GitHub or Apache can be used in the CI under Apache's policy. So it's used with submodule. Kwanhur Huang TL;DR

2022年2月16日 下午8:45,Peter Zhu @.***> 写道: @starsz commented on this pull request. In .gitmodules <#6340 (comment)>: > @@ -7,3 +7,6 @@ [submodule "t/grpc_server_example"] path = t/grpc_server_example url = https://github.com/api7/grpc_server_example +[submodule ".github/actions/action-shellcheck"] + path = .github/actions/action-shellcheck + url = https://github.com/ludeeus/action-shellcheck Hi, Why do you add this into the submodule? — Reply to this email directly, view it on GitHub <#6340 (review)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANVRBSRKWZ4I36DNHZTH5TU3OL63ANCNFSM5OQX4MDA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

Thanks for your patient explanation.Got it.

@@ -1,3 +1,5 @@
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

The common.sh is imported in other scripts, so there is no need to add #!.

@@ -1,3 +1,5 @@
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

The common.sh is imported in other scripts, so there is no need to add #!.

@spacewander
Copy link
Member

spacewander commented Feb 18, 2022

The shellcheck action is imported but doesn't run at all...
To run it in the CI, we need to add it in https://github.com/apache/apisix/tree/master/.github/workflows.

I think we should write our own GitHub action, like what we have done with editorconfig action: #5391

The submodule way doesn't obey ASF's policy "Actions not from Github or ASF are forbidden.". It just bypasses the restriction set in the CI. The policy maker of ASF won't be happy to see this.

@spacewander
Copy link
Member

A PR is submitted to remove the tmate action finally: #6367

@kwanhur
Copy link
Contributor Author

kwanhur commented Feb 19, 2022

From the context, make one shellcheck action under Apache License 2.0 will be a better solution.

I'll stop working on this PR under confirmation.

@spacewander
Copy link
Member

I am afraid we can't create a repo for shellcheck under Apache's GitHub organization. We need to apply for the new repo and a fork of shellcheck action may not be acceptable. I think just copying some code to the lint action is enough.

@kwanhur
Copy link
Contributor Author

kwanhur commented Feb 20, 2022

Copying codes or code files, these all need to reserve license declaration, will it have any conflicts?

action-shellcheck and shellcheck under MIT license

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

@spacewander
Copy link
Member

So we need to write our own installation to add shellcheck in the CI.

@kwanhur
Copy link
Contributor Author

kwanhur commented Feb 21, 2022

I'll try it. Thanks for the guidance.

@kwanhur
Copy link
Contributor Author

kwanhur commented Feb 23, 2022

After a trial, using a local action works fine, have a look at shellcheck action and test case:

  1. check all successfully
  2. SC2148 check failed
In ci/common-test.sh line 1:
. .common.sh
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
Error: Process completed with exit code 1.

Summary, two solutions can do the shellcheck:

I prefer solution1, what's your opinion, @spacewander ?

  1. solution1: add one job sc-lint at code-lint.yml with step run commands
        scversion="latest"
        wget -O- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
        cp -av "shellcheck-${scversion}/shellcheck" /usr/local/bin/
        shellcheck --version
        shellcheck **/*.sh
  1. solution2: add one job sc-lint at code-lint.yml with step use a local action
runs:
  using: composite
  steps:
    - id: shellcheck
      run: |
        scversion="${{ inputs.scversion }}"
        wget -O- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
        cp -av "shellcheck-${scversion}/shellcheck" /usr/local/bin/
        shellcheck --version
        shellcheck **/*.sh
      shell: bash

@spacewander
Copy link
Member

spacewander commented Feb 23, 2022

I vote for the first solution.

@kwanhur
Copy link
Contributor Author

kwanhur commented Feb 23, 2022

Solution1 implements with #6428

This PR closed :-)

@kwanhur kwanhur closed this Feb 23, 2022
@kwanhur kwanhur deleted the ci-action-shellcheck branch February 23, 2022 10:31
@kwanhur kwanhur mentioned this pull request Feb 28, 2022
4 tasks
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.

4 participants