build.yml 39 KB

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