Skip to content

Commit 28e95ce

Browse files
authored
Merge pull request #1 from TysonAndre/add-travis
Add a travis config, to show the number of passing/failing tests
2 parents 78b4ac6 + 9f65bc8 commit 28e95ce

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: php
2+
3+
php:
4+
- 7.1
5+
6+
cache:
7+
directories:
8+
- $HOME/.composer/cache
9+
10+
before_install:
11+
- ./tests/setup.sh
12+
- composer validate
13+
14+
install:
15+
- composer --prefer-dist install
16+
17+
script:
18+
- ./test

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
PHP-Parser to php-ast
22
=====================
33

4-
This is incomplete.
4+
[![Build Status](https://travis-ci.org/TysonAndre/php-parser-to-php-ast.svg?branch=master)](https://travis-ci.org/TysonAndre/php-parser-to-php-ast)
5+
6+
This is incomplete. Only 6 of 28 tests are passing.

tests/setup.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
# php-ast installation and configuration script, taken from Etsy/Phan
3+
4+
function build {
5+
phpize
6+
./configure
7+
make
8+
}
9+
10+
function cleanBuild {
11+
make clean
12+
build
13+
}
14+
15+
function install {
16+
make install
17+
echo "extension=ast.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
18+
}
19+
20+
# Ensure the build directory exists
21+
[[ -d "build" ]] || mkdir build
22+
23+
# Ensure that the PHP version hasn't changed under us. If it has, we'll have to
24+
# rebuild the extension.
25+
if [[ -e "build/phpversion.txt" ]]; then
26+
if ! diff -q build/phpversion.txt <(php -r "echo PHP_VERSION_ID;"); then
27+
# Something has changed, so nuke the build/ast directory if it exists.
28+
echo "New version of PHP detected. Removing build/ast so we can do a fresh build."
29+
rm -rf build/ast
30+
fi
31+
fi
32+
33+
# Ensure that we have a copy of the ast extension source code.
34+
if [[ ! -e "build/ast/config.m4" ]]; then
35+
# If build/ast exists, but build/ast/config.m4 doesn't, nuke it and start over.
36+
[[ ! -d "build/ast" ]] || rm -rf build/ast
37+
git clone --depth 1 https://github.com/nikic/php-ast.git build/ast
38+
fi
39+
40+
# Install the ast extension
41+
pushd ./build/ast
42+
# If we don't have ast.so, we have to build it.
43+
if [[ ! -e "modules/ast.so" ]]; then
44+
echo "No cached extension found. Building..."
45+
build
46+
else
47+
# If there are new commits, we need to rebuild the extension.
48+
git fetch origin master
49+
newCommits=$(git rev-list HEAD...origin/master --count)
50+
if [[ "$newCommits" != "0" ]]; then
51+
echo "New commits found upstream. Updating and rebuilding..."
52+
git pull origin master
53+
cleanBuild
54+
else
55+
echo "Using cached extension."
56+
fi
57+
fi
58+
59+
# No matter what, we still have to move the .so into place and enable it.
60+
install
61+
popd
62+
63+
# Note the PHP version for later builds.
64+
php -r "echo PHP_VERSION_ID;" > build/phpversion.txt
65+
66+
# Disable xdebug, since we aren't currently gathering code coverage data and
67+
# having xdebug slows down Composer a bit.
68+
phpenv config-rm xdebug.ini

0 commit comments

Comments
 (0)