summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Mazoyer <gmazoyer@gravitons.in>2016-07-11 18:58:23 +0200
committerGuillaume Mazoyer <gmazoyer@gravitons.in>2016-07-11 18:58:23 +0200
commitb0c0a04f88416be87bff3f6ea9963295e69e50e9 (patch)
treebdd4cde71d521f7383b00c214fb06bdde285f609
parent6aceee36e5c1bb548b0f0f23ee3b51bd325c3a7f (diff)
Add build script to check syntax of php files.
-rw-r--r--.travis.yml3
-rw-r--r--scripts/cibuild.sh26
2 files changed, 29 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
index 4369807..d0eac46 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,3 +7,6 @@ php:
- 5.6
- 7.0
- hhvm
+
+script:
+ - ./scripts/cibuild.sh
diff --git a/scripts/cibuild.sh b/scripts/cibuild.sh
new file mode 100644
index 0000000..11e1fa2
--- /dev/null
+++ b/scripts/cibuild.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+EXIT=0
+
+# Output a line prefixed with a timestamp
+info() {
+ echo "$(date +'%F %T') |"
+}
+
+# Track number of seconds required to run script
+START=$(date +%s)
+echo "$(info) starting build checks."
+
+# Syntax check all php files
+SYNTAX=$(find . -name "*.php" -type f -exec php --syntax-check {} \; > /dev/null)
+if [[ ! -z ${SYNTAX} ]]; then
+ echo -e "${SYNTAX}"
+ echo -e "\n$(info) detected one or more syntax errors, failing build."
+ EXIT=1
+fi
+
+# Show build duration
+END=$(date +%s)
+echo "$(info) exiting with code ${EXIT} after $((${END} - ${START})) seconds."
+
+exit ${EXIT}