summaryrefslogtreecommitdiffstats
path: root/.travis.yml
blob: e1b89dfa1c1b2973f4df6fb819662020dcf8d501 (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
sudo: true
language: c
services:
- docker

# This is a hook to help us introduce "soft" errors on our process
matrix:
  allow_failures:
    - env: ALLOW_SOFT_FAILURE_HERE=true

# Install dependencies for all, once
#
install:
- sudo apt-get install -y libcap2-bin zlib1g-dev uuid-dev fakeroot libipmimonitoring-dev libmnl-dev libnetfilter-acct-dev gnupg python-pip
- sudo apt install -y --only-upgrade docker-ce
- sudo pip install git-semver
- docker info
- source tests/installer/slack.sh

# Setup notification system
#
notifications:
  webhooks: https://app.fossa.io/hooks/travisci

# Define the stage sequence and conditionals
#
stages:
# Mandatory runs, we always want these executed
- name: Code quality, linting, syntax, code style
- name: Build process
- name: Artifacts validation

  # Nightly operations
- name: Nightly operations
  if: branch = master AND type = cron
- name: Nightly release
  if: branch = master AND type = cron

  # Scheduled releases
- name: Packaging for release
  if: branch = master AND type != pull_request AND type != cron

- name: Publish for release
  if: branch = master AND type != pull_request AND type != cron AND commit_message =~ /(\[netdata release candidate\]|\[netdata major release\]|\[netdata minor release\]|\[netdata patch release\])/



# Define stage implementation details
#
jobs:
  include:
    # Do code quality, syntax checking and other pre-build activities
  - stage: Code quality, linting, syntax, code style

    name: Run shellchecking on BASH
    script: shellcheck --format=gcc $(find . -name '*.sh.in' -not -iwholename '*.git*')

    # This falls under same stage defined earlier
  - name: Run checksum checks on kickstart files
    script: ./tests/installer/checksums.sh
    env: LOCAL_ONLY="true"

    # This falls under same stage defined earlier
  - name: Web Dashboard pre-generated file consistency checks (dashboard.js)
    script: cp web/gui/dashboard.js /tmp/dashboard.js && ./build/build.sh && diff /tmp/dashboard.js web/gui/dashboard.js



    # Ensure netdata code builds successfully
  - stage: Build process

    name: Standard netdata build
    script: fakeroot ./netdata-installer.sh --install $HOME --dont-wait --dont-start-it --enable-plugin-nfacct --enable-plugin-freeipmi --disable-lto
    env: CFLAGS='-O1 -DNETDATA_INTERNAL_CHECKS=1 -DNETDATA_VERIFY_LOCKS=1'
    after_failure: post_message "TRAVIS_MESSAGE" "<!here> standard netdata build is failing (Still dont know which one, will improve soon)"

  - name: Docker container build process (alpine installation)
    script: packaging/docker/build.sh
    env: DEVEL="true"
    after_failure: post_message "TRAVIS_MESSAGE" "Docker build process failed"

  - name: Run 'make dist' validation
    before_script: mkdir /tmp/netdata-makedist-test
    script:
    - echo "GIT Branch:" && git branch
    - echo "Last commit:" && git log -1
    - echo "GIT Describe:" && git describe
    - echo "packaging/version:" && cat packaging/version
    - docker run -it -v "${PWD}:/netdata:rw" -v "/tmp/netdata-makedist-test:/netdata_install:rw" -w /netdata "netdata/os-test:ubuntu1804" make clean || echo "Nothing to clean"
    - docker run -it -v "${PWD}:/netdata:rw" -v "/tmp/netdata-makedist-test:/netdata_install:rw" -w /netdata "netdata/os-test:ubuntu1804" make distclean || echo "Nothing to distclean"
    - docker run -it -v "${PWD}:/netdata:rw" -v "/tmp/netdata-makedist-test:/netdata_install:rw" -w /netdata "netdata/os-test:ubuntu1804" autoreconf -ivf && ./configure --prefix=/netdata_install/usr --sysconfdir=/netdata_install/etc --localstatedir=/netdata_install/var --with-zlib --with-math --with-user=netdata CFLAGS=-O2
    - docker run -it -v "${PWD}:/netdata:rw" -v "/tmp/netdata-makedist-test:/netdata_install:rw" -w /netdata "netdata/os-test:ubuntu1804" make dist
    - docker run -it -v "${PWD}:/netdata:rw" -v "/tmp/netdata-makedist-test:/netdata_install:rw" -w /netdata "netdata/os-test:ubuntu1804" ls -ltr ./netdata-$(git describe).tar.gz || ls -ltr ./netdata-$(cat packaging/version | tr -d '\n').tar.gz
    - .travis/run_install_with_dist_file.sh
    - docker run -it -v "${PWD}:/netdata:rw" -v "/tmp/netdata-makedist-test:/netdata_install:rw" -w /netdata "netdata/os-test:ubuntu1804" make distclean
    git:
      depth: false
    after_script: rm -rf /tmp/netdata-makedist-test
    after_failure: post_message "TRAVIS_MESSAGE" "'make dist' failed"



  - stage: Artifacts validation

    name: Unit Testing
    script:
    - fakeroot ./netdata-installer.sh --install $HOME --dont-wait --dont-start-it --enable-plugin-nfacct --enable-plugin-freeipmi --disable-lto
    - $HOME/netdata/usr/sbin/netdata -W unittest
    env: CFLAGS='-O1 -DNETDATA_INTERNAL_CHECKS=1 -DNETDATA_VERIFY_LOCKS=1'
    after_failure: post_message "TRAVIS_MESSAGE" "Unit testing failed"

  - name: Build/install on ubuntu 14.04 (not containerized)
    script: fakeroot ./netdata-installer.sh --dont-wait --dont-start-it --install $HOME
    after_failure: post_message "TRAVIS_MESSAGE" "Build/Install failed on ubuntu 14.04"

  - name: Build/Install for ubuntu 18.04 (not containerized)
    script: fakeroot ./netdata-installer.sh --dont-wait --dont-start-it --install $HOME
    after_failure: post_message "TRAVIS_MESSAGE" "Build/Install failed on ubuntu 18.04"

  - name: Run netdata lifecycle, on ubuntu 18.04 (Containerized)
    script: docker run -it -v "${PWD}:/netdata:rw" -w /netdata "netdata/os-test:ubuntu1804" bats --tap tests/lifecycle.bats
    after_failure: post_message "TRAVIS_MESSAGE" "Netdata lifecycle test script failed on ubuntu 18.04"

  - name: Run netdata lifecycle from stable to current, on CentOS 7 (Containerized)
    script: docker run -it -v "${PWD}:/netdata:rw" -w /netdata "netdata/os-test:centos7" tests/updater_checks.sh
    after_failure: post_message "TRAVIS_MESSAGE" "Netdata updater process failed on CentOS 7"

  - name: Build/install for CentOS 6 (Containerized)
    script: docker run -it -v "${PWD}:/netdata:rw" -w /netdata "netdata/os-test:centos6" ./netdata-installer.sh --dont-wait --dont-start-it --install /tmp
    after_failure: post_message "TRAVIS_MESSAGE" "Build/Install failed on CentOS 6"

  - name: Build/install for CentOS 7 (Containerized)
    script: docker run -it -v "${PWD}:/netdata:rw" -w /netdata "netdata/os-test:centos7" ./netdata-installer.sh --dont-wait --dont-start-it --install /tmp
    after_failure: post_message "TRAVIS_MESSAGE" "Build/Install failed on CentOS 7"



  - stage: Packaging for release

    name: Generate changelog and TAG the release (only on special commit msg)
    before_script: post_message "TRAVIS_MESSAGE" "Packaging step for release initiated"
    script:
    - echo "GIT Branch:" && git branch
    - echo "Last commit:" && git log -1
    - echo "GIT Describe:" && git describe
    - echo "packaging/version:" && cat packaging/version
    - .travis/generate_changelog_and_tag_release.sh
    after_failure: post_message "TRAVIS_MESSAGE" "<!here> Packaging for release failed"
    git:
      depth: false

  - name: Run labeler on github issues
    script: .travis/labeler.sh # labeler should be replaced with GitHub Actions when they hit GA



    # We only publish if a TAG has been set during packaging
  - stage: Publish for release

    name: Build & Publish docker images
    before_script: post_message "TRAVIS_MESSAGE" "Publishing docker images"
    script:
    - echo "GIT Branch:" && git branch
    - echo "Last commit:" && git log -1
    - echo "GIT Describe:" && git describe
    - echo "packaging/version:" && cat packaging/version
    - packaging/docker/check_login.sh
    - packaging/docker/build.sh
    - packaging/docker/publish.sh
    after_failure: post_message "TRAVIS_MESSAGE" "<!here> Docker image publishing failed"
    git:
      depth: false
    env: ALLOW_SOFT_FAILURE_HERE=true
    # We don't run on release candidates
    if: tag !~ /(-rc)/

  - name: Create release draft
    before_script: post_message "TRAVIS_MESSAGE" "Drafting release on github"
    script:
    - echo "GIT Branch:" && git branch
    - echo "Last commit:" && git log -1
    - echo "GIT Describe:" && git describe
    - echo "packaging/version:" && cat packaging/version
    - echo "Generating release artifacts" && .travis/create_artifacts.sh # Could/should be a common storage to put this and share between jobs
    - .travis/draft_release.sh
    git:
      depth: false
    after_failure: post_message "TRAVIS_MESSAGE" "<!here> Draft release submission failed"
    # We don't run on release candidates
    if: tag !~ /(-rc)/



    # This is the nightly pre-execution step (Jobs, preparatory steps for nightly, etc)
  - stage: Nightly operations

    name: Run coverity scan
    # Just notify people that Nightly ops triggered, use the first step as a hook to do that
    before_script: post_message "TRAVIS_MESSAGE" "Starting nightly operations"
    script: ./coverity-install.sh && ./coverity-scan.sh || echo "Coverity failed :("

  - name: Kickstart files integrity testing (extended)
    script: ./tests/installer/checksums.sh

  - name: Run labeler on github issues
    script: .travis/labeler.sh # labeler should be replaced with GitHub Actions when they hit GA

    # This is generating the changelog for nightly release and publish it
  - name: Generate nightly changelog
    before_script: post_message "TRAVIS_MESSAGE" "Starting changelog generation for nightlies"
    script: ".travis/nightlies.sh"
    after_failure: post_message "TRAVIS_MESSAGE" "<!here> Nightly changelog generation failed"
    git:
      depth: false



    # This is the nightly execution step
    #
  - stage: Nightly release

    name: Build & Publish docker images
    before_script: post_message "TRAVIS_MESSAGE" "Publishing docker images for nightlies"
    script:
    - echo "GIT Branch:" && git branch
    - echo "Last commit:" && git log -1
    - echo "GIT Describe:" && git describe
    - echo "packaging/version:" && cat packaging/version
    - docker info
    - packaging/docker/check_login.sh
    - packaging/docker/build.sh
    - packaging/docker/publish.sh
    after_failure: post_message "TRAVIS_MESSAGE" "<!here> Nightly docker image publish failed"
    git:
      depth: false
    env: ALLOW_SOFT_FAILURE_HERE=true

  - name: Create nightly release artifacts, publish to GCS
    before_script: post_message "TRAVIS_MESSAGE" "Starting artifacts generation for nightlies"
    script:
    - echo "GIT Branch:" && git branch
    - echo "Last commit:" && git log -1
    - echo "GIT Describe:" && git describe
    - echo "packaging/version:" && cat packaging/version
    - .travis/create_artifacts.sh
    after_failure: post_message "TRAVIS_MESSAGE" "<!here> Nightly artifacts generation failed"
    git:
      depth: false
    before_deploy:
      echo "Preparing creds under ${TRAVIS_REPO_SLUG}";
      if [ "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
         openssl aes-256-cbc -K $encrypted_8daf19481253_key -iv $encrypted_8daf19481253_iv -in .travis/gcs-credentials.json.enc -out .travis/gcs-credentials.json -d;
      else
         echo "Beta deployment stage in progress";
         openssl aes-256-cbc -K $encrypted_8daf19481253_key -iv $encrypted_8daf19481253_iv -in .travis/gcs-credentials.json.enc -out .travis/gcs-credentials.json -d;
      fi;
    deploy:
      # Beta storage, used for testing purposes
      - provider: gcs
        edge:
          branch: gcs-ng
        project_id: netdata-storage
        credentials: .travis/gcs-credentials.json
        bucket: "netdata-dev-nightlies"
        skip_cleanup: true
        local_dir: "artifacts"
        on:
          # Only deploy on netdata/netdata, master branch, when artifacts directory is created
          repo: ${TRAVIS_REPO_SLUG}
          branch: master
          condition: -d "artifacts" && ${TRAVIS_REPO_SLUG} != "netdata/netdata"

      # Production storage
      - provider: gcs
        edge:
          branch: gcs-ng
        project_id: netdata-storage
        credentials: .travis/gcs-credentials.json
        bucket: "netdata-nightlies"
        skip_cleanup: true
        local_dir: "artifacts"
        on:
          # Only deploy on netdata/netdata, master branch, when artifacts directory is created
          repo: netdata/netdata
          branch: master
          condition: -d "artifacts" && ${TRAVIS_REPO_SLUG} = "netdata/netdata"
    after_deploy: rm -f .travis/gcs-credentials.json