From f5a052505f801530c032343920f6f674f109dc1d Mon Sep 17 00:00:00 2001 From: Croydon Date: Sun, 29 Jul 2018 11:38:18 +0200 Subject: [PATCH 1/2] Travis: Add Conan testing & uploading --- .travis.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4625dfb087..3b7096353e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -117,6 +117,49 @@ matrix: - LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread - ENABLE_SANITIZER=1 - EXTRA_FLAGS="-stdlib=libc++ -g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" + # Conan testing and uploading + - compiler: gcc + env: CONAN=True + language: python + python: "3.6" + before_script: + - pip install -U pip + before_install: + - pip --version + install: + - pip install conan + script: + - conan create . benchmark/master@google/testing --build + after_success: + # If this build is NOT triggered by a pull request; AND got triggered by either a tag OR push to master + # and the following environment variables are set: + # CONAN_UPLOAD - a reference to the Conan repository e.g. https://bintray.com/google/conan + # CONAN_LOGIN_USERNAME - user for the upload e.g. upload_bot_username + # CONAN_PASSWORD - password for the CONAN_LOGIN_USERNAME; for Bintray this is the API key + # then upload the new recipe version to the Conan repository. + # + # For the tag pushes we are using for the + # version the tag name, removing the "v" + # channel "stable" + # For master pushes we are using for the + # version simply "master" + # channel "testing" + - if [[ "${TRAVIS_PULL_REQUEST}" == "false" && ( -n "${TRAVIS_TAG}" || "${TRAVIS_BRANCH}" == "master" ) && -n "${CONAN_UPLOAD}" && -n "${CONAN_LOGIN_USERNAME}" && -n "${CONAN_PASSWORD}" ]]; then + conan remote add benchmark ${CONAN_UPLOAD} --insert; + conan remote list; + + if [ -n "${TRAVIS_TAG}" ]; then + CONANVERSION=${TRAVIS_TAG//v}; + CONANREFERENCE=benchmark/${CONANVERSION}@google/stable; + conan export . ${CONANREFERENCE}; + else + CONANVERSION="master"; + CONANREFERENCE=benchmark/${CONANVERSION}@google/testing; + fi; + + conan user -p "${CONAN_PASSWORD}" -r benchmark "${CONAN_LOGIN_USERNAME}"; + conan upload --force -r benchmark --retry 3 --retry-wait 10 --confirm "${CONANREFERENCE}"; + fi; - os: osx osx_image: xcode8.3 compiler: clang From 866b12145cc9f9e9f2ba3732e7d18d2d7f72786c Mon Sep 17 00:00:00 2001 From: Croydon Date: Fri, 4 Jan 2019 05:22:51 +0100 Subject: [PATCH 2/2] Complete Conan packages building and uploading --- .travis.yml | 137 ++++++++++++++++++++++-------- appveyor.yml | 83 +++++++++++++----- conan/appveyor/build.py | 8 ++ conan/appveyor/install.py | 8 ++ conan/build.py | 48 +++++++++++ conan/ci/build.sh | 14 +++ conan/ci/install.sh | 22 +++++ conan/test_package/CMakeLists.txt | 2 +- 8 files changed, 264 insertions(+), 58 deletions(-) create mode 100644 conan/appveyor/build.py create mode 100644 conan/appveyor/install.py create mode 100644 conan/build.py create mode 100644 conan/ci/build.sh create mode 100644 conan/ci/install.sh diff --git a/.travis.yml b/.travis.yml index 3b7096353e..605290c644 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,38 @@ language: cpp env: global: - /usr/local/bin:$PATH + - CONAN_USERNAME="google" + - CONAN_PACKAGE_NAME="benchmark" + +conan-buildsteps: &conan-buildsteps + before_install: + # use this step if you desire to manipulate CONAN variables programmatically + # dummy to overwrite default build steps + - true + install: + - chmod +x ./conan/ci/install.sh + - ./conan/ci/install.sh + script: + - chmod +x ./conan/ci/build.sh + - ./conan/ci/build.sh + # the following are dummies to overwrite default build steps + before_script: + - true + after_success: + - true + if: tag IS present +conan-linux: &conan-linux + os: linux + dist: xenial + language: python + python: "3.7" + services: + - docker + <<: *conan-buildsteps +conan-osx: &conan-osx + os: osx + language: generic + <<: *conan-buildsteps matrix: include: @@ -117,26 +149,50 @@ matrix: - LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread - ENABLE_SANITIZER=1 - EXTRA_FLAGS="-stdlib=libc++ -g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" + - os: osx + osx_image: xcode8.3 + compiler: clang + env: + - COMPILER=clang++ BUILD_TYPE=Debug + - os: osx + osx_image: xcode8.3 + compiler: clang + env: + - COMPILER=clang++ BUILD_TYPE=Release + - os: osx + osx_image: xcode8.3 + compiler: clang + env: + - COMPILER=clang++ BUILD_TYPE=Release BUILD_32_BITS=ON + - os: osx + osx_image: xcode8.3 + compiler: gcc + env: + - COMPILER=g++-7 C_COMPILER=gcc-7 BUILD_TYPE=Debug # Conan testing and uploading - compiler: gcc env: CONAN=True language: python - python: "3.6" - before_script: - - pip install -U pip + dist: xenial + python: "3.7" before_install: - - pip --version + - pip install -U pip install: - pip install conan + before_script: + - pip --version + - conan --version script: - - conan create . benchmark/master@google/testing --build + - CONAN_FULL_REFERENCE=${CONAN_PACKAGE_NAME}/master@${CONAN_USERNAME}/testing + - conan create . ${CONAN_FULL_REFERENCE} --build --test-folder "conan/test_package" after_success: # If this build is NOT triggered by a pull request; AND got triggered by either a tag OR push to master # and the following environment variables are set: - # CONAN_UPLOAD - a reference to the Conan repository e.g. https://bintray.com/google/conan + # CONAN_UPLOAD - a reference to the Conan repository e.g. https://api.bintray.com/google/conan # CONAN_LOGIN_USERNAME - user for the upload e.g. upload_bot_username # CONAN_PASSWORD - password for the CONAN_LOGIN_USERNAME; for Bintray this is the API key # then upload the new recipe version to the Conan repository. + # For tag pushes we are also building and uploading packages for common configurations. # # For the tag pushes we are using for the # version the tag name, removing the "v" @@ -144,42 +200,49 @@ matrix: # For master pushes we are using for the # version simply "master" # channel "testing" - - if [[ "${TRAVIS_PULL_REQUEST}" == "false" && ( -n "${TRAVIS_TAG}" || "${TRAVIS_BRANCH}" == "master" ) && -n "${CONAN_UPLOAD}" && -n "${CONAN_LOGIN_USERNAME}" && -n "${CONAN_PASSWORD}" ]]; then - conan remote add benchmark ${CONAN_UPLOAD} --insert; + - if [[ "${TRAVIS_PULL_REQUEST}" == "false" && "${TRAVIS_BRANCH}" == "master" && -n "${CONAN_UPLOAD}" && -n "${CONAN_LOGIN_USERNAME}" && -n "${CONAN_PASSWORD}" ]]; then + conan remote add ${CONAN_PACKAGE_NAME} ${CONAN_UPLOAD} --insert; conan remote list; - if [ -n "${TRAVIS_TAG}" ]; then - CONANVERSION=${TRAVIS_TAG//v}; - CONANREFERENCE=benchmark/${CONANVERSION}@google/stable; - conan export . ${CONANREFERENCE}; - else - CONANVERSION="master"; - CONANREFERENCE=benchmark/${CONANVERSION}@google/testing; - fi; - conan user -p "${CONAN_PASSWORD}" -r benchmark "${CONAN_LOGIN_USERNAME}"; - conan upload --force -r benchmark --retry 3 --retry-wait 10 --confirm "${CONANREFERENCE}"; + conan upload --force -r ${CONAN_PACKAGE_NAME} --retry 3 --retry-wait 10 --confirm "${CONAN_FULL_REFERENCE}"; fi; - - os: osx - osx_image: xcode8.3 - compiler: clang - env: - - COMPILER=clang++ BUILD_TYPE=Debug - - os: osx + if: NOT tag IS present + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=conanio/gcc49 + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=conanio/gcc5 + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=conanio/gcc6 + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7 + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=conanio/clang39 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=conanio/clang40 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7 + - <<: *conan-osx + osx_image: xcode7.3 + env: CONAN_APPLE_CLANG_VERSIONS=7.3 + - <<: *conan-osx osx_image: xcode8.3 - compiler: clang - env: - - COMPILER=clang++ BUILD_TYPE=Release - - os: osx - osx_image: xcode8.3 - compiler: clang - env: - - COMPILER=clang++ BUILD_TYPE=Release BUILD_32_BITS=ON - - os: osx - osx_image: xcode8.3 - compiler: gcc - env: - - COMPILER=g++-7 C_COMPILER=gcc-7 BUILD_TYPE=Debug + env: CONAN_APPLE_CLANG_VERSIONS=8.1 + - <<: *conan-osx + osx_image: xcode9 + env: CONAN_APPLE_CLANG_VERSIONS=9.0 + - <<: *conan-osx + osx_image: xcode9.4 + env: CONAN_APPLE_CLANG_VERSIONS=9.1 + - <<: *conan-osx + osx_image: xcode10.1 + env: CONAN_APPLE_CLANG_VERSIONS=10.0 before_script: - if [ -n "${LIBCXX_BUILD}" ]; then diff --git a/appveyor.yml b/appveyor.yml index cf240190be..525ed02de7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,6 +7,10 @@ configuration: - Release environment: + global: + CONAN_USERNAME: "google" + CONAN_PACKAGE_NAME: "benchmark" + CONAN_DISABLE_SHARED_BUILD: "True" # Remove this line altogether when shared Win builds are fixed matrix: - compiler: msvc-15-seh generator: "Visual Studio 15 2017" @@ -25,26 +29,65 @@ environment: cxx_path: 'C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin' APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 14 + CONAN_BUILD_TYPES: Release + CONAN: true + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 14 + CONAN_BUILD_TYPES: Debug + CONAN: true + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CONAN_VISUAL_VERSIONS: 15 + CONAN_BUILD_TYPES: Release + CONAN: true + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CONAN_VISUAL_VERSIONS: 15 + CONAN_BUILD_TYPES: Debug + CONAN: true + matrix: + exclude: + # We only need one time all Conan jobs, so exclude all but one configuration from matrix expanding + - CONAN: true + configuration: Debug fast_finish: true -install: - # git bash conflicts with MinGW makefiles - - if "%generator%"=="MinGW Makefiles" (set "PATH=%PATH:C:\Program Files\Git\usr\bin;=%") - - if not "%cxx_path%"=="" (set "PATH=%PATH%;%cxx_path%") - -build_script: - - md _build -Force - - cd _build - - echo %configuration% - - cmake -G "%generator%" "-DCMAKE_BUILD_TYPE=%configuration%" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON .. - - cmake --build . --config %configuration% - -test_script: - - ctest -c %configuration% --timeout 300 --output-on-failure - -artifacts: - - path: '_build/CMakeFiles/*.log' - name: logs - - path: '_build/Testing/**/*.xml' - name: test_results +for: +- + matrix: + except: + - CONAN: true + + install: + # git bash conflicts with MinGW makefiles + - if "%generator%"=="MinGW Makefiles" (set "PATH=%PATH:C:\Program Files\Git\usr\bin;=%") + - if not "%cxx_path%"=="" (set "PATH=%PATH%;%cxx_path%") + + build_script: + - md _build -Force + - cd _build + - echo %configuration% + - cmake -G "%generator%" "-DCMAKE_BUILD_TYPE=%configuration%" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON .. + - cmake --build . --config %configuration% + + test_script: + - ctest -c %configuration% --timeout 300 --output-on-failure + + artifacts: + - path: '_build/CMakeFiles/*.log' + name: logs + - path: '_build/Testing/**/*.xml' + name: test_results + +- + matrix: + only: + - CONAN: true + skip_non_tags: true + + install: + - python conan/appveyor/install.py + + build_script: + - python conan/appveyor/build.py diff --git a/conan/appveyor/build.py b/conan/appveyor/build.py new file mode 100644 index 0000000000..9bac46dbe7 --- /dev/null +++ b/conan/appveyor/build.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os + +if os.getenv("APPVEYOR_REPO_TAG") != "true": + print("Skip build step. It's not TAG") +else: + os.system("python conan/build.py") diff --git a/conan/appveyor/install.py b/conan/appveyor/install.py new file mode 100644 index 0000000000..962c7da6b7 --- /dev/null +++ b/conan/appveyor/install.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os + +if os.getenv("APPVEYOR_REPO_TAG") != "true": + print("Skip step. It's not TAG") +else: + os.system("pip install conan conan-package-tools") diff --git a/conan/build.py b/conan/build.py new file mode 100644 index 0000000000..5ce9904b39 --- /dev/null +++ b/conan/build.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from cpt.packager import ConanMultiPackager +import os + +def set_appveyor_environment(): + if os.getenv("APPVEYOR") is not None: + os.environ["CONAN_STABLE_BRANCH_PATTERN"] = os.getenv("CONAN_STABLE_BRANCH_PATTERN", "master") + os.environ["CONAN_ARCHS"] = os.getenv("CONAN_ARCHS", "x86,x86_64") + os.environ["CONAN_BUILD_TYPES"] = os.getenv("CONAN_BUILD_TYPES", "Release,Debug").replace('"', '') + os.environ["CONAN_PACKAGE_VERSION"] = os.getenv("CONAN_PACKAGE_VERSION", os.getenv("APPVEYOR_REPO_TAG_NAME")) + +if __name__ == "__main__": + set_appveyor_environment() + login_username = os.getenv("CONAN_LOGIN_USERNAME") + username = os.getenv("CONAN_USERNAME") + tag_version = os.getenv("CONAN_PACKAGE_VERSION", os.getenv("TRAVIS_TAG")) + package_version = tag_version.replace("v", "") + package_name_unset = "SET-CONAN_PACKAGE_NAME-OR-CONAN_REFERENCE" + package_name = os.getenv("CONAN_PACKAGE_NAME", package_name_unset) + reference = "{}/{}".format(package_name, package_version) + channel = os.getenv("CONAN_CHANNEL", "stable") + upload = os.getenv("CONAN_UPLOAD") + stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*") + test_folder = os.getenv("CPT_TEST_FOLDER", os.path.join("conan", "test_package")) + upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True) + + disable_shared = os.getenv("CONAN_DISABLE_SHARED_BUILD", "False") + if disable_shared == "True" and package_name == package_name_unset: + raise Exception("CONAN_DISABLE_SHARED_BUILD: True is only supported when you define CONAN_PACKAGE_NAME") + + builder = ConanMultiPackager(username=username, + reference=reference, + channel=channel, + login_username=login_username, + upload=upload, + stable_branch_pattern=stable_branch_pattern, + upload_only_when_stable=upload_only_when_stable, + test_folder=test_folder) + builder.add_common_builds(pure_c=False) + + filtered_builds = [] + for settings, options, env_vars, build_requires, reference in builder.items: + if disable_shared == "False" or not options["{}:shared".format(package_name)]: + filtered_builds.append([settings, options, env_vars, build_requires]) + builder.builds = filtered_builds + + builder.run() diff --git a/conan/ci/build.sh b/conan/ci/build.sh new file mode 100644 index 0000000000..069ced202f --- /dev/null +++ b/conan/ci/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e +set -x + +if [[ "$(uname -s)" == 'Darwin' ]]; then + if which pyenv > /dev/null; then + eval "$(pyenv init -)" + fi + pyenv activate conan +fi + +conan user +python conan/build.py diff --git a/conan/ci/install.sh b/conan/ci/install.sh new file mode 100644 index 0000000000..2017e5e1ef --- /dev/null +++ b/conan/ci/install.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e +set -x + +if [[ "$(uname -s)" == 'Darwin' ]]; then + brew update || brew update + brew outdated pyenv || brew upgrade pyenv + brew install pyenv-virtualenv + brew install cmake || true + + if which pyenv > /dev/null; then + eval "$(pyenv init -)" + fi + + pyenv install 3.7.1 + pyenv virtualenv 3.7.1 conan + pyenv rehash + pyenv activate conan +fi + +pip install -U conan_package_tools conan diff --git a/conan/test_package/CMakeLists.txt b/conan/test_package/CMakeLists.txt index 089a6c729d..56a1bba89a 100644 --- a/conan/test_package/CMakeLists.txt +++ b/conan/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 2.8.12) project(test_package) set(CMAKE_VERBOSE_MAKEFILE TRUE)