summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/tests.yml86
-rw-r--r--.travis.yml11
-rwxr-xr-x.travis/run-unit-tests.sh85
-rwxr-xr-xtests/run-unit-tests.sh39
4 files changed, 125 insertions, 96 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000000..f41a621c30
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,86 @@
+---
+# Runs Tests on Pushes to `master` and Pull Requests
+name: Tests
+on:
+ push:
+ branches:
+ - master
+ paths:
+ - '**.c'
+ - '**.h'
+ pull_request:
+ paths:
+ - '**.c'
+ - '**.h'
+jobs:
+ unit-tests-legacy:
+ name: Unit Tests (legacy)
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Prepare environment
+ run: |
+ ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all
+ sudo apt-get install -y libjson-c-dev libipmimonitoring-dev libcups2-dev libsnappy-dev \
+ libprotobuf-dev libprotoc-dev libssl-dev protobuf-compiler \
+ libnetfilter-acct-dev
+ - name: Run ./tests/run-unit-tests.sh
+ env:
+ CFLAGS: "-O1 -DNETDATA_INTERNAL_CHECKS=1 -DNETDATA_VERIFY_LOCKS=1"
+ run: |
+ ./tests/run-unit-tests.sh
+
+ unit-tests-cmocka:
+ name: Unit Tests (cmocka)
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Prepare environment
+ run: |
+ ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all
+ sudo apt-get install -y libjson-c-dev libipmimonitoring-dev libcups2-dev libsnappy-dev \
+ libprotobuf-dev libprotoc-dev libssl-dev protobuf-compiler \
+ libnetfilter-acct-dev libmongoc-dev libcmocka-dev
+ - name: Configure
+ run: |
+ autoreconf -ivf
+ ./configure
+ # XXX: Work-around for bug with libbson-1.0 in Ubuntu 18.04
+ # See: https://bugs.launchpad.net/ubuntu/+source/libmongoc/+bug/1790771
+ # https://jira.mongodb.org/browse/CDRIVER-2818
+ - name: Fix libbson
+ run: |
+ pushd /usr/lib || exit 1
+ sudo ln -s /usr/include .
+ popd || exit 1
+ - name: Build
+ run: |
+ mkdir build-tmp
+ cd build-tmp
+ cmake \
+ -D UNIT_TESTING=1 \
+ -D BUILD_TESTING=1 \
+ -D CMAKE_BUILD_TYPE="Debug" \
+ -D BSON_LIBRARY=/usr/lib/x86_64-linux-gnu/libbson-1.0.so \
+ -D MONGOC_LIBRARY=/usr/lib/x86_64-linux-gnu/libmongoc-1.0.so \
+ ..
+ make
+ - name: Run ctest
+ run: |
+ cd build-tmp
+ ctest
+ - name: Prepare Artifacts
+ if: always()
+ run: |
+ mkdir logs
+ pushd build-tmp || exit 1
+ find . -type f -name '*.log' -exec cp {} ../logs/ \;
+ popd || exit 1
+ - name: Upload Artifacts
+ uses: actions/upload-artifact@v1
+ if: always()
+ with:
+ name: logs
+ path: logs
diff --git a/.travis.yml b/.travis.yml
index 8d590eb0af..eda5361352 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,7 +47,6 @@ notifications:
stages:
# Mandatory runs, we always want these executed
- name: Build process
- - name: Artifacts validation
# Nightly operations
- name: Nightly operations
@@ -107,16 +106,6 @@ jobs:
env: DEVEL="true"
after_failure: post_message "TRAVIS_MESSAGE" "Docker build process failed"
- - stage: Artifacts validation
- name: Unit Testing
- script:
- - .travis/run-unit-tests.sh
- env: CFLAGS='-O1 -DNETDATA_INTERNAL_CHECKS=1 -DNETDATA_VERIFY_LOCKS=1'
- # We need a full deep clone for the checks done by the unit testing script to work.
- git:
- depth: false
- after_failure: post_message "TRAVIS_MESSAGE" "Unit testing failed"
-
- name: Build/Install for ubuntu 18.04 (not containerized)
script: fakeroot ./netdata-installer.sh --dont-wait --dont-start-it --install $HOME
after_failure: post_message "TRAVIS_MESSAGE" "Build/Install failed on ubuntu 18.04"
diff --git a/.travis/run-unit-tests.sh b/.travis/run-unit-tests.sh
deleted file mode 100755
index f69150cfc7..0000000000
--- a/.travis/run-unit-tests.sh
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env bash
-#
-# Unit-testing script
-#
-# This script does the following:
-# 1. Check whether any files were modified that would necessitate unit testing (using the `TRAVIS_COMMIT_RANGE` environment variable).
-# 2. If there are no changed files that require unit testing, exit successfully.
-# 3. Otherwise, run all the unit tests.
-#
-# We do things this way because our unit testing takes a rather long
-# time (average 18-19 minutes as of the original creation of this script),
-# so skipping it when we don't actually need it can significantly speed
-# up the CI process.
-#
-# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
-#
-# Author: Austin S. Hemmelgarn <austin@netdata.cloud>
-#
-# shellcheck disable=SC2230
-
-install_netdata() {
- echo "Installing Netdata"
- fakeroot ./netdata-installer.sh --install $HOME --dont-wait --dont-start-it --enable-plugin-nfacct --enable-plugin-freeipmi --disable-lto
-}
-
-c_unit_tests() {
- echo "Running C code unit tests"
- $HOME/netdata/usr/sbin/netdata -W unittest
-}
-
-run_c_unit_tests=
-
-if [ -z ${TRAVIS_COMMIT_RANGE} ] ; then
- # Travis gave us no commit range, so just run all the unit tests.
- # Per the docs, this is the case when a new branch is pushed for the first time.
- echo "No commit range supplied, assuming the worst case and running all unit tests."
- run_c_unit_tests=1
-else
- changed_paths=
-
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ] ; then
- # This is not a PR build.
- COMMIT1="$(echo ${TRAVIS_COMMIT_RANGE} | cut -f 1 -d '.')"
- COMMIT2="$(echo ${TRAVIS_COMMIT_RANGE} | cut -f 4 -d '.')"
-
- if [ "$(git cat-file -t ${COMMIT1} 2>/dev/null)" = commit -a "$(git cat-file -t ${COMMIT2} 2>/dev/null)" = commit ] ; then
- # Examine the exact set of commits passed by Travis.
- echo "Checking commits:"
- git log --format=oneline --abbrev-commit ${COMMIT1}..${COMMIT2}
- changed_paths="$(git diff --name-only ${COMMIT1}..${COMMIT2} --)"
- else
- # We couldn't find at least one of the changesets, so this build
- # was probably triggered by a history rewrite. Since we can't
- # figure out what chnaged, we need to just run all the tests anyway.
- echo "Cannot determine which commits we are testing, running all unit tests."
- run_c_unit_tests=1
- fi
- else
- # This is a PR build, look at all commits from the target branch
- # to HEAD.
- echo "Checking commits:"
- git log --format=oneline --abbrev-commit ${TRAVIS_BRANCH}..HEAD
- changed_paths="$(git diff --name-only ${TRAVIS_BRANCH}..HEAD --)"
- fi
-
- if [ -n "${changed_paths}" ] ; then
- # Check for changes that would require the C code to be re-tested
- if (echo ${changed_paths} | grep -qE "daemon/unit_test|database") ; then
- echo "Commits appear to change C code with unit tests, queueing C unit tests."
- run_c_unit_tests=1
- fi
- fi
-fi
-
-if [ -z ${run_c_unit_tests} ] ; then
- # No tests to run, log this and exit with success
- echo "Commit range ${TRAVIS_COMMIT_RANGE} appears to make no changes that require unit tests, skipping unit testing."
- exit 0
-else
- install_netdata || exit 1
-
- if [ -n ${run_c_unit_tests} ] ; then
- c_unit_tests || exit 1
- fi
-fi
diff --git a/tests/run-unit-tests.sh b/tests/run-unit-tests.sh
new file mode 100755
index 0000000000..70d618ad7e
--- /dev/null
+++ b/tests/run-unit-tests.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+#
+# Unit-testing script
+#
+# This script does the following:
+# 1. Check whether any files were modified that would necessitate unit testing (using the `TRAVIS_COMMIT_RANGE` environment variable).
+# 2. If there are no changed files that require unit testing, exit successfully.
+# 3. Otherwise, run all the unit tests.
+#
+# We do things this way because our unit testing takes a rather long
+# time (average 18-19 minutes as of the original creation of this script),
+# so skipping it when we don't actually need it can significantly speed
+# up the CI process.
+#
+# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Author: Austin S. Hemmelgarn <austin@netdata.cloud>
+#
+# shellcheck disable=SC2230
+
+install_netdata() {
+ echo "Installing Netdata"
+ fakeroot ./netdata-installer.sh \
+ --install "$HOME" \
+ --dont-wait \
+ --dont-start-it \
+ --enable-plugin-nfacct \
+ --enable-plugin-freeipmi \
+ --disable-lto
+}
+
+c_unit_tests() {
+ echo "Running C code unit tests"
+ "$HOME"/netdata/usr/sbin/netdata -W unittest
+}
+
+install_netdata || exit 1
+
+c_unit_tests || exit 1