Skip to content

Commit bfa586e

Browse files
committed
Update travis build scripts
Fix a typo
1 parent e4c8479 commit bfa586e

File tree

3 files changed

+41
-55
lines changed

3 files changed

+41
-55
lines changed

.phan/config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use \Phan\Issue;
44

55
/**
6-
* This configuration will be read and overlayed on top of the
6+
* This configuration will be read and overlaid on top of the
77
* default configuration. Command line arguments will be applied
88
* after this file is read.
99
*

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ php:
44
- 7.0
55
- 7.1
66
- 7.2
7+
- 7.3.0RC1
8+
9+
# TODO: Clean up 'sudo: required' once https://github.com/travis-ci/travis-ci/issues/9717 is resolved
10+
dist: xenial
11+
sudo: required
712

813
cache:
914
directories:
1015
- $HOME/.composer/cache
16+
- $HOME/.cache/phan-ast/build
1117

1218
before_install:
19+
- sudo apt-get update -y
20+
- sudo apt-get install -y libzip4
1321
- ./tests/setup.sh
1422

1523
install:

tests/setup.sh

+32-54
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,45 @@
11
#!/usr/bin/env bash
2-
# php-ast installation and configuration script, taken from Etsy/Phan
2+
# php-ast installation and configuration script, taken from https://github.com/phan/phan
3+
# NOTE: You may want to replace all of this with `pecl install ast` or `pecl install ast-0.1.7`
4+
# in your own scripts to ensure stable versions are installed instead of development versions.
5+
set -xeu
6+
7+
if [[ "x$TRAVIS" == "x" ]]; then
8+
echo "This should only be run in travis"
9+
exit 1
10+
fi
311

4-
function build {
5-
phpize
6-
./configure
7-
make
8-
}
12+
# Ensure the build directory exist
13+
PHP_VERSION_ID=$(php -r "echo PHP_VERSION_ID;")
14+
PHAN_BUILD_DIR="$HOME/.cache/phan-ast-build"
15+
EXPECTED_AST_FILE="$PHAN_BUILD_DIR/build/php-ast-$PHP_VERSION_ID.so"
916

10-
function cleanBuild {
11-
make clean
12-
build
13-
}
17+
[[ -d "$PHAN_BUILD_DIR" ]] || mkdir -p "$PHAN_BUILD_DIR"
1418

15-
function install {
16-
make install
17-
echo "extension=ast.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
18-
}
19+
cd "$PHAN_BUILD_DIR"
1920

20-
# Ensure the build directory exists
21-
[[ -d "build" ]] || mkdir build
21+
if [[ ! -e "$EXPECTED_AST_FILE" ]]; then
22+
echo "No cached extension found. Building..."
23+
rm -rf php-ast build
24+
mkdir build
2225

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
26+
git clone --depth 1 https://github.com/nikic/php-ast.git php-ast
3227

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
28+
pushd php-ast
29+
# Install the ast extension
30+
phpize
31+
./configure
32+
make
3933

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
34+
cp modules/ast.so "$EXPECTED_AST_FILE"
35+
popd
36+
else
37+
echo "Using cached extension."
38+
fi
5839

59-
# No matter what, we still have to move the .so into place and enable it.
60-
install
61-
popd
40+
php -r 'function_exists("ast\parse_code") || exit("Failed to enable php-ast");'
6241

63-
# Note the PHP version for later builds.
64-
php -r "echo PHP_VERSION_ID;" > build/phpversion.txt
42+
echo "extension=$EXPECTED_AST_FILE" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
6543

6644
# Disable xdebug, since we aren't currently gathering code coverage data and
6745
# having xdebug slows down Composer a bit.

0 commit comments

Comments
 (0)