From: mtmail Date: Wed, 11 Apr 2018 22:54:59 +0000 (+0200) Subject: get apt-get php-db package running on travis-ci (#973) X-Git-Tag: v3.2.0~92 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/3cdbcbff8f02d7b46dde503c32bc8327e4264f6f get apt-get php-db package running on travis-ci (#973) travis: /usr/bin/env php whenever calling PHP scripts to deal with phpenv --- diff --git a/.travis.yml b/.travis.yml index c67f155e..1184d283 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,8 +18,8 @@ before_script: script: - cd $TRAVIS_BUILD_DIR/build - if [[ $TEST_SUITE == "monaco" ]]; then wget --no-verbose --output-document=../data/monaco.osm.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf; fi - - if [[ $TEST_SUITE == "monaco" ]]; then ./utils/setup.php --osm-file ../data/monaco.osm.pbf --osm2pgsql-cache 1000 --all 2>&1 | grep -v 'ETA (seconds)'; fi - - if [[ $TEST_SUITE == "monaco" ]]; then ./utils/specialphrases.php --wiki-import | psql -d test_api_nominatim >/dev/null; fi + - if [[ $TEST_SUITE == "monaco" ]]; then /usr/bin/env php ./utils/setup.php --osm-file ../data/monaco.osm.pbf --osm2pgsql-cache 1000 --all 2>&1 | grep -v 'ETA (seconds)'; fi + - if [[ $TEST_SUITE == "monaco" ]]; then /usr/bin/env php ./utils/specialphrases.php --wiki-import | psql -d test_api_nominatim >/dev/null; fi - cd $TRAVIS_BUILD_DIR/test/php - if [[ $TEST_SUITE == "tests" ]]; then phpunit ./ ; fi - if [[ $TEST_SUITE == "tests" ]]; then phpcs --report-width=120 . ; fi diff --git a/test/bdd/environment.py b/test/bdd/environment.py index 90c75724..2bea3180 100644 --- a/test/bdd/environment.py +++ b/test/bdd/environment.py @@ -151,7 +151,8 @@ class NominatimEnvironment(object): self.run_nominatim_script('update', *args, **kwargs) def run_nominatim_script(self, script, *args, **kwargs): - cmd = [os.path.join(self.build_dir, 'utils', '%s.php' % script)] + cmd = ['/usr/bin/env', 'php', '-Cq'] + cmd.append(os.path.join(self.build_dir, 'utils', '%s.php' % script)) cmd.extend(['--%s' % x for x in args]) for k, v in kwargs.items(): cmd.extend(('--' + k.replace('_', '-'), str(v))) diff --git a/test/bdd/steps/queries.py b/test/bdd/steps/queries.py index 963aad4d..731dc1b5 100644 --- a/test/bdd/steps/queries.py +++ b/test/bdd/steps/queries.py @@ -236,8 +236,9 @@ class DetailsResponse(GenericResponse): def query_cmd(context, query, dups): """ Query directly via PHP script. """ - cmd = [os.path.join(context.nominatim.build_dir, 'utils', 'query.php'), - '--search', query] + cmd = ['/usr/bin/env', 'php'] + cmd.append(os.path.join(context.nominatim.build_dir, 'utils', 'query.php')) + cmd.extend(['--search', query]) # add more parameters in table form if context.table: for h in context.table.headings: @@ -282,7 +283,7 @@ def send_api_query(endpoint, params, fmt, context): if hasattr(context, 'http_headers'): env.update(context.http_headers) - cmd = ['/usr/bin/php-cgi', '-f'] + cmd = ['/usr/bin/env', 'php-cgi', '-f'] if context.nominatim.code_coverage_path: env['COV_SCRIPT_FILENAME'] = env['SCRIPT_FILENAME'] env['COV_PHP_DIR'] = os.path.join(context.nominatim.src_dir, "lib") @@ -307,7 +308,7 @@ def send_api_query(endpoint, params, fmt, context): + outp + "\n===============================\n") assert_equals(0, proc.returncode, - "query.php failed with message: %s\noutput: %s" % (err, outp)) + "%s failed with message: %s\noutput: %s" % (env['SCRIPT_FILENAME'], err, outp)) assert_equals(0, len(err), "Unexpected PHP error: %s" % (err)) @@ -392,7 +393,6 @@ def website_lookup_request(context, fmt, query): context.response = SearchResponse(outp, outfmt, status) - @step(u'(?Pless than|more than|exactly|at least|at most) (?P\d+) results? (?:is|are) returned') def validate_result_number(context, operator, number): eq_(context.response.errorcode, 200) diff --git a/vagrant/install-on-travis-ci.sh b/vagrant/install-on-travis-ci.sh index f156ea45..05681ae3 100755 --- a/vagrant/install-on-travis-ci.sh +++ b/vagrant/install-on-travis-ci.sh @@ -16,12 +16,32 @@ sudo apt-get install -y -qq libboost-dev libboost-system-dev \ libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\ libbz2-dev libpq-dev libgeos-c1 libgeos++-dev libproj-dev \ postgresql-server-dev-9.6 postgresql-9.6-postgis-2.3 postgresql-contrib-9.6 \ - apache2 php5 php5-pgsql php-pear php-db php5-intl + apache2 php5 php5-pgsql php5-intl php-pear -sudo apt-get install -y -qq python3-dev python3-pip python3-psycopg2 phpunit php5-cgi +sudo apt-get install -y -qq python3-dev python3-pip python3-psycopg2 php5-cgi pip3 install --quiet behave nose pytidylib psycopg2 -sudo pear -q install PHP_CodeSniffer + +# Travis uses phpenv to support multiple PHP versions. We need to make sure +# these packages get installed to the phpenv-set PHP (below /home/travis/.phpenv/), +# not the system PHP (/usr/bin/php) +sudo PHP_PEAR_PHP_BIN=`which php` pear -q install pear/PEAR-1.10.0 +sudo PHP_PEAR_PHP_BIN=`which php` pear -q install DB +sudo PHP_PEAR_PHP_BIN=`which php` pear -q install PHP_CodeSniffer +sudo PHP_PEAR_PHP_BIN=`which php` pear list +# re-populate the shims/ directory, e.g. adds phpcs +phpenv rehash +ls -la /home/travis/.phpenv/shims/ + +# $PHPENV_VERSION and $TRAVIS_PHP_VERSION are unset. +export PHPENV_VERSION=$(cat /home/travis/.phpenv/version) + +# add lib/php/pear to the PHP include path +tee /tmp/travis.php.ini << EOF +include_path = .:/home/travis/.phpenv/versions/$PHPENV_VERSION/share/pear:/home/travis/.phpenv/versions/$PHPENV_VERSION/lib/php/pear +EOF +phpenv config-add /tmp/travis.php.ini + sudo -u postgres createuser -S www-data