.travis.yml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. ---
  2. dist: focal
  3. language: c
  4. addons:
  5. apt:
  6. packages: ['moreutils']
  7. env:
  8. global:
  9. - RELEASE_CHANNEL=nightly
  10. before_install:
  11. - exec > >(ts -s '%H:%M:%.S ') 2>&1
  12. - source .travis/utils.sh
  13. # Install dependencies for all, once
  14. #
  15. install:
  16. - sudo apt-get install -y libuv1-dev liblz4-dev libjudy-dev libcap2-bin zlib1g-dev uuid-dev fakeroot libipmimonitoring-dev libmnl-dev libnetfilter-acct-dev gnupg python3-pip
  17. - sudo pip install git-semver==0.3.2 # 11/Sep/2019: git-semver tip was broken, so we had to force last good run of it
  18. - source tests/installer/slack.sh
  19. - export NOTIF_CHANNEL="automation-beta"
  20. - if [ "${TRAVIS_REPO_SLUG}" = "netdata/netdata" ]; then export NOTIF_CHANNEL="automation"; fi;
  21. - export BUILD_VERSION="$(cat packaging/version | cut -d'-' -f1)"
  22. - export LATEST_RELEASE_VERSION="$(cat packaging/version | cut -d'-' -f1)"
  23. - export LATEST_RELEASE_DATE="$(git log -1 --format=%aD "${LATEST_RELEASE_VERSION}" | cat)"
  24. - if [[ "${TRAVIS_COMMIT_MESSAGE}" = *"[Build latest]"* ]]; then export BUILD_VERSION="$(cat packaging/version | cut -d'-' -f1,2 | sed -e 's/-/./g').latest"; fi;
  25. - export DEPLOY_REPO="netdata" # Default production packaging repository
  26. - export PACKAGING_USER="netdata" # Standard package cloud account
  27. - if [[ "${TRAVIS_COMMIT_MESSAGE}" = *"[Build latest]"* ]]; then export DEPLOY_REPO="netdata-edge"; fi;
  28. - export PACKAGE_CLOUD_RETENTION_DAYS=30
  29. - if [ ! "${TRAVIS_REPO_SLUG}" = "netdata/netdata" ]; then export DEPLOY_REPO="netdata-devel"; fi;
  30. # These are release-related artifacts and have to be evaluated before we start doing conditional checks inside stages
  31. - source ".travis/tagger.sh"
  32. - export GIT_TAG="$(git tag --points-at)"
  33. - git submodule update --init --recursive
  34. # Setup notification system
  35. #
  36. notifications:
  37. webhooks:
  38. urls:
  39. - https://app.fossa.io/hooks/travisci
  40. # Define the stage sequence and conditionals
  41. #
  42. stages:
  43. # Mandatory runs, we always want these executed
  44. - name: Build process
  45. if: commit_message =~ /^((?!\[Package (amd64|arm64|i386) (DEB|RPM)( .*)?\]).)*$/
  46. # Nightly operations
  47. - name: Nightly operations
  48. if: branch = master AND type = cron AND env(RUN_NIGHTLY) = yes
  49. - name: Nightly release
  50. if: branch = master AND type = cron AND env(RUN_NIGHTLY) = yes
  51. # Scheduled releases
  52. - name: Support activities on main branch
  53. if: branch = master AND type != pull_request AND type != cron AND repo = netdata/netdata
  54. # We don't run on release candidates
  55. - name: Publish for release
  56. if: >-
  57. branch = master
  58. AND type != pull_request
  59. AND type != cron
  60. AND tag !~ /(-rc)/
  61. AND commit_message =~ /\[netdata (release candidate|(major|minor|patch) release)\]/
  62. # Define stage implementation details
  63. #
  64. jobs:
  65. # This is a hook to help us introduce "soft" errors on our process
  66. allow_failures:
  67. - env: ALLOW_SOFT_FAILURE_HERE=true
  68. include:
  69. # Ensure netdata code builds successfully
  70. - stage: Build process
  71. name: Standard netdata build
  72. script: fakeroot ./netdata-installer.sh --install $HOME --dont-wait --dont-start-it --enable-plugin-nfacct --enable-plugin-freeipmi --disable-lto
  73. env: CFLAGS='-O1 -Wall -Wextra -Wformat-signedness -fstack-protector-all -fno-common -DNETDATA_INTERNAL_CHECKS=1 -D_FORTIFY_SOURCE=2 -DNETDATA_VERIFY_LOCKS=1'
  74. after_failure: post_message "TRAVIS_MESSAGE" "<!here> standard netdata build is failing (Still dont know which one, will improve soon)"
  75. - stage: Support activities on main branch
  76. name: Generate changelog for release (only on special and tagged commit msg)
  77. before_script: post_message "TRAVIS_MESSAGE" "Support activities on main branch initiated" "${NOTIF_CHANNEL}"
  78. script:
  79. - echo "GIT Branch:" && git branch
  80. - echo "Last commit:" && git log -1
  81. - echo "GIT Describe:" && git describe
  82. - echo "packaging/version:" && cat packaging/version
  83. - if [[ -z "${GIT_TAG}" ]]; then echo "Running set tag for release" && set_tag_for_release; fi;
  84. - .travis/generate_changelog_and_tag_release.sh
  85. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Changelog generation and tag of release, failed"
  86. git:
  87. depth: false
  88. if: commit_message =~ /\[netdata (release candidate|(major|minor|patch) release)\]/ AND tag !~ /(-rc)/ OR (env(GIT_TAG) IS present AND NOT env(GIT_TAG) IS blank)
  89. # We only publish if a TAG has been set during packaging
  90. - stage: Publish for release
  91. name: Create release draft
  92. git:
  93. depth: false
  94. env:
  95. - RELEASE_CHANNEL=stable
  96. before_script: post_message "TRAVIS_MESSAGE" "Drafting release on github" "${NOTIF_CHANNEL}"
  97. script:
  98. - echo "GIT Branch:" && git branch
  99. - echo "Last commit:" && git log -1
  100. - echo "GIT Describe:" && git describe
  101. - echo "packaging/version:" && cat packaging/version
  102. - echo "Generating release artifacts" && .travis/create_artifacts.sh # Could/should be a common storage to put this and share between jobs
  103. - .travis/draft_release.sh
  104. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Draft release submission failed"
  105. - name: Trigger Docker image build and publish
  106. script:
  107. - git checkout "${TRAVIS_BRANCH}" && export BUILD_VERSION="$(cat packaging/version | cut -d'-' -f1)"
  108. - .travis/trigger_docker_build.sh "${GITHUB_TOKEN}" "${BUILD_VERSION}"
  109. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Failed to trigger docker build during release" "${NOTIF_CHANNEL}"
  110. - name: Trigger DEB and RPM package build
  111. script:
  112. - git checkout "${TRAVIS_BRANCH}" && export BUILD_VERSION="$(cat packaging/version | sed 's/^v//' | cut -d'-' -f1)"
  113. - .travis/trigger_package_build.sh "${GITHUB_TOKEN}" "${BUILD_VERSION}" "release"
  114. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Failed to trigger deb and rpm package build during release" "${NOTIF_CHANNEL}"
  115. # This is the nightly pre-execution step (Jobs, preparatory steps for nightly, etc)
  116. - stage: Nightly operations
  117. name: Kickstart files integrity testing (extended)
  118. script: ./tests/installer/checksums.sh
  119. # This is generating the changelog for nightly release and publish it
  120. - name: Generate nightly changelog
  121. script:
  122. - ".travis/nightlies.sh"
  123. - ".travis/check_changelog_last_modification.sh"
  124. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Nightly changelog generation failed"
  125. git:
  126. depth: false
  127. # This is the nightly execution step
  128. #
  129. - stage: Nightly release
  130. _template: &NIGHTLY_TEMPLATE
  131. git:
  132. depth: false
  133. script:
  134. - echo "GIT Branch:" && git branch
  135. - echo "Last commit:" && git log -1
  136. - echo "GIT Describe:" && git describe
  137. - echo "packaging/version:" && cat packaging/version
  138. - "sudo echo '{\"experimental\": true}' > /etc/docker/daemon.json && sudo systemctl restart docker"
  139. - packaging/docker/check_login.sh
  140. && tick packaging/docker/build.sh
  141. && packaging/docker/publish.sh
  142. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Nightly docker image publish failed"
  143. name: Create nightly release artifacts, publish to GCS
  144. script:
  145. - echo "GIT Branch:" && git branch
  146. - echo "Last commit:" && git log -1
  147. - echo "GIT Describe:" && git describe
  148. - echo "packaging/version:" && cat packaging/version
  149. - .travis/create_artifacts.sh
  150. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Nightly artifacts generation failed"
  151. git:
  152. depth: false
  153. before_deploy:
  154. echo "Preparing creds under ${TRAVIS_REPO_SLUG}";
  155. if [ "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
  156. openssl aes-256-cbc -K $encrypted_8daf19481253_key -iv $encrypted_8daf19481253_iv -in .travis/gcs-credentials.json.enc -out .travis/gcs-credentials.json -d;
  157. else
  158. echo "Beta deployment stage in progress";
  159. openssl aes-256-cbc -K $encrypted_8daf19481253_key -iv $encrypted_8daf19481253_iv -in .travis/gcs-credentials.json.enc -out .travis/gcs-credentials.json -d;
  160. fi;
  161. deploy:
  162. # Beta storage, used for testing purposes
  163. - provider: gcs
  164. edge:
  165. branch: gcs-ng
  166. project_id: netdata-storage
  167. credentials: .travis/gcs-credentials.json
  168. bucket: "netdata-dev-nightlies"
  169. skip_cleanup: true
  170. local_dir: "artifacts"
  171. on:
  172. # Only deploy on netdata/netdata, master branch, when artifacts directory is created
  173. repo: ${TRAVIS_REPO_SLUG}
  174. branch: master
  175. condition: -d "artifacts" && ${TRAVIS_REPO_SLUG} != "netdata/netdata"
  176. # Production storage
  177. - provider: gcs
  178. edge:
  179. branch: gcs-ng
  180. project_id: netdata-storage
  181. credentials: .travis/gcs-credentials.json
  182. bucket: "netdata-nightlies"
  183. skip_cleanup: true
  184. local_dir: "artifacts"
  185. on:
  186. # Only deploy on netdata/netdata, master branch, when artifacts directory is created
  187. repo: netdata/netdata
  188. branch: master
  189. condition: -d "artifacts" && ${TRAVIS_REPO_SLUG} = "netdata/netdata"
  190. after_deploy: rm -f .travis/gcs-credentials.json
  191. - name: Trigger Docker image build and publish
  192. script: .travis/trigger_docker_build.sh "${GITHUB_TOKEN}" "nightly"
  193. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Failed to trigger docker build during nightly release" "${NOTIF_CHANNEL}"
  194. - name: Trigger DEB and RPM package build
  195. script:
  196. - git checkout "${TRAVIS_BRANCH}" && export BUILD_VERSION="$(cat packaging/version | sed 's/^v//')"
  197. - .travis/trigger_package_build.sh "${GITHUB_TOKEN}" "${BUILD_VERSION}" "nightly"
  198. after_failure: post_message "TRAVIS_MESSAGE" "<!here> Failed to trigger deb and rpm package build during nightly release" "${NOTIF_CHANNEL}"