File tree Expand file tree Collapse file tree 3 files changed +64
-8
lines changed Expand file tree Collapse file tree 3 files changed +64
-8
lines changed Original file line number Diff line number Diff line change
1
+ name : " Coding Standards"
2
+
3
+ on :
4
+ pull_request :
5
+ branches :
6
+ - " v*.*"
7
+ - " master"
8
+ push :
9
+ branches :
10
+ - " v*.*"
11
+ - " master"
12
+
13
+ jobs :
14
+ coding-standards :
15
+ name : " Coding Standards"
16
+ runs-on : " ubuntu-20.04"
17
+
18
+ strategy :
19
+ matrix :
20
+ php-version :
21
+ - " 7.4"
22
+
23
+ steps :
24
+ - name : " Checkout"
25
+ uses : " actions/checkout@v2"
26
+ with :
27
+ submodules : true
28
+
29
+ - name : " Install PHP"
30
+ uses : " shivammathur/setup-php@v2"
31
+ with :
32
+ php-version : " ${{ matrix.php-version }}"
33
+ extensions : " :mongodb"
34
+ tools : " phpize"
35
+
36
+ - name : " Configure driver"
37
+ run : .github/workflows/configure.sh
38
+
39
+ - name : " Run clang-format"
40
+ run : " make format-check"
Original file line number Diff line number Diff line change 1
- .PHONY : coverage test-clean package package.xml format format-changed
1
+ .PHONY : coverage test-clean package package.xml format format-changed format-check
2
2
3
3
DATE =` date +%Y-%m-%d--%H-%M-%S `
4
4
MONGODB_VERSION =$(shell php -n -dextension=modules/mongodb.so -r 'echo MONGODB_VERSION;')
@@ -70,6 +70,9 @@ format:
70
70
format-changed :
71
71
$(top_srcdir ) /scripts/clang-format.sh changed
72
72
73
+ format-check :
74
+ $(top_srcdir ) /scripts/clang-format.sh check
75
+
73
76
distcheck : package test-virtual
74
77
75
78
test-virtual : package
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
- if test x" $1 " = x; then
3
+ CLANG_ARGS=" -Werror"
4
+
5
+ if test x" $1 " = xchanged; then
6
+ FILES1=` git ls-files | grep -v " src/contrib" | grep ' \.[ch]$' `
7
+ FILES2=` git ls-files --others --exclude-standard | grep -v " src/contrib" | grep ' \.[ch]$' `
8
+ FILES=" $FILES1 $FILES2 "
9
+ else
4
10
FILES1=` git ls-files | grep -v " src/contrib" | grep ' \.[ch]$' `
5
11
FILES2=` git ls-files --others --exclude-standard | grep -v " src/contrib" | grep ' \.[ch]$' `
6
12
FILES=" $FILES1 $FILES2 "
7
13
fi
8
- if test x" $1 " = xchanged; then
9
- FILES1=` git diff --name-only | grep -v " src/contrib" | grep ' \.[ch]$' `
10
- FILES2=` git diff --cached --name-only | grep -v " src/contrib" | grep ' \.[ch]$' `
11
- FILES3=` git ls-files --others --exclude-standard | grep ' \.[ch]$' `
12
- FILES=" $FILES1 $FILES2 $FILES3 "
14
+
15
+ if test x" $1 " = xcheck; then
16
+ CLANG_ARGS=" $CLANG_ARGS -n"
13
17
fi
14
18
15
19
# Find clang-format, we prefer -6.0, but also allow binaries without -suffix as
@@ -33,7 +37,16 @@ if [ $VERSION_MAJOR -lt 6 ]; then
33
37
exit
34
38
fi
35
39
40
+ FAILURE=" "
41
+
36
42
# Run formatter
37
43
for i in $FILES ; do
38
- $CLANG_FORMAT -i $i
44
+ $CLANG_FORMAT $CLANG_ARGS -i $i
45
+ [ $? -eq 0 ] || FAILURE=" yes"
39
46
done
47
+
48
+ if [ -z " $FAILURE " ]; then
49
+ exit 0
50
+ fi
51
+
52
+ exit 1
You can’t perform that action at this time.
0 commit comments