From faac4cf2ea42c265e6b4ba133e35d0476680978a Mon Sep 17 00:00:00 2001 From: Daniel Baston Date: Fri, 28 Sep 2018 14:13:34 +0000 Subject: [PATCH] Add Travis build matrix using prebuilt Docker images git-svn-id: http://svn.osgeo.org/postgis/trunk@16848 b70326c6-7e19-0410-871a-916f4a2858ee --- .github/codecov_env.bash | 223 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 90 ++++------------ ci/travis/run_tests.sh | 22 ++++ liblwgeom/lwspheroid.c | 2 +- 4 files changed, 268 insertions(+), 69 deletions(-) create mode 100644 .github/codecov_env.bash create mode 100644 ci/travis/run_tests.sh diff --git a/.github/codecov_env.bash b/.github/codecov_env.bash new file mode 100644 index 000000000..b3f48e716 --- /dev/null +++ b/.github/codecov_env.bash @@ -0,0 +1,223 @@ +#!/usr/bin/env bash + +# Apache License Version 2.0, January 2004 +# https://github.com/codecov/codecov-bash/blob/master/LICENSE + +set -e +o pipefail + +VERSION="0b37652" + +add(){ + if [ ! -z "$1" ]; + then + echo -n "-e $1 " + fi +} + +add "CODECOV_ENV" +add "CODECOV_TOKEN" +add "CODECOV_URL" +add "CODECOV_SLUG" +add "VCS_COMMIT_ID" +add "VCS_BRANCH_NAME" +add "VCS_PULL_REQUEST" +add "VCS_SLUG" +add "VCS_TAG" +add "CI_BUILD_URL" +add "CI_BUILD_ID" +add "CI_JOB_ID" + +if [ "$JENKINS_URL" != "" ]; +then + add "JENKINS_URL" + add "ghprbSourceBranch" + add "GIT_BRANCH" + add "ghprbActualCommit" + add "GIT_COMMIT" + add "CHANGE_ID" + add "BRANCH_NAME" + add "BUILD_NUMBER" + add "ghprbPullId" + add "BUILD_URL" + +elif [ "$CI" = "true" ] && [ "$TRAVIS" = "true" ] && [ "$SHIPPABLE" != "true" ]; +then + add "CI" + add "TRAVIS" + add "SHIPPABLE" + add "TRAVIS_BRANCH" + add "TRAVIS_COMMIT" + add "TRAVIS_JOB_NUMBER" + add "TRAVIS_PULL_REQUEST" + add "TRAVIS_JOB_ID" + add "TRAVIS_REPO_SLUG" + add "TRAVIS_TAG" + add "TRAVIS_OS_NAME" + +elif [ "$CI" = "true" ] && [ "$CI_NAME" = "codeship" ]; +then + add "CI" + add "CI_NAME" + add "CI_BRANCH" + add "CI_BUILD_NUMBER" + add "CI_BUILD_URL" + add "CI_COMMIT_ID" + +elif [ "$TEAMCITY_VERSION" != "" ]; +then + add "TEAMCITY_VERSION" + add "TEAMCITY_BUILD_BRANCH" + add "TEAMCITY_BUILD_ID" + add "TEAMCITY_BUILD_URL" + add "TEAMCITY_BUILD_COMMIT" + add "TEAMCITY_BUILD_COMMIT" + add "BUILD_VCS_NUMBER" + add "TEAMCITY_BUILD_REPOSITORY" + +elif [ "$CI" = "true" ] && [ "$CIRCLECI" = "true" ]; +then + add "CI" + add "CIRCLECI" + add "CIRCLE_BRANCH" + add "CIRCLE_BUILD_NUM" + add "CIRCLE_NODE_INDEX" + add "CIRCLE_PROJECT_USERNAME" + add "CIRCLE_PROJECT_REPONAME" + add "CIRCLE_REPOSITORY_URL" + add "CIRCLE_PR_NUMBER" + add "CIRCLE_SHA1" + add "CIRCLE_ARTIFACTS" + add "CIRCLE_TEST_REPORTS" + +elif [ "$BUDDYBUILD_BRANCH" != "" ]; +then + add "BUDDYBUILD_BRANCH" + add "BUDDYBUILD_BUILD_NUMBER" + add "BUDDYBUILD_BUILD_ID" + add "BUDDYBUILD_APP_ID" + +elif [ "${bamboo_planRepository_revision}" != "" ]; +then + add "bamboo_planRepository_revision" + add "bamboo_planRepository_branch" + add "bamboo_buildNumber" + add "bamboo_buildResultsUrl" + add "bamboo_planRepository_repositoryUrl" + +elif [ "$CI" = "true" ] && [ "$BITRISE_IO" = "true" ]; +then + add "CI" + add "BITRISE_IO" + add "BITRISE_GIT_BRANCH" + add "BITRISE_BUILD_NUMBER" + add "BITRISE_BUILD_URL" + add "BITRISE_PULL_REQUEST" + add "BITRISE_GIT_COMMIT" + +elif [ "$CI" = "true" ] && [ "$SEMAPHORE" = "true" ]; +then + add "CI" + add "SEMAPHORE" + add "BRANCH_NAME" + add "SEMAPHORE_BUILD_NUMBER" + add "SEMAPHORE_CURRENT_THREAD" + add "PULL_REQUEST_NUMBER" + add "SEMAPHORE_REPO_SLUG" + add "REVISION" + add "SEMAPHORE_TRIGGER_SOURCE" + +elif [ "$CI" = "true" ] && [ "$BUILDKITE" = "true" ]; +then + add "CI" + add "BUILDKITE" + add "BUILDKITE_BRANCH" + add "BUILDKITE_BUILD_NUMBER" + add "BUILDKITE_JOB_ID" + add "BUILDKITE_BUILD_URL" + add "BUILDKITE_PROJECT_SLUG" + add "BUILDKITE_COMMIT" + +elif [ "$CI" = "drone" ]; +then + add "CI" + add "DRONE_BRANCH" + add "DRONE_BUILD_NUMBER" + add "DRONE_BUILD_LINK" + add "DRONE_PULL_REQUEST" + add "DRONE_JOB_NUMBER" + add "DRONE_TAG" + add "CI_BUILD_URL" + +elif [ "$HEROKU_TEST_RUN_BRANCH" != "" ]; +then + add "HEROKU_TEST_RUN_BRANCH" + add "HEROKU_TEST_RUN_ID" + +elif [ "$CI" = "True" ] && [ "$APPVEYOR" = "True" ]; +then + add "CI" + add "APPVEYOR" + add "APPVEYOR_REPO_BRANCH" + add "APPVEYOR_JOB_ID" + add "APPVEYOR_PULL_REQUEST_NUMBER" + add "APPVEYOR_ACCOUNT_NAME" + add "APPVEYOR_PROJECT_SLUG" + add "APPVEYOR_BUILD_VERSION" + add "APPVEYOR_REPO_NAME" + add "APPVEYOR_REPO_COMMIT" + +elif [ "$CI" = "true" ] && [ "$WERCKER_GIT_BRANCH" != "" ]; +then + add "CI" + add "WERCKER_GIT_BRANCH" + add "WERCKER_MAIN_PIPELINE_STARTED" + add "WERCKER_GIT_OWNER" + add "WERCKER_GIT_REPOSITORY" + add "WERCKER_GIT_COMMIT" + +elif [ "$CI" = "true" ] && [ "$MAGNUM" = "true" ]; +then + add "CI" + add "MAGNUM" + add "CI_BRANCH" + add "CI_BUILD_NUMBER" + add "CI_COMMIT" + +elif [ "$SHIPPABLE" = "true" ]; +then + add "SHIPPABLE" + add "HEAD_BRANCH" + add "BRANCH" + add "BUILD_NUMBER" + add "BUILD_URL" + add "PULL_REQUEST" + add "REPO_FULL_NAME" + add "COMMIT" + +elif [ "$TDDIUM" != "" ]; +then + add "TDDIUM" + add "TDDIUM_CURRENT_COMMIT" + add "TDDIUM_CURRENT_BRANCH" + add "TDDIUM_TID" + add "TDDIUM_PR_ID" + +elif [ "$GREENHOUSE" = "true" ]; +then + add "GREENHOUSE" + add "GREENHOUSE_BRANCH" + add "GREENHOUSE_BUILD_NUMBER" + add "GREENHOUSE_BUILD_URL" + add "GREENHOUSE_PULL_REQUES" + add "GREENHOUSE_COMMIT" + add "GREENHOUSE_EXPORT_DIR" + +elif [ "$GITLAB_CI" != "" ]; +then + add "GITLAB_CI" + add "CI_BUILD_REF_NAME" + add "CI_BUILD_ID" + add "CI_BUILD_REPO" + add "CI_BUILD_REF" + +fi diff --git a/.travis.yml b/.travis.yml index 436f00f60..80421da4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,77 +1,31 @@ -env: - matrix: - - CFLAGS="-g -O1" MATRIX_EVAL="touch check-no-trailing-blanks" - - CFLAGS="-g -O2 -fstack-protector -Wformat -Werror=format-security" LDFLAGS="-Wl,-Bsymbolic-functions -Wl,-z,relro" - - CFLAGS="-g -O3 -mtune=generic -fno-omit-frame-pointer -Werror -Wall -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-unknown-warning-option -Wno-cast-function-type" - - CFLAGS="-g -O0 --coverage -fprofile-arcs -ftest-coverage" LDFLAGS="--coverage -fprofile-arcs -ftest-coverage" CONFIGURE_FLAGS="--enable-debug" - -addons: - apt: - sources: - - sourceline: 'deb http://apt.postgresql.org/pub/repos/apt bionic-pgdg 11' - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' - packages: - - eatmydata - -before_install: - - eval "${MATRIX_EVAL}" - - sudo sh -c "echo /usr/lib/x86_64-linux-gnu/libeatmydata.so >> /etc/ld.so.preload" - - sudo service postgresql stop - - - curl -sSfL https://github.com/mapbox/logbt/archive/v2.0.3.tar.gz | sudo tar --gunzip --extract --strip-components=1 --exclude="*md" --exclude="test*" --directory=/usr/local - - curl -sSfL https://raw.githubusercontent.com/mapbox/logbt/30c554dd37b6c96c23fc424f75910fc6d6696f00/bin/logbt | sudo tee /usr/local/bin/logbt > /dev/null - - sudo logbt --setup - - - sudo apt-get remove postgresql-9.4 postgresql-9.5 postgresql-9.6 postgresql-10 postgresql-client-9.4 postgresql-client-9.5 postgresql-client-9.6 postgresql-client-10 - - sudo add-apt-repository --yes ppa:ubuntugis/ppa - - sudo add-apt-repository --yes ppa:ubuntugis/ubuntugis-unstable - - sudo sh -c "echo deb http://archive.ubuntu.com/ubuntu/ cosmic main restricted universe multiverse >> /etc/apt/sources.list" - - sudo apt-get update -qq - - mkdir -p /home/travis/deb && touch /home/travis/deb/__ && sudo cp -n /home/travis/deb/* /var/cache/apt/archives || true - - sudo apt-get install -y --allow-unauthenticated --no-install-recommends --no-install-suggests postgresql-11 postgresql-client-11 postgresql-server-dev-11 postgresql-11-dbgsym libproj-dev libprotobuf-c-dev protobuf-c-compiler libc++abi-dev libc++-dev libgcc1-dbg libsfcgal1 libsfcgal-dev libxml2-utils libcunit1-dev xsltproc docbook-xsl docbook-mathml dblatex libgeos-dev libjson-c-dev libgdal-dev gdb libc6-dbg gcc - - - cp -n /var/cache/apt/archives/* /home/travis/deb || true - - - echo "postgres soft core unlimited" | sudo tee -a /etc/security/limits.conf - - echo "postgres hard core unlimited" | sudo tee -a /etc/security/limits.conf - - echo "pg_ctl_options = '-c'" | sudo tee /etc/postgresql/11/main/pg_ctl.conf - - sudo service postgresql stop - - sudo chown -hRL --from=postgres travis:travis /etc /var /tmp - - sudo usermod -u 1000 postgres - - sudo adduser travis ssl-cert - - sudo service postgresql start - - sudo service postgresql status - - sudo -u postgres createuser --superuser travis - - - sudo ldconfig - -after_failure: - - sudo head -n1000 /var/log/postgresql/postgresql-11-main.log - -after_success: - - bash .github/codecov.bash +services: + - docker +sudo: false language: c -compiler: gcc - -dist: xenial +env: + - tag=latest + - tag=pg11-geos37-gdal23-proj52 + - tag=pg10-geos36-gdal23-proj49 + - tag=pg96-geos36-gdal22-proj49 + - tag=pg95-geos36-gdal22-proj49 + - tag=pg94-geos35-gdal111-proj48 -cache: - ccache: true - directories: - - /home/travis/deb +matrix: + allow_failures: + - env: tag=latest script: - - ./autogen.sh - - ./configure CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" $CONFIGURE_FLAGS || cat config.log - - make -j - - chmod 755 /home/travis - - logbt -- make check "RUNTESTFLAGS=--verbose" - - logbt -- make check "RUNTESTFLAGS='--dumprestore --verbose'" - - sudo make install - - logbt -- make installcheck "RUNTESTFLAGS=--verbose" - - logbt -- make installcheck "RUNTESTFLAGS=--dumprestore --verbose" + - echo "FROM postgis/postgis-build-env:${tag}" > Dockerfile + - echo "ADD --chown=postgres:postgres . /src/postgis" >> Dockerfile + - echo "CMD ci/travis/run_tests.sh && bash .github/codecov.bash" >> Dockerfile + - docker build -t pgtest . + - ci_env=`bash .github/codecov_env.bash` + - docker run $ci_env --name pgtest-${TRAVIS_BUILD_NUMBER} pgtest + +after_success: + - docker rm pgtest-${TRAVIS_BUILD_NUMBER} notifications: email: false diff --git a/ci/travis/run_tests.sh b/ci/travis/run_tests.sh new file mode 100644 index 000000000..d7637274a --- /dev/null +++ b/ci/travis/run_tests.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e + +WARNINGS="-Werror -Wall -Wextra -Wformat -Werror=format-security" +WARNINGS_DISABLED="-Wno-unused-parameter -Wno-implicit-fallthrough -Wno-unknown-warning-option -Wno-cast-function-type" + +CFLAGS_STD="-g -O2 -mtune=generic -fno-omit-frame-pointer ${WARNINGS} ${WARNINGS_DISABLED}" +LDFLAGS_STD="-Wl,-Bsymbolic-functions -Wl,-z,relro" + +CFLAGS_COV="-g -O0 --coverage" +LDFLAGS_COV="--coverage" + +/usr/local/pgsql/bin/pg_ctl -l /tmp/logfile start +./autogen.sh + +CFLAGS="${CFLAGS_STD}" LDFLAGS="${LDFLAGS_COV}" ./configure +make -j2 +make check + +CFLAGS="${CFLAGS_COV}" LDFLAGS="${LDFLAGS_COV}" ./configure +make -j2 +make check diff --git a/liblwgeom/lwspheroid.c b/liblwgeom/lwspheroid.c index 66322917a..dcd44e7f9 100644 --- a/liblwgeom/lwspheroid.c +++ b/liblwgeom/lwspheroid.c @@ -495,7 +495,7 @@ static double ptarray_area_spheroid(const POINTARRAY *pa, const SPHEROID *sphero { GEOGRAPHIC_POINT a, b; POINT2D p; - int i; + uint32_t i; double area = 0.0; GBOX gbox2d; int in_south = LW_FALSE; -- 2.40.0