21 Commits
0.1.0 ... 0.2.0

Author SHA1 Message Date
Joakim Sørensen
f22efe748c Merge pull request #13 from ludeeus/testfiles
Add exclude and testfiles
2020-05-30 12:02:57 +02:00
ludeeus
b44aa9b87a Update 2020-05-30 12:02:32 +02:00
ludeeus
acc4e4fe97 take both 2020-05-30 12:01:39 +02:00
ludeeus
6eb62923bc Update 2020-05-30 12:00:24 +02:00
ludeeus
3a4806a465 Update readme 2020-05-30 11:57:50 +02:00
ludeeus
21696cbf1a simplify 2020-05-30 11:55:03 +02:00
ludeeus
fa3cc6ede4 Use self 2020-05-30 11:46:07 +02:00
ludeeus
18c29dd450 Add exclude and testfiles 2020-05-30 11:44:01 +02:00
ludeeus
c07d062aa5 Fix remnants of tests 2020-05-30 00:12:17 +02:00
ludeeus
a1eeadd7ec Add back bash 2020-05-30 00:06:50 +02:00
ludeeus
f615dc5486 restructure 2020-05-30 00:06:39 +02:00
ludeeus
b443c466bf Remove bash 2020-05-29 23:13:38 +02:00
ludeeus
35efb355bc Update README 2020-05-29 23:11:34 +02:00
ludeeus
5e7f90b47a Move image to alpine 2020-05-29 23:11:06 +02:00
Joakim Sørensen
70c0c19934 Merge pull request #10 from cramte/fix-runaction-exitcode
Fix runaction.sh return values
2020-05-05 08:29:47 +02:00
cramte
9f3543661d Fix runaction.sh return values 2020-05-03 22:11:15 +02:00
Joakim Sørensen
746dd2ddc0 Merge pull request #4 from kurahaupo/patch-1
apply to all Bash, Ksh, Zsh & POSIX Shell files
2019-12-01 10:17:06 +01:00
Joakim Sørensen
88a963fbeb Merge pull request #2 from tchia04/migrate_to_yml
converted main.workflow to Actions V2 yml files
2019-11-29 22:30:12 +01:00
Martin Kealey
2e9d4c556d Update runaction.sh 2019-11-20 16:56:37 +11:00
Martin Kealey
9445381284 apply to all Bash, Ksh, Zsh & POSIX Shell files
Does not need bash to run; standard posix sh suffices.

Apply shellcheck to:

* files with shbang lines that indicate a shell (sh, bash, ash, bsh, ksh, zsh)

* typical home directory shell startup files:
  for posix sh & all shells: .profile
  for bash: .bashrc, .bash_aliases, .bash_completion, .bash_login, .bash_logout, .bash_profile
  for ksh: .profile
  for zsh: .zprofile, .zlogin, .zlogout, .zshenv, .zshrc

* typical system-wide shell startup files:
  for posix sh & all shells: /etc/profile
  for bash: /etc/bashrc, /etc/bash_profile
  for ksh:
  for zsh: /etc/zprofile, /etc/zlogin, /etc/zlogout, /etc/zshenv, /etc/zshrc

* files with suffixes: .bash, .zsh, .ksh, & .sh
2019-11-20 16:45:19 +11:00
Tony Chia
370adf4cb6 converted main.workflow to Actions V2 yml files 2019-09-18 13:28:56 -07:00
11 changed files with 166 additions and 41 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
* text=auto eol=lf

View File

@@ -1,8 +0,0 @@
workflow "Trigger: Push" {
on = "push"
resolves = ["Shellcheck"]
}
action "Shellcheck" {
uses = "ludeeus/action-shellcheck@master"
}

13
.github/workflows/push.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
on: push
name: 'Trigger: Push'
jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Run ShellCheck
uses: ./
with:
ignore: ignore

View File

@@ -1,16 +1,6 @@
FROM debian:latest
FROM alpine:3.11.6
COPY runaction.sh /runaction.sh
RUN chmod +x /runaction.sh
RUN apt update
RUN apt install -y shellcheck
RUN apk add --no-cache shellcheck bash
ENTRYPOINT ["/runaction.sh"]
LABEL "name"="shellcheck"
LABEL "maintainer"="Ludeeus <ludeeus@gmail.com>"
LABEL "version"="0.1.0"
LABEL "com.github.actions.name"="shellcheck"
LABEL "com.github.actions.description"="Run shell check on ALL sh files in the repository."
LABEL "com.github.actions.icon"="terminal"
LABEL "com.github.actions.color"="black"
COPY runaction.sh /action/runaction.sh
ENTRYPOINT ["bash", "/action/runaction.sh"]

View File

@@ -1,24 +1,59 @@
# SHELLCHECK
# ShellCheck
[![BuyMeCoffee][buymecoffeebedge]][buymecoffee]
_Run shellcheck on ALL sh files in the repository._
_GitHub action for ShellCheck._
## Example
```
workflow "Shellcheck" {
on = "push"
resolves = [
"Shellcheck",
]
}
```yaml
on:
push:
branch:
- master
name: 'Trigger: Push action'
action "Shellcheck" {
uses = "ludeeus/actions/shellcheck@master"
}
jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
```
[buymecoffee]: https://www.buymeacoffee.com/ludeeus
[buymecoffeebedge]: https://camo.githubusercontent.com/cd005dca0ef55d7725912ec03a936d3a7c8de5b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275792532306d6525323061253230636f666665652d646f6e6174652d79656c6c6f772e737667
## Globally disable checks
To disable specific checks add it to a `SHELLCHECK_OPTS` env key in the job definition.
example:
```yaml
...
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -e SC2059 -e SC2034 -e SC1090
```
## Ignore paths
You can use the `ignore` input to disable specific directories.
```text
sample structure:
sample/directory/with/files/toignore/test.sh
sample/directory/with/files/test.sh
```
example:
```yaml
...
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
ignore: toignore
```
This will skip `sample/directory/with/files/toignore/test.sh`

14
action.yaml Normal file
View File

@@ -0,0 +1,14 @@
name: "ShellCheck"
author: "Ludeeus <hi@ludeeus.dev>"
description: "GitHub action for ShellCheck."
inputs:
ignore:
description: 'Paths to ignore when running ShellCheck'
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
branding:
icon: 'terminal'
color: 'gray-dark'

72
runaction.sh Normal file → Executable file
View File

@@ -1,6 +1,72 @@
#!/bin/bash
cd "$GITHUB_WORKSPACE" || exit 1
find . -name \*.sh -exec shellcheck {} +
find . -name \*.bashrc -exec shellcheck {} +
find . -name \*.bash_profile -exec shellcheck {} +
declare statuscode
declare -a filepaths
declare -a excludes
declare -a tmp
statuscode=0
excludes+=( ! -path *./.git/* )
for path in ${INPUT_IGNORE}; do
echo "::debug:: Adding '${path}' to excludes"
excludes+=(! -path "*./${path}/*" )
excludes+=(! -path "*/${path}/*" )
done
readarray -d '' filepaths < <(find . "${excludes[@]}" \
'(' \
\
-name '*.bash' \
-o -path '*/.bash*' \
-o -path '*/bash*' \
-o -name '*.ksh' \
-o -name 'ksh*' \
-o -path '*/.ksh*' \
-o -path '*/ksh*' \
-o -name 'suid_profile' \
-o -name '*.zsh' \
-o -name '.zlogin*' \
-o -name 'zlogin*' \
-o -name '.zlogout*' \
-o -name 'zlogout*' \
-o -name '.zprofile*' \
-o -name 'zprofile*' \
-o -path '*/.zsh*' \
-o -path '*/zsh*' \
-o -name '*.sh' \
-o -path '*/.profile*' \
-o -path '*/profile*' \
-o -path '*/.shlib*' \
-o -path '*/shlib*' \
')'\
\
-print0)
readarray -d '' tmp < <(find . "${excludes[@]}" -type f ! -name '*.*' -perm /111 -print0)
for file in "${tmp[@]}"; do
head -n1 "$file" | grep -Eqs "^#! */[^ ]*/[abkz]*sh" || continue
filepaths+=("$file")
done
if find . "${excludes[@]}" -path '*bin/*/*' -type f -perm /111 -print |
grep .
then
echo >&2 "::warning:: subdirectories of bin directories are not usable via PATH"
fi
if find . "${excludes[@]}" -path '*bin/*' -name '*.*' -type f -perm /111 -perm /444 -print |
grep .
then
echo >&2 "::warning:: programs in PATH should not have a filename suffix"
fi
for file in "${filepaths[@]}"; do
echo "::debug:: Checking $file"
shellcheck "$file" || statuscode=$?
done
exit "$statuscode"

View File

@@ -0,0 +1,3 @@
#!/bin/sh
echo $test

4
testfiles/test Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
test="test"
echo "$test"

3
testfiles/test.bash Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
test="test"
echo "$test"

4
testfiles/test.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/sh
test="test"
echo "$test"