File tree 2 files changed +28
-7
lines changed
2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
3
echo " Starting check shell code issues ..."
4
- find . -name " *.sh" | xargs --no-run-if-empty shellcheck || exit 1
4
+ find . -name " *.sh" -print0 | xargs -0 --no-run-if-empty shellcheck || exit 1
5
5
6
6
echo " Starting check Rust code format ..."
7
7
has_issues=0
8
8
edition=2018
9
9
10
10
for file in $( git diff --name-only --staged | grep ' \.rs$' ) ; do
11
- if [ -f ${file} ] && ! rustfmt --edition ${edition} --check --color auto ${file} ; then
11
+ if [ -f " ${file} " ] && ! rustfmt --edition ${edition} --check --color auto " ${file} " ; then
12
12
echo " "
13
13
has_issues=1
14
- rustfmt --edition ${edition} ${file}
14
+ rustfmt --edition ${edition} " ${file} "
15
15
fi
16
16
done
17
17
18
18
if [ ${has_issues} -eq 0 ]; then
19
19
exit 0
20
20
fi
21
21
22
- echo ' Your code contains formatting issues and has been corrected. Please run `git add` to add them and commit them.'
22
+ echo " Your code contains formatting issues and has been corrected. Please run \ ` git add\ ` to add them and commit them."
23
23
exit 1
Original file line number Diff line number Diff line change @@ -20,10 +20,30 @@ jobs:
20
20
- name : Check
21
21
shell : bash
22
22
run : |
23
- # Run code formatting check
23
+ set +o pipefail
24
+
25
+ # Determine the two commits to be compared
26
+ if [ "$GITHUB_BASE_REF" ]; then # is pull_request event
27
+ before_commit=${{ github.event.pull_request.base.sha }}
28
+ else # is push event
29
+ if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
30
+ before_commit="HEAD~1"
31
+ else
32
+ before_commit=${{ github.event.before }}
33
+ fi
34
+ fi
35
+ after_commit=$GITHUB_SHA
36
+ echo "before_commit: ${before_commit} after_commit: ${after_commit}"
37
+ git fetch origin "${before_commit}" --depth=1
38
+
39
+ # Run Shell code issues check
40
+ git diff --name-only "${before_commit}".."${after_commit}" | grep '\.rs$' | xargs --no-run-if-empty ls -1df 2>/dev/null | xargs --no-run-if-empty shellcheck || { echo "shell check failed and exit"; exit 1; }
41
+ echo 'Shell code issues check passed.'
42
+
43
+ # Run Rust code formatting check
24
44
has_issues=0
25
- for file in $(git diff --name-only ${{ github.event.before }}..${{ github.event.after }} | grep '\.rs$'); do
26
- if [ -f ${file} ] && ! rustfmt --edition 2018 --check --color auto ${file}; then
45
+ for file in $(git diff --name-only "${before_commit}".."${after_commit}" | grep '\.rs$'); do
46
+ if [ -f " ${file}" ] && ! rustfmt --edition 2018 --check --color auto " ${file}" ; then
27
47
echo ""
28
48
has_issues=1
29
49
fi
34
54
echo 'Code formatting issues detected.'
35
55
exit 1
36
56
fi
57
+
37
58
# Run clippy check
38
59
cargo clippy
39
60
- name : Build
You can’t perform that action at this time.
0 commit comments