File tree 7 files changed +164
-61
lines changed
7 files changed +164
-61
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,11 @@ name: Shellcheck
3
3
on : [pull_request]
4
4
5
5
jobs :
6
- shellcheck :
7
- runs-on : ubuntu-latest
8
-
9
- steps :
10
- - uses : actions/checkout@v2
11
- - name : shellcheck
12
- id : shellcheck
13
- uses : project-chip/action-shellcheck@master
14
- env :
15
- EXCLUDE_DIRS : third_party
6
+ shellcheck :
7
+ runs-on : ubuntu-latest
8
+
9
+ steps :
10
+ - uses : actions/checkout@v2
11
+
12
+ - name : shellcheck
13
+ run : integrations/docker/images/chip-build/run.sh integrations/shellcheck_tree.sh
Original file line number Diff line number Diff line change
1
+ # configuration for shellcheck_tree.sh
2
+ excludes+=('third_party/*' 'build/*')
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # build.sh - utility for building (and optionally) tagging and pushing
4
+ # the a Docker image
5
+ #
6
+ # This script expects to find a Dockerfile next to $0, so symlink
7
+ # in an image name directory is the expected use case.
8
+
9
+ me=$( basename " $0 " )
10
+ cd " $( dirname " $0 " ) "
11
+
12
+ ORG=${DOCKER_BUILD_ORG:- connectedhomeip}
13
+
14
+ # directory name is
15
+ IMAGE=${DOCKER_BUILD_IMAGE:- $(basename " $( pwd) " )}
16
+
17
+ # version
18
+ VERSION=${DOCKER_BUILD_VERSION:- $(cat version)}
19
+
20
+ [[ ${*/ --help// } != " ${* } " ]] && {
21
+ set +x
22
+ echo " Usage: $me <OPTIONS>
23
+
24
+ Build and (optionally tag as latest, push) a docker image from Dockerfile in CWD
25
+
26
+ Options:
27
+ --latest update latest to the current built version (\" $VERSION \" )
28
+ --push push image(s) to docker.io (requires docker login for \" $ORG \" )
29
+ --help get this message
30
+
31
+ "
32
+ exit 0
33
+ }
34
+
35
+ die () {
36
+ echo " $me : *** ERROR: $* "
37
+ exit 1
38
+ }
39
+
40
+ set -ex
41
+
42
+ [[ -n $VERSION ]] || die " version cannot be empty"
43
+
44
+ docker build -t " $ORG /$IMAGE :$VERSION " .
45
+
46
+ [[ ${*/ --latest// } != " ${* } " ]] && {
47
+ docker tag " $ORG " /" $IMAGE " :" $VERSION " " $ORG " /" $IMAGE " :latest
48
+ }
49
+
50
+ [[ ${*/ --push// } != " ${* } " ]] && {
51
+ docker push " $ORG " /" $IMAGE " :" $VERSION "
52
+ [[ ${*/ --latest// } != " ${* } " ]] && {
53
+ docker push " $ORG " /" $IMAGE " :latest
54
+ }
55
+ }
56
+
57
+ exit 0
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ ../../build.sh
Original file line number Diff line number Diff line change
1
+ ../../run.sh
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # run.sh - utility for running a Docker image
4
+ #
5
+ # This script expects to live in a directory named after the image
6
+ # with a version file next to it. So: use symlinks
7
+ #
8
+ here=$( cd " $( dirname " $0 " ) " && pwd)
9
+ me=$( basename " $0 " )
10
+
11
+ ORG=${DOCKER_RUN_ORG:- connectedhomeip}
12
+
13
+ # directory name is
14
+ IMAGE=${DOCKER_RUN_IMAGE:- $(basename " $here " )}
15
+
16
+ # version
17
+ VERSION=${DOCKER_RUN_VERSION:- $(cat " $here /version" )}
18
+
19
+ # where
20
+ RUN_DIR=${DOCKER_RUN_DIR:- $(pwd)}
21
+
22
+ [[ ${*/ --help// } != " ${* } " ]] && {
23
+ set +x
24
+ echo " Usage: $me command
25
+
26
+ Run a command in a docker image described by $here
27
+
28
+ Options:
29
+ --help get this message
30
+
31
+ "
32
+ exit 0
33
+ }
34
+
35
+ docker run --rm -w " $RUN_DIR " -v " $RUN_DIR :$RUN_DIR " " $ORG /$IMAGE :$VERSION " " $@ "
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ me=$( basename " $0 " )
4
+
5
+ # Run shellcheck on all the shell-ish files in the tree
6
+ patterns=(' *.bash*' ' bash*'
7
+ ' *.ksh*' ' ksh*'
8
+ ' *.zsh*' ' zsh*'
9
+ ' .zlogin*' ' zlogin*'
10
+ ' .zlogout*' ' zlogout*'
11
+ ' .zprofile*' ' zprofile*'
12
+ ' *.sh' ' .shlib*' ' shlib*'
13
+ ' .profile*' ' profile*'
14
+ ' suid_profile' )
15
+
16
+ # excluding these directories (e.g. third_party/* )
17
+ excludes=()
18
+
19
+ # shellcheck disable=SC1091
20
+ [[ -f .shellcheck_tree ]] && . .shellcheck_tree
21
+
22
+ [[ ${*/ --help// } != " ${* } " ]] && {
23
+ echo " Usage: $me <OPTIONS>
24
+
25
+ Shellcheck all scripts in the tree.
26
+
27
+ Options:
28
+ --git shellcheck via git ls-files, default is 'find .'
29
+ --help get this message
30
+
31
+ "
32
+ exit 0
33
+ }
34
+
35
+ if [[ ${*/ --git// } != " ${* } " ]]; then
36
+ #
37
+ # To run on git-files only
38
+ #
39
+ git ls-files -- " ${patterns[@]} " | while read -r file; do
40
+ for exclude in " ${excludes[@]} " ; do
41
+ [[ $file =~ $exclude ]] && continue 2
42
+ done
43
+ shellcheck -f gcc " $file "
44
+ done
45
+ else
46
+ #
47
+ # use find
48
+ #
49
+ exclude_args=()
50
+ for exclude in " ${excludes[@]} " ; do
51
+ exclude_args+=(' !' -path " ./$exclude " -a)
52
+ done
53
+
54
+ pattern_args=()
55
+ for pattern in " ${patterns[@]} " ; do
56
+ pattern_args+=(-o -name " $pattern " )
57
+ done
58
+
59
+ find . " ${exclude_args[@]} " ' (' " ${pattern_args[@]: 1} " ' )' -exec shellcheck -f gcc {} +
60
+ fi
You can’t perform that action at this time.
0 commit comments