Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: do not throw away exit codes #275

Merged
merged 1 commit into from Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -3,6 +3,7 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/bin/ export-ignore
/docs/ export-ignore
/phpcs.xml.dist export-ignore
/tests/ export-ignore
Expand Down
13 changes: 2 additions & 11 deletions Makefile
@@ -1,21 +1,12 @@
.PHONY: test test-report test-fix update-compatibility-patch

PHP_VERSION:=$(shell php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")
PATCH_FILE="tests/php$(PHP_VERSION)-compatibility.patch"

test: test-report test-fix

test-report: vendor
@if [ -f "$(PATCH_FILE)" ]; then git apply $(PATCH_FILE) ; fi
@vendor/bin/phpcs `find tests/input/* | sort` --report=summary --report-file=phpcs.log; diff -u tests/expected_report.txt phpcs.log; if [ $$? -ne 0 ] && [ -f "$(PATCH_FILE)" ]; then git apply -R $(PATCH_FILE) ; exit 1; fi
@if [ -f "$(PATCH_FILE)" ]; then git apply -R $(PATCH_FILE) ; fi
./bin/test-report

test-fix: vendor
@if [ -f "$(PATCH_FILE)" ]; then git apply $(PATCH_FILE) ; fi
@cp -R tests/input/ tests/input2/
@vendor/bin/phpcbf tests/input2; diff -u tests/input2 tests/fixed; if [ $$? -ne 0 ]; then rm -rf tests/input2/; if [ -f "$(PATCH_FILE)" ]; then git apply -R $(PATCH_FILE) ; fi; exit 1; fi
@rm -rf tests/input2/;
@if [ -f "$(PATCH_FILE)" ]; then git apply -R $(PATCH_FILE) ; fi
./bin/test-fix

update-compatibility-patch-74:
@git apply tests/php74-compatibility.patch
Expand Down
7 changes: 7 additions & 0 deletions bin/cleanup
@@ -0,0 +1,7 @@
#!/bin/bash

greg0ire marked this conversation as resolved.
Show resolved Hide resolved
. bin/patch-file

rm -f phpcs.log
rm -rf tests/input2/
if [ -f "$PATCH_FILE" ]; then git apply -R "$PATCH_FILE" ; fi
5 changes: 5 additions & 0 deletions bin/init
@@ -0,0 +1,5 @@
#!/bin/bash

. bin/patch-file

if [ -f "$PATCH_FILE" ]; then git apply "$PATCH_FILE" ; fi
6 changes: 6 additions & 0 deletions bin/patch-file
@@ -0,0 +1,6 @@
#!/bin/bash

PHP_VERSION="$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")"
PATCH_FILE="tests/php$PHP_VERSION-compatibility.patch"

export PATCH_FILE;
12 changes: 12 additions & 0 deletions bin/test-fix
@@ -0,0 +1,12 @@
#!/bin/bash

set -eu

bin/init
trap 'bin/cleanup' EXIT

set +e

cp -R tests/input/ tests/input2/
vendor/bin/phpcbf tests/input2
diff -u tests/input2 tests/fixed
12 changes: 12 additions & 0 deletions bin/test-report
@@ -0,0 +1,12 @@
#!/bin/bash

set -eu

bin/init
trap 'bin/cleanup' EXIT

set +e

# shellcheck disable=SC2046
vendor/bin/phpcs $(find tests/input/* | sort) --report=summary --report-file=phpcs.log
diff -u tests/expected_report.txt phpcs.log
7 changes: 4 additions & 3 deletions tests/expected_report.txt
Expand Up @@ -35,19 +35,20 @@ tests/input/semicolon_spacing.php 3 0
tests/input/single-line-array-spacing.php 5 0
tests/input/spread-operator.php 6 0
tests/input/static-closures.php 1 0
tests/input/strings.php 1 0
greg0ire marked this conversation as resolved.
Show resolved Hide resolved
tests/input/superfluous-naming.php 11 0
tests/input/test-case.php 8 0
tests/input/trailing_comma_on_array.php 1 0
tests/input/traits-uses.php 11 0
tests/input/type-hints.php 4 0
tests/input/type-hints.php 7 0
tests/input/UnusedVariables.php 1 0
tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
----------------------------------------------------------------------
PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


10 changes: 5 additions & 5 deletions tests/php74-compatibility.patch
Expand Up @@ -23,26 +23,26 @@ index c644926..7d122d2 100644
tests/input/null_coalesce_operator.php 3 0
tests/input/optimized-functions.php 1 0
tests/input/PropertyDeclaration.php 6 0
@@ -35,19 +35,20 @@ tests/input/semicolon_spacing.php 3 0
@@ -35,20 +35,20 @@ tests/input/semicolon_spacing.php 3 0
tests/input/single-line-array-spacing.php 5 0
tests/input/spread-operator.php 6 0
tests/input/static-closures.php 1 0
+tests/input/strings.php 1 0
tests/input/strings.php 1 0
tests/input/superfluous-naming.php 11 0
tests/input/test-case.php 8 0
tests/input/trailing_comma_on_array.php 1 0
tests/input/traits-uses.php 11 0
-tests/input/type-hints.php 4 0
-tests/input/type-hints.php 7 0
+tests/input/type-hints.php 8 0
tests/input/UnusedVariables.php 1 0
tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 390 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 324 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Expand Down
10 changes: 5 additions & 5 deletions tests/php80-compatibility.patch
Expand Up @@ -2,7 +2,7 @@ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index 476a58b..54630dd 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -14,40 +14,43 @@ tests/input/constants-var.php 6 0
@@ -14,41 +14,43 @@ tests/input/constants-var.php 6 0
tests/input/ControlStructures.php 28 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
Expand Down Expand Up @@ -36,24 +36,24 @@ index 476a58b..54630dd 100644
tests/input/single-line-array-spacing.php 5 0
tests/input/spread-operator.php 6 0
tests/input/static-closures.php 1 0
+tests/input/strings.php 1 0
tests/input/strings.php 1 0
tests/input/superfluous-naming.php 11 0
tests/input/test-case.php 8 0
tests/input/trailing_comma_on_array.php 1 0
+tests/input/TrailingCommaOnFunctions.php 2 0
tests/input/traits-uses.php 11 0
-tests/input/type-hints.php 4 0
-tests/input/type-hints.php 7 0
+tests/input/type-hints.php 9 0
tests/input/UnusedVariables.php 1 0
tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
-tests/input/UselessConditions.php 20 0
+tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
-A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 412 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 346 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Expand Down
10 changes: 5 additions & 5 deletions tests/php81-compatibility.patch
Expand Up @@ -2,7 +2,7 @@ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index 476a58b..54630dd 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -14,40 +14,43 @@ tests/input/constants-var.php 6 0
@@ -14,41 +14,43 @@ tests/input/constants-var.php 6 0
tests/input/ControlStructures.php 28 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
Expand Down Expand Up @@ -36,24 +36,24 @@ index 476a58b..54630dd 100644
tests/input/single-line-array-spacing.php 5 0
tests/input/spread-operator.php 6 0
tests/input/static-closures.php 1 0
+tests/input/strings.php 1 0
tests/input/strings.php 1 0
tests/input/superfluous-naming.php 11 0
tests/input/test-case.php 8 0
tests/input/trailing_comma_on_array.php 1 0
+tests/input/TrailingCommaOnFunctions.php 2 0
tests/input/traits-uses.php 11 0
-tests/input/type-hints.php 4 0
-tests/input/type-hints.php 7 0
+tests/input/type-hints.php 9 0
tests/input/UnusedVariables.php 1 0
tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
-tests/input/UselessConditions.php 20 0
+tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
-A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 412 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 346 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Expand Down