build.yml 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. ---
  2. # Ci code for building release artifacts.
  3. name: Build
  4. on:
  5. push: # Master branch checks only validate the build and generate artifacts for testing.
  6. branches:
  7. - master
  8. pull_request: null # PR checks only validate the build and generate artifacts for testing.
  9. workflow_dispatch: # Dispatch runs build and validate, then push to the appropriate storage location.
  10. inputs:
  11. type:
  12. description: Build Type
  13. default: nightly
  14. required: true
  15. version:
  16. description: Version Tag
  17. default: nightly
  18. required: true
  19. concurrency: # This keeps multiple instances of the job from running concurrently for the same ref and event type.
  20. group: build-${{ github.ref }}-${{ github.event_name }}
  21. cancel-in-progress: true
  22. jobs:
  23. file-check: # Check what files changed if we’re being run in a PR or on a push.
  24. name: Check Modified Files
  25. runs-on: ubuntu-latest
  26. outputs:
  27. run: ${{ steps.check-run.outputs.run }}
  28. steps:
  29. - name: Checkout
  30. id: checkout
  31. uses: actions/checkout@v4
  32. with:
  33. fetch-depth: 0
  34. submodules: recursive
  35. - name: Check files
  36. id: check-files
  37. uses: tj-actions/changed-files@v40
  38. with:
  39. since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
  40. files: |
  41. **.c
  42. **.cc
  43. **.h
  44. **.hh
  45. **.in
  46. configure.ac
  47. netdata-installer.sh
  48. **/Makefile*
  49. Makefile*
  50. .github/data/distros.yml
  51. .github/workflows/build.yml
  52. .github/scripts/build-static.sh
  53. .github/scripts/get-static-cache-key.sh
  54. .github/scripts/gen-matrix-build.py
  55. .github/scripts/run-updater-check.sh
  56. build/**
  57. packaging/makeself/**
  58. packaging/installer/**
  59. aclk/aclk-schemas/
  60. ml/dlib/
  61. mqtt_websockets
  62. web/server/h2o/libh2o
  63. files_ignore: |
  64. netdata.spec.in
  65. **.md
  66. - name: Check Run
  67. id: check-run
  68. run: |
  69. if [ "${{ steps.check-files.outputs.any_modified }}" == "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
  70. echo 'run=true' >> "${GITHUB_OUTPUT}"
  71. else
  72. echo 'run=false' >> "${GITHUB_OUTPUT}"
  73. fi
  74. build-dist: # Build the distribution tarball and store it as an artifact.
  75. name: Build Distribution Tarball
  76. runs-on: ubuntu-latest
  77. needs:
  78. - file-check
  79. outputs:
  80. distfile: ${{ steps.build.outputs.distfile }}
  81. steps:
  82. - name: Skip Check
  83. id: skip
  84. if: needs.file-check.outputs.run != 'true'
  85. run: echo "SKIPPED"
  86. - name: Checkout
  87. id: checkout
  88. if: needs.file-check.outputs.run == 'true'
  89. uses: actions/checkout@v4
  90. with:
  91. fetch-depth: 0
  92. submodules: recursive
  93. - name: Fix tags
  94. id: fix-tags
  95. if: github.event_name != 'push' && needs.file-check.outputs.run == 'true'
  96. run: |
  97. git fetch --tags --force
  98. - name: Mark Stable
  99. id: channel
  100. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly' && needs.file-check.outputs.run == 'true'
  101. run: |
  102. sed -i 's/^RELEASE_CHANNEL="nightly"/RELEASE_CHANNEL="stable"/' netdata-installer.sh
  103. - name: Build
  104. id: build
  105. if: needs.file-check.outputs.run == 'true'
  106. run: |
  107. git describe
  108. mkdir -p artifacts
  109. ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata
  110. autoreconf -ivf
  111. ./configure --prefix=/usr \
  112. --sysconfdir=/etc \
  113. --localstatedir=/var \
  114. --libexecdir=/usr/libexec \
  115. --with-zlib \
  116. --with-math \
  117. --with-user=netdata
  118. make dist
  119. echo "distfile=$(find . -name 'netdata-*.tar.gz')" >> "${GITHUB_OUTPUT}"
  120. cp netdata-*.tar.gz artifacts/
  121. - name: Store
  122. id: store
  123. if: needs.file-check.outputs.run == 'true'
  124. uses: actions/upload-artifact@v3
  125. with:
  126. name: dist-tarball
  127. path: artifacts/*.tar.gz
  128. retention-days: 30
  129. - name: Failure Notification
  130. uses: rtCamp/action-slack-notify@v2
  131. env:
  132. SLACK_COLOR: 'danger'
  133. SLACK_FOOTER: ''
  134. SLACK_ICON_EMOJI: ':github-actions:'
  135. SLACK_TITLE: 'Distribution tarball creation failed:'
  136. SLACK_USERNAME: 'GitHub Actions'
  137. SLACK_MESSAGE: |-
  138. ${{ github.repository }}: Failed to create source tarball for distribution.
  139. Checkout: ${{ steps.checkout.outcome }}
  140. Fix Tags: ${{ steps.fix-tags.outcome }}
  141. Mark stable: ${{ steps.channel.outcome }}
  142. Build: ${{ steps.build.outcome }}
  143. Store: ${{ steps.store.outcome }}
  144. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  145. if: >-
  146. ${{
  147. failure()
  148. && startsWith(github.ref, 'refs/heads/master')
  149. && github.event_name != 'pull_request'
  150. && github.repository == 'netdata/netdata'
  151. && needs.file-check.outputs.run == 'true'
  152. }}
  153. build-static: # Build the static binary archives, and store them as artifacts.
  154. name: Build Static
  155. runs-on: ubuntu-latest
  156. needs:
  157. - file-check
  158. strategy:
  159. matrix:
  160. arch:
  161. - x86_64
  162. - armv7l
  163. - aarch64
  164. - ppc64le
  165. steps:
  166. - name: Skip Check
  167. id: skip
  168. if: needs.file-check.outputs.run != 'true'
  169. run: echo "SKIPPED"
  170. - name: Checkout
  171. id: checkout
  172. if: needs.file-check.outputs.run == 'true'
  173. uses: actions/checkout@v4
  174. with:
  175. fetch-depth: 0
  176. submodules: recursive
  177. - name: Fix tags
  178. id: fix-tags
  179. if: github.event_name != 'push' && needs.file-check.outputs.run == 'true'
  180. run: |
  181. git fetch --tags --force
  182. - name: Mark Stable
  183. id: channel
  184. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly' && needs.file-check.outputs.run == 'true'
  185. run: |
  186. sed -i 's/^RELEASE_CHANNEL="nightly"/RELEASE_CHANNEL="stable"/' netdata-installer.sh packaging/makeself/install-or-update.sh
  187. - name: Get Cache Key
  188. if: (github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache')) && needs.file-check.outputs.run == 'true'
  189. id: cache-key
  190. run: .github/scripts/get-static-cache-key.sh ${{ matrix.arch }} "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache') }}"
  191. - name: Cache
  192. if: (github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache')) && needs.file-check.outputs.run == 'true'
  193. id: cache
  194. uses: actions/cache@v3
  195. with:
  196. path: artifacts/cache
  197. key: ${{ steps.cache-key.outputs.key }}
  198. - name: Build
  199. if: github.event_name != 'workflow_dispatch' && needs.file-check.outputs.run == 'true' # Don’t use retries on PRs.
  200. run: .github/scripts/build-static.sh ${{ matrix.arch }}
  201. - name: Build
  202. if: github.event_name == 'workflow_dispatch' && needs.file-check.outputs.run == 'true'
  203. id: build
  204. uses: nick-fields/retry@v2
  205. with:
  206. timeout_minutes: 180
  207. max_attempts: 3
  208. command: .github/scripts/build-static.sh ${{ matrix.arch }}
  209. - name: Store
  210. id: store
  211. if: needs.file-check.outputs.run == 'true'
  212. uses: actions/upload-artifact@v3
  213. with:
  214. name: static-archive
  215. path: artifacts/*.gz.run
  216. retention-days: 30
  217. - name: Failure Notification
  218. uses: rtCamp/action-slack-notify@v2
  219. env:
  220. SLACK_COLOR: 'danger'
  221. SLACK_FOOTER: ''
  222. SLACK_ICON_EMOJI: ':github-actions:'
  223. SLACK_TITLE: 'Static build failed:'
  224. SLACK_USERNAME: 'GitHub Actions'
  225. SLACK_MESSAGE: |-
  226. ${{ github.repository }}: Failed to create static installer archive for ${{ matrix.arch }}.
  227. Checkout: ${{ steps.checkout.outcome }}
  228. Fix Tags: ${{ steps.fix-tags.outcome }}
  229. Mark stable: ${{ steps.channel.outcome }}
  230. Build: ${{ steps.build.outcome }}
  231. Store: ${{ steps.store.outcome }}
  232. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  233. if: >-
  234. ${{
  235. failure()
  236. && startsWith(github.ref, 'refs/heads/master')
  237. && github.event_name != 'pull_request'
  238. && github.repository == 'netdata/netdata'
  239. && needs.file-check.outputs.run == 'true'
  240. }}
  241. matrix: # Generate the shared build matrix for our build tests.
  242. name: Prepare Build Matrix
  243. runs-on: ubuntu-latest
  244. if: github.event_name != 'workflow_dispatch'
  245. outputs:
  246. matrix: ${{ steps.set-matrix.outputs.matrix }}
  247. steps:
  248. - name: Checkout
  249. id: checkout
  250. uses: actions/checkout@v4
  251. - name: Prepare tools
  252. id: prepare
  253. run: |
  254. sudo apt-get update && sudo apt-get install -y python3-ruamel.yaml
  255. - name: Read build matrix
  256. id: set-matrix
  257. run: |
  258. matrix="$(.github/scripts/gen-matrix-build.py)"
  259. echo "Generated matrix: ${matrix}"
  260. echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
  261. - name: Failure Notification
  262. uses: rtCamp/action-slack-notify@v2
  263. env:
  264. SLACK_COLOR: 'danger'
  265. SLACK_FOOTER: ''
  266. SLACK_ICON_EMOJI: ':github-actions:'
  267. SLACK_TITLE: 'Build matrix preparation failed:'
  268. SLACK_USERNAME: 'GitHub Actions'
  269. SLACK_MESSAGE: |-
  270. ${{ github.repository }}: Failed to prepare build matrix for build checks.
  271. Checkout: ${{ steps.checkout.outcome }}
  272. Prepare tools: ${{ steps.prepare.outcome }}
  273. Read build matrix: ${{ steps.set-matrix.outcome }}
  274. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  275. if: >-
  276. ${{
  277. failure()
  278. && startsWith(github.ref, 'refs/heads/master')
  279. && github.event_name != 'pull_request'
  280. && github.repository == 'netdata/netdata'
  281. }}
  282. prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
  283. name: Prepare Test Environments
  284. runs-on: ubuntu-latest
  285. if: github.event_name != 'workflow_dispatch'
  286. needs:
  287. - matrix
  288. env:
  289. RETRY_DELAY: 300
  290. strategy:
  291. # Unlike the actual build tests, this completes _very_ fast (average of about 3 minutes for each job), so we
  292. # just run everything in parallel instead lof limiting job concurrency.
  293. fail-fast: false
  294. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  295. steps:
  296. - name: Checkout
  297. id: checkout
  298. uses: actions/checkout@v4
  299. - name: Setup Buildx
  300. id: buildx
  301. uses: docker/setup-buildx-action@v3
  302. - name: Build test environment
  303. id: build1
  304. uses: docker/build-push-action@v5
  305. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  306. with:
  307. push: false
  308. load: false
  309. file: .github/dockerfiles/Dockerfile.build_test
  310. build-args: |
  311. BASE=${{ matrix.distro }}
  312. PRE=${{ matrix.env_prep }}
  313. RMJSONC=${{ matrix.jsonc_removal }}
  314. outputs: type=docker,dest=/tmp/image.tar
  315. tags: test:${{ matrix.artifact_key }}
  316. - name: Retry delay
  317. if: ${{ steps.build1.outcome == 'failure' }}
  318. run: sleep "${RETRY_DELAY}"
  319. - name: Build test environment (attempt 2)
  320. if: ${{ steps.build1.outcome == 'failure' }}
  321. id: build2
  322. uses: docker/build-push-action@v5
  323. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  324. with:
  325. push: false
  326. load: false
  327. file: .github/dockerfiles/Dockerfile.build_test
  328. build-args: |
  329. BASE=${{ matrix.distro }}
  330. PRE=${{ matrix.env_prep }}
  331. RMJSONC=${{ matrix.jsonc_removal }}
  332. outputs: type=docker,dest=/tmp/image.tar
  333. tags: test:${{ matrix.artifact_key }}
  334. - name: Retry delay
  335. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  336. run: sleep "${RETRY_DELAY}"
  337. - name: Build test environment (attempt 3)
  338. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  339. id: build3
  340. uses: docker/build-push-action@v5
  341. with:
  342. push: false
  343. load: false
  344. file: .github/dockerfiles/Dockerfile.build_test
  345. build-args: |
  346. BASE=${{ matrix.distro }}
  347. PRE=${{ matrix.env_prep }}
  348. RMJSONC=${{ matrix.jsonc_removal }}
  349. outputs: type=docker,dest=/tmp/image.tar
  350. tags: test:${{ matrix.artifact_key }}
  351. - name: Upload image artifact
  352. id: upload
  353. uses: actions/upload-artifact@v3
  354. with:
  355. name: ${{ matrix.artifact_key }}-test-env
  356. path: /tmp/image.tar
  357. retention-days: 30
  358. - name: Failure Notification
  359. uses: rtCamp/action-slack-notify@v2
  360. env:
  361. SLACK_COLOR: 'danger'
  362. SLACK_FOOTER: ''
  363. SLACK_ICON_EMOJI: ':github-actions:'
  364. SLACK_TITLE: 'Test environment preparation for ${{ matrix.distro }} failed:'
  365. SLACK_USERNAME: 'GitHub Actions'
  366. SLACK_MESSAGE: |-
  367. ${{ github.repository }}: Test environment preparation for ${{ matrix.distro }} failed.
  368. Checkout: ${{ steps.checkout.outcome }}
  369. Set up Buildx: ${{ steps.buildx.outcome }}
  370. Build test environment: ${{ steps.build1.outcome }}
  371. Build test environment (attempt 2): ${{ steps.build2.outcome }}
  372. Build test environment (attempt 3): ${{ steps.build3.outcome }}
  373. Upload: ${{ steps.upload.outcome }}
  374. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  375. if: >-
  376. ${{
  377. failure()
  378. && startsWith(github.ref, 'refs/heads/master')
  379. && github.event_name != 'pull_request'
  380. && github.repository == 'netdata/netdata'
  381. }}
  382. source-build: # Test various source build arrangements.
  383. name: Test Source Build
  384. runs-on: ubuntu-latest
  385. if: github.event_name != 'workflow_dispatch'
  386. needs:
  387. - matrix
  388. - prepare-test-images
  389. - file-check
  390. strategy:
  391. fail-fast: false
  392. max-parallel: 8
  393. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  394. steps:
  395. - name: Skip Check
  396. id: skip
  397. if: needs.file-check.outputs.run != 'true'
  398. run: echo "SKIPPED"
  399. - name: Checkout
  400. id: checkout
  401. if: needs.file-check.outputs.run == 'true'
  402. uses: actions/checkout@v4
  403. with:
  404. submodules: recursive
  405. - name: Fetch test environment
  406. id: fetch
  407. if: needs.file-check.outputs.run == 'true'
  408. uses: actions/download-artifact@v3
  409. with:
  410. name: ${{ matrix.artifact_key }}-test-env
  411. - name: Load test environment
  412. id: load
  413. if: needs.file-check.outputs.run == 'true'
  414. run: docker load --input image.tar
  415. - name: Regular build on ${{ matrix.distro }}
  416. id: build-basic
  417. if: needs.file-check.outputs.run == 'true'
  418. run: |
  419. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  420. /bin/sh -c 'autoreconf -ivf && ./configure --disable-dependency-tracking && make -j2'
  421. - name: netdata-installer on ${{ matrix.distro }}, disable cloud
  422. id: build-no-cloud
  423. if: needs.file-check.outputs.run == 'true'
  424. run: |
  425. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  426. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud --one-time-build'
  427. - name: netdata-installer on ${{ matrix.distro }}, require cloud
  428. id: build-cloud
  429. if: needs.file-check.outputs.run == 'true'
  430. run: |
  431. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  432. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  433. - name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
  434. id: build-no-jsonc
  435. if: matrix.jsonc_removal != '' && needs.file-check.outputs.run == 'true'
  436. run: |
  437. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  438. /bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  439. - name: Failure Notification
  440. uses: rtCamp/action-slack-notify@v2
  441. env:
  442. SLACK_COLOR: 'danger'
  443. SLACK_FOOTER: ''
  444. SLACK_ICON_EMOJI: ':github-actions:'
  445. SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
  446. SLACK_USERNAME: 'GitHub Actions'
  447. SLACK_MESSAGE: |-
  448. ${{ github.repository }}: Build tests for ${{ matrix.distro }} failed.
  449. Checkout: ${{ steps.checkout.outcome }}
  450. Fetch test environment: ${{ steps.fetch.outcome }}
  451. Load test environment: ${{ steps.load.outcome }}
  452. Regular build: ${{ steps.build-basic.outcome }}
  453. netdata-installer, disable cloud: ${{ steps.build-no-cloud.outcome }}
  454. netdata-installer, require cloud: ${{ steps.build-cloud.outcome }}
  455. netdata-installer, no JSON-C: ${{ steps.build-no-jsonc.outcome }}
  456. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  457. if: >-
  458. ${{
  459. failure()
  460. && startsWith(github.ref, 'refs/heads/master')
  461. && github.event_name != 'pull_request'
  462. && github.repository == 'netdata/netdata'
  463. && needs.file-check.outputs.run == 'true'
  464. }}
  465. updater-check: # Test the generated dist archive using the updater code.
  466. name: Test Generated Distfile and Updater Code
  467. runs-on: ubuntu-latest
  468. if: github.event_name != 'workflow_dispatch'
  469. needs:
  470. - build-dist
  471. - matrix
  472. - prepare-test-images
  473. - file-check
  474. strategy:
  475. fail-fast: false
  476. max-parallel: 8
  477. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  478. services:
  479. apache: # This gets used to serve the dist tarball for the updater script.
  480. image: httpd:2.4
  481. ports:
  482. - 8080:80
  483. volumes:
  484. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  485. steps:
  486. - name: Skip Check
  487. id: skip
  488. if: needs.file-check.outputs.run != 'true'
  489. run: echo "SKIPPED"
  490. - name: Checkout
  491. id: checkout
  492. if: needs.file-check.outputs.run == 'true'
  493. uses: actions/checkout@v4
  494. - name: Fetch dist tarball artifacts
  495. id: fetch-tarball
  496. if: needs.file-check.outputs.run == 'true'
  497. uses: actions/download-artifact@v3
  498. with:
  499. name: dist-tarball
  500. path: dist-tarball
  501. - name: Prepare artifact directory
  502. id: prepare
  503. if: needs.file-check.outputs.run == 'true'
  504. run: |
  505. mkdir -p artifacts/download/latest || exit 1
  506. echo "9999.0.0-0" > artifacts/download/latest/latest-version.txt || exit 1
  507. cp dist-tarball/* artifacts/download/latest || exit 1
  508. cd artifacts/download/latest || exit 1
  509. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  510. sha256sum -b ./* > "sha256sums.txt" || exit 1
  511. cat sha256sums.txt
  512. - name: Fetch test environment
  513. id: fetch-test-environment
  514. if: needs.file-check.outputs.run == 'true'
  515. uses: actions/download-artifact@v3
  516. with:
  517. name: ${{ matrix.artifact_key }}-test-env
  518. - name: Load test environment
  519. id: load
  520. if: needs.file-check.outputs.run == 'true'
  521. run: docker load --input image.tar
  522. - name: Install netdata and run the updater on ${{ matrix.distro }}
  523. id: updater-check
  524. if: needs.file-check.outputs.run == 'true'
  525. run: |
  526. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --network host -w /netdata test:${{ matrix.artifact_key }} \
  527. /netdata/.github/scripts/run-updater-check.sh
  528. - name: Failure Notification
  529. uses: rtCamp/action-slack-notify@v2
  530. env:
  531. SLACK_COLOR: 'danger'
  532. SLACK_FOOTER: ''
  533. SLACK_ICON_EMOJI: ':github-actions:'
  534. SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
  535. SLACK_USERNAME: 'GitHub Actions'
  536. SLACK_MESSAGE: |-
  537. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  538. Checkout: ${{ steps.checkout.outcome }}
  539. Fetch dist tarball: ${{ steps.fetch-tarball.outcome }}
  540. Prepare artifact directory: ${{ steps.prepare.outcome }}
  541. Fetch test environment: ${{ steps.fetch-test-environment.outcome }}
  542. Load test environment: ${{ steps.load.outcome }}
  543. Updater check: ${{ steps.updater-check.outcome }}
  544. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  545. if: >-
  546. ${{
  547. failure()
  548. && startsWith(github.ref, 'refs/heads/master')
  549. && github.event_name != 'pull_request'
  550. && github.repository == 'netdata/netdata'
  551. && needs.file-check.outputs.run == 'true'
  552. }}
  553. prepare-upload: # Consolidate the artifacts for uploading or releasing.
  554. name: Prepare Artifacts
  555. runs-on: ubuntu-latest
  556. needs:
  557. - build-dist
  558. - build-static
  559. - file-check
  560. steps:
  561. - name: Skip Check
  562. id: skip
  563. if: needs.file-check.outputs.run != 'true'
  564. run: echo "SKIPPED"
  565. - name: Checkout
  566. id: checkout
  567. if: needs.file-check.outputs.run == 'true'
  568. uses: actions/checkout@v4
  569. - name: Prepare Environment
  570. id: prepare
  571. if: needs.file-check.outputs.run == 'true'
  572. run: mkdir -p artifacts
  573. - name: Retrieve Dist Tarball
  574. id: fetch-dist
  575. if: needs.file-check.outputs.run == 'true'
  576. uses: actions/download-artifact@v3
  577. with:
  578. name: dist-tarball
  579. path: dist-tarball
  580. - name: Retrieve Static Build Artifacts
  581. id: fetch-static
  582. if: needs.file-check.outputs.run == 'true'
  583. uses: actions/download-artifact@v3
  584. with:
  585. name: static-archive
  586. path: static-archive
  587. - name: Prepare Artifacts
  588. id: consolidate
  589. if: needs.file-check.outputs.run == 'true'
  590. working-directory: ./artifacts/
  591. run: |
  592. mv ../dist-tarball/* . || exit 1
  593. mv ../static-archive/* . || exit 1
  594. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  595. cp ../packaging/version ./latest-version.txt || exit 1
  596. cp ../integrations/integrations.js ./integrations.js || exit 1
  597. sha256sum -b ./* > sha256sums.txt || exit 1
  598. cat sha256sums.txt
  599. - name: Store Artifacts
  600. id: store
  601. if: needs.file-check.outputs.run == 'true'
  602. uses: actions/upload-artifact@v3
  603. with:
  604. name: final-artifacts
  605. path: artifacts/*
  606. retention-days: 30
  607. - name: Failure Notification
  608. uses: rtCamp/action-slack-notify@v2
  609. env:
  610. SLACK_COLOR: 'danger'
  611. SLACK_FOOTER: ''
  612. SLACK_ICON_EMOJI: ':github-actions:'
  613. SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
  614. SLACK_USERNAME: 'GitHub Actions'
  615. SLACK_MESSAGE: |-
  616. ${{ github.repository }}: Failed to prepare release artifacts for upload.
  617. CHeckout: ${{ steps.checkout.outcome }}
  618. Prepare environment: ${{ steps.prepare.outcome }}
  619. Fetch dist tarball: ${{ steps.fetch-dist.outcome }}
  620. Fetch static builds: ${{ steps.fetch-static.outcome }}
  621. Consolidate artifacts: ${{ steps.consolidate.outcome }}
  622. Store: ${{ steps.store.outcome }}
  623. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  624. if: >-
  625. ${{
  626. failure()
  627. && startsWith(github.ref, 'refs/heads/master')
  628. && github.event_name != 'pull_request'
  629. && github.repository == 'netdata/netdata'
  630. && needs.file-check.outputs.run == 'true'
  631. }}
  632. artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
  633. name: Test Consolidated Artifacts (Source)
  634. runs-on: ubuntu-latest
  635. needs:
  636. - prepare-upload
  637. - file-check
  638. services:
  639. apache: # This gets used to serve the dist tarball for the updater script.
  640. image: httpd:2.4
  641. ports:
  642. - 8080:80
  643. volumes:
  644. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  645. steps:
  646. - name: Skip Check
  647. id: skip
  648. if: needs.file-check.outputs.run != 'true'
  649. run: echo "SKIPPED"
  650. - name: Checkout
  651. id: checkout
  652. if: needs.file-check.outputs.run == 'true'
  653. uses: actions/checkout@v4
  654. - name: Fetch artifacts
  655. id: fetch
  656. if: needs.file-check.outputs.run == 'true'
  657. uses: actions/download-artifact@v3
  658. with:
  659. name: final-artifacts
  660. path: artifacts
  661. - name: Prepare artifacts directory
  662. id: prepare
  663. if: needs.file-check.outputs.run == 'true'
  664. run: |
  665. mkdir -p download/latest
  666. mv artifacts/* download/latest
  667. - name: Verify that artifacts work with installer
  668. id: verify
  669. if: needs.file-check.outputs.run == 'true'
  670. env:
  671. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  672. run: packaging/installer/kickstart.sh --build-only --dont-start-it --disable-telemetry --dont-wait
  673. - name: Failure Notification
  674. uses: rtCamp/action-slack-notify@v2
  675. env:
  676. SLACK_COLOR: 'danger'
  677. SLACK_FOOTER: ''
  678. SLACK_ICON_EMOJI: ':github-actions:'
  679. SLACK_TITLE: 'Artifact verification for source tarball failed.'
  680. SLACK_USERNAME: 'GitHub Actions'
  681. SLACK_MESSAGE: |-
  682. ${{ github.repository }}: Artifact verification for source tarball failed.
  683. Checkout: ${{ steps.checkout.outcome }}
  684. Fetch artifacts: ${{ steps.fetch.outcome }}
  685. Verify artifacts: ${{ steps.verify.outcome }}
  686. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  687. if: >-
  688. ${{
  689. failure()
  690. && startsWith(github.ref, 'refs/heads/master')
  691. && github.event_name != 'pull_request'
  692. && github.repository == 'netdata/netdata'
  693. && needs.file-check.outputs.run == 'true'
  694. }}
  695. artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
  696. name: Test Consolidated Artifacts (Static)
  697. runs-on: ubuntu-latest
  698. needs:
  699. - prepare-upload
  700. - file-check
  701. services:
  702. apache: # This gets used to serve the static archives.
  703. image: httpd:2.4
  704. ports:
  705. - 8080:80
  706. volumes:
  707. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  708. steps:
  709. - name: Skip Check
  710. id: skip
  711. if: needs.file-check.outputs.run != 'true'
  712. run: echo "SKIPPED"
  713. - name: Checkout
  714. id: checkout
  715. if: needs.file-check.outputs.run == 'true'
  716. uses: actions/checkout@v4
  717. - name: Fetch artifacts
  718. id: fetch-artifacts
  719. if: needs.file-check.outputs.run == 'true'
  720. uses: actions/download-artifact@v3
  721. with:
  722. name: final-artifacts
  723. path: artifacts
  724. - name: Prepare artifacts directory
  725. id: prepare
  726. if: needs.file-check.outputs.run == 'true'
  727. run: |
  728. mkdir -p download/latest
  729. mv artifacts/* download/latest
  730. - name: Verify that artifacts work with installer
  731. id: verify
  732. if: needs.file-check.outputs.run == 'true'
  733. env:
  734. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  735. run: packaging/installer/kickstart.sh --static-only --dont-start-it --disable-telemetry
  736. - name: Failure Notification
  737. uses: rtCamp/action-slack-notify@v2
  738. env:
  739. SLACK_COLOR: 'danger'
  740. SLACK_FOOTER: ''
  741. SLACK_ICON_EMOJI: ':github-actions:'
  742. SLACK_TITLE: 'Artifact verification for static build failed.'
  743. SLACK_USERNAME: 'GitHub Actions'
  744. SLACK_MESSAGE: |-
  745. ${{ github.repository }}: Artifact verification for static build failed.
  746. Checkout: ${{ steps.checkout.outcome }}
  747. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  748. Verify artifacts: ${{ steps.verify.outcome }}
  749. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  750. if: >-
  751. ${{
  752. failure()
  753. && startsWith(github.ref, 'refs/heads/master')
  754. && github.event_name != 'pull_request'
  755. && github.repository == 'netdata/netdata'
  756. && needs.file-check.outputs.run == 'true'
  757. }}
  758. upload-nightly: # Upload the nightly build artifacts to GCS.
  759. name: Upload Nightly Artifacts
  760. runs-on: ubuntu-latest
  761. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  762. needs:
  763. - artifact-verification-dist
  764. - artifact-verification-static
  765. steps:
  766. - name: Retrieve Artifacts
  767. id: fetch
  768. uses: actions/download-artifact@v3
  769. with:
  770. name: final-artifacts
  771. path: final-artifacts
  772. - name: Authenticate to GCS
  773. id: gcs-auth
  774. uses: google-github-actions/auth@v1
  775. with:
  776. project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
  777. credentials_json: ${{ secrets.GCS_STORAGE_SERVICE_KEY_JSON }}
  778. - name: Setup GCS
  779. id: gcs-setup
  780. uses: google-github-actions/setup-gcloud@v1.1.1
  781. - name: Upload Artifacts
  782. id: upload
  783. uses: google-github-actions/upload-cloud-storage@v1.0.3
  784. with:
  785. destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
  786. gzip: false
  787. path: ./final-artifacts
  788. parent: false
  789. - name: Failure Notification
  790. uses: rtCamp/action-slack-notify@v2
  791. env:
  792. SLACK_COLOR: 'danger'
  793. SLACK_FOOTER: ''
  794. SLACK_ICON_EMOJI: ':github-actions:'
  795. SLACK_TITLE: 'Failed to upload nightly release artifacts:'
  796. SLACK_USERNAME: 'GitHub Actions'
  797. SLACK_MESSAGE: |-
  798. ${{ github.repository }}: Failed to upload nightly release artifacts.
  799. Fetch artifacts: ${{ steps.fetch.outcome }}
  800. Authenticatie GCS: ${{ steps.gcs-auth.outcome }}
  801. Setup GCS: ${{ steps.gcs-setup.outcome }}
  802. Upload artifacts: ${{ steps.upload.outcome }}
  803. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  804. if: >-
  805. ${{
  806. failure()
  807. && startsWith(github.ref, 'refs/heads/master')
  808. && github.event_name != 'pull_request'
  809. }}
  810. create-nightly: # Create a nightly build release in netdata/netdata-nightlies
  811. name: Create Nightly Release
  812. runs-on: ubuntu-latest
  813. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  814. needs:
  815. - artifact-verification-dist
  816. - artifact-verification-static
  817. steps:
  818. - name: Checkout Main Repo
  819. id: checkout-main
  820. uses: actions/checkout@v4
  821. with:
  822. path: main
  823. - name: Checkout Nightly Repo
  824. id: checkout-nightly
  825. uses: actions/checkout@v4
  826. with:
  827. repository: netdata/netdata-nightlies
  828. path: nightlies
  829. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  830. - name: Retrieve Artifacts
  831. id: fetch
  832. uses: actions/download-artifact@v3
  833. with:
  834. name: final-artifacts
  835. path: final-artifacts
  836. - name: Prepare version info
  837. id: version
  838. run: |
  839. # shellcheck disable=SC2129
  840. echo "version=$(cat main/packaging/version)" >> "${GITHUB_OUTPUT}"
  841. echo "commit=$(cd nightlies && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
  842. echo "date=$(date +%F)" >> "${GITHUB_OUTPUT}"
  843. - name: Create Release
  844. id: create-release
  845. uses: ncipollo/release-action@v1
  846. with:
  847. allowUpdates: false
  848. artifactErrorsFailBuild: true
  849. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  850. owner: netdata
  851. repo: netdata-nightlies
  852. body: Netdata nightly build for ${{ steps.version.outputs.date }}.
  853. commit: ${{ steps.version.outputs.commit }}
  854. makeLatest: true
  855. tag: ${{ steps.version.outputs.version }}
  856. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  857. - name: Checkout netdata main Repo # Checkout back to netdata/netdata repo to the update latest packaged versions
  858. id: checkout-netdata
  859. uses: actions/checkout@v4
  860. with:
  861. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  862. - name: Init python environment for publish release metadata
  863. uses: actions/setup-python@v4
  864. id: init-python
  865. with:
  866. python-version: "3.12"
  867. - name: Setup python environment
  868. id: setup-python
  869. run: |
  870. pip install -r .github/scripts/modules/requirements.txt
  871. - name: Check if the version is latest and published
  872. id: check-latest-version
  873. run: |
  874. python .github/scripts/check_latest_versions.py ${{ steps.version.outputs.version }}
  875. - name: SSH setup
  876. id: ssh-setup
  877. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  878. uses: shimataro/ssh-key-action@v2
  879. with:
  880. key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
  881. name: id_ecdsa
  882. known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
  883. - name: Sync newer releases
  884. id: sync-releases
  885. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  886. run: |
  887. .github/scripts/upload-new-version-tags.sh
  888. - name: Failure Notification
  889. uses: rtCamp/action-slack-notify@v2
  890. env:
  891. SLACK_COLOR: 'danger'
  892. SLACK_FOOTER: ''
  893. SLACK_ICON_EMOJI: ':github-actions:'
  894. SLACK_TITLE: 'Failed to draft release:'
  895. SLACK_USERNAME: 'GitHub Actions'
  896. SLACK_MESSAGE: |-
  897. ${{ github.repository }}: Failed to create nightly release or attach artifacts.
  898. Checkout netdata/netdata: ${{ steps.checkout-main.outcome }}
  899. Checkout netdata/netdata-nightlies: ${{ steps.checkout-nightly.outcome }}
  900. Fetch artifacts: ${{ steps.fetch.outcome }}
  901. Prepare version info: ${{ steps.version.outcome }}
  902. Create release: ${{ steps.create-release.outcome }}
  903. Checkout back netdata/netdata: ${{ steps.checkout-netdata.outcome }}
  904. Init python environment: ${{ steps.init-python.outcome }}
  905. Setup python environment: ${{ steps.setup-python.outcome }}
  906. Check the nearly published release against the advertised: ${{ steps.check-latest-version.outcome }}
  907. Setup ssh: ${{ steps.ssh-setup.outcome }}
  908. Sync with the releases: ${{ steps.sync-releases.outcome }}
  909. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  910. if: >-
  911. ${{
  912. failure()
  913. && github.event_name == 'workflow_dispatch'
  914. }}
  915. normalize-tag: # Fix the release tag if needed
  916. name: Normalize Release Tag
  917. runs-on: ubuntu-latest
  918. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  919. outputs:
  920. tag: ${{ steps.tag.outputs.tag }}
  921. steps:
  922. - name: Normalize Tag
  923. id: tag
  924. run: |
  925. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  926. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  927. else
  928. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  929. fi
  930. upload-release: # Create the draft release and upload the build artifacts.
  931. name: Create Release Draft
  932. runs-on: ubuntu-latest
  933. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  934. needs:
  935. - artifact-verification-dist
  936. - artifact-verification-static
  937. - normalize-tag
  938. steps:
  939. - name: Checkout
  940. id: checkout
  941. uses: actions/checkout@v4
  942. - name: Retrieve Artifacts
  943. id: fetch
  944. uses: actions/download-artifact@v3
  945. with:
  946. name: final-artifacts
  947. path: final-artifacts
  948. - name: Create Release
  949. id: create-release
  950. uses: ncipollo/release-action@v1
  951. with:
  952. allowUpdates: false
  953. artifactErrorsFailBuild: true
  954. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  955. draft: true
  956. tag: ${{ needs.normalize-tag.outputs.tag }}
  957. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  958. - name: Failure Notification
  959. uses: rtCamp/action-slack-notify@v2
  960. env:
  961. SLACK_COLOR: 'danger'
  962. SLACK_FOOTER: ''
  963. SLACK_ICON_EMOJI: ':github-actions:'
  964. SLACK_TITLE: 'Failed to draft release:'
  965. SLACK_USERNAME: 'GitHub Actions'
  966. SLACK_MESSAGE: |-
  967. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  968. Checkout: ${{ steps.checkout.outcome }}
  969. Fetch artifacts: ${{ steps.fetch.outcome }}
  970. Create draft release: ${{ steps.create-release.outcome }}
  971. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  972. if: >-
  973. ${{
  974. failure()
  975. && github.event_name == 'workflow_dispatch'
  976. }}
  977. - name: Success Notification
  978. uses: rtCamp/action-slack-notify@v2
  979. env:
  980. SLACK_COLOR: 'good'
  981. SLACK_FOOTER: ''
  982. SLACK_ICON_EMOJI: ':github-actions:'
  983. SLACK_TITLE: 'Created agent draft release:'
  984. SLACK_USERNAME: 'GitHub Actions'
  985. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  986. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  987. if: >-
  988. ${{
  989. success()
  990. && github.event_name == 'workflow_dispatch'
  991. }}