--- stages: - code-check - build - tests - package - benchmark variables: DOCKER_DRIVER: overlay # Cache a folder between builds. # Tox sets it to be our pip cache. cache: untracked: true key: soledad-shared-pip-cache paths: - testing/.cache/ before_script: - echo "Running on ${HOST_HOSTNAME:=$(hostname)}" .job_template: &job_definition stage: package image: "0xacab.org:4567/leap/gitlab-buildpackage:build_${DIST}_${ARCH}" script: - "if [ -z \"$(git remote | grep upstream)\" ]; then git remote add upstream https://0xacab.org/leap/soledad; fi" - "git fetch --tags upstream" - "pwd; git describe" - build-build-package # Test the package with lintian - build-test-lintian - "if [ -n \"${SSH_PRIVATE_KEY}\" ]; then upload-package; else echo \"Skipping package upload because SSH_PRIVATE_KEY is not set.\"; fi" # sleep 1h to allow debugging of running container # - sleep 3600 artifacts: expire_in: 1w paths: - '*_*.xz' - '*_*.dsc' - '*_amd64.changes' - '*.deb' - 'results/*' code-check: stage: code-check image: 0xacab.org:4567/leap/soledad:latest script: - cd testing - tox -e code-check tests: stage: tests image: 0xacab.org:4567/leap/soledad:latest services: - couchdb script: - cd testing - tox -- --couch-url http://couchdb:5984 benchmark: stage: benchmark image: 0xacab.org:4567/leap/soledad:latest tags: - benchmark services: - couchdb allow_failure: true script: # By default, gitlab-runner will checkout in a detached HEAD # (see https://gitlab.com/gitlab-org/gitlab-ce/issues/19421) # We want pytest-benchmark to report the proper branch name, # so we make sure we stay at the current branch - git checkout -B "$CI_BUILD_REF_NAME" "$CI_BUILD_REF" # Gitlab will checkout current revision as master / origin/master # We need some files from the "furure" in order to post the right # benchmarking data to elasticsearch. - git remote add leap https://leap.se/git/soledad - git fetch leap - git checkout leap/master testing/tox.ini testing/tests/benchmarks/conftest.py testing/tests/conftest.py - sed -i 's/drebs.*$/varac\/pytest-benchmark.git@unmerged_prs/' testing/tox.ini - grep -A 9 'testenv:benchmark' testing/tox.ini - git status - git show -s --pretty=fuller - cd testing - curl -s couchdb:5984 # You can provide a $NETRC variable containing the creds for your # elasticsearch instance so it's protected from being leaked in the # CI console # We can't get it working inside docker for unknown reasons. # - echo "$NETRC" > /root/.netrc && chmod 600 /root/.netrc # # Add $PYTEST_OPTS to pytest.ini to allow posting benchmark tests # to an elasticsearch instance - echo "addopts=$PYTEST_OPTS" >> pytest.ini && chmod 600 pytest.ini - /usr/bin/unbuffer tox --recreate -e benchmark -- --couch-url http://couchdb:5984 | /usr/bin/ts -s # Output locally saved benchmarks if they exist - 'if [ -d .benchmarks ]; then find .benchmarks -type f -exec cat {} \; ; fi' build_docker_image: stage: build image: 0xacab.org:4567/leap/soledad:latest services: - docker:dind tags: - docker-in-docker before_script: - > export LAST_COMMIT=$(curl -s \ --header "PRIVATE-TOKEN: ${LEAP_CODE_O_MATIC_PRIVATE_TOKEN}" \ https://0xacab.org/api/v4/projects/519/pipelines | \ python -c "import sys, json; print json.load(sys.stdin)[1]['sha']") script: - > if git diff $LAST_COMMIT HEAD --name-only|grep testing/docker; then docker --version docker info docker login -u gitlab-ci-token -e sysdev@leap.se \ -p $CI_JOB_TOKEN $CI_REGISTRY docker build -t ${CI_REGISTRY_IMAGE}:latest testing/docker docker push ${CI_REGISTRY_IMAGE}:latest fi package:amd64_jessie: variables: ARCH: "amd64" DIST: "jessie" REPONAMES: "platform" # Default is to fail on warnings, we disable it here # unless a manpage is included (see #8895) LINTIAN_OPTS: "-X filename-length" <<: *job_definition # package:amd64_stretch: # variables: # ARCH: "amd64" # DIST: "stretch" # REPONAMES: "platform" # # Default is to fail on warnings, we disable it here # # unless a manpage is included (see #8895) # LINTIAN_OPTS: "-X filename-length" # <<: *job_definition