MinecraftServerControl / mscs

Powerful command-line control for UNIX and Linux powered Minecraft servers
https://minecraftservercontrol.github.io
BSD 2-Clause "Simplified" License
479 stars 61 forks source link

Add ShellCheck functionality through GitHub Actions #288

Closed Roflicide closed 3 years ago

Roflicide commented 3 years ago

Hi,

ShellCheck is a popular static-analysis tool for shell scripts that gives warnings on potential coding errors as well as style suggestions.

GitHub Actions is a free service provided by GitHub that enables a continuous integration/automatic testing pipeline. You can create your own actions or browse from their marketplace of community created actions. Essentially, you configure what the triggers for the action will be (such as on a code push or PR request) and the actions will be performed automatically when the event happens.

ShellCheck is useful, but can be a pain to perform every time manually when code changes. This PR adds the ability for ShellCheck to be ran automatically in the mscs repository every time code is pushed or a PR is made, thanks to the ShellCheck community-provided action.

Here's how it works:

  1. Upon a push or a PR to the main branch, the shellcheck-action.yml action is triggered.

  2. This action runs the ShellCheck script on a GitHub provided Ubuntu machine (what they call "runners"), for free. You can see the action output via the "actions" tab at the top: image

  3. If errors are detected, the action will failure, and you will get a notice in the PR or the push commit that it failed:

image

Pretty neat, right? You can see an example of the action working on this PR--the action will trigger, and it should say that all checks have failed since shellcheck detected errors.

In the future, I want to add automatic unit-testing upon pushes/PRs using GitHub Actions + something like shunit2

Let me know what you think!

Thanks

zanix commented 3 years ago

Nice, I've also been checking out github actions to replace CircleCi for work. I've also been using actions on a personal repo for my Home Assistant configuration.

This could also come in handy if we ever write tests for the script.

sandain commented 3 years ago

This looks good. Thanks for the suggestion and patch. It looks like we have a lot of cleanup to do..

sandain commented 3 years ago

I accepted this PR, but it doesn't seem to be working. It just posts Error: without any details of what went wrong. Any ideas?

Roflicide commented 3 years ago

Hey @sandain, where does it say that error? It looks like it's working to me--it's popping up in the Actions tab, and I see that it's automatically running on your pull request ( #290 )

sandain commented 3 years ago

Screenshot_2021-05-03 Build software better, together

Roflicide commented 3 years ago

that's super weird, i have no idea why that is. on my screen i can see it fine:

image

what does it say when you click on this dropdown on your screen? image

sandain commented 3 years ago

It shows in my screenshot above. If I unclick it, it looks like this: Screenshot_2021-05-03 Fixshellcheck by sandain · Pull Request #290 · MinecraftServerControl mscs

sandain commented 3 years ago

I can get raw log files: Screenshot_2021-05-03 https pipelines actions githubusercontent com

Roflicide commented 3 years ago

are you able to open the other dropdowns and see output? like this one:

image

sandain commented 3 years ago

Nope, just "Error:" Screenshot_2021-05-03 Build software better, together

sandain commented 3 years ago

Try doing a manual run for me. I think it was working before I did that for the first time. It might break it for you though..

Roflicide commented 3 years ago

Tested it with a manual run and it still works fine for me. I'm stumped, i think you discovered some bug haha. Maybe try deleting the .github/workflows/shellcheck-action.yml file (which will automatically delete the action) and re-creating it to see if it will fix the issue?

sandain commented 3 years ago

Well it works on my Windows 10 box!?! Maybe it is an issue with my Ubuntu box? I'll try restarting. Lol

Roflicide commented 3 years ago

That is weird--maybe try clearing your cookies/cache or using a different browser?

sandain commented 3 years ago

Clearing the cache did the trick. Lol. Thanks for the help!

Roflicide commented 3 years ago

no problem :)