build.yml 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  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@v45
  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@v45
  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
  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
  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. windows-build: # Test building on Windows
  276. name: Test building on Windows
  277. runs-on: windows-latest
  278. needs:
  279. - file-check
  280. steps:
  281. - name: Skip Check
  282. id: skip
  283. if: needs.file-check.outputs.run != 'true'
  284. run: Write-Output "SKIPPED"
  285. - name: Checkout
  286. uses: actions/checkout@v4
  287. id: checkout
  288. if: needs.file-check.outputs.run == 'true'
  289. with:
  290. submodules: recursive
  291. lfs: true
  292. - name: Set Up Go
  293. id: golang
  294. if: needs.file-check.outputs.run == 'true'
  295. uses: actions/setup-go@v5
  296. with:
  297. go-version: "^1.22"
  298. - name: Set Up Dependencies
  299. id: deps
  300. if: needs.file-check.outputs.run == 'true'
  301. run: ./packaging/windows/install-dependencies.ps1
  302. - name: Build Netdata
  303. id: build
  304. if: needs.file-check.outputs.run == 'true'
  305. env:
  306. BUILD_DIR: ${{ github.workspace }}\build
  307. run: ./packaging/windows/build.ps1
  308. - name: Sign Agent Code
  309. id: sign-agent
  310. if: needs.file-check.outputs.run == 'true' && github.event_name != 'pull_request'
  311. uses: azure/trusted-signing-action@v0.4.0
  312. with:
  313. azure-tenant-id: ${{ secrets.CODE_SIGNING_TENNANT_ID }}
  314. azure-client-id: ${{ secrets.CODE_SIGNING_CLIENT_ID }}
  315. azure-client-secret: ${{ secrets.CODE_SIGNING_CLIENT_SECRET }}
  316. endpoint: "https://eus.codesigning.azure.net/"
  317. trusted-signing-account-name: Netdata
  318. certificate-profile-name: Netdata
  319. files-folder: ${{ github.workspace }}\build
  320. files-folder-filter: exe,dll
  321. files-folder-recurse: true
  322. file-digest: SHA256
  323. timestamp-rfc3161: "http://timestamp.acs.microsoft.com"
  324. timestamp-digest: SHA256
  325. - name: Package Netdata
  326. id: package
  327. if: needs.file-check.outputs.run == 'true'
  328. env:
  329. BUILD_DIR: ${{ github.workspace }}\build
  330. run: ./packaging/windows/package.ps1
  331. - name: Sign Installer
  332. id: sign-installer
  333. if: needs.file-check.outputs.run == 'true' && github.event_name != 'pull_request'
  334. uses: azure/trusted-signing-action@v0.4.0
  335. with:
  336. azure-tenant-id: ${{ secrets.CODE_SIGNING_TENNANT_ID }}
  337. azure-client-id: ${{ secrets.CODE_SIGNING_CLIENT_ID }}
  338. azure-client-secret: ${{ secrets.CODE_SIGNING_CLIENT_SECRET }}
  339. endpoint: "https://eus.codesigning.azure.net/"
  340. trusted-signing-account-name: Netdata
  341. certificate-profile-name: Netdata
  342. files: ${{ github.workspace }}\packaging\windows\netdata-installer.exe
  343. file-digest: SHA256
  344. timestamp-rfc3161: "http://timestamp.acs.microsoft.com"
  345. timestamp-digest: SHA256
  346. - name: Upload Installer
  347. id: upload
  348. uses: actions/upload-artifact@v4
  349. with:
  350. name: windows-x86_64-installer
  351. path: packaging\windows\netdata-installer.exe
  352. retention-days: 30
  353. - name: Failure Notification
  354. uses: rtCamp/action-slack-notify@v2
  355. env:
  356. SLACK_COLOR: 'danger'
  357. SLACK_FOOTER: ''
  358. SLACK_ICON_EMOJI: ':github-actions:'
  359. SLACK_TITLE: 'Windows build failed:'
  360. SLACK_USERNAME: 'GitHub Actions'
  361. SLACK_MESSAGE: |-
  362. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  363. Checkout: ${{ steps.checkout.outcome }}
  364. Set Up Dependencies: ${{ steps.deps.outcome }}
  365. Build Netdata: ${{ steps.build.outcome }}
  366. Sign Agent Code: ${{ steps.sign-agent.outcome }}
  367. Package Netdata: ${{ steps.package.outcome }}
  368. Sign Installer: ${{ steps.sign-installer.outcome }}
  369. Upload Installer: ${{ steps.upload.outcome }}
  370. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  371. if: >-
  372. ${{
  373. failure()
  374. && startsWith(github.ref, 'refs/heads/master')
  375. && github.event_name != 'pull_request'
  376. && github.repository == 'netdata/netdata'
  377. && needs.file-check.outputs.run == 'true'
  378. }}
  379. prepare-upload: # Consolidate the artifacts for uploading or releasing.
  380. name: Prepare Artifacts
  381. runs-on: ubuntu-latest
  382. needs:
  383. - build-dist
  384. - build-static
  385. - windows-build
  386. - file-check
  387. steps:
  388. - name: Skip Check
  389. id: skip
  390. if: needs.file-check.outputs.run != 'true'
  391. run: echo "SKIPPED"
  392. - name: Checkout
  393. id: checkout
  394. if: needs.file-check.outputs.run == 'true'
  395. uses: actions/checkout@v4
  396. - name: Prepare Environment
  397. id: prepare
  398. if: needs.file-check.outputs.run == 'true'
  399. run: mkdir -p artifacts
  400. - name: Retrieve Build Artifacts
  401. id: fetch-dist
  402. if: needs.file-check.outputs.run == 'true'
  403. uses: Wandalen/wretry.action@v3
  404. with:
  405. action: actions/download-artifact@v4
  406. with: |
  407. pattern: dist-*
  408. path: dist-artifacts
  409. merge-multiple: true
  410. attempt_limit: 3
  411. attempt_delay: 2000
  412. - name: Retrieve Windows Artifacts
  413. id: fetch-windows
  414. if: needs.file-check.outputs.run == 'true' && github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly'
  415. uses: Wandalen/wretry.action@v3
  416. with:
  417. action: actions/download-artifact@v4
  418. with: |
  419. pattern: windows-*-installer
  420. path: dist-artifacts
  421. merge-multiple: true
  422. attempt_limit: 3
  423. attempt_delay: 2000
  424. - name: Prepare Artifacts
  425. id: consolidate
  426. if: needs.file-check.outputs.run == 'true'
  427. working-directory: ./artifacts/
  428. run: |
  429. mv ../dist-artifacts/* . || exit 1
  430. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  431. cp ../packaging/version ./latest-version.txt || exit 1
  432. cp ../integrations/integrations.js ./integrations.js || exit 1
  433. sha256sum -b ./* > sha256sums.txt || exit 1
  434. cat sha256sums.txt
  435. - name: Store Artifacts
  436. id: store
  437. if: needs.file-check.outputs.run == 'true'
  438. uses: actions/upload-artifact@v4
  439. with:
  440. name: final-artifacts
  441. path: artifacts/*
  442. retention-days: 30
  443. - name: Failure Notification
  444. uses: rtCamp/action-slack-notify@v2
  445. env:
  446. SLACK_COLOR: 'danger'
  447. SLACK_FOOTER: ''
  448. SLACK_ICON_EMOJI: ':github-actions:'
  449. SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
  450. SLACK_USERNAME: 'GitHub Actions'
  451. SLACK_MESSAGE: |-
  452. ${{ github.repository }}: Failed to prepare release artifacts for upload.
  453. Checkout: ${{ steps.checkout.outcome }}
  454. Prepare environment: ${{ steps.prepare.outcome }}
  455. Fetch dist artifacts: ${{ steps.fetch-dist.outcome }}
  456. Fetch Windows installers: ${{ steps.fetch-windows.outcome }}
  457. Consolidate artifacts: ${{ steps.consolidate.outcome }}
  458. Store: ${{ steps.store.outcome }}
  459. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  460. if: >-
  461. ${{
  462. failure()
  463. && startsWith(github.ref, 'refs/heads/master')
  464. && github.event_name != 'pull_request'
  465. && github.repository == 'netdata/netdata'
  466. && needs.file-check.outputs.run == 'true'
  467. }}
  468. artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
  469. name: Test Consolidated Artifacts (Source)
  470. runs-on: ubuntu-latest
  471. needs:
  472. - prepare-upload
  473. - file-check
  474. services:
  475. apache: # This gets used to serve the dist tarball for the updater script.
  476. image: httpd:2.4
  477. ports:
  478. - 8080:80
  479. volumes:
  480. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  481. steps:
  482. - name: Skip Check
  483. id: skip
  484. if: needs.file-check.outputs.run != 'true'
  485. run: echo "SKIPPED"
  486. - name: Checkout
  487. id: checkout
  488. if: needs.file-check.outputs.run == 'true'
  489. uses: actions/checkout@v4
  490. - name: Fetch artifacts
  491. id: fetch
  492. if: needs.file-check.outputs.run == 'true'
  493. uses: Wandalen/wretry.action@v3
  494. with:
  495. action: actions/download-artifact@v4
  496. with: |
  497. name: final-artifacts
  498. path: artifacts
  499. attempt_limit: 3
  500. attempt_delay: 2000
  501. - name: Prepare artifacts directory
  502. id: prepare
  503. if: needs.file-check.outputs.run == 'true'
  504. run: |
  505. mkdir -p download/latest
  506. mv artifacts/* download/latest
  507. ls -al download/latest
  508. - name: Verify that artifacts work with installer
  509. id: verify
  510. if: needs.file-check.outputs.run == 'true'
  511. env:
  512. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  513. run: sh -x packaging/installer/kickstart.sh --build-only --dont-start-it --disable-telemetry --dont-wait
  514. - name: Failure Notification
  515. uses: rtCamp/action-slack-notify@v2
  516. env:
  517. SLACK_COLOR: 'danger'
  518. SLACK_FOOTER: ''
  519. SLACK_ICON_EMOJI: ':github-actions:'
  520. SLACK_TITLE: 'Artifact verification for source tarball failed.'
  521. SLACK_USERNAME: 'GitHub Actions'
  522. SLACK_MESSAGE: |-
  523. ${{ github.repository }}: Artifact verification for source tarball failed.
  524. Checkout: ${{ steps.checkout.outcome }}
  525. Fetch artifacts: ${{ steps.fetch.outcome }}
  526. Verify artifacts: ${{ steps.verify.outcome }}
  527. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  528. if: >-
  529. ${{
  530. failure()
  531. && startsWith(github.ref, 'refs/heads/master')
  532. && github.event_name != 'pull_request'
  533. && github.repository == 'netdata/netdata'
  534. && needs.file-check.outputs.run == 'true'
  535. }}
  536. artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
  537. name: Test Consolidated Artifacts (Static)
  538. runs-on: ubuntu-latest
  539. needs:
  540. - prepare-upload
  541. - file-check
  542. services:
  543. apache: # This gets used to serve the static archives.
  544. image: httpd:2.4
  545. ports:
  546. - 8080:80
  547. volumes:
  548. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  549. steps:
  550. - name: Skip Check
  551. id: skip
  552. if: needs.file-check.outputs.run != 'true'
  553. run: echo "SKIPPED"
  554. - name: Checkout
  555. id: checkout
  556. if: needs.file-check.outputs.run == 'true'
  557. uses: actions/checkout@v4
  558. - name: Fetch artifacts
  559. id: fetch-artifacts
  560. if: needs.file-check.outputs.run == 'true'
  561. uses: Wandalen/wretry.action@v3
  562. with:
  563. action: actions/download-artifact@v4
  564. with: |
  565. name: final-artifacts
  566. path: artifacts
  567. attempt_limit: 3
  568. attempt_delay: 2000
  569. - name: Prepare artifacts directory
  570. id: prepare
  571. if: needs.file-check.outputs.run == 'true'
  572. run: |
  573. mkdir -p download/latest
  574. mv artifacts/* download/latest
  575. ls -al download/latest
  576. - name: Verify that artifacts work with installer
  577. id: verify
  578. if: needs.file-check.outputs.run == 'true'
  579. env:
  580. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  581. run: sh -x packaging/installer/kickstart.sh --static-only --dont-start-it --disable-telemetry
  582. - name: Failure Notification
  583. uses: rtCamp/action-slack-notify@v2
  584. env:
  585. SLACK_COLOR: 'danger'
  586. SLACK_FOOTER: ''
  587. SLACK_ICON_EMOJI: ':github-actions:'
  588. SLACK_TITLE: 'Artifact verification for static build failed.'
  589. SLACK_USERNAME: 'GitHub Actions'
  590. SLACK_MESSAGE: |-
  591. ${{ github.repository }}: Artifact verification for static build failed.
  592. Checkout: ${{ steps.checkout.outcome }}
  593. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  594. Verify artifacts: ${{ steps.verify.outcome }}
  595. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  596. if: >-
  597. ${{
  598. failure()
  599. && startsWith(github.ref, 'refs/heads/master')
  600. && github.event_name != 'pull_request'
  601. && github.repository == 'netdata/netdata'
  602. && needs.file-check.outputs.run == 'true'
  603. }}
  604. create-nightly: # Create a nightly build release in netdata/netdata-nightlies
  605. name: Create Nightly Release
  606. runs-on: ubuntu-latest
  607. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  608. needs:
  609. - prepare-upload
  610. - artifact-verification-dist
  611. - artifact-verification-static
  612. steps:
  613. - name: Checkout Main Repo
  614. id: checkout-main
  615. uses: actions/checkout@v4
  616. with:
  617. path: main
  618. - name: Checkout Nightly Repo
  619. id: checkout-nightly
  620. uses: actions/checkout@v4
  621. with:
  622. repository: netdata/netdata-nightlies
  623. path: nightlies
  624. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  625. - name: Retrieve Artifacts
  626. id: fetch
  627. uses: Wandalen/wretry.action@v3
  628. with:
  629. action: actions/download-artifact@v4
  630. with: |
  631. name: final-artifacts
  632. path: final-artifacts
  633. attempt_limit: 3
  634. attempt_delay: 2000
  635. - name: Prepare version info
  636. id: version
  637. run: |
  638. # shellcheck disable=SC2129
  639. echo "version=$(cat main/packaging/version)" >> "${GITHUB_OUTPUT}"
  640. echo "commit=$(cd nightlies && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
  641. echo "date=$(date +%F)" >> "${GITHUB_OUTPUT}"
  642. - name: Create Release
  643. id: create-release
  644. uses: ncipollo/release-action@v1
  645. with:
  646. allowUpdates: false
  647. artifactErrorsFailBuild: true
  648. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/netdata-*.exe,final-artifacts/integrations.js'
  649. owner: netdata
  650. repo: netdata-nightlies
  651. body: Netdata nightly build for ${{ steps.version.outputs.date }}.
  652. commit: ${{ steps.version.outputs.commit }}
  653. makeLatest: true
  654. tag: ${{ steps.version.outputs.version }}
  655. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  656. - name: Checkout netdata main Repo # Checkout back to netdata/netdata repo to the update latest packaged versions
  657. id: checkout-netdata
  658. uses: actions/checkout@v4
  659. with:
  660. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  661. - name: Init python environment for publish release metadata
  662. uses: actions/setup-python@v5
  663. id: init-python
  664. with:
  665. python-version: "3.12"
  666. - name: Setup python environment
  667. id: setup-python
  668. run: |
  669. pip install -r .github/scripts/modules/requirements.txt
  670. - name: Check if the version is latest and published
  671. id: check-latest-version
  672. run: |
  673. python .github/scripts/check_latest_versions.py ${{ steps.version.outputs.version }}
  674. - name: SSH setup
  675. id: ssh-setup
  676. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  677. uses: shimataro/ssh-key-action@v2
  678. with:
  679. key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
  680. name: id_ecdsa
  681. known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
  682. - name: Sync release info to packages.netdata.cloud
  683. id: sync-releases
  684. continue-on-error: true
  685. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  686. run: |
  687. .github/scripts/upload-new-version-tags.sh packages.netdata.cloud
  688. - name: Sync release info to packages2.netdata.cloud
  689. id: sync-releases2
  690. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  691. run: |
  692. .github/scripts/upload-new-version-tags.sh packages.netdata.cloud
  693. - name: Failure Notification
  694. uses: rtCamp/action-slack-notify@v2
  695. env:
  696. SLACK_COLOR: 'danger'
  697. SLACK_FOOTER: ''
  698. SLACK_ICON_EMOJI: ':github-actions:'
  699. SLACK_TITLE: 'Failed to draft release:'
  700. SLACK_USERNAME: 'GitHub Actions'
  701. SLACK_MESSAGE: |-
  702. ${{ github.repository }}: Failed to create nightly release or attach artifacts.
  703. Checkout netdata/netdata: ${{ steps.checkout-main.outcome }}
  704. Checkout netdata/netdata-nightlies: ${{ steps.checkout-nightly.outcome }}
  705. Fetch artifacts: ${{ steps.fetch.outcome }}
  706. Prepare version info: ${{ steps.version.outcome }}
  707. Create release: ${{ steps.create-release.outcome }}
  708. Checkout back netdata/netdata: ${{ steps.checkout-netdata.outcome }}
  709. Init python environment: ${{ steps.init-python.outcome }}
  710. Setup python environment: ${{ steps.setup-python.outcome }}
  711. Check the nearly published release against the advertised: ${{ steps.check-latest-version.outcome }}
  712. Setup ssh: ${{ steps.ssh-setup.outcome }}
  713. Sync release info to packages.netdata.cloud: ${{ steps.sync-releases.outcome }}
  714. Sync release info to packages2.netdata.cloud: ${{ steps.sync-releases2.outcome }}
  715. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  716. if: >-
  717. ${{
  718. failure()
  719. && github.event_name == 'workflow_dispatch'
  720. }}
  721. normalize-tag: # Fix the release tag if needed
  722. name: Normalize Release Tag
  723. runs-on: ubuntu-latest
  724. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  725. outputs:
  726. tag: ${{ steps.tag.outputs.tag }}
  727. steps:
  728. - name: Normalize Tag
  729. id: tag
  730. run: |
  731. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  732. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  733. else
  734. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  735. fi
  736. upload-release: # Create the draft release and upload the build artifacts.
  737. name: Create Release Draft
  738. runs-on: ubuntu-latest
  739. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  740. needs:
  741. - artifact-verification-dist
  742. - artifact-verification-static
  743. - normalize-tag
  744. steps:
  745. - name: Checkout
  746. id: checkout
  747. uses: actions/checkout@v4
  748. - name: Retrieve Artifacts
  749. id: fetch
  750. uses: Wandalen/wretry.action@v3
  751. with:
  752. action: actions/download-artifact@v4
  753. with: |
  754. name: final-artifacts
  755. path: final-artifacts
  756. attempt_limit: 3
  757. attempt_delay: 2000
  758. - name: Create Release
  759. id: create-release
  760. uses: ncipollo/release-action@v1
  761. with:
  762. allowUpdates: false
  763. artifactErrorsFailBuild: true
  764. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/netdata-*.exe,final-artifacts/integrations.js'
  765. draft: true
  766. tag: ${{ needs.normalize-tag.outputs.tag }}
  767. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  768. - name: Failure Notification
  769. uses: rtCamp/action-slack-notify@v2
  770. env:
  771. SLACK_COLOR: 'danger'
  772. SLACK_FOOTER: ''
  773. SLACK_ICON_EMOJI: ':github-actions:'
  774. SLACK_TITLE: 'Failed to draft release:'
  775. SLACK_USERNAME: 'GitHub Actions'
  776. SLACK_MESSAGE: |-
  777. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  778. Checkout: ${{ steps.checkout.outcome }}
  779. Fetch artifacts: ${{ steps.fetch.outcome }}
  780. Create draft release: ${{ steps.create-release.outcome }}
  781. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  782. if: >-
  783. ${{
  784. failure()
  785. && github.event_name == 'workflow_dispatch'
  786. }}
  787. - name: Success Notification
  788. uses: rtCamp/action-slack-notify@v2
  789. env:
  790. SLACK_COLOR: 'good'
  791. SLACK_FOOTER: ''
  792. SLACK_ICON_EMOJI: ':github-actions:'
  793. SLACK_TITLE: 'Created agent draft release:'
  794. SLACK_USERNAME: 'GitHub Actions'
  795. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  796. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  797. if: >-
  798. ${{
  799. success()
  800. && github.event_name == 'workflow_dispatch'
  801. }}
  802. # Remaining jobs are only used for CI checks, and not as part of the release process
  803. matrix: # Generate the shared build matrix for our Linux build tests.
  804. name: Prepare Build Matrix
  805. runs-on: ubuntu-latest
  806. if: github.event_name != 'workflow_dispatch'
  807. outputs:
  808. matrix: ${{ steps.set-matrix.outputs.matrix }}
  809. steps:
  810. - name: Checkout
  811. id: checkout
  812. uses: actions/checkout@v4
  813. - name: Prepare tools
  814. id: prepare
  815. run: |
  816. sudo apt-get update || true
  817. sudo apt-get install -y python3-ruamel.yaml
  818. - name: Read build matrix
  819. id: set-matrix
  820. run: |
  821. matrix="$(.github/scripts/gen-matrix-build.py)"
  822. echo "Generated matrix: ${matrix}"
  823. echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
  824. - name: Failure Notification
  825. uses: rtCamp/action-slack-notify@v2
  826. env:
  827. SLACK_COLOR: 'danger'
  828. SLACK_FOOTER: ''
  829. SLACK_ICON_EMOJI: ':github-actions:'
  830. SLACK_TITLE: 'Build matrix preparation failed:'
  831. SLACK_USERNAME: 'GitHub Actions'
  832. SLACK_MESSAGE: |-
  833. ${{ github.repository }}: Failed to prepare build matrix for build checks.
  834. Checkout: ${{ steps.checkout.outcome }}
  835. Prepare tools: ${{ steps.prepare.outcome }}
  836. Read build matrix: ${{ steps.set-matrix.outcome }}
  837. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  838. if: >-
  839. ${{
  840. failure()
  841. && startsWith(github.ref, 'refs/heads/master')
  842. && github.event_name != 'pull_request'
  843. && github.repository == 'netdata/netdata'
  844. }}
  845. prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
  846. name: Prepare Test Environments
  847. runs-on: ubuntu-latest
  848. if: github.event_name != 'workflow_dispatch'
  849. needs:
  850. - matrix
  851. env:
  852. RETRY_DELAY: 300
  853. strategy:
  854. # Unlike the actual build tests, this completes _very_ fast (average of about 3 minutes for each job), so we
  855. # just run everything in parallel instead lof limiting job concurrency.
  856. fail-fast: false
  857. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  858. steps:
  859. - name: Checkout
  860. id: checkout
  861. uses: actions/checkout@v4
  862. - name: Setup Buildx
  863. id: buildx
  864. uses: docker/setup-buildx-action@v3
  865. - name: Build test environment
  866. id: build1
  867. uses: docker/build-push-action@v6
  868. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  869. with:
  870. push: false
  871. load: false
  872. file: .github/dockerfiles/Dockerfile.build_test
  873. build-args: |
  874. BASE=${{ matrix.distro }}
  875. PRE=${{ matrix.env_prep }}
  876. RMJSONC=${{ matrix.jsonc_removal }}
  877. outputs: type=docker,dest=/tmp/image.tar
  878. tags: test:${{ matrix.artifact_key }}
  879. - name: Retry delay
  880. if: ${{ steps.build1.outcome == 'failure' }}
  881. run: sleep "${RETRY_DELAY}"
  882. - name: Build test environment (attempt 2)
  883. if: ${{ steps.build1.outcome == 'failure' }}
  884. id: build2
  885. uses: docker/build-push-action@v6
  886. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  887. with:
  888. push: false
  889. load: false
  890. file: .github/dockerfiles/Dockerfile.build_test
  891. build-args: |
  892. BASE=${{ matrix.distro }}
  893. PRE=${{ matrix.env_prep }}
  894. RMJSONC=${{ matrix.jsonc_removal }}
  895. outputs: type=docker,dest=/tmp/image.tar
  896. tags: test:${{ matrix.artifact_key }}
  897. - name: Retry delay
  898. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  899. run: sleep "${RETRY_DELAY}"
  900. - name: Build test environment (attempt 3)
  901. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  902. id: build3
  903. uses: docker/build-push-action@v6
  904. with:
  905. push: false
  906. load: false
  907. file: .github/dockerfiles/Dockerfile.build_test
  908. build-args: |
  909. BASE=${{ matrix.distro }}
  910. PRE=${{ matrix.env_prep }}
  911. RMJSONC=${{ matrix.jsonc_removal }}
  912. outputs: type=docker,dest=/tmp/image.tar
  913. tags: test:${{ matrix.artifact_key }}
  914. - name: Upload image artifact
  915. id: upload
  916. uses: actions/upload-artifact@v4
  917. with:
  918. name: ${{ matrix.artifact_key }}-test-env
  919. path: /tmp/image.tar
  920. retention-days: 30
  921. - name: Failure Notification
  922. uses: rtCamp/action-slack-notify@v2
  923. env:
  924. SLACK_COLOR: 'danger'
  925. SLACK_FOOTER: ''
  926. SLACK_ICON_EMOJI: ':github-actions:'
  927. SLACK_TITLE: 'Test environment preparation for ${{ matrix.distro }} failed:'
  928. SLACK_USERNAME: 'GitHub Actions'
  929. SLACK_MESSAGE: |-
  930. ${{ github.repository }}: Test environment preparation for ${{ matrix.distro }} failed.
  931. Checkout: ${{ steps.checkout.outcome }}
  932. Set up Buildx: ${{ steps.buildx.outcome }}
  933. Build test environment: ${{ steps.build1.outcome }}
  934. Build test environment (attempt 2): ${{ steps.build2.outcome }}
  935. Build test environment (attempt 3): ${{ steps.build3.outcome }}
  936. Upload: ${{ steps.upload.outcome }}
  937. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  938. if: >-
  939. ${{
  940. failure()
  941. && startsWith(github.ref, 'refs/heads/master')
  942. && github.event_name != 'pull_request'
  943. && github.repository == 'netdata/netdata'
  944. }}
  945. source-build: # Test various source build arrangements.
  946. name: Test Source Build
  947. runs-on: ubuntu-latest
  948. if: github.event_name != 'workflow_dispatch'
  949. needs:
  950. - matrix
  951. - prepare-test-images
  952. - file-check
  953. strategy:
  954. fail-fast: false
  955. max-parallel: 8
  956. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  957. steps:
  958. - name: Skip Check
  959. id: skip
  960. if: needs.file-check.outputs.run != 'true'
  961. run: echo "SKIPPED"
  962. - name: Checkout
  963. id: checkout
  964. if: needs.file-check.outputs.run == 'true'
  965. uses: actions/checkout@v4
  966. with:
  967. submodules: recursive
  968. - name: Fetch test environment
  969. id: fetch
  970. if: needs.file-check.outputs.run == 'true'
  971. uses: Wandalen/wretry.action@v3
  972. with:
  973. action: actions/download-artifact@v4
  974. with: |
  975. name: ${{ matrix.artifact_key }}-test-env
  976. path: .
  977. attempt_limit: 3
  978. attempt_delay: 2000
  979. - name: Load test environment
  980. id: load
  981. if: needs.file-check.outputs.run == 'true'
  982. run: docker load --input image.tar
  983. - name: netdata-installer on ${{ matrix.distro }}, require cloud
  984. id: build-cloud
  985. if: needs.file-check.outputs.run == 'true'
  986. run: |
  987. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  988. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --one-time-build ${{ needs.file-check.outputs.skip-go }}'
  989. - name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
  990. id: build-no-jsonc
  991. if: matrix.jsonc_removal != '' && needs.file-check.outputs.run == 'true'
  992. run: |
  993. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  994. /bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --one-time-build ${{ needs.file-check.outputs.skip-go }}'
  995. - name: Failure Notification
  996. uses: rtCamp/action-slack-notify@v2
  997. env:
  998. SLACK_COLOR: 'danger'
  999. SLACK_FOOTER: ''
  1000. SLACK_ICON_EMOJI: ':github-actions:'
  1001. SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
  1002. SLACK_USERNAME: 'GitHub Actions'
  1003. SLACK_MESSAGE: |-
  1004. ${{ github.repository }}: Build tests for ${{ matrix.distro }} failed.
  1005. Checkout: ${{ steps.checkout.outcome }}
  1006. Fetch test environment: ${{ steps.fetch.outcome }}
  1007. Load test environment: ${{ steps.load.outcome }}
  1008. netdata-installer: ${{ steps.build-cloud.outcome }}
  1009. netdata-installer, no JSON-C: ${{ steps.build-no-jsonc.outcome }}
  1010. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1011. if: >-
  1012. ${{
  1013. failure()
  1014. && startsWith(github.ref, 'refs/heads/master')
  1015. && github.event_name != 'pull_request'
  1016. && github.repository == 'netdata/netdata'
  1017. && needs.file-check.outputs.run == 'true'
  1018. }}
  1019. macos-build: # Test building on macOS
  1020. name: Test building on macOS
  1021. runs-on: ${{ matrix.runner }}
  1022. if: github.event_name != 'workflow_dispatch'
  1023. needs:
  1024. - file-check
  1025. strategy:
  1026. fail-fast: false
  1027. max-parallel: 8
  1028. matrix:
  1029. include:
  1030. - name: macos-12
  1031. runner: macos-12
  1032. - name: macos-13
  1033. runner: macos-13
  1034. - name: macos-14-M1
  1035. runner: macos-14
  1036. steps:
  1037. - name: Skip Check
  1038. id: skip
  1039. if: needs.file-check.outputs.run != 'true'
  1040. run: echo "SKIPPED"
  1041. - uses: actions/checkout@v4
  1042. id: checkout
  1043. if: needs.file-check.outputs.run == 'true'
  1044. with:
  1045. submodules: recursive
  1046. - name: Install latest bash
  1047. id: install-bash
  1048. if: needs.file-check.outputs.run == 'true'
  1049. run: |
  1050. brew install bash
  1051. - name: Install netdata dependencies
  1052. id: install-nd-dep
  1053. if: needs.file-check.outputs.run == 'true'
  1054. run: |
  1055. bash ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all
  1056. - name: Build from source
  1057. id: build-source
  1058. if: needs.file-check.outputs.run == 'true'
  1059. run: |
  1060. sudo bash ./netdata-installer.sh --install-no-prefix /usr/local/netdata --dont-wait --dont-start-it --one-time-build
  1061. - name: Test Agent start up
  1062. id: test-agent
  1063. if: needs.file-check.outputs.run == 'true'
  1064. run: |
  1065. /usr/local/netdata/usr/sbin/netdata -D > ./netdata.log 2>&1 &
  1066. ./packaging/runtime-check.sh
  1067. - name: Failure Notification
  1068. uses: rtCamp/action-slack-notify@v2
  1069. env:
  1070. SLACK_COLOR: 'danger'
  1071. SLACK_FOOTER: ''
  1072. SLACK_ICON_EMOJI: ':github-actions:'
  1073. SLACK_TITLE: 'Build & test from source macOS failed:'
  1074. SLACK_USERNAME: 'GitHub Actions'
  1075. SLACK_MESSAGE: |-
  1076. ${{ github.repository }}: macOS Build and test.
  1077. Checkout: ${{ steps.checkout.outcome }}
  1078. Setup runner: ${{ steps.install-bash.outcome }}
  1079. Install netdata required packages: ${{ steps.install-nd-dep.outcome }}
  1080. Build from source: ${{ steps.build-source.outcome }}
  1081. Test Agent runtime: ${{ steps.test-agent.outcome }}
  1082. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1083. if: >-
  1084. ${{
  1085. failure()
  1086. && startsWith(github.ref, 'refs/heads/master')
  1087. && github.event_name != 'pull_request'
  1088. && github.repository == 'netdata/netdata'
  1089. }}
  1090. updater-check: # Test the generated dist archive using the updater code.
  1091. name: Test Generated Distfile and Updater Code
  1092. runs-on: ubuntu-latest
  1093. if: github.event_name != 'workflow_dispatch'
  1094. needs:
  1095. - build-dist
  1096. - matrix
  1097. - prepare-test-images
  1098. - file-check
  1099. strategy:
  1100. fail-fast: false
  1101. max-parallel: 8
  1102. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  1103. services:
  1104. apache: # This gets used to serve the dist tarball for the updater script.
  1105. image: httpd:2.4
  1106. ports:
  1107. - 8080:80
  1108. volumes:
  1109. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  1110. steps:
  1111. - name: Skip Check
  1112. id: skip
  1113. if: needs.file-check.outputs.run != 'true'
  1114. run: echo "SKIPPED"
  1115. - name: Checkout
  1116. id: checkout
  1117. if: needs.file-check.outputs.run == 'true'
  1118. uses: actions/checkout@v4
  1119. - name: Fetch dist tarball artifacts
  1120. id: fetch-tarball
  1121. if: needs.file-check.outputs.run == 'true'
  1122. uses: Wandalen/wretry.action@v3
  1123. with:
  1124. action: actions/download-artifact@v4
  1125. with: |
  1126. name: dist-tarball
  1127. path: dist-tarball
  1128. attempt_limit: 3
  1129. attempt_delay: 2000
  1130. - name: Prepare artifact directory
  1131. id: prepare
  1132. if: needs.file-check.outputs.run == 'true'
  1133. run: |
  1134. mkdir -p artifacts/download/v9999.0.0 || exit 1
  1135. mkdir -p artifacts/latest || exit 1
  1136. echo "v9999.0.0" > artifacts/latest/latest-version.txt || exit 1
  1137. cp dist-tarball/* artifacts/download/v9999.0.0 || exit 1
  1138. cd artifacts/download/v9999.0.0 || exit 1
  1139. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  1140. ls -lFh
  1141. sha256sum -b ./* > "sha256sums.txt" || exit 1
  1142. cat sha256sums.txt
  1143. cd ../.. || exit 1
  1144. ls -lR
  1145. - name: Fetch test environment
  1146. id: fetch-test-environment
  1147. if: needs.file-check.outputs.run == 'true'
  1148. uses: Wandalen/wretry.action@v3
  1149. with:
  1150. action: actions/download-artifact@v4
  1151. with: |
  1152. name: ${{ matrix.artifact_key }}-test-env
  1153. path: .
  1154. attempt_limit: 3
  1155. attempt_delay: 2000
  1156. - name: Load test environment
  1157. id: load
  1158. if: needs.file-check.outputs.run == 'true'
  1159. run: docker load --input image.tar
  1160. - name: Install netdata and run the updater on ${{ matrix.distro }}
  1161. id: updater-check
  1162. if: needs.file-check.outputs.run == 'true'
  1163. run: |
  1164. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --network host -w /netdata \
  1165. -e EXTRA_INSTALL_FLAGS=${{ needs.file-check.outputs.skip-go }} \
  1166. test:${{ matrix.artifact_key }} /netdata/.github/scripts/run-updater-check.sh
  1167. - name: Failure Notification
  1168. uses: rtCamp/action-slack-notify@v2
  1169. env:
  1170. SLACK_COLOR: 'danger'
  1171. SLACK_FOOTER: ''
  1172. SLACK_ICON_EMOJI: ':github-actions:'
  1173. SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
  1174. SLACK_USERNAME: 'GitHub Actions'
  1175. SLACK_MESSAGE: |-
  1176. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  1177. Checkout: ${{ steps.checkout.outcome }}
  1178. Fetch dist tarball: ${{ steps.fetch-tarball.outcome }}
  1179. Prepare artifact directory: ${{ steps.prepare.outcome }}
  1180. Fetch test environment: ${{ steps.fetch-test-environment.outcome }}
  1181. Load test environment: ${{ steps.load.outcome }}
  1182. Updater check: ${{ steps.updater-check.outcome }}
  1183. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1184. if: >-
  1185. ${{
  1186. failure()
  1187. && startsWith(github.ref, 'refs/heads/master')
  1188. && github.event_name != 'pull_request'
  1189. && github.repository == 'netdata/netdata'
  1190. && needs.file-check.outputs.run == 'true'
  1191. }}
  1192. gitignore-check: # Verify that the build process does not make any changes to the source tree.
  1193. name: .gitignore
  1194. needs:
  1195. - file-check
  1196. runs-on: ubuntu-latest
  1197. steps:
  1198. - name: Skip Check
  1199. id: skip
  1200. if: needs.file-check.outputs.run != 'true'
  1201. run: echo "SKIPPED"
  1202. - name: Checkout
  1203. if: needs.file-check.outputs.run == 'true'
  1204. uses: actions/checkout@v4
  1205. with:
  1206. submodules: recursive
  1207. - name: Prepare environment
  1208. if: needs.file-check.outputs.run == 'true'
  1209. run: ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata
  1210. - name: Build netdata
  1211. if: needs.file-check.outputs.run == 'true'
  1212. run: ./netdata-installer.sh --dont-start-it --disable-telemetry --dont-wait --install-prefix /tmp/install --one-time-build ${{ needs.file-check.outputs.skip-go }}
  1213. - name: Check that repo is clean
  1214. if: needs.file-check.outputs.run == 'true'
  1215. run: |
  1216. git status --porcelain=v1 > /tmp/porcelain
  1217. if [ -s /tmp/porcelain ]; then
  1218. cat /tmp/porcelain
  1219. exit 1
  1220. fi