build.yml 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  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 does limited validation, then pushes 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: ${{ github.workflow }}-${{ 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. skip-go: ${{ steps.check-go.outputs.skip-go }}
  29. steps:
  30. - name: Checkout
  31. id: checkout
  32. uses: actions/checkout@v4
  33. with:
  34. fetch-depth: 0
  35. submodules: recursive
  36. - name: Check source files
  37. id: check-source-files
  38. uses: tj-actions/changed-files@v44
  39. with:
  40. since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
  41. files: |
  42. **/*.c
  43. **/*.cc
  44. **/*.h
  45. **/*.hh
  46. **/*.in
  47. **/*.patch
  48. src/aclk/aclk-schemas/
  49. src/ml/dlib/
  50. src/fluent-bit/
  51. src/web/server/h2o/libh2o/
  52. files_ignore: |
  53. netdata.spec.in
  54. **/*.md
  55. - name: Check build files
  56. id: check-build-files
  57. uses: tj-actions/changed-files@v44
  58. with:
  59. since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
  60. files: |
  61. **/*.cmake
  62. CMakeLists.txt
  63. netdata-installer.sh
  64. .github/data/distros.yml
  65. .github/workflows/build.yml
  66. .github/scripts/build-static.sh
  67. .github/scripts/get-static-cache-key.sh
  68. .github/scripts/gen-matrix-build.py
  69. .github/scripts/run-updater-check.sh
  70. packaging/cmake/
  71. packaging/makeself/
  72. packaging/installer/
  73. packaging/windows/
  74. packaging/*.sh
  75. packaging/*.version
  76. packaging/*.checksums
  77. files_ignore: |
  78. **/*.md
  79. packaging/repoconfig/
  80. - name: List all changed files in pattern
  81. continue-on-error: true
  82. if: github.event_name != 'workflow_dispatch'
  83. env:
  84. CHANGED_SOURCE_FILES: ${{ steps.check-source-files.outputs.all_changed_files }}
  85. CHANGED_BUILD_FILES: ${{ steps.check-build-files.outputs.all_changed_files }}
  86. run: |
  87. for file in ${CHANGED_SOURCE_FILES} ${CHANGED_BUILD_FILES} ; do
  88. echo "$file was changed"
  89. done
  90. - name: Check Run
  91. id: check-run
  92. run: |
  93. if [ "${{ steps.check-source-files.outputs.any_modified }}" == "true" ] || [ "${{ steps.check-build-files.outputs.any_modified }}" == "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
  94. echo 'run=true' >> "${GITHUB_OUTPUT}"
  95. else
  96. echo 'run=false' >> "${GITHUB_OUTPUT}"
  97. fi
  98. - name: Check Go
  99. id: check-go
  100. run: |
  101. if [ '${{ github.event_name }}' == 'pull_request' ]; then
  102. if echo "${{ steps.check-source-files.outputs.other_changed_files }}" | grep -q '.*/(.*\.go|go\.mod|go\.sum)$' || [ "${{ steps.check-build-files.outputs.any_modified }}" == "true" ]; then
  103. echo 'skip-go=' >> "${GITHUB_OUTPUT}"
  104. else
  105. echo 'skip-go=--disable-go' >> "${GITHUB_OUTPUT}"
  106. fi
  107. else
  108. echo 'skip-go=' >> "${GITHUB_OUTPUT}"
  109. fi
  110. build-dist: # Build the distribution tarball and store it as an artifact.
  111. name: Build Distribution Tarball
  112. runs-on: ubuntu-latest
  113. needs:
  114. - file-check
  115. outputs:
  116. distfile: ${{ steps.build.outputs.distfile }}
  117. steps:
  118. - name: Skip Check
  119. id: skip
  120. if: needs.file-check.outputs.run != 'true'
  121. run: echo "SKIPPED"
  122. - name: Checkout
  123. id: checkout
  124. if: needs.file-check.outputs.run == 'true'
  125. uses: actions/checkout@v4
  126. with:
  127. fetch-depth: 0
  128. submodules: recursive
  129. - name: Fix tags
  130. id: fix-tags
  131. if: github.event_name != 'push' && needs.file-check.outputs.run == 'true'
  132. run: |
  133. git fetch --tags --force
  134. - name: Mark Stable
  135. id: channel
  136. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly' && needs.file-check.outputs.run == 'true'
  137. run: |
  138. sed -i 's/^RELEASE_CHANNEL="nightly"/RELEASE_CHANNEL="stable"/' netdata-installer.sh
  139. - name: Build
  140. id: build
  141. if: needs.file-check.outputs.run == 'true'
  142. run: |
  143. mkdir -p artifacts/
  144. tar --create --file "artifacts/netdata-$(git describe).tar.gz" \
  145. --sort=name --posix --auto-compress --exclude=artifacts/ --exclude=.git \
  146. --exclude=.gitignore --exclude=.gitattributes --exclude=.gitmodules \
  147. --transform "s/^\\.\\//netdata-$(git describe)\\//" --verbose .
  148. cd artifacts/
  149. echo "distfile=$(find . -name 'netdata-*.tar.gz')" >> "${GITHUB_OUTPUT}"
  150. - name: Store
  151. id: store
  152. if: needs.file-check.outputs.run == 'true'
  153. uses: actions/upload-artifact@v4.4.2
  154. with:
  155. name: dist-tarball
  156. path: artifacts/*.tar.gz
  157. retention-days: 30
  158. - name: Failure Notification
  159. uses: rtCamp/action-slack-notify@v2
  160. env:
  161. SLACK_COLOR: 'danger'
  162. SLACK_FOOTER: ''
  163. SLACK_ICON_EMOJI: ':github-actions:'
  164. SLACK_TITLE: 'Distribution tarball creation failed:'
  165. SLACK_USERNAME: 'GitHub Actions'
  166. SLACK_MESSAGE: |-
  167. ${{ github.repository }}: Failed to create source tarball for distribution.
  168. Checkout: ${{ steps.checkout.outcome }}
  169. Fix Tags: ${{ steps.fix-tags.outcome }}
  170. Mark stable: ${{ steps.channel.outcome }}
  171. Build: ${{ steps.build.outcome }}
  172. Store: ${{ steps.store.outcome }}
  173. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  174. if: >-
  175. ${{
  176. failure()
  177. && startsWith(github.ref, 'refs/heads/master')
  178. && github.event_name != 'pull_request'
  179. && github.repository == 'netdata/netdata'
  180. && needs.file-check.outputs.run == 'true'
  181. }}
  182. build-static: # Build the static binary archives, and store them as artifacts.
  183. name: Build Static
  184. runs-on: ubuntu-latest
  185. needs:
  186. - file-check
  187. strategy:
  188. matrix:
  189. arch:
  190. - x86_64
  191. - armv6l
  192. - armv7l
  193. - aarch64
  194. - ppc64le
  195. steps:
  196. - name: Skip Check
  197. id: skip
  198. if: needs.file-check.outputs.run != 'true'
  199. run: echo "SKIPPED"
  200. - name: Checkout
  201. id: checkout
  202. if: needs.file-check.outputs.run == 'true'
  203. uses: actions/checkout@v4
  204. with:
  205. fetch-depth: 0
  206. submodules: recursive
  207. - name: Fix tags
  208. id: fix-tags
  209. if: github.event_name != 'push' && needs.file-check.outputs.run == 'true'
  210. run: |
  211. git fetch --tags --force
  212. - name: Mark Stable
  213. id: channel
  214. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly' && needs.file-check.outputs.run == 'true'
  215. run: |
  216. sed -i 's/^RELEASE_CHANNEL="nightly"/RELEASE_CHANNEL="stable"/' netdata-installer.sh packaging/makeself/install-or-update.sh
  217. - name: Get Cache Key
  218. if: (github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache')) && needs.file-check.outputs.run == 'true'
  219. id: cache-key
  220. run: .github/scripts/get-static-cache-key.sh ${{ matrix.arch }} "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache') }}"
  221. - name: Cache
  222. if: (github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache')) && needs.file-check.outputs.run == 'true'
  223. id: cache
  224. uses: actions/cache@v4
  225. with:
  226. path: artifacts/cache
  227. key: ${{ steps.cache-key.outputs.key }}
  228. - name: Build
  229. if: github.event_name != 'workflow_dispatch' && needs.file-check.outputs.run == 'true' # Don’t use retries on PRs.
  230. run: |
  231. export EXTRA_INSTALL_FLAGS=${{ needs.file-check.outputs.skip-go }}
  232. .github/scripts/build-static.sh ${{ matrix.arch }}
  233. - name: Build
  234. if: github.event_name == 'workflow_dispatch' && needs.file-check.outputs.run == 'true'
  235. id: build
  236. uses: nick-fields/retry@v3
  237. with:
  238. timeout_minutes: 180
  239. max_attempts: 3
  240. command: |
  241. export EXTRA_INSTALL_FLAGS=${{ needs.file-check.outputs.skip-go }}
  242. .github/scripts/build-static.sh ${{ matrix.arch }}
  243. - name: Store
  244. id: store
  245. if: needs.file-check.outputs.run == 'true'
  246. uses: actions/upload-artifact@v4.4.2
  247. with:
  248. name: dist-static-${{ matrix.arch }}
  249. path: artifacts/*.gz.run
  250. retention-days: 30
  251. - name: Failure Notification
  252. uses: rtCamp/action-slack-notify@v2
  253. env:
  254. SLACK_COLOR: 'danger'
  255. SLACK_FOOTER: ''
  256. SLACK_ICON_EMOJI: ':github-actions:'
  257. SLACK_TITLE: 'Static build failed:'
  258. SLACK_USERNAME: 'GitHub Actions'
  259. SLACK_MESSAGE: |-
  260. ${{ github.repository }}: Failed to create static installer archive for ${{ matrix.arch }}.
  261. Checkout: ${{ steps.checkout.outcome }}
  262. Fix Tags: ${{ steps.fix-tags.outcome }}
  263. Mark stable: ${{ steps.channel.outcome }}
  264. Build: ${{ steps.build.outcome }}
  265. Store: ${{ steps.store.outcome }}
  266. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  267. if: >-
  268. ${{
  269. failure()
  270. && startsWith(github.ref, 'refs/heads/master')
  271. && github.event_name != 'pull_request'
  272. && github.repository == 'netdata/netdata'
  273. && needs.file-check.outputs.run == 'true'
  274. }}
  275. prepare-upload: # Consolidate the artifacts for uploading or releasing.
  276. name: Prepare Artifacts
  277. runs-on: ubuntu-latest
  278. needs:
  279. - build-dist
  280. - build-static
  281. - file-check
  282. steps:
  283. - name: Skip Check
  284. id: skip
  285. if: needs.file-check.outputs.run != 'true'
  286. run: echo "SKIPPED"
  287. - name: Checkout
  288. id: checkout
  289. if: needs.file-check.outputs.run == 'true'
  290. uses: actions/checkout@v4
  291. - name: Prepare Environment
  292. id: prepare
  293. if: needs.file-check.outputs.run == 'true'
  294. run: mkdir -p artifacts
  295. - name: Retrieve Build Artifacts
  296. id: fetch-dist
  297. if: needs.file-check.outputs.run == 'true'
  298. uses: Wandalen/wretry.action@v3
  299. with:
  300. action: actions/download-artifact@v4
  301. with: |
  302. pattern: dist-*
  303. path: dist-artifacts
  304. merge-multiple: true
  305. attempt_limit: 3
  306. attempt_delay: 2000
  307. - name: Prepare Artifacts
  308. id: consolidate
  309. if: needs.file-check.outputs.run == 'true'
  310. working-directory: ./artifacts/
  311. run: |
  312. mv ../dist-artifacts/* . || exit 1
  313. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  314. cp ../packaging/version ./latest-version.txt || exit 1
  315. cp ../integrations/integrations.js ./integrations.js || exit 1
  316. sha256sum -b ./* > sha256sums.txt || exit 1
  317. cat sha256sums.txt
  318. - name: Store Artifacts
  319. id: store
  320. if: needs.file-check.outputs.run == 'true'
  321. uses: actions/upload-artifact@v4.4.2
  322. with:
  323. name: final-artifacts
  324. path: artifacts/*
  325. retention-days: 30
  326. - name: Failure Notification
  327. uses: rtCamp/action-slack-notify@v2
  328. env:
  329. SLACK_COLOR: 'danger'
  330. SLACK_FOOTER: ''
  331. SLACK_ICON_EMOJI: ':github-actions:'
  332. SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
  333. SLACK_USERNAME: 'GitHub Actions'
  334. SLACK_MESSAGE: |-
  335. ${{ github.repository }}: Failed to prepare release artifacts for upload.
  336. Checkout: ${{ steps.checkout.outcome }}
  337. Prepare environment: ${{ steps.prepare.outcome }}
  338. Fetch dist tarball: ${{ steps.fetch-dist.outcome }}
  339. Consolidate artifacts: ${{ steps.consolidate.outcome }}
  340. Store: ${{ steps.store.outcome }}
  341. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  342. if: >-
  343. ${{
  344. failure()
  345. && startsWith(github.ref, 'refs/heads/master')
  346. && github.event_name != 'pull_request'
  347. && github.repository == 'netdata/netdata'
  348. && needs.file-check.outputs.run == 'true'
  349. }}
  350. artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
  351. name: Test Consolidated Artifacts (Source)
  352. runs-on: ubuntu-latest
  353. needs:
  354. - prepare-upload
  355. - file-check
  356. services:
  357. apache: # This gets used to serve the dist tarball for the updater script.
  358. image: httpd:2.4
  359. ports:
  360. - 8080:80
  361. volumes:
  362. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  363. steps:
  364. - name: Skip Check
  365. id: skip
  366. if: needs.file-check.outputs.run != 'true'
  367. run: echo "SKIPPED"
  368. - name: Checkout
  369. id: checkout
  370. if: needs.file-check.outputs.run == 'true'
  371. uses: actions/checkout@v4
  372. - name: Fetch artifacts
  373. id: fetch
  374. if: needs.file-check.outputs.run == 'true'
  375. uses: Wandalen/wretry.action@v3
  376. with:
  377. action: actions/download-artifact@v4
  378. with: |
  379. name: final-artifacts
  380. path: artifacts
  381. attempt_limit: 3
  382. attempt_delay: 2000
  383. - name: Prepare artifacts directory
  384. id: prepare
  385. if: needs.file-check.outputs.run == 'true'
  386. run: |
  387. mkdir -p download/latest
  388. mv artifacts/* download/latest
  389. ls -al download/latest
  390. - name: Verify that artifacts work with installer
  391. id: verify
  392. if: needs.file-check.outputs.run == 'true'
  393. env:
  394. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  395. run: sh -x packaging/installer/kickstart.sh --build-only --dont-start-it --disable-telemetry --dont-wait
  396. - name: Failure Notification
  397. uses: rtCamp/action-slack-notify@v2
  398. env:
  399. SLACK_COLOR: 'danger'
  400. SLACK_FOOTER: ''
  401. SLACK_ICON_EMOJI: ':github-actions:'
  402. SLACK_TITLE: 'Artifact verification for source tarball failed.'
  403. SLACK_USERNAME: 'GitHub Actions'
  404. SLACK_MESSAGE: |-
  405. ${{ github.repository }}: Artifact verification for source tarball failed.
  406. Checkout: ${{ steps.checkout.outcome }}
  407. Fetch artifacts: ${{ steps.fetch.outcome }}
  408. Verify artifacts: ${{ steps.verify.outcome }}
  409. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  410. if: >-
  411. ${{
  412. failure()
  413. && startsWith(github.ref, 'refs/heads/master')
  414. && github.event_name != 'pull_request'
  415. && github.repository == 'netdata/netdata'
  416. && needs.file-check.outputs.run == 'true'
  417. }}
  418. artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
  419. name: Test Consolidated Artifacts (Static)
  420. runs-on: ubuntu-latest
  421. needs:
  422. - prepare-upload
  423. - file-check
  424. services:
  425. apache: # This gets used to serve the static archives.
  426. image: httpd:2.4
  427. ports:
  428. - 8080:80
  429. volumes:
  430. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  431. steps:
  432. - name: Skip Check
  433. id: skip
  434. if: needs.file-check.outputs.run != 'true'
  435. run: echo "SKIPPED"
  436. - name: Checkout
  437. id: checkout
  438. if: needs.file-check.outputs.run == 'true'
  439. uses: actions/checkout@v4
  440. - name: Fetch artifacts
  441. id: fetch-artifacts
  442. if: needs.file-check.outputs.run == 'true'
  443. uses: Wandalen/wretry.action@v3
  444. with:
  445. action: actions/download-artifact@v4
  446. with: |
  447. name: final-artifacts
  448. path: artifacts
  449. attempt_limit: 3
  450. attempt_delay: 2000
  451. - name: Prepare artifacts directory
  452. id: prepare
  453. if: needs.file-check.outputs.run == 'true'
  454. run: |
  455. mkdir -p download/latest
  456. mv artifacts/* download/latest
  457. ls -al download/latest
  458. - name: Verify that artifacts work with installer
  459. id: verify
  460. if: needs.file-check.outputs.run == 'true'
  461. env:
  462. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  463. run: sh -x packaging/installer/kickstart.sh --static-only --dont-start-it --disable-telemetry
  464. - name: Failure Notification
  465. uses: rtCamp/action-slack-notify@v2
  466. env:
  467. SLACK_COLOR: 'danger'
  468. SLACK_FOOTER: ''
  469. SLACK_ICON_EMOJI: ':github-actions:'
  470. SLACK_TITLE: 'Artifact verification for static build failed.'
  471. SLACK_USERNAME: 'GitHub Actions'
  472. SLACK_MESSAGE: |-
  473. ${{ github.repository }}: Artifact verification for static build failed.
  474. Checkout: ${{ steps.checkout.outcome }}
  475. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  476. Verify artifacts: ${{ steps.verify.outcome }}
  477. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  478. if: >-
  479. ${{
  480. failure()
  481. && startsWith(github.ref, 'refs/heads/master')
  482. && github.event_name != 'pull_request'
  483. && github.repository == 'netdata/netdata'
  484. && needs.file-check.outputs.run == 'true'
  485. }}
  486. upload-nightly: # Upload the nightly build artifacts to GCS.
  487. name: Upload Nightly Artifacts
  488. runs-on: ubuntu-latest
  489. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  490. needs:
  491. - artifact-verification-dist
  492. - artifact-verification-static
  493. steps:
  494. - name: Retrieve Artifacts
  495. id: fetch
  496. uses: Wandalen/wretry.action@v3
  497. with:
  498. action: actions/download-artifact@v4
  499. with: |
  500. name: final-artifacts
  501. path: final-artifacts
  502. attempt_limit: 3
  503. attempt_delay: 2000
  504. - name: Authenticate to GCS
  505. id: gcs-auth
  506. uses: google-github-actions/auth@v2
  507. with:
  508. project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
  509. credentials_json: ${{ secrets.GCS_STORAGE_SERVICE_KEY_JSON }}
  510. - name: Setup GCS
  511. id: gcs-setup
  512. uses: google-github-actions/setup-gcloud@v2.1.1
  513. - name: Upload Artifacts
  514. id: upload
  515. uses: google-github-actions/upload-cloud-storage@v2.1.2
  516. with:
  517. destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
  518. gzip: false
  519. path: ./final-artifacts/latest-version.txt
  520. parent: false
  521. - name: Failure Notification
  522. uses: rtCamp/action-slack-notify@v2
  523. env:
  524. SLACK_COLOR: 'danger'
  525. SLACK_FOOTER: ''
  526. SLACK_ICON_EMOJI: ':github-actions:'
  527. SLACK_TITLE: 'Failed to upload nightly release artifacts:'
  528. SLACK_USERNAME: 'GitHub Actions'
  529. SLACK_MESSAGE: |-
  530. ${{ github.repository }}: Failed to upload nightly release artifacts.
  531. Fetch artifacts: ${{ steps.fetch.outcome }}
  532. Authenticatie GCS: ${{ steps.gcs-auth.outcome }}
  533. Setup GCS: ${{ steps.gcs-setup.outcome }}
  534. Upload artifacts: ${{ steps.upload.outcome }}
  535. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  536. if: >-
  537. ${{
  538. failure()
  539. && startsWith(github.ref, 'refs/heads/master')
  540. && github.event_name != 'pull_request'
  541. }}
  542. create-nightly: # Create a nightly build release in netdata/netdata-nightlies
  543. name: Create Nightly Release
  544. runs-on: ubuntu-latest
  545. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  546. needs:
  547. - artifact-verification-dist
  548. - artifact-verification-static
  549. steps:
  550. - name: Checkout Main Repo
  551. id: checkout-main
  552. uses: actions/checkout@v4
  553. with:
  554. path: main
  555. - name: Checkout Nightly Repo
  556. id: checkout-nightly
  557. uses: actions/checkout@v4
  558. with:
  559. repository: netdata/netdata-nightlies
  560. path: nightlies
  561. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  562. - name: Retrieve Artifacts
  563. id: fetch
  564. uses: Wandalen/wretry.action@v3
  565. with:
  566. action: actions/download-artifact@v4
  567. with: |
  568. name: final-artifacts
  569. path: final-artifacts
  570. attempt_limit: 3
  571. attempt_delay: 2000
  572. - name: Prepare version info
  573. id: version
  574. run: |
  575. # shellcheck disable=SC2129
  576. echo "version=$(cat main/packaging/version)" >> "${GITHUB_OUTPUT}"
  577. echo "commit=$(cd nightlies && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
  578. echo "date=$(date +%F)" >> "${GITHUB_OUTPUT}"
  579. - name: Create Release
  580. id: create-release
  581. uses: ncipollo/release-action@v1
  582. with:
  583. allowUpdates: false
  584. artifactErrorsFailBuild: true
  585. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  586. owner: netdata
  587. repo: netdata-nightlies
  588. body: Netdata nightly build for ${{ steps.version.outputs.date }}.
  589. commit: ${{ steps.version.outputs.commit }}
  590. makeLatest: true
  591. tag: ${{ steps.version.outputs.version }}
  592. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  593. - name: Checkout netdata main Repo # Checkout back to netdata/netdata repo to the update latest packaged versions
  594. id: checkout-netdata
  595. uses: actions/checkout@v4
  596. with:
  597. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  598. - name: Init python environment for publish release metadata
  599. uses: actions/setup-python@v5
  600. id: init-python
  601. with:
  602. python-version: "3.12"
  603. - name: Setup python environment
  604. id: setup-python
  605. run: |
  606. pip install -r .github/scripts/modules/requirements.txt
  607. - name: Check if the version is latest and published
  608. id: check-latest-version
  609. run: |
  610. python .github/scripts/check_latest_versions.py ${{ steps.version.outputs.version }}
  611. - name: SSH setup
  612. id: ssh-setup
  613. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  614. uses: shimataro/ssh-key-action@v2
  615. with:
  616. key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
  617. name: id_ecdsa
  618. known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
  619. - name: Sync release info to packages.netdata.cloud
  620. id: sync-releases
  621. continue-on-error: true
  622. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  623. run: |
  624. .github/scripts/upload-new-version-tags.sh packages.netdata.cloud
  625. - name: Sync release info to packages2.netdata.cloud
  626. id: sync-releases2
  627. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  628. run: |
  629. .github/scripts/upload-new-version-tags.sh packages.netdata.cloud
  630. - name: Failure Notification
  631. uses: rtCamp/action-slack-notify@v2
  632. env:
  633. SLACK_COLOR: 'danger'
  634. SLACK_FOOTER: ''
  635. SLACK_ICON_EMOJI: ':github-actions:'
  636. SLACK_TITLE: 'Failed to draft release:'
  637. SLACK_USERNAME: 'GitHub Actions'
  638. SLACK_MESSAGE: |-
  639. ${{ github.repository }}: Failed to create nightly release or attach artifacts.
  640. Checkout netdata/netdata: ${{ steps.checkout-main.outcome }}
  641. Checkout netdata/netdata-nightlies: ${{ steps.checkout-nightly.outcome }}
  642. Fetch artifacts: ${{ steps.fetch.outcome }}
  643. Prepare version info: ${{ steps.version.outcome }}
  644. Create release: ${{ steps.create-release.outcome }}
  645. Checkout back netdata/netdata: ${{ steps.checkout-netdata.outcome }}
  646. Init python environment: ${{ steps.init-python.outcome }}
  647. Setup python environment: ${{ steps.setup-python.outcome }}
  648. Check the nearly published release against the advertised: ${{ steps.check-latest-version.outcome }}
  649. Setup ssh: ${{ steps.ssh-setup.outcome }}
  650. Sync release info to packages.netdata.cloud: ${{ steps.sync-releases.outcome }}
  651. Sync release info to packages2.netdata.cloud: ${{ steps.sync-releases2.outcome }}
  652. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  653. if: >-
  654. ${{
  655. failure()
  656. && github.event_name == 'workflow_dispatch'
  657. }}
  658. normalize-tag: # Fix the release tag if needed
  659. name: Normalize Release Tag
  660. runs-on: ubuntu-latest
  661. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  662. outputs:
  663. tag: ${{ steps.tag.outputs.tag }}
  664. steps:
  665. - name: Normalize Tag
  666. id: tag
  667. run: |
  668. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  669. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  670. else
  671. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  672. fi
  673. upload-release: # Create the draft release and upload the build artifacts.
  674. name: Create Release Draft
  675. runs-on: ubuntu-latest
  676. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  677. needs:
  678. - artifact-verification-dist
  679. - artifact-verification-static
  680. - normalize-tag
  681. steps:
  682. - name: Checkout
  683. id: checkout
  684. uses: actions/checkout@v4
  685. - name: Retrieve Artifacts
  686. id: fetch
  687. uses: Wandalen/wretry.action@v3
  688. with:
  689. action: actions/download-artifact@v4
  690. with: |
  691. name: final-artifacts
  692. path: final-artifacts
  693. attempt_limit: 3
  694. attempt_delay: 2000
  695. - name: Create Release
  696. id: create-release
  697. uses: ncipollo/release-action@v1
  698. with:
  699. allowUpdates: false
  700. artifactErrorsFailBuild: true
  701. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  702. draft: true
  703. tag: ${{ needs.normalize-tag.outputs.tag }}
  704. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  705. - name: Failure Notification
  706. uses: rtCamp/action-slack-notify@v2
  707. env:
  708. SLACK_COLOR: 'danger'
  709. SLACK_FOOTER: ''
  710. SLACK_ICON_EMOJI: ':github-actions:'
  711. SLACK_TITLE: 'Failed to draft release:'
  712. SLACK_USERNAME: 'GitHub Actions'
  713. SLACK_MESSAGE: |-
  714. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  715. Checkout: ${{ steps.checkout.outcome }}
  716. Fetch artifacts: ${{ steps.fetch.outcome }}
  717. Create draft release: ${{ steps.create-release.outcome }}
  718. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  719. if: >-
  720. ${{
  721. failure()
  722. && github.event_name == 'workflow_dispatch'
  723. }}
  724. - name: Success Notification
  725. uses: rtCamp/action-slack-notify@v2
  726. env:
  727. SLACK_COLOR: 'good'
  728. SLACK_FOOTER: ''
  729. SLACK_ICON_EMOJI: ':github-actions:'
  730. SLACK_TITLE: 'Created agent draft release:'
  731. SLACK_USERNAME: 'GitHub Actions'
  732. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  733. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  734. if: >-
  735. ${{
  736. success()
  737. && github.event_name == 'workflow_dispatch'
  738. }}
  739. # Remaining jobs are only used for CI checks, and not as part of the release process
  740. matrix: # Generate the shared build matrix for our Linux build tests.
  741. name: Prepare Build Matrix
  742. runs-on: ubuntu-latest
  743. if: github.event_name != 'workflow_dispatch'
  744. outputs:
  745. matrix: ${{ steps.set-matrix.outputs.matrix }}
  746. steps:
  747. - name: Checkout
  748. id: checkout
  749. uses: actions/checkout@v4
  750. - name: Prepare tools
  751. id: prepare
  752. run: |
  753. sudo apt-get update || true
  754. sudo apt-get install -y python3-ruamel.yaml
  755. - name: Read build matrix
  756. id: set-matrix
  757. run: |
  758. matrix="$(.github/scripts/gen-matrix-build.py)"
  759. echo "Generated matrix: ${matrix}"
  760. echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
  761. - name: Failure Notification
  762. uses: rtCamp/action-slack-notify@v2
  763. env:
  764. SLACK_COLOR: 'danger'
  765. SLACK_FOOTER: ''
  766. SLACK_ICON_EMOJI: ':github-actions:'
  767. SLACK_TITLE: 'Build matrix preparation failed:'
  768. SLACK_USERNAME: 'GitHub Actions'
  769. SLACK_MESSAGE: |-
  770. ${{ github.repository }}: Failed to prepare build matrix for build checks.
  771. Checkout: ${{ steps.checkout.outcome }}
  772. Prepare tools: ${{ steps.prepare.outcome }}
  773. Read build matrix: ${{ steps.set-matrix.outcome }}
  774. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  775. if: >-
  776. ${{
  777. failure()
  778. && startsWith(github.ref, 'refs/heads/master')
  779. && github.event_name != 'pull_request'
  780. && github.repository == 'netdata/netdata'
  781. }}
  782. prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
  783. name: Prepare Test Environments
  784. runs-on: ubuntu-latest
  785. if: github.event_name != 'workflow_dispatch'
  786. needs:
  787. - matrix
  788. env:
  789. RETRY_DELAY: 300
  790. strategy:
  791. # Unlike the actual build tests, this completes _very_ fast (average of about 3 minutes for each job), so we
  792. # just run everything in parallel instead lof limiting job concurrency.
  793. fail-fast: false
  794. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  795. steps:
  796. - name: Checkout
  797. id: checkout
  798. uses: actions/checkout@v4
  799. - name: Setup Buildx
  800. id: buildx
  801. uses: docker/setup-buildx-action@v3
  802. - name: Build test environment
  803. id: build1
  804. uses: docker/build-push-action@v6
  805. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  806. with:
  807. push: false
  808. load: false
  809. file: .github/dockerfiles/Dockerfile.build_test
  810. build-args: |
  811. BASE=${{ matrix.distro }}
  812. PRE=${{ matrix.env_prep }}
  813. RMJSONC=${{ matrix.jsonc_removal }}
  814. outputs: type=docker,dest=/tmp/image.tar
  815. tags: test:${{ matrix.artifact_key }}
  816. - name: Retry delay
  817. if: ${{ steps.build1.outcome == 'failure' }}
  818. run: sleep "${RETRY_DELAY}"
  819. - name: Build test environment (attempt 2)
  820. if: ${{ steps.build1.outcome == 'failure' }}
  821. id: build2
  822. uses: docker/build-push-action@v6
  823. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  824. with:
  825. push: false
  826. load: false
  827. file: .github/dockerfiles/Dockerfile.build_test
  828. build-args: |
  829. BASE=${{ matrix.distro }}
  830. PRE=${{ matrix.env_prep }}
  831. RMJSONC=${{ matrix.jsonc_removal }}
  832. outputs: type=docker,dest=/tmp/image.tar
  833. tags: test:${{ matrix.artifact_key }}
  834. - name: Retry delay
  835. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  836. run: sleep "${RETRY_DELAY}"
  837. - name: Build test environment (attempt 3)
  838. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  839. id: build3
  840. uses: docker/build-push-action@v6
  841. with:
  842. push: false
  843. load: false
  844. file: .github/dockerfiles/Dockerfile.build_test
  845. build-args: |
  846. BASE=${{ matrix.distro }}
  847. PRE=${{ matrix.env_prep }}
  848. RMJSONC=${{ matrix.jsonc_removal }}
  849. outputs: type=docker,dest=/tmp/image.tar
  850. tags: test:${{ matrix.artifact_key }}
  851. - name: Upload image artifact
  852. id: upload
  853. uses: actions/upload-artifact@v4.4.2
  854. with:
  855. name: ${{ matrix.artifact_key }}-test-env
  856. path: /tmp/image.tar
  857. retention-days: 30
  858. - name: Failure Notification
  859. uses: rtCamp/action-slack-notify@v2
  860. env:
  861. SLACK_COLOR: 'danger'
  862. SLACK_FOOTER: ''
  863. SLACK_ICON_EMOJI: ':github-actions:'
  864. SLACK_TITLE: 'Test environment preparation for ${{ matrix.distro }} failed:'
  865. SLACK_USERNAME: 'GitHub Actions'
  866. SLACK_MESSAGE: |-
  867. ${{ github.repository }}: Test environment preparation for ${{ matrix.distro }} failed.
  868. Checkout: ${{ steps.checkout.outcome }}
  869. Set up Buildx: ${{ steps.buildx.outcome }}
  870. Build test environment: ${{ steps.build1.outcome }}
  871. Build test environment (attempt 2): ${{ steps.build2.outcome }}
  872. Build test environment (attempt 3): ${{ steps.build3.outcome }}
  873. Upload: ${{ steps.upload.outcome }}
  874. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  875. if: >-
  876. ${{
  877. failure()
  878. && startsWith(github.ref, 'refs/heads/master')
  879. && github.event_name != 'pull_request'
  880. && github.repository == 'netdata/netdata'
  881. }}
  882. source-build: # Test various source build arrangements.
  883. name: Test Source Build
  884. runs-on: ubuntu-latest
  885. if: github.event_name != 'workflow_dispatch'
  886. needs:
  887. - matrix
  888. - prepare-test-images
  889. - file-check
  890. strategy:
  891. fail-fast: false
  892. max-parallel: 8
  893. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  894. steps:
  895. - name: Skip Check
  896. id: skip
  897. if: needs.file-check.outputs.run != 'true'
  898. run: echo "SKIPPED"
  899. - name: Checkout
  900. id: checkout
  901. if: needs.file-check.outputs.run == 'true'
  902. uses: actions/checkout@v4
  903. with:
  904. submodules: recursive
  905. - name: Fetch test environment
  906. id: fetch
  907. if: needs.file-check.outputs.run == 'true'
  908. uses: Wandalen/wretry.action@v3
  909. with:
  910. action: actions/download-artifact@v4
  911. with: |
  912. name: ${{ matrix.artifact_key }}-test-env
  913. path: .
  914. attempt_limit: 3
  915. attempt_delay: 2000
  916. - name: Load test environment
  917. id: load
  918. if: needs.file-check.outputs.run == 'true'
  919. run: docker load --input image.tar
  920. - name: netdata-installer on ${{ matrix.distro }}, disable cloud
  921. id: build-no-cloud
  922. if: needs.file-check.outputs.run == 'true'
  923. run: |
  924. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  925. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud --one-time-build ${{ needs.file-check.outputs.skip-go }}'
  926. - name: netdata-installer on ${{ matrix.distro }}, require cloud
  927. id: build-cloud
  928. if: needs.file-check.outputs.run == 'true'
  929. run: |
  930. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  931. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build ${{ needs.file-check.outputs.skip-go }}'
  932. - name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
  933. id: build-no-jsonc
  934. if: matrix.jsonc_removal != '' && needs.file-check.outputs.run == 'true'
  935. run: |
  936. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  937. /bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build ${{ needs.file-check.outputs.skip-go }}'
  938. - name: Failure Notification
  939. uses: rtCamp/action-slack-notify@v2
  940. env:
  941. SLACK_COLOR: 'danger'
  942. SLACK_FOOTER: ''
  943. SLACK_ICON_EMOJI: ':github-actions:'
  944. SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
  945. SLACK_USERNAME: 'GitHub Actions'
  946. SLACK_MESSAGE: |-
  947. ${{ github.repository }}: Build tests for ${{ matrix.distro }} failed.
  948. Checkout: ${{ steps.checkout.outcome }}
  949. Fetch test environment: ${{ steps.fetch.outcome }}
  950. Load test environment: ${{ steps.load.outcome }}
  951. netdata-installer, disable cloud: ${{ steps.build-no-cloud.outcome }}
  952. netdata-installer, require cloud: ${{ steps.build-cloud.outcome }}
  953. netdata-installer, no JSON-C: ${{ steps.build-no-jsonc.outcome }}
  954. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  955. if: >-
  956. ${{
  957. failure()
  958. && startsWith(github.ref, 'refs/heads/master')
  959. && github.event_name != 'pull_request'
  960. && github.repository == 'netdata/netdata'
  961. && needs.file-check.outputs.run == 'true'
  962. }}
  963. macos-build: # Test building on macOS
  964. name: Test building on macOS
  965. runs-on: ${{ matrix.runner }}
  966. if: github.event_name != 'workflow_dispatch'
  967. needs:
  968. - file-check
  969. strategy:
  970. fail-fast: false
  971. max-parallel: 8
  972. matrix:
  973. include:
  974. - name: macos-12
  975. runner: macos-12
  976. - name: macos-13
  977. runner: macos-13
  978. - name: macos-14-M1
  979. runner: macos-14
  980. steps:
  981. - name: Skip Check
  982. id: skip
  983. if: needs.file-check.outputs.run != 'true'
  984. run: echo "SKIPPED"
  985. - uses: actions/checkout@v4
  986. id: checkout
  987. if: needs.file-check.outputs.run == 'true'
  988. with:
  989. submodules: recursive
  990. - name: Install latest bash
  991. id: install-bash
  992. if: needs.file-check.outputs.run == 'true'
  993. run: |
  994. brew install bash
  995. - name: Install netdata dependencies
  996. id: install-nd-dep
  997. if: needs.file-check.outputs.run == 'true'
  998. run: |
  999. bash ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all
  1000. - name: Build from source
  1001. id: build-source
  1002. if: needs.file-check.outputs.run == 'true'
  1003. run: |
  1004. sudo bash ./netdata-installer.sh --install-no-prefix /usr/local/netdata --dont-wait --dont-start-it --require-cloud --one-time-build
  1005. - name: Test Agent start up
  1006. id: test-agent
  1007. if: needs.file-check.outputs.run == 'true'
  1008. run: |
  1009. /usr/local/netdata/usr/sbin/netdata -D > ./netdata.log 2>&1 &
  1010. ./packaging/runtime-check.sh
  1011. - name: Failure Notification
  1012. uses: rtCamp/action-slack-notify@v2
  1013. env:
  1014. SLACK_COLOR: 'danger'
  1015. SLACK_FOOTER: ''
  1016. SLACK_ICON_EMOJI: ':github-actions:'
  1017. SLACK_TITLE: 'Build & test from source macOS failed:'
  1018. SLACK_USERNAME: 'GitHub Actions'
  1019. SLACK_MESSAGE: |-
  1020. ${{ github.repository }}: macOS Build and test.
  1021. Checkout: ${{ steps.checkout.outcome }}
  1022. Setup runner: ${{ steps.install-bash.outcome }}
  1023. Install netdata required packages: ${{ steps.install-nd-dep.outcome }}
  1024. Build from source: ${{ steps.build-source.outcome }}
  1025. Test Agent runtime: ${{ steps.test-agent.outcome }}
  1026. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1027. if: >-
  1028. ${{
  1029. failure()
  1030. && startsWith(github.ref, 'refs/heads/master')
  1031. && github.event_name != 'pull_request'
  1032. && github.repository == 'netdata/netdata'
  1033. }}
  1034. windows-build: # Test building on Windows
  1035. name: Test building on Windows
  1036. runs-on: windows-latest
  1037. if: github.event_name != 'workflow_dispatch'
  1038. needs:
  1039. - file-check
  1040. steps:
  1041. - name: Skip Check
  1042. id: skip
  1043. if: needs.file-check.outputs.run != 'true'
  1044. run: Write-Output "SKIPPED"
  1045. - name: Checkout
  1046. uses: actions/checkout@v4
  1047. id: checkout
  1048. if: needs.file-check.outputs.run == 'true'
  1049. with:
  1050. submodules: recursive
  1051. lfs: true
  1052. - name: Set Up Go
  1053. id: golang
  1054. if: needs.file-check.outputs.run == 'true'
  1055. uses: actions/setup-go@v5
  1056. with:
  1057. go-version: "^1.22"
  1058. - name: Set Up Dependencies
  1059. id: deps
  1060. if: needs.file-check.outputs.run == 'true'
  1061. run: ./packaging/windows/install-dependencies.ps1
  1062. - name: Build Netdata
  1063. id: build
  1064. if: needs.file-check.outputs.run == 'true'
  1065. env:
  1066. BUILD_DIR: ${{ github.workspace }}\build
  1067. run: ./packaging/windows/build.ps1
  1068. - name: Sign Agent Code
  1069. id: sign-agent
  1070. if: needs.file-check.outputs.run == 'true' && github.event_name != 'pull_request'
  1071. uses: azure/trusted-signing-action@v0.4.0
  1072. with:
  1073. azure-tenant-id: ${{ secrets.CODE_SIGNING_TENNANT_ID }}
  1074. azure-client-id: ${{ secrets.CODE_SIGNING_CLIENT_ID }}
  1075. azure-client-secret: ${{ secrets.CODE_SIGNING_CLIENT_SECRET }}
  1076. endpoint: "https://eus.codesigning.azure.net/"
  1077. trusted-signing-account-name: Netdata
  1078. certificate-profile-name: Netdata
  1079. files-folder: ${{ github.workspace }}\build
  1080. files-folder-filter: exe,dll
  1081. files-folder-recurse: true
  1082. file-digest: SHA256
  1083. timestamp-rfc3161: "http://timestamp.acs.microsoft.com"
  1084. timestamp-digest: SHA256
  1085. - name: Package Netdata
  1086. id: package
  1087. if: needs.file-check.outputs.run == 'true'
  1088. env:
  1089. BUILD_DIR: ${{ github.workspace }}\build
  1090. run: ./packaging/windows/package.ps1
  1091. - name: Sign Installer
  1092. id: sign-installer
  1093. if: needs.file-check.outputs.run == 'true' && github.event_name != 'pull_request'
  1094. uses: azure/trusted-signing-action@v0.4.0
  1095. with:
  1096. azure-tenant-id: ${{ secrets.CODE_SIGNING_TENNANT_ID }}
  1097. azure-client-id: ${{ secrets.CODE_SIGNING_CLIENT_ID }}
  1098. azure-client-secret: ${{ secrets.CODE_SIGNING_CLIENT_SECRET }}
  1099. endpoint: "https://eus.codesigning.azure.net/"
  1100. trusted-signing-account-name: Netdata
  1101. certificate-profile-name: Netdata
  1102. files: ${{ github.workspace }}\packaging\windows\netdata-installer.exe
  1103. file-digest: SHA256
  1104. timestamp-rfc3161: "http://timestamp.acs.microsoft.com"
  1105. timestamp-digest: SHA256
  1106. - name: Upload Installer
  1107. id: upload
  1108. uses: actions/upload-artifact@v4.4.2
  1109. with:
  1110. name: windows-x86_64-installer
  1111. path: packaging\windows\netdata-installer.exe
  1112. retention-days: 30
  1113. - name: Failure Notification
  1114. uses: rtCamp/action-slack-notify@v2
  1115. env:
  1116. SLACK_COLOR: 'danger'
  1117. SLACK_FOOTER: ''
  1118. SLACK_ICON_EMOJI: ':github-actions:'
  1119. SLACK_TITLE: 'Windows build failed:'
  1120. SLACK_USERNAME: 'GitHub Actions'
  1121. SLACK_MESSAGE: |-
  1122. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  1123. Checkout: ${{ steps.checkout.outcome }}
  1124. Set Up Dependencies: ${{ steps.deps.outcome }}
  1125. Build Netdata: ${{ steps.build.outcome }}
  1126. Sign Agent Code: ${{ steps.sign-agent.outcome }}
  1127. Package Netdata: ${{ steps.package.outcome }}
  1128. Sign Installer: ${{ steps.sign-installer.outcome }}
  1129. Upload Installer: ${{ steps.upload.outcome }}
  1130. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1131. if: >-
  1132. ${{
  1133. failure()
  1134. && startsWith(github.ref, 'refs/heads/master')
  1135. && github.event_name != 'pull_request'
  1136. && github.repository == 'netdata/netdata'
  1137. && needs.file-check.outputs.run == 'true'
  1138. }}
  1139. updater-check: # Test the generated dist archive using the updater code.
  1140. name: Test Generated Distfile and Updater Code
  1141. runs-on: ubuntu-latest
  1142. if: github.event_name != 'workflow_dispatch'
  1143. needs:
  1144. - build-dist
  1145. - matrix
  1146. - prepare-test-images
  1147. - file-check
  1148. strategy:
  1149. fail-fast: false
  1150. max-parallel: 8
  1151. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  1152. services:
  1153. apache: # This gets used to serve the dist tarball for the updater script.
  1154. image: httpd:2.4
  1155. ports:
  1156. - 8080:80
  1157. volumes:
  1158. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  1159. steps:
  1160. - name: Skip Check
  1161. id: skip
  1162. if: needs.file-check.outputs.run != 'true'
  1163. run: echo "SKIPPED"
  1164. - name: Checkout
  1165. id: checkout
  1166. if: needs.file-check.outputs.run == 'true'
  1167. uses: actions/checkout@v4
  1168. - name: Fetch dist tarball artifacts
  1169. id: fetch-tarball
  1170. if: needs.file-check.outputs.run == 'true'
  1171. uses: Wandalen/wretry.action@v3
  1172. with:
  1173. action: actions/download-artifact@v4
  1174. with: |
  1175. name: dist-tarball
  1176. path: dist-tarball
  1177. attempt_limit: 3
  1178. attempt_delay: 2000
  1179. - name: Prepare artifact directory
  1180. id: prepare
  1181. if: needs.file-check.outputs.run == 'true'
  1182. run: |
  1183. mkdir -p artifacts/download/v9999.0.0 || exit 1
  1184. mkdir -p artifacts/latest || exit 1
  1185. echo "v9999.0.0" > artifacts/latest/latest-version.txt || exit 1
  1186. cp dist-tarball/* artifacts/download/v9999.0.0 || exit 1
  1187. cd artifacts/download/v9999.0.0 || exit 1
  1188. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  1189. ls -lFh
  1190. sha256sum -b ./* > "sha256sums.txt" || exit 1
  1191. cat sha256sums.txt
  1192. cd ../.. || exit 1
  1193. ls -lR
  1194. - name: Fetch test environment
  1195. id: fetch-test-environment
  1196. if: needs.file-check.outputs.run == 'true'
  1197. uses: Wandalen/wretry.action@v3
  1198. with:
  1199. action: actions/download-artifact@v4
  1200. with: |
  1201. name: ${{ matrix.artifact_key }}-test-env
  1202. path: .
  1203. attempt_limit: 3
  1204. attempt_delay: 2000
  1205. - name: Load test environment
  1206. id: load
  1207. if: needs.file-check.outputs.run == 'true'
  1208. run: docker load --input image.tar
  1209. - name: Install netdata and run the updater on ${{ matrix.distro }}
  1210. id: updater-check
  1211. if: needs.file-check.outputs.run == 'true'
  1212. run: |
  1213. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --network host -w /netdata \
  1214. -e EXTRA_INSTALL_FLAGS=${{ needs.file-check.outputs.skip-go }} \
  1215. test:${{ matrix.artifact_key }} /netdata/.github/scripts/run-updater-check.sh
  1216. - name: Failure Notification
  1217. uses: rtCamp/action-slack-notify@v2
  1218. env:
  1219. SLACK_COLOR: 'danger'
  1220. SLACK_FOOTER: ''
  1221. SLACK_ICON_EMOJI: ':github-actions:'
  1222. SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
  1223. SLACK_USERNAME: 'GitHub Actions'
  1224. SLACK_MESSAGE: |-
  1225. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  1226. Checkout: ${{ steps.checkout.outcome }}
  1227. Fetch dist tarball: ${{ steps.fetch-tarball.outcome }}
  1228. Prepare artifact directory: ${{ steps.prepare.outcome }}
  1229. Fetch test environment: ${{ steps.fetch-test-environment.outcome }}
  1230. Load test environment: ${{ steps.load.outcome }}
  1231. Updater check: ${{ steps.updater-check.outcome }}
  1232. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1233. if: >-
  1234. ${{
  1235. failure()
  1236. && startsWith(github.ref, 'refs/heads/master')
  1237. && github.event_name != 'pull_request'
  1238. && github.repository == 'netdata/netdata'
  1239. && needs.file-check.outputs.run == 'true'
  1240. }}
  1241. gitignore-check: # Verify that the build process does not make any changes to the source tree.
  1242. name: .gitignore
  1243. needs:
  1244. - file-check
  1245. runs-on: ubuntu-latest
  1246. steps:
  1247. - name: Skip Check
  1248. id: skip
  1249. if: needs.file-check.outputs.run != 'true'
  1250. run: echo "SKIPPED"
  1251. - name: Checkout
  1252. if: needs.file-check.outputs.run == 'true'
  1253. uses: actions/checkout@v4
  1254. with:
  1255. submodules: recursive
  1256. - name: Prepare environment
  1257. if: needs.file-check.outputs.run == 'true'
  1258. run: ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata
  1259. - name: Build netdata
  1260. if: needs.file-check.outputs.run == 'true'
  1261. run: ./netdata-installer.sh --dont-start-it --disable-telemetry --dont-wait --install-prefix /tmp/install --one-time-build ${{ needs.file-check.outputs.skip-go }}
  1262. - name: Check that repo is clean
  1263. if: needs.file-check.outputs.run == 'true'
  1264. run: |
  1265. git status --porcelain=v1 > /tmp/porcelain
  1266. if [ -s /tmp/porcelain ]; then
  1267. cat /tmp/porcelain
  1268. exit 1
  1269. fi