diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5f4bbe08..984bdb86 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,19 +1,32 @@ -# default build for all distros -# only create artifacts of the build directory when something fails (for cmake logs) -# cache the ccache/ directory for each job separately -.build_template: &distro_build +# all builds use the same ccache folder in the project root that is cached +variables: + CCACHE_BASEDIR: '$CI_PROJECT_DIR' + CCACHE_DIR: '$CI_PROJECT_DIR/ccache' + +# default config for all distros: +# - install dependencies via script +# - create ccache dir & setup caching of it (for each job separately) +.build_config: &default_config before_script: - ci/install_dependencies.sh + - mkdir -p ccache + cache: + key: "$CI_JOB_NAME" + paths: + - ccache/ + +# default build job: +# - run build script +# - only create artifacts of the build directory when something fails +# (for cmake logs) +.build_template: &distro_build script: - python3 ci/test_build.py artifacts: when: on_failure paths: - build/ - cache: - key: "$CI_JOB_NAME" - paths: - - ccache/ + stages: - test @@ -21,33 +34,38 @@ stages: Fedora: image: fedora:28 + <<: *default_config <<: *distro_build Debian: image: debian:9 + <<: *default_config <<: *distro_build Archlinux: image: base/archlinux + <<: *default_config <<: *distro_build Ubuntu: image: ubuntu:18.04 + <<: *default_config <<: *distro_build CentOS: image: centos:7 + <<: *default_config <<: *distro_build OpenSUSE: image: opensuse:tumbleweed + <<: *default_config <<: *distro_build Install: image: fedora:28 stage: deploy - before_script: - - ci/install_dependencies.sh + <<: *default_config script: - mkdir build && cd build - cmake -DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=/usr/ -DBUILD_WITH_CCACHE=ON .. diff --git a/ci/test_build.py b/ci/test_build.py index 62a25496..73bb5d2c 100644 --- a/ci/test_build.py +++ b/ci/test_build.py @@ -37,10 +37,8 @@ def call_wrapper(*args, **kwargs): sys.exit(return_code) -# create build & ccache directory (ccache could already exist in the CI's cache) +# create build directory os.mkdir("build") -if not os.path.exists('ccache'): - os.mkdir("ccache") root_dir = os.path.abspath(os.getcwd()) @@ -64,8 +62,6 @@ for params in itertools.product(SHARED_LIBS, CCS, BUILD_TYPES): env_copy = os.environ.copy() env_copy["CC"] = cc env_copy["CXX"] = cxx - env_copy["CCACHE_BASEDIR"] = root_dir - env_copy["CCACHE_DIR"] = os.path.join(root_dir, "ccache") # location of the binaries for the new test suite: env_copy["EXIV2_BINDIR"] = os.path.join(cwd, "bin")