Overhaul build CI. (#11699)

* Overhaul build CI.

This makes a number of changes that make our build CI easier to maintain
and much safer with respect to the possibility of accidentally pushing
broken nightlies.

* The release-build.yml workflow has been renamed to just build.yml
* The updater.yml and build-and-install.yml workflows have been
  consolidated into the build.yml workflow.
* The updater checks now use the dist tarball produced by the dist
  tarball build instead of building one for each matrix job.
* The updater and build checks now use a set of jobs for generating
  their test environments.
* The updater and build checks and their shared test environment builds
  now use a unified build matrix, handled in an external data file
  (.github/data/build-matrix.json).
* Nightly artifact uploads and release creation are now dependent on the
  updater checks passing.

* Properly handle generated build matrix.

* Minor fixes.

* Fix shellcheck complaints.

* Fixed stub script handling.

* Mangle the build matrix JSON properly.

* Properly handle stub scripts.

* Fix distro name handling.

* Fix typos.

* Fix test environment image handling.

* Fix updater checks.

* Skip CentOS 7 JSON-C bundling check.

* Fix handling of artifacts for updater check.

* Fix yamllint errors.

* Fix dist tarball handling.

* Fix updater check script permissions.

* Restructure build test Dockerfile for better caching.

* Remove parallelization limits for test environment builds.

These complete fast enough that it is perfectly reasonable to run them
all in parallel simultaneously. In the best case scenario, this will
save roughly 5-10 minutes of time during CI runs.

* Add more in-line documentation and tidy up a few unneeded parameters.

* Add checks to verify consolidated artifacts are good.

* Fix distfile name handling.

* Fix artifact checking.

* Better delineate phases of updater check in logs.

* Simplify updater checks.

* Print checksums of artifacts.

To simplify debugging.

* Fix handling of updater checks.
This commit is contained in:
Austin S. Hemmelgarn 2021-11-15 10:02:57 -05:00 committed by GitHub
parent 25007979f3
commit 0cab09f488
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 662 additions and 479 deletions

109
.github/data/build-matrix.json vendored Normal file
View File

@ -0,0 +1,109 @@
{
"include": [
{
"distro": "alpine:edge",
"artifact_key": "alpine-edge",
"pre": "apk add -U bash",
"rmjsonc": "apk del json-c-dev"
},
{
"distro": "alpine:3.14",
"artifact_key": "alpine-3.14",
"pre": "apk add -U bash",
"rmjsonc": "apk del json-c-dev"
},
{
"distro": "alpine:3.13",
"artifact_key": "alpine-3.13",
"pre": "apk add -U bash",
"rmjsonc": "apk del json-c-dev"
},
{
"distro": "alpine:3.12",
"artifact_key": "alpine-3.12",
"pre": "apk add -U bash",
"rmjsonc": "apk del json-c-dev"
},
{
"distro": "archlinux:latest",
"artifact_key": "archlinux",
"pre": "pacman --noconfirm -Syu && pacman --noconfirm -Sy grep libffi"
},
{
"distro": "centos:7",
"artifact_key": "centos7"
},
{
"distro": "centos:8",
"artifact_key": "centos8",
"rmjsonc": "dnf remove -y json-c-devel"
},
{
"distro": "debian:11",
"artifact_key": "debian11",
"pre": "apt-get update",
"rmjsonc": "apt-get remove -y libjson-c-dev"
},
{
"distro": "debian:10",
"artifact_key": "debian10",
"pre": "apt-get update",
"rmjsonc": "apt-get remove -y libjson-c-dev"
},
{
"distro": "debian:9",
"artifact_key": "debian9",
"pre": "apt-get update",
"rmjsonc": "apt-get remove -y libjson-c-dev"
},
{
"distro": "fedora:35",
"artifact_key": "fedora35",
"rmjsonc": "dnf remove -y json-c-devel"
},
{
"distro": "fedora:34",
"artifact_key": "fedora34",
"rmjsonc": "dnf remove -y json-c-devel"
},
{
"distro": "fedora:33",
"artifact_key": "fedora33",
"rmjsonc": "dnf remove -y json-c-devel"
},
{
"distro": "opensuse/leap:15.3",
"artifact_key": "opensuse15.3",
"rmjsonc": "zypper rm -y libjson-c-devel"
},
{
"distro": "opensuse/leap:15.2",
"artifact_key": "opensuse15.2",
"rmjsonc": "zypper rm -y libjson-c-devel"
},
{
"distro": "ubuntu:21.10",
"artifact_key": "ubuntu21.10",
"pre": "rm -f /etc/apt/apt.conf.d/docker && apt-get update",
"rmjsonc": "apt-get remove -y libjson-c-dev"
},
{
"distro": "ubuntu:21.04",
"artifact_key": "ubuntu21.04",
"pre": "apt-get update",
"rmjsonc": "apt-get remove -y libjson-c-dev"
},
{
"distro": "ubuntu:20.04",
"artifact_key": "ubuntu20.04",
"pre": "apt-get update",
"rmjsonc": "apt-get remove -y libjson-c-dev"
},
{
"distro": "ubuntu:18.04",
"artifact_key": "ubuntu18.04",
"pre": "apt-get update",
"rmjsonc": "apt-get remove -y libjson-c-dev"
}
]
}

View File

@ -4,10 +4,15 @@ FROM ${BASE}
ARG PRE
ENV PRE=${PRE}
ARG RMJSONC
ENV RMJSONC=${RMJSONC}
ENV DO_NOT_TRACK=1
ENV GITHUB_ACTIONS=true
RUN echo "${PRE}" > /prep-cmd.sh && \
echo "${RMJSONC}" > /rmjsonc.sh && chmod +x /rmjsonc.sh && \
/bin/sh /prep-cmd.sh
COPY . /netdata
RUN /bin/sh /netdata/prep-cmd.sh
RUN /netdata/packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all

9
.github/scripts/run-updater-check.sh vendored Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
echo ">>> Installing Netdata..."
/netdata/packaging/installer/kickstart.sh --dont-wait --disable-telemetry || exit 1
echo ">>> Updating Netdata..."
export NETDATA_NIGHTLIES_BASEURL="http://localhost:8080/artifacts/" # Pull the tarball from the local web server.
/netdata/packaging/installer/netdata-updater.sh --not-running-from-cron --no-updater-self-update || exit 1
echo ">>> Checking if update was successful..."
/netdata/.github/scripts/check-updater.sh || exit 1

View File

@ -1,125 +0,0 @@
---
name: Builder
on:
push:
branches:
- master
pull_request: null
env:
DO_NOT_TRACK: 1
concurrency:
group: builder-${{ github.ref }}
cancel-in-progress: true
jobs:
source-build:
name: Build & Install
strategy:
fail-fast: false
max-parallel: 8
matrix:
distro:
- 'alpine:edge'
- 'alpine:3.14'
- 'alpine:3.13'
- 'alpine:3.12'
- 'archlinux:latest'
- 'centos:8'
- 'centos:7'
- 'debian:bullseye' # 11
- 'debian:10'
- 'debian:9'
- 'fedora:35'
- 'fedora:34'
- 'fedora:33'
- 'opensuse/leap:15.2'
- 'opensuse/leap:15.3'
- 'ubuntu:21.10'
- 'ubuntu:21.04'
- 'ubuntu:20.04'
- 'ubuntu:18.04'
include:
- distro: 'alpine:edge'
pre: 'apk add -U bash'
rmjsonc: 'apk del json-c-dev'
- distro: 'alpine:3.14'
pre: 'apk add -U bash'
rmjsonc: 'apk del json-c-dev'
- distro: 'alpine:3.13'
pre: 'apk add -U bash'
rmjsonc: 'apk del json-c-dev'
- distro: 'alpine:3.12'
pre: 'apk add -U bash'
rmjsonc: 'apk del json-c-dev'
- distro: 'archlinux:latest'
pre: 'pacman --noconfirm -Syu && pacman --noconfirm -Sy grep libffi'
- distro: 'centos:8'
rmjsonc: 'dnf remove -y json-c-devel'
- distro: 'debian:bullseye' # 11
pre: 'apt-get update'
rmjsonc: 'apt-get remove -y libjson-c-dev'
- distro: 'debian:10'
pre: 'apt-get update'
rmjsonc: 'apt-get remove -y libjson-c-dev'
- distro: 'debian:9'
pre: 'apt-get update'
rmjsonc: 'apt-get remove -y libjson-c-dev'
- distro: 'fedora:35'
rmjsonc: 'dnf remove -y json-c-devel'
- distro: 'fedora:34'
rmjsonc: 'dnf remove -y json-c-devel'
- distro: 'fedora:33'
rmjsonc: 'dnf remove -y json-c-devel'
- distro: 'opensuse/leap:15.2'
rmjsonc: 'zypper rm -y libjson-c-devel'
- distro: 'opensuse/leap:15.3'
rmjsonc: 'zypper rm -y libjson-c-devel'
- distro: 'ubuntu:21.10'
pre: 'rm -f /etc/apt/apt.conf.d/docker* && apt-get update'
rmjsonc: 'apt-get remove -y libjson-c-dev'
- distro: 'ubuntu:21.04'
pre: 'apt-get update'
rmjsonc: 'apt-get remove -y libjson-c-dev'
- distro: 'ubuntu:20.04'
pre: 'apt-get update'
rmjsonc: 'apt-get remove -y libjson-c-dev'
- distro: 'ubuntu:18.04'
pre: 'apt-get update'
rmjsonc: 'apt-get remove -y libjson-c-dev'
runs-on: ubuntu-latest
steps:
- name: Git clone repository
uses: actions/checkout@v2
with:
submodules: recursive
- name: install-required-packages.sh on ${{ matrix.distro }}
env:
PRE: ${{ matrix.pre }}
RMJSONC: ${{ matrix.rmjsonc }}
run: |
echo $PRE > ./prep-cmd.sh
echo $RMJSONC > ./rmjsonc.sh && chmod +x ./rmjsonc.sh
docker build . -f .github/dockerfiles/Dockerfile.build_test -t test --build-arg BASE=${{ matrix.distro }}
- name: Regular build on ${{ matrix.distro }}
run: |
docker run --security-opt seccomp=unconfined -w /netdata test /bin/sh -c 'autoreconf -ivf && ./configure && make -j2'
- name: netdata-installer on ${{ matrix.distro }}, disable cloud
run: |
docker run --security-opt seccomp=unconfined -w /netdata test /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud'
- name: netdata-installer on ${{ matrix.distro }}, require cloud
run: |
docker run --security-opt seccomp=unconfined -w /netdata test /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud'
- name: netdata-installer on ${{ matrix.distro }}, require cloud, require ACLK-NG
run: |
docker run --security-opt seccomp=unconfined -w /netdata -e NETDATA_CONFIGURE_OPTIONS='--with-aclk-ng' test \
/bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud'
- name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
if: matrix.rmjsonc != ''
run: |
docker run --security-opt seccomp=unconfined -w /netdata test \
/bin/sh -c '/netdata/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud'

537
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,537 @@
---
# Ci code for building release artifacts.
name: Build
on:
push: # Master branch checks only validate the build and generate artifacts for testing.
branches:
- master
pull_request: null # PR checks only validate the build and generate artifacts for testing.
workflow_dispatch: # Dispatch runs build and validate, then push to the appropriate storage location.
inputs:
type:
description: Build Type
default: nightly
required: true
version:
description: Version Tag
default: nightly
required: true
concurrency: # This keeps multiple instances of the job from running concurrently for the same ref and event type.
group: release-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
build-dist: # Build the distribution tarball and store it as an artifact.
name: Build Distribution Tarball
runs-on: ubuntu-latest
outputs:
distfile: ${{ steps.build.outputs.distfile }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Mark Stable
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly'
run: |
sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' netdata-installer.sh
- name: Build
id: build
run: |
mkdir -p artifacts
./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata
autoreconf -ivf
./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--libexecdir=/usr/libexec \
--with-zlib \
--with-math \
--with-user=netdata
make dist
echo "::set-output name=distfile::$(find . -name 'netdata-*.tar.gz')"
cp netdata-*.tar.gz artifacts/
- name: Store
uses: actions/upload-artifact@v2
with:
name: dist-tarball
path: artifacts/*.tar.gz
retention-days: 30
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Distribution tarball build failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Distribution tarball build failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
build-static: # Build the static binary archives, and store them as artifacts.
name: Build Static
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- 'x86_64'
- 'armv7l'
- 'aarch64'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Mark Stable
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly'
run: |
sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' netdata-installer.sh packaging/makeself/install-or-update.sh
- name: Build
run: .github/scripts/build-static.sh ${{ matrix.arch }}
- name: Store
uses: actions/upload-artifact@v2
with:
name: static-archive
path: artifacts/*.gz.run
retention-days: 30
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Static build for ${{ matrix.arch }} failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Static build for ${{ matrix.arch }} failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
matrix: # Generate the shared build matrix for our build tests.
name: Prepare Build Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare tools
run: |
sudo apt-get update && sudo apt-get install -y jq
- name: Read build matrix
id: set-matrix
run: |
TASKS="$(jq -c . .github/data/build-matrix.json)"
echo "Generated Matrix: $TASKS"
echo "::set-output name=matrix::$TASKS"
prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
name: Prepare Test Environments
runs-on: ubuntu-latest
needs:
- matrix
strategy:
# Unlike the actal build tests, this completes _very_ fast (average of about 3 minutes for each job), so we
# just run everything in parallel instead lof limiting job concurrency.
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Git clone repository
uses: actions/checkout@v2
- name: Setup Buildx
uses: docker/setup-buildx-action@v1
- name: Build test environment
uses: docker/build-push-action@v2
with:
push: false
load: false
file: .github/dockerfiles/Dockerfile.build_test
build-args: |
BASE=${{ matrix.distro }}
PRE=${{ matrix.pre }}
RMJSONC=${{ matrix.rmjsonc }}
outputs: type=oci,dest=/tmp/image.tar
tags: test:${{ matrix.artifact_key }}
- name: Upload image artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifact_key }}-test-env
path: /tmp/image.tar
retention-days: 30
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Test environment preparation for ${{ matrix.distro }} failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Test environment preparation for ${{ matrix.distro }} failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
source-build: # Test various source build arrangements.
name: Test Source Build
runs-on: ubuntu-latest
needs:
- matrix
- prepare-test-images
strategy:
fail-fast: false
max-parallel: 8
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Git clone repository
uses: actions/checkout@v2
with:
submodules: recursive
- name: Fetch test environment
uses: actions/download-artifact@v2
with:
name: ${{ matrix.artifact_key }}-test-env
- name: Load test environment
id: load
run: |
docker load --input image.tar | tee image-info.txt
echo "::set-output name=image::$(cut -d ':' -f 3 image-info.txt)"
- name: Regular build on ${{ matrix.distro }}
run: |
docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
/bin/sh -c 'autoreconf -ivf && ./configure && make -j2'
- name: netdata-installer on ${{ matrix.distro }}, disable cloud
run: |
docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
/bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud'
- name: netdata-installer on ${{ matrix.distro }}, require cloud
run: |
docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
/bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud'
- name: netdata-installer on ${{ matrix.distro }}, require cloud, require ACLK-NG
run: |
docker run --security-opt seccomp=unconfined -w /netdata -e NETDATA_CONFIGURE_OPTIONS='--with-aclk-ng' \
sha256:${{ steps.load.outputs.image }} /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud'
- name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
if: matrix.rmjsonc != ''
run: |
docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
/bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud'
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Build tests for ${{ matrix.distro }} failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
updater-check: # Test the generated dist archive using the updater code.
name: Test Generated Distfile and Updater Code
runs-on: ubuntu-latest
needs:
- build-dist
- matrix
- prepare-test-images
strategy:
fail-fast: false
max-parallel: 8
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
services:
apache: # This gets used to serve the dist tarball for the updater script.
image: httpd:2.4
ports:
- 8080:80
volumes:
- ${{ github.workspace }}:/usr/local/apache2/htdocs/
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch dist tarball artifacts
uses: actions/download-artifact@v2
with:
name: dist-tarball
path: dist-tarball
- name: Prepare artifact directory
run: |
mkdir -p artifacts || exit 1
echo "9999.0.0-0" > artifacts/latest-version.txt || exit 1
cp dist-tarball/* artifacts || exit 1
cd artifacts || exit 1
ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
sha256sum -b ./* > "sha256sums.txt" || exit 1
cat sha256sums.txt
- name: Fetch test environment
uses: actions/download-artifact@v2
with:
name: ${{ matrix.artifact_key }}-test-env
- name: Load test environment
id: load
run: |
docker load --input image.tar | tee image-info.txt
echo "::set-output name=image::$(cut -d ':' -f 3 image-info.txt)"
- name: Install netdata and run the updater on ${{ matrix.distro }}
run: |
docker run --security-opt seccomp=unconfined -e DO_NOT_TRACK=1 --network host -w /netdata sha256:${{ steps.load.outputs.image }} \
/netdata/.github/scripts/run-updater-check.sh
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Updater checks for ${{ matrix.distro }} failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
prepare-upload: # Consolidate the artifacts for uploading or releasing.
name: Prepare Artifacts
runs-on: ubuntu-latest
needs:
- build-dist
- build-static
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare Environment
run: mkdir -p artifacts
- name: Retrieve Dist Tarball
uses: actions/download-artifact@v2
with:
name: dist-tarball
path: dist-tarball
- name: Retrieve Static Build Artifacts
uses: actions/download-artifact@v2
with:
name: static-archive
path: static-archive
- name: Prepare Artifacts
working-directory: ./artifacts/
run: |
mv ../dist-tarball/* . || exit 1
mv ../static-archive/* . || exit 1
ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
cp ../packaging/version ./latest-version.txt || exit 1
sha256sum -b ./* > sha256sums.txt || exit 1
cat sha256sums.txt
- name: Store Artifacts
uses: actions/upload-artifact@v2
with:
name: final-artifacts
path: artifacts/*
retention-days: 30
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Failed to prepare release artifacts for upload."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
name: Test Consolidated Artifacts (Source)
runs-on: ubuntu-latest
needs:
- prepare-upload
services:
apache: # This gets used to serve the dist tarball for the updater script.
image: httpd:2.4
ports:
- 8080:80
volumes:
- ${{ github.workspace }}:/usr/local/apache2/htdocs/
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch artifacts
uses: actions/download-artifact@v2
with:
name: final-artifacts
path: artifacts
- name: Verify that artifacts work with installer
env:
NETDATA_TARBALL_BASEURL: http://localhost:8080/artifacts
run: packaging/installer/kickstart.sh --dont-start-it --disable-telemetry --dont-wait
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Artifact verification for source tarball failed.'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Artifact verification for source tarball failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
name: Test Consolidated Artifacts (Static)
runs-on: ubuntu-latest
needs:
- prepare-upload
services:
apache: # This gets used to serve the static archives.
image: httpd:2.4
ports:
- 8080:80
volumes:
- ${{ github.workspace }}:/usr/local/apache2/htdocs/
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch artifacts
uses: actions/download-artifact@v2
with:
name: final-artifacts
path: artifacts
- name: Verify that artifacts work with installer
env:
NETDATA_TARBALL_BASEURL: http://localhost:8080/artifacts
run: packaging/installer/kickstart-static64.sh --dont-start-it --disable-telemetry
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Artifact verification for static build failed.'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Artifact verification for static build failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
upload-nightly: # Upload the nightly build artifacts to GCS.
name: Upload Nightly Artifacts
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly'
needs:
- updater-check
- source-build
- artifact-verification-dist
- artifact-verification-static
steps:
- name: Retrieve Artifacts
uses: actions/download-artifact@v2
with:
name: final-artifacts
path: final-artifacts
- name: Setup Gcloud
uses: google-github-actions/setup-gcloud@v0.2.1
with:
project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
service_account_key: ${{ secrets.GCP_STORAGE_SERVICE_ACCOUNT_KEY }}
export_default_credentials: true
- name: Upload Artifacts
uses: google-github-actions/upload-cloud-storage@v0.4.0
with:
destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
gzip: false
path: ./final-artifacts
parent: false
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Failed to upload nightly release artifacts:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Failed to upload nightly release artifacts."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
upload-release: # Create the draft release and upload the build artifacts.
name: Create Release Draft
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
needs:
- updater-check
- source-build
- artifact-verification-dist
- artifact-verification-static
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve Artifacts
uses: actions/download-artifact@v2
with:
name: final-artifacts
path: final-artifacts
- name: Create Release
uses: ncipollo/release-action@v1
with:
allowUpdates: false
artifactErrorsFailBuild: true
artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run'
draft: true
tag: ${{ github.event.inputs.version }}
token: ${{ secrets.NETDATABOT_TOKEN }}
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Failed to draft release:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Failed to draft release."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name == 'workflow_dispatch'
}}

View File

@ -1,257 +0,0 @@
---
# Ci code for building release artifacts.
name: Release Build
on:
push: # Master branch checks only validate the build and generate artifacts for testing.
branches:
- master
pull_request: null # PR checks only validate the build and generate artifacts for testing.
workflow_dispatch:
inputs:
type:
description: Build Type
default: nightly
required: true
version:
description: Version Tag
default: nightly
required: true
concurrency:
group: release-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
build-dist: # Build the distribution tarball and store it as an artifact.
name: Build Distribution Tarball
runs-on: ubuntu-latest
outputs:
distfile: ${{ steps.build.outputs.distfile }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Mark Stable
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly'
run: |
sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' netdata-installer.sh
- name: Build
id: build
run: |
mkdir -p artifacts
./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all
autoreconf -ivf
./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--libexecdir=/usr/libexec \
--with-zlib \
--with-math \
--with-user=netdata
make dist
echo "::set-output name=distfile::$(find . -name 'netdata-*.tar.gz')"
cp netdata-*.tar.gz artifacts/
- name: Test
run: |
.github/scripts/run_install_with_dist_file.sh ${{ steps.build.outputs.distfile }}
- name: Store
uses: actions/upload-artifact@v2
with:
name: dist-tarball
path: artifacts/*.tar.gz
retention-days: 30
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Distribution tarball build failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Distribution tarball build failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
build-static: # Build the static binary archives, and store them as artifacts.
name: Build Static
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- 'x86_64'
- 'armv7l'
- 'aarch64'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Mark Stable
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly'
run: |
sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' netdata-installer.sh packaging/makeself/install-or-update.sh
- name: Build
run: .github/scripts/build-static.sh ${{ matrix.arch }}
- name: Store
uses: actions/upload-artifact@v2
with:
name: static-archive
path: artifacts/*.gz.run
retention-days: 30
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Static build for ${{ matrix.arch }} failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Static build for ${{ matrix.arch }} failed."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
prepare-upload: # Consolidate the artifacts for uploading or releasing.
name: Prepare Artifacts
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs:
- build-dist
- build-static
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare Environment
run: mkdir -p artifacts
- name: Retrieve Dist Tarball
uses: actions/download-artifact@v2
with:
name: dist-tarball
path: dist-tarball
- name: Retrieve Static Build Artifacts
uses: actions/download-artifact@v2
with:
name: static-archive
path: static-archive
- name: Prepare Artifacts
working-directory: ./artifacts/
run: |
mv ../dist-tarball/* .
mv ../static-archive/* .
ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz
cp ../packaging/version ./latest-version.txt
sha256sum -b ./* > sha256sums.txt
- name: Store Artifacts
uses: actions/upload-artifact@v2
with:
name: final-artifacts
path: artifacts/*
retention-days: 30
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Failed to prepare release artifacts for upload."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
upload-nightly: # Upload the nightly build artifacts to GCS.
name: Upload Nightly Artifacts
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly'
needs:
- prepare-upload
steps:
- name: Retrieve Artifacts
uses: actions/download-artifact@v2
with:
name: final-artifacts
path: final-artifacts
- name: Setup Gcloud
uses: google-github-actions/setup-gcloud@v0.2.1
with:
project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
service_account_key: ${{ secrets.GCP_STORAGE_SERVICE_ACCOUNT_KEY }}
export_default_credentials: true
- name: Upload Artifacts
uses: google-github-actions/upload-cloud-storage@v0.4.0
with:
destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
gzip: false
path: ./final-artifacts
parent: false
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Failed to upload nightly release artifacts:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Failed to upload nightly release artifacts."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name != 'pull_request'
}}
upload-release: # Create the draft release and upload the build artifacts.
name: Create Release Draft
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
needs:
- prepare-upload
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve Artifacts
uses: actions/download-artifact@v2
with:
name: final-artifacts
path: final-artifacts
- name: Create Release
uses: ncipollo/release-action@v1
with:
allowUpdates: false
artifactErrorsFailBuild: true
artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run'
draft: true
tag: ${{ github.event.inputs.version }}
token: ${{ secrets.NETDATABOT_TOKEN }}
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_FOOTER: ''
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Failed to draft release:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: "Failed to draft release."
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& startsWith(github.ref, 'refs/heads/master')
&& github.event_name == 'workflow_dispatch'
}}

View File

@ -1,95 +0,0 @@
---
name: Updater
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
DO_NOT_TRACK: 1
concurrency:
group: updater-${{ github.ref }}
cancel-in-progress: true
jobs:
source-build:
name: Install, Build & Update
strategy:
fail-fast: false
max-parallel: 8
matrix:
distro:
- 'alpine:3.14'
- 'alpine:3.13'
- 'alpine:3.12'
- 'archlinux:latest'
- 'centos:7'
- 'centos:8'
- 'debian:9'
- 'debian:10'
- 'debian:bullseye' # 11
- 'fedora:33'
- 'fedora:34'
- 'fedora:35'
- 'ubuntu:18.04'
- 'ubuntu:20.04'
- 'ubuntu:21.04'
- 'ubuntu:21.10'
include:
- distro: 'alpine:3.14'
pre: 'apk add -U bash'
- distro: 'alpine:3.13'
pre: 'apk add -U bash'
- distro: 'alpine:3.12'
pre: 'apk add -U bash'
- distro: 'debian:9'
pre: 'apt-get update'
- distro: 'debian:10'
pre: 'apt-get update'
- distro: 'debian:bullseye' # 11
pre: 'apt-get update'
- distro: 'ubuntu:18.04'
pre: 'apt-get update'
- distro: 'ubuntu:20.04'
pre: 'apt-get update'
- distro: 'ubuntu:21.04'
pre: 'apt-get update'
- distro: 'ubuntu:21.10'
pre: 'rm -f /etc/apt/apt.conf.d/docker* && apt-get update'
runs-on: ubuntu-latest
steps:
- name: Git clone repository
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install required packages & build tarball
run: |
./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all
.github/scripts/build-dist.sh
- name: Run a dockerised web server to serve files used by the custom update script
run: |
docker run -dit --name my-apache-app -p 8080:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
- name: Replace URLs in updater script to point at the local web server
run: |
ORIG_TARBALL="export NETDATA_TARBALL_URL=.*"
ORIG_CHECKSUM="export NETDATA_TARBALL_CHECKSUM_URL=.*"
CURRENT_VERSION="current_version=.*"
NEW_TARBALL="export NETDATA_TARBALL_URL=http://localhost:8080/artifacts/netdata-latest.tar.gz"
NEW_CHECKSUM="export NETDATA_TARBALL_CHECKSUM_URL=http://localhost:8080/artifacts/sha256sums.txt"
sed -i "s|${ORIG_TARBALL}|${NEW_TARBALL}|g" packaging/installer/netdata-updater.sh
sed -i "s|${ORIG_CHECKSUM}|${NEW_CHECKSUM}|g" packaging/installer/netdata-updater.sh
sed -i "s|"current_version=.*"|"current_version=1"|g" packaging/installer/netdata-updater.sh
- name: Install netdata and run the updater on ${{ matrix.distro }}
env:
PRE: ${{ matrix.pre }}
run: |
echo $PRE > ./prep-cmd.sh
docker build . -f .github/dockerfiles/Dockerfile.build_test -t test --build-arg BASE=${{ matrix.distro }}
docker run --security-opt seccomp=unconfined -e DO_NOT_TRACK=1 --network host -w /netdata test \
/bin/sh -c '/netdata/packaging/installer/kickstart.sh --dont-wait \
&& /netdata/packaging/installer/netdata-updater.sh --not-running-from-cron --no-updater-self-update \
&& bash /netdata/.github/scripts/check-updater.sh'

View File

@ -7,7 +7,7 @@ type="${3}"
resp="$(curl -X POST \
-H 'Accept: application/vnd.github.v3+json' \
-H "Authorization: Bearer ${token}" \
"https://api.github.com/repos/netdata/netdata/actions/workflows/release-build.yml/dispatches" \
"https://api.github.com/repos/netdata/netdata/actions/workflows/build.yml/dispatches" \
-d "{\"ref\": \"master\", \"inputs\": {\"version\": \"${version}\", \"type\": \"${type}\"}}")"
if [ -z "${resp}" ]; then