summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 1d93558603b6bab704fa70246854f0f857a76f73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
stages:
  - code-check
  - build
  - tests
  - package
  - benchmark

image: 0xacab.org:4567/leap/soledad:latest

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:
    - "pwd; git describe"
    - build-build-package
    # Test the package with lintian
    - build-test-lintian
    - upload-package
    # 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
  script:
    - cd testing
    - tox -e code-check

tests:
  stage: tests
  services:
    - couchdb
  script:
    - cd testing
    - tox -- --couch-url http://couchdb:5984

benchmark:
  stage: benchmark
  tags:
    - benchmark
  services:
    - couchdb
  allow_failure: true
  script:
    - 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 -m 'not synchronous' | /usr/bin/ts -s

build_docker_image:
  image: 0xacab.org:4567/leap/soledad:latest
  stage: build
  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"
    LINTIAN_OPTS: "-X filename-length"
  <<: *job_definition

#package:amd64_stretch:
#  variables:
#    ARCH: "amd64"
#    DIST: "stretch"
#    REPONAMES: "platform"
#    LINTIAN_OPTS: "-X filename-length"
#  <<: *job_definition