build.yml 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  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@v3
  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@v3
  204. with:
  205. name: static-archive
  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@v3
  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: actions/download-artifact@v3
  400. with:
  401. name: ${{ matrix.artifact_key }}-test-env
  402. - name: Load test environment
  403. id: load
  404. if: needs.file-check.outputs.run == 'true'
  405. run: docker load --input image.tar
  406. - name: netdata-installer on ${{ matrix.distro }}, disable cloud
  407. id: build-no-cloud
  408. if: needs.file-check.outputs.run == 'true'
  409. run: |
  410. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  411. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud --one-time-build'
  412. - name: netdata-installer on ${{ matrix.distro }}, require cloud
  413. id: build-cloud
  414. if: needs.file-check.outputs.run == 'true'
  415. run: |
  416. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  417. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  418. - name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
  419. id: build-no-jsonc
  420. if: matrix.jsonc_removal != '' && needs.file-check.outputs.run == 'true'
  421. run: |
  422. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  423. /bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  424. - name: Failure Notification
  425. uses: rtCamp/action-slack-notify@v2
  426. env:
  427. SLACK_COLOR: 'danger'
  428. SLACK_FOOTER: ''
  429. SLACK_ICON_EMOJI: ':github-actions:'
  430. SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
  431. SLACK_USERNAME: 'GitHub Actions'
  432. SLACK_MESSAGE: |-
  433. ${{ github.repository }}: Build tests for ${{ matrix.distro }} failed.
  434. Checkout: ${{ steps.checkout.outcome }}
  435. Fetch test environment: ${{ steps.fetch.outcome }}
  436. Load test environment: ${{ steps.load.outcome }}
  437. netdata-installer, disable cloud: ${{ steps.build-no-cloud.outcome }}
  438. netdata-installer, require cloud: ${{ steps.build-cloud.outcome }}
  439. netdata-installer, no JSON-C: ${{ steps.build-no-jsonc.outcome }}
  440. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  441. if: >-
  442. ${{
  443. failure()
  444. && startsWith(github.ref, 'refs/heads/master')
  445. && github.event_name != 'pull_request'
  446. && github.repository == 'netdata/netdata'
  447. && needs.file-check.outputs.run == 'true'
  448. }}
  449. updater-check: # Test the generated dist archive using the updater code.
  450. name: Test Generated Distfile and Updater Code
  451. runs-on: ubuntu-latest
  452. if: github.event_name != 'workflow_dispatch'
  453. needs:
  454. - build-dist
  455. - matrix
  456. - prepare-test-images
  457. - file-check
  458. strategy:
  459. fail-fast: false
  460. max-parallel: 8
  461. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  462. services:
  463. apache: # This gets used to serve the dist tarball for the updater script.
  464. image: httpd:2.4
  465. ports:
  466. - 8080:80
  467. volumes:
  468. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  469. steps:
  470. - name: Skip Check
  471. id: skip
  472. if: needs.file-check.outputs.run != 'true'
  473. run: echo "SKIPPED"
  474. - name: Checkout
  475. id: checkout
  476. if: needs.file-check.outputs.run == 'true'
  477. uses: actions/checkout@v4
  478. - name: Fetch dist tarball artifacts
  479. id: fetch-tarball
  480. if: needs.file-check.outputs.run == 'true'
  481. uses: actions/download-artifact@v3
  482. with:
  483. name: dist-tarball
  484. path: dist-tarball
  485. - name: Prepare artifact directory
  486. id: prepare
  487. if: needs.file-check.outputs.run == 'true'
  488. run: |
  489. mkdir -p artifacts/download/latest || exit 1
  490. echo "9999.0.0-0" > artifacts/download/latest/latest-version.txt || exit 1
  491. cp dist-tarball/* artifacts/download/latest || exit 1
  492. cd artifacts/download/latest || exit 1
  493. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  494. ls -lFh
  495. sha256sum -b ./* > "sha256sums.txt" || exit 1
  496. cat sha256sums.txt
  497. - name: Fetch test environment
  498. id: fetch-test-environment
  499. if: needs.file-check.outputs.run == 'true'
  500. uses: actions/download-artifact@v3
  501. with:
  502. name: ${{ matrix.artifact_key }}-test-env
  503. - name: Load test environment
  504. id: load
  505. if: needs.file-check.outputs.run == 'true'
  506. run: docker load --input image.tar
  507. - name: Install netdata and run the updater on ${{ matrix.distro }}
  508. id: updater-check
  509. if: needs.file-check.outputs.run == 'true'
  510. run: |
  511. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --network host -w /netdata test:${{ matrix.artifact_key }} \
  512. /netdata/.github/scripts/run-updater-check.sh
  513. - name: Failure Notification
  514. uses: rtCamp/action-slack-notify@v2
  515. env:
  516. SLACK_COLOR: 'danger'
  517. SLACK_FOOTER: ''
  518. SLACK_ICON_EMOJI: ':github-actions:'
  519. SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
  520. SLACK_USERNAME: 'GitHub Actions'
  521. SLACK_MESSAGE: |-
  522. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  523. Checkout: ${{ steps.checkout.outcome }}
  524. Fetch dist tarball: ${{ steps.fetch-tarball.outcome }}
  525. Prepare artifact directory: ${{ steps.prepare.outcome }}
  526. Fetch test environment: ${{ steps.fetch-test-environment.outcome }}
  527. Load test environment: ${{ steps.load.outcome }}
  528. Updater check: ${{ steps.updater-check.outcome }}
  529. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  530. if: >-
  531. ${{
  532. failure()
  533. && startsWith(github.ref, 'refs/heads/master')
  534. && github.event_name != 'pull_request'
  535. && github.repository == 'netdata/netdata'
  536. && needs.file-check.outputs.run == 'true'
  537. }}
  538. prepare-upload: # Consolidate the artifacts for uploading or releasing.
  539. name: Prepare Artifacts
  540. runs-on: ubuntu-latest
  541. needs:
  542. - build-dist
  543. - build-static
  544. - file-check
  545. steps:
  546. - name: Skip Check
  547. id: skip
  548. if: needs.file-check.outputs.run != 'true'
  549. run: echo "SKIPPED"
  550. - name: Checkout
  551. id: checkout
  552. if: needs.file-check.outputs.run == 'true'
  553. uses: actions/checkout@v4
  554. - name: Prepare Environment
  555. id: prepare
  556. if: needs.file-check.outputs.run == 'true'
  557. run: mkdir -p artifacts
  558. - name: Retrieve Dist Tarball
  559. id: fetch-dist
  560. if: needs.file-check.outputs.run == 'true'
  561. uses: actions/download-artifact@v3
  562. with:
  563. name: dist-tarball
  564. path: dist-tarball
  565. - name: Retrieve Static Build Artifacts
  566. id: fetch-static
  567. if: needs.file-check.outputs.run == 'true'
  568. uses: actions/download-artifact@v3
  569. with:
  570. name: static-archive
  571. path: static-archive
  572. - name: Prepare Artifacts
  573. id: consolidate
  574. if: needs.file-check.outputs.run == 'true'
  575. working-directory: ./artifacts/
  576. run: |
  577. mv ../dist-tarball/* . || exit 1
  578. mv ../static-archive/* . || exit 1
  579. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  580. cp ../packaging/version ./latest-version.txt || exit 1
  581. cp ../integrations/integrations.js ./integrations.js || exit 1
  582. sha256sum -b ./* > sha256sums.txt || exit 1
  583. cat sha256sums.txt
  584. - name: Store Artifacts
  585. id: store
  586. if: needs.file-check.outputs.run == 'true'
  587. uses: actions/upload-artifact@v3
  588. with:
  589. name: final-artifacts
  590. path: artifacts/*
  591. retention-days: 30
  592. - name: Failure Notification
  593. uses: rtCamp/action-slack-notify@v2
  594. env:
  595. SLACK_COLOR: 'danger'
  596. SLACK_FOOTER: ''
  597. SLACK_ICON_EMOJI: ':github-actions:'
  598. SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
  599. SLACK_USERNAME: 'GitHub Actions'
  600. SLACK_MESSAGE: |-
  601. ${{ github.repository }}: Failed to prepare release artifacts for upload.
  602. CHeckout: ${{ steps.checkout.outcome }}
  603. Prepare environment: ${{ steps.prepare.outcome }}
  604. Fetch dist tarball: ${{ steps.fetch-dist.outcome }}
  605. Fetch static builds: ${{ steps.fetch-static.outcome }}
  606. Consolidate artifacts: ${{ steps.consolidate.outcome }}
  607. Store: ${{ steps.store.outcome }}
  608. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  609. if: >-
  610. ${{
  611. failure()
  612. && startsWith(github.ref, 'refs/heads/master')
  613. && github.event_name != 'pull_request'
  614. && github.repository == 'netdata/netdata'
  615. && needs.file-check.outputs.run == 'true'
  616. }}
  617. artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
  618. name: Test Consolidated Artifacts (Source)
  619. runs-on: ubuntu-latest
  620. needs:
  621. - prepare-upload
  622. - file-check
  623. services:
  624. apache: # This gets used to serve the dist tarball for the updater script.
  625. image: httpd:2.4
  626. ports:
  627. - 8080:80
  628. volumes:
  629. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  630. steps:
  631. - name: Skip Check
  632. id: skip
  633. if: needs.file-check.outputs.run != 'true'
  634. run: echo "SKIPPED"
  635. - name: Checkout
  636. id: checkout
  637. if: needs.file-check.outputs.run == 'true'
  638. uses: actions/checkout@v4
  639. - name: Fetch artifacts
  640. id: fetch
  641. if: needs.file-check.outputs.run == 'true'
  642. uses: actions/download-artifact@v3
  643. with:
  644. name: final-artifacts
  645. path: artifacts
  646. - name: Prepare artifacts directory
  647. id: prepare
  648. if: needs.file-check.outputs.run == 'true'
  649. run: |
  650. mkdir -p download/latest
  651. mv artifacts/* download/latest
  652. - name: Verify that artifacts work with installer
  653. id: verify
  654. if: needs.file-check.outputs.run == 'true'
  655. env:
  656. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  657. run: packaging/installer/kickstart.sh --build-only --dont-start-it --disable-telemetry --dont-wait
  658. - name: Failure Notification
  659. uses: rtCamp/action-slack-notify@v2
  660. env:
  661. SLACK_COLOR: 'danger'
  662. SLACK_FOOTER: ''
  663. SLACK_ICON_EMOJI: ':github-actions:'
  664. SLACK_TITLE: 'Artifact verification for source tarball failed.'
  665. SLACK_USERNAME: 'GitHub Actions'
  666. SLACK_MESSAGE: |-
  667. ${{ github.repository }}: Artifact verification for source tarball failed.
  668. Checkout: ${{ steps.checkout.outcome }}
  669. Fetch artifacts: ${{ steps.fetch.outcome }}
  670. Verify artifacts: ${{ steps.verify.outcome }}
  671. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  672. if: >-
  673. ${{
  674. failure()
  675. && startsWith(github.ref, 'refs/heads/master')
  676. && github.event_name != 'pull_request'
  677. && github.repository == 'netdata/netdata'
  678. && needs.file-check.outputs.run == 'true'
  679. }}
  680. artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
  681. name: Test Consolidated Artifacts (Static)
  682. runs-on: ubuntu-latest
  683. needs:
  684. - prepare-upload
  685. - file-check
  686. services:
  687. apache: # This gets used to serve the static archives.
  688. image: httpd:2.4
  689. ports:
  690. - 8080:80
  691. volumes:
  692. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  693. steps:
  694. - name: Skip Check
  695. id: skip
  696. if: needs.file-check.outputs.run != 'true'
  697. run: echo "SKIPPED"
  698. - name: Checkout
  699. id: checkout
  700. if: needs.file-check.outputs.run == 'true'
  701. uses: actions/checkout@v4
  702. - name: Fetch artifacts
  703. id: fetch-artifacts
  704. if: needs.file-check.outputs.run == 'true'
  705. uses: actions/download-artifact@v3
  706. with:
  707. name: final-artifacts
  708. path: artifacts
  709. - name: Prepare artifacts directory
  710. id: prepare
  711. if: needs.file-check.outputs.run == 'true'
  712. run: |
  713. mkdir -p download/latest
  714. mv artifacts/* download/latest
  715. - name: Verify that artifacts work with installer
  716. id: verify
  717. if: needs.file-check.outputs.run == 'true'
  718. env:
  719. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  720. run: packaging/installer/kickstart.sh --static-only --dont-start-it --disable-telemetry
  721. - name: Failure Notification
  722. uses: rtCamp/action-slack-notify@v2
  723. env:
  724. SLACK_COLOR: 'danger'
  725. SLACK_FOOTER: ''
  726. SLACK_ICON_EMOJI: ':github-actions:'
  727. SLACK_TITLE: 'Artifact verification for static build failed.'
  728. SLACK_USERNAME: 'GitHub Actions'
  729. SLACK_MESSAGE: |-
  730. ${{ github.repository }}: Artifact verification for static build failed.
  731. Checkout: ${{ steps.checkout.outcome }}
  732. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  733. Verify artifacts: ${{ steps.verify.outcome }}
  734. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  735. if: >-
  736. ${{
  737. failure()
  738. && startsWith(github.ref, 'refs/heads/master')
  739. && github.event_name != 'pull_request'
  740. && github.repository == 'netdata/netdata'
  741. && needs.file-check.outputs.run == 'true'
  742. }}
  743. upload-nightly: # Upload the nightly build artifacts to GCS.
  744. name: Upload Nightly Artifacts
  745. runs-on: ubuntu-latest
  746. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  747. needs:
  748. - artifact-verification-dist
  749. - artifact-verification-static
  750. steps:
  751. - name: Retrieve Artifacts
  752. id: fetch
  753. uses: actions/download-artifact@v3
  754. with:
  755. name: final-artifacts
  756. path: final-artifacts
  757. - name: Authenticate to GCS
  758. id: gcs-auth
  759. uses: google-github-actions/auth@v2
  760. with:
  761. project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
  762. credentials_json: ${{ secrets.GCS_STORAGE_SERVICE_KEY_JSON }}
  763. - name: Setup GCS
  764. id: gcs-setup
  765. uses: google-github-actions/setup-gcloud@v2.0.1
  766. - name: Upload Artifacts
  767. id: upload
  768. uses: google-github-actions/upload-cloud-storage@v2.0.0
  769. with:
  770. destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
  771. gzip: false
  772. path: ./final-artifacts
  773. parent: false
  774. - name: Failure Notification
  775. uses: rtCamp/action-slack-notify@v2
  776. env:
  777. SLACK_COLOR: 'danger'
  778. SLACK_FOOTER: ''
  779. SLACK_ICON_EMOJI: ':github-actions:'
  780. SLACK_TITLE: 'Failed to upload nightly release artifacts:'
  781. SLACK_USERNAME: 'GitHub Actions'
  782. SLACK_MESSAGE: |-
  783. ${{ github.repository }}: Failed to upload nightly release artifacts.
  784. Fetch artifacts: ${{ steps.fetch.outcome }}
  785. Authenticatie GCS: ${{ steps.gcs-auth.outcome }}
  786. Setup GCS: ${{ steps.gcs-setup.outcome }}
  787. Upload artifacts: ${{ steps.upload.outcome }}
  788. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  789. if: >-
  790. ${{
  791. failure()
  792. && startsWith(github.ref, 'refs/heads/master')
  793. && github.event_name != 'pull_request'
  794. }}
  795. create-nightly: # Create a nightly build release in netdata/netdata-nightlies
  796. name: Create Nightly Release
  797. runs-on: ubuntu-latest
  798. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  799. needs:
  800. - artifact-verification-dist
  801. - artifact-verification-static
  802. steps:
  803. - name: Checkout Main Repo
  804. id: checkout-main
  805. uses: actions/checkout@v4
  806. with:
  807. path: main
  808. - name: Checkout Nightly Repo
  809. id: checkout-nightly
  810. uses: actions/checkout@v4
  811. with:
  812. repository: netdata/netdata-nightlies
  813. path: nightlies
  814. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  815. - name: Retrieve Artifacts
  816. id: fetch
  817. uses: actions/download-artifact@v3
  818. with:
  819. name: final-artifacts
  820. path: final-artifacts
  821. - name: Prepare version info
  822. id: version
  823. run: |
  824. # shellcheck disable=SC2129
  825. echo "version=$(cat main/packaging/version)" >> "${GITHUB_OUTPUT}"
  826. echo "commit=$(cd nightlies && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
  827. echo "date=$(date +%F)" >> "${GITHUB_OUTPUT}"
  828. - name: Create Release
  829. id: create-release
  830. uses: ncipollo/release-action@v1
  831. with:
  832. allowUpdates: false
  833. artifactErrorsFailBuild: true
  834. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  835. owner: netdata
  836. repo: netdata-nightlies
  837. body: Netdata nightly build for ${{ steps.version.outputs.date }}.
  838. commit: ${{ steps.version.outputs.commit }}
  839. makeLatest: true
  840. tag: ${{ steps.version.outputs.version }}
  841. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  842. - name: Checkout netdata main Repo # Checkout back to netdata/netdata repo to the update latest packaged versions
  843. id: checkout-netdata
  844. uses: actions/checkout@v4
  845. with:
  846. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  847. - name: Init python environment for publish release metadata
  848. uses: actions/setup-python@v5
  849. id: init-python
  850. with:
  851. python-version: "3.12"
  852. - name: Setup python environment
  853. id: setup-python
  854. run: |
  855. pip install -r .github/scripts/modules/requirements.txt
  856. - name: Check if the version is latest and published
  857. id: check-latest-version
  858. run: |
  859. python .github/scripts/check_latest_versions.py ${{ steps.version.outputs.version }}
  860. - name: SSH setup
  861. id: ssh-setup
  862. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  863. uses: shimataro/ssh-key-action@v2
  864. with:
  865. key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
  866. name: id_ecdsa
  867. known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
  868. - name: Sync newer releases
  869. id: sync-releases
  870. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  871. run: |
  872. .github/scripts/upload-new-version-tags.sh
  873. - name: Failure Notification
  874. uses: rtCamp/action-slack-notify@v2
  875. env:
  876. SLACK_COLOR: 'danger'
  877. SLACK_FOOTER: ''
  878. SLACK_ICON_EMOJI: ':github-actions:'
  879. SLACK_TITLE: 'Failed to draft release:'
  880. SLACK_USERNAME: 'GitHub Actions'
  881. SLACK_MESSAGE: |-
  882. ${{ github.repository }}: Failed to create nightly release or attach artifacts.
  883. Checkout netdata/netdata: ${{ steps.checkout-main.outcome }}
  884. Checkout netdata/netdata-nightlies: ${{ steps.checkout-nightly.outcome }}
  885. Fetch artifacts: ${{ steps.fetch.outcome }}
  886. Prepare version info: ${{ steps.version.outcome }}
  887. Create release: ${{ steps.create-release.outcome }}
  888. Checkout back netdata/netdata: ${{ steps.checkout-netdata.outcome }}
  889. Init python environment: ${{ steps.init-python.outcome }}
  890. Setup python environment: ${{ steps.setup-python.outcome }}
  891. Check the nearly published release against the advertised: ${{ steps.check-latest-version.outcome }}
  892. Setup ssh: ${{ steps.ssh-setup.outcome }}
  893. Sync with the releases: ${{ steps.sync-releases.outcome }}
  894. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  895. if: >-
  896. ${{
  897. failure()
  898. && github.event_name == 'workflow_dispatch'
  899. }}
  900. normalize-tag: # Fix the release tag if needed
  901. name: Normalize Release Tag
  902. runs-on: ubuntu-latest
  903. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  904. outputs:
  905. tag: ${{ steps.tag.outputs.tag }}
  906. steps:
  907. - name: Normalize Tag
  908. id: tag
  909. run: |
  910. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  911. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  912. else
  913. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  914. fi
  915. upload-release: # Create the draft release and upload the build artifacts.
  916. name: Create Release Draft
  917. runs-on: ubuntu-latest
  918. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  919. needs:
  920. - artifact-verification-dist
  921. - artifact-verification-static
  922. - normalize-tag
  923. steps:
  924. - name: Checkout
  925. id: checkout
  926. uses: actions/checkout@v4
  927. - name: Retrieve Artifacts
  928. id: fetch
  929. uses: actions/download-artifact@v3
  930. with:
  931. name: final-artifacts
  932. path: final-artifacts
  933. - name: Create Release
  934. id: create-release
  935. uses: ncipollo/release-action@v1
  936. with:
  937. allowUpdates: false
  938. artifactErrorsFailBuild: true
  939. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  940. draft: true
  941. tag: ${{ needs.normalize-tag.outputs.tag }}
  942. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  943. - name: Failure Notification
  944. uses: rtCamp/action-slack-notify@v2
  945. env:
  946. SLACK_COLOR: 'danger'
  947. SLACK_FOOTER: ''
  948. SLACK_ICON_EMOJI: ':github-actions:'
  949. SLACK_TITLE: 'Failed to draft release:'
  950. SLACK_USERNAME: 'GitHub Actions'
  951. SLACK_MESSAGE: |-
  952. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  953. Checkout: ${{ steps.checkout.outcome }}
  954. Fetch artifacts: ${{ steps.fetch.outcome }}
  955. Create draft release: ${{ steps.create-release.outcome }}
  956. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  957. if: >-
  958. ${{
  959. failure()
  960. && github.event_name == 'workflow_dispatch'
  961. }}
  962. - name: Success Notification
  963. uses: rtCamp/action-slack-notify@v2
  964. env:
  965. SLACK_COLOR: 'good'
  966. SLACK_FOOTER: ''
  967. SLACK_ICON_EMOJI: ':github-actions:'
  968. SLACK_TITLE: 'Created agent draft release:'
  969. SLACK_USERNAME: 'GitHub Actions'
  970. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  971. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  972. if: >-
  973. ${{
  974. success()
  975. && github.event_name == 'workflow_dispatch'
  976. }}