build.yml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  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@v39
  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: Failure Notification
  858. uses: rtCamp/action-slack-notify@v2
  859. env:
  860. SLACK_COLOR: 'danger'
  861. SLACK_FOOTER: ''
  862. SLACK_ICON_EMOJI: ':github-actions:'
  863. SLACK_TITLE: 'Failed to draft release:'
  864. SLACK_USERNAME: 'GitHub Actions'
  865. SLACK_MESSAGE: |-
  866. ${{ github.repository }}: Failed to create nightly release or attach artifacts.
  867. Checkout netdata/netdata: ${{ steps.checkout-main.outcome }}
  868. Checkout netdata/netdata-nightlies: ${{ steps.checkout-nightly.outcome }}
  869. Fetch artifacts: ${{ steps.fetch.outcome }}
  870. Prepare version info: ${{ steps.version.outcome }}
  871. Create release: ${{ steps.create-release.outcome }}
  872. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  873. if: >-
  874. ${{
  875. failure()
  876. && github.event_name == 'workflow_dispatch'
  877. }}
  878. normalize-tag: # Fix the release tag if needed
  879. name: Normalize Release Tag
  880. runs-on: ubuntu-latest
  881. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  882. outputs:
  883. tag: ${{ steps.tag.outputs.tag }}
  884. steps:
  885. - name: Normalize Tag
  886. id: tag
  887. run: |
  888. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  889. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  890. else
  891. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  892. fi
  893. upload-release: # Create the draft release and upload the build artifacts.
  894. name: Create Release Draft
  895. runs-on: ubuntu-latest
  896. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  897. needs:
  898. - artifact-verification-dist
  899. - artifact-verification-static
  900. - normalize-tag
  901. steps:
  902. - name: Checkout
  903. id: checkout
  904. uses: actions/checkout@v4
  905. - name: Retrieve Artifacts
  906. id: fetch
  907. uses: actions/download-artifact@v3
  908. with:
  909. name: final-artifacts
  910. path: final-artifacts
  911. - name: Create Release
  912. id: create-release
  913. uses: ncipollo/release-action@v1
  914. with:
  915. allowUpdates: false
  916. artifactErrorsFailBuild: true
  917. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  918. draft: true
  919. tag: ${{ needs.normalize-tag.outputs.tag }}
  920. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  921. - name: Failure Notification
  922. uses: rtCamp/action-slack-notify@v2
  923. env:
  924. SLACK_COLOR: 'danger'
  925. SLACK_FOOTER: ''
  926. SLACK_ICON_EMOJI: ':github-actions:'
  927. SLACK_TITLE: 'Failed to draft release:'
  928. SLACK_USERNAME: 'GitHub Actions'
  929. SLACK_MESSAGE: |-
  930. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  931. Checkout: ${{ steps.checkout.outcome }}
  932. Fetch artifacts: ${{ steps.fetch.outcome }}
  933. Create draft release: ${{ steps.create-release.outcome }}
  934. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  935. if: >-
  936. ${{
  937. failure()
  938. && github.event_name == 'workflow_dispatch'
  939. }}
  940. - name: Success Notification
  941. uses: rtCamp/action-slack-notify@v2
  942. env:
  943. SLACK_COLOR: 'good'
  944. SLACK_FOOTER: ''
  945. SLACK_ICON_EMOJI: ':github-actions:'
  946. SLACK_TITLE: 'Created agent draft release:'
  947. SLACK_USERNAME: 'GitHub Actions'
  948. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  949. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  950. if: >-
  951. ${{
  952. success()
  953. && github.event_name == 'workflow_dispatch'
  954. }}