diff options
Diffstat (limited to '.travis')
-rw-r--r-- | .travis/README.md | 170 | ||||
-rwxr-xr-x | .travis/create_artifacts.sh | 13 | ||||
-rwxr-xr-x | .travis/draft_release.sh | 69 | ||||
-rwxr-xr-x | .travis/generate_changelog_and_tag_release.sh | 69 | ||||
-rwxr-xr-x | .travis/generate_changelog_for_nightlies.sh (renamed from .travis/generate_changelog.sh) | 7 | ||||
-rwxr-xr-x | .travis/generate_changelog_for_release.sh | 7 | ||||
-rwxr-xr-x | .travis/nightlies.sh | 24 | ||||
-rwxr-xr-x | .travis/releaser.sh | 96 | ||||
-rwxr-xr-x | .travis/run_install_with_dist_file.sh | 48 | ||||
-rwxr-xr-x | .travis/tagger.sh | 42 |
10 files changed, 338 insertions, 207 deletions
diff --git a/.travis/README.md b/.travis/README.md index d67df293d..5f3d65105 100644 --- a/.travis/README.md +++ b/.travis/README.md @@ -4,88 +4,94 @@ - GITHUB_TOKEN - GitHub token with push access to repository - DOCKER_USERNAME - Username (netdatabot) with write access to docker hub repository -- DOCKER_PASSWORD - Password to docker hub +- DOCKER_PASS - Password to docker hub - encrypted_8daf19481253_key - key needed by openssl to decrypt GCS credentials file - encrypted_8daf19481253_iv - IV needed by openssl to decrypt GCS credentials file - COVERITY_SCAN_TOKEN - Token to allow coverity test analysis uploads - -## Stages - -### Test - -Unit tests and coverage tests are executed here. Stage consists of 2 parallel jobs: - - C tests - executed every time - - dashboard.js - test if source files create the same file as it is in current repo - - coverity test - executed only when pipeline was triggered from cron - -### Build - -Stage is executed every time and consists of 5 parallel jobs which execute containerized and non-containerized -installations of netdata. Jobs are run on following operating systems: - - OSX - - ubuntu 14.04 - - ubuntu 16.04 (containerized) - - CentOS 6 (containerized) - - CentOS 7 (containerized) - - alpine (containerized) - -Images for system containers are stored on dockerhub and are created from Dockerfiles located in -[netdata/helper-images](https://github.com/netdata/helper-images) repository. - -### Packaging - -This stage is executed only on "master" brach and allows us to create a new tag just looking at git commit message. -It executes one script called `releaser.sh` which is responsible for creating a release on GitHub by using -[hub](https://github.com/github/hub). This script is also executing other scripts which can also be used in other -CI jobs: - - `.travis/tagger.sh` - - `.travis/generate_changelog.sh` - - `packaging/docker/build.sh` - - `.travis/create_artifacts.sh` - -Alternatively new release can be also created by pushing new tag to master branch. -Additionally this step is also executing `.travis/labeler.sh` which is a temporary workaround to automatically label -issues and PR. This script should be replaced with GitHub Actions when they are available to public. - -##### tagger.sh - -Script responsible to find out what will be the next tag based on a keyword in last commit message. Keywords are: - - `[netdata patch release]` to bump patch number - - `[netdata minor release]` to bump minor number - - `[netdata major release]` to bump major number - - `[netdata release candidate]` to create a new release candidate (appends or modifies suffix `-rcX` of previous tag) -All keywords MUST be surrounded with square brackets. -Tag is then stored in `GIT_TAG` variable. - -##### generate_changelog.sh - -Automatic changelog generator which updates our CHANGELOG.md file based on GitHub features (mostly labels and pull -requests). Internally it uses -[github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator) and more -information can be found on that project site. - -##### build.sh and create_artifacts.sh - -Scripts used to build new container images and provide release artifacts (tar.gz and makeself archives) - -### Nightlies - -##### Tarball and self-extractor build AND Nightly docker images - -As names might suggest those two jobs are responsible for nightly netdata package creation and are run every day (in -cron). Combined they produce: - - docker images - - tar.gz archive (soon to be removed) - - self-extracting package - -This is achieved by running 2 scripts described earlier: - - `create_artifacts.sh` - - `build.sh` - -Artifacts are pushed to GCS and container images are stored in docker hub. - -##### Changelog generation - -This job is responsible for regenerating changelog every day by executing `generate_changelog.sh` script. This is done -only once a day due to github rate limiter. - +- SLACK_USERNAME - This is required for the slack notifications triggered by travis pipeline +- SLACK_CHANNEL - This is the channel that Travis will be posting messages +- SLACK_NOTIFY_WEBHOOK_URL - This is the incoming URL webhook as provided by slack integration. Visit Apps integration in slack to generate the required hook +- SLACK_BOT_NAME - This is the name your bot will appear with on slack + +## CI workflow details +Our CI pipeline is designed to help us identify and mitigate risks at all stages of implementation. +To accommodate this need, we used [Travis CI](http://www.travis-ci.com) as our CI/CD tool. +Our main areas of concern are: +1) Only push code that is working. That means fail fast so that we can improve before we reach the public + +2) Reduce the time to market to minimum, by streamlining the release process. + That means a lot of testing, a lot of consistency checks, a lot of validations + +3) Generated artifacts consistency. We should not allow broken software to reach the public. + When this happens, it's embarassing and we struggle to eliminate it. + +4) We are an innovative company, so we love to automate :) + + +Having said that, here's a brief introduction to Netdata's improved CI/CD pipeline with Travis. +Our CI/CD lifecycle contains three different execution entry points: +1) A user opens a pull request to netdata/master: Travis will run a pipeline on the branch under that PR +2) A merge or commit happens on netdata/master. This will trigger travis to run, but we have two distinct cases in this scenario: + a) A user merges a pull request to netdata/master: Travis will run on master, after the merge. + b) A user runs a commit/merge with a special keyword (mentioned later). + This triggers a release for either minor, major or release candidate versions, depending the keyword +3) A scheduled job runs on master once per day: Travis will run on master at the scheduled interval + +To accommodate all three entry points our CI/CD workflow has a set of steps that run on all three entry points. +Once all these steps are successfull, then our pipeline executes another subset of steps for entry points 2 and 3. +In travis terms the "steps" are "Stages" and within each stage we execute a set of activities called "jobs" in travis. + +### Always run: Stages that running on all three execution entry points + +## Code quality, linting, syntax, code style +At this early stage we iterate through a set of basic quality control checks: +- Shell checking: Run linters for our various BASH scripts +- Checksum validators: Run validators to ensure our installers and documentation are in sync +- Dashboard validator: We provide a pre-generated dashboard.js script file that we need to make sure its up to date. We validate that. + +## Build process +At this stage, basically, we build :-) +We do a baseline check of our build artifacts to guarantee they are not broken +Briefly our activities include: +- Verify docker builds successfully +- Run the standard netdata installer, to make sure we build & run properly +- Do the same through 'make dist', as this is our stable channel for our kickstart files + +## Artifacts validation +At this point we know our software is building, we need to go through the a set of checks, to guarantee +that our product meets certain epxectations. At the current stage, we are focusing on basic capabilities +like installing in different distributions, running the full lifecycle of install-run-update-install and so on. +We are still working on enriching this with more and more use cases, to get us closer to achieving full stability of our software. +Briefly we currently evaluate the following activities: +- Basic software unit testing +- Non containerized build and install on ubuntu 14.04 +- Non containerized build and install on ubuntu 18.04 +- Running the full netdata lifecycle (install, update, uninstall) on ubuntu 18.04 +- Build and install on CentOS 6 +- Build and install on CentOS 7 +(More to come) + +### Nightly operations: Stages that run daily under cronjob +The nightly stages are related to the daily nightly activities, that produce our daily latest releases. +We also maintain a couple of cronjobs that run during the night to provide us with deeper insights, +like for example coverity scanning or extended kickstart checksum checks + +## Nightly operations +At this stage we run scheduled jobs and execute the nightly changelog generator, coverity scans, +labeler for our issues and extended kickstart files checksum validations. + +## Nightly release +During this stage we are building and publishing latest docker images, prepare the nightly artifacts +and deploy them (the artifacts) to our google cloud service provider. + + +### Publishing +Publishing is responsible for executing the major/minor/patch releases and is separated +in two stages: packaging preparation process and publishing. + +## Packaging for release +During packaging we are preparing the release changelog information and run the labeler. + +## Publish for release +The publishing stage is the most complex part in publishing. This is the stage were we generate and publish docker images, +prepare the release artifacts and get ready with the release draft. diff --git a/.travis/create_artifacts.sh b/.travis/create_artifacts.sh index 18c85287c..2c142e8d0 100755 --- a/.travis/create_artifacts.sh +++ b/.travis/create_artifacts.sh @@ -8,6 +8,19 @@ if [ ! -f .gitignore ]; then exit 1 fi +if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then + echo "Beta mode on ${TRAVIS_REPO_SLUG}, not running anything here" + exit 0 +fi; + +echo "--- Initialize git configuration ---" +export GIT_MAIL="bot@netdata.cloud" +export GIT_USER="netdatabot" +git config user.email "${GIT_MAIL}" +git config user.name "${GIT_USER}" +git checkout master +git pull + # Everything from this directory will be uploaded to GCS mkdir -p artifacts BASENAME="netdata-$(git describe)" diff --git a/.travis/draft_release.sh b/.travis/draft_release.sh new file mode 100755 index 000000000..bfdfdfb0c --- /dev/null +++ b/.travis/draft_release.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# +# Draft release generator. +# This utility is responsible for submitting a draft release to github repo +# It is agnostic of other processes, when executed it will draft a release, +# based on the most recent reachable tag. +# +# Requirements: +# - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo +# - artifacts directory in place +# - The directory is created by create_artifacts.sh mechanism +# - The artifacts need to be created with the same tag, obviously +# +# Copyright: SPDX-License-Identifier: GPL-3.0-or-later +# +# Author: Pavlos Emm. Katsoulakis <paul@netdata.cloud> + +set -e + +if [ ! -f .gitignore ]; then + echo "Run as ./travis/$(basename "$0") from top level directory of git repository" + exit 1 +fi + +echo "--- Initialize git configuration ---" +export GIT_MAIL="bot@netdata.cloud" +export GIT_USER="netdatabot" +git config user.email "${GIT_MAIL}" +git config user.name "${GIT_USER}" +git checkout master +git pull + + +if [[ $(git describe) =~ -rc* ]]; then + echo "This is a release candidate tag, we do not generate a release draft" + exit 0 +fi + +# Load the tag, if any +GIT_TAG=$(git describe) + +if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then + echo "Beta mode on ${TRAVIS_REPO_SLUG}, i was about to run for release (${GIT_TAG}), but i am emulating, so bye" + exit 0 +fi; + +echo "---- CREATING RELEASE DRAFT WITH ASSETS -----" +# Download hub +HUB_VERSION=${HUB_VERSION:-"2.5.1"} +wget "https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-linux-amd64-${HUB_VERSION}.tgz" -O "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz" +tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz" +export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin" + +# Create a release draft +if [ -z ${GIT_TAG+x} ]; then + echo "Variable GIT_TAG is not set. Something went terribly wrong! Exiting." + exit 1 +fi +if [ "${GIT_TAG}" != "$(git tag --points-at)" ]; then + echo "ERROR! Current commit is not tagged. Stopping release creation." + exit 1 +fi +until hub release create --draft \ + -a "artifacts/netdata-${GIT_TAG}.tar.gz" \ + -a "artifacts/netdata-${GIT_TAG}.gz.run" \ + -a "artifacts/sha256sums.txt" \ + -m "${GIT_TAG}" "${GIT_TAG}"; do + sleep 5 +done diff --git a/.travis/generate_changelog_and_tag_release.sh b/.travis/generate_changelog_and_tag_release.sh new file mode 100755 index 000000000..0f3d1bb5d --- /dev/null +++ b/.travis/generate_changelog_and_tag_release.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# +# Script to automatically do a couple of things: +# - generate a new tag according to semver (https://semver.org/) +# - generate CHANGELOG.md by using https://github.com/skywinder/github-changelog-generator +# +# Tags are generated by searching for a keyword in last commit message. Keywords are: +# - [patch] or [fix] to bump patch number +# - [minor], [feature] or [feat] to bump minor number +# - [major] or [breaking change] to bump major number +# All keywords MUST be surrounded with square braces. +# +# Script uses git mechanisms for locking, so it can be used in parallel builds +# +# Requirements: +# - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo +# - docker +# +# This is a modified version of: +# https://github.com/paulfantom/travis-helper/blob/master/releasing/releaser.sh +# +# Copyright: SPDX-License-Identifier: GPL-3.0-or-later +# +# Author: Pavlos Emm. Katsoulakis <paul@netdata.cloud> +# Author: Pawel Krupa (@paulfantom) +set -e + +if [ ! -f .gitignore ]; then + echo "Run as ./travis/$(basename "$0") from top level directory of git repository" + exit 1 +fi + +echo "--- Executing Tagging facility to determine TAG ---" +source .travis/tagger.sh + +echo "--- Changelog generator and tagger script starting ---" +# If tagger script hasn't produced a TAG, there is nothing to do so bail out happy +if [ -z "${GIT_TAG}" ]; then + echo "GIT_TAG is empty, nothing to do for now (Value: $GIT_TAG)" + exit 0 +fi + +if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then + echo "Beta mode on ${TRAVIS_REPO_SLUG}, nothing to do on the changelog generator and tagging script for (${GIT_TAG}), bye" + exit 0 +fi + +echo "--- Initialize git configuration ---" +export GIT_MAIL="bot@netdata.cloud" +export GIT_USER="netdatabot" +git config user.email "${GIT_MAIL}" +git config user.name "${GIT_USER}" +git checkout master +git pull + +echo "---- UPDATE VERSION FILE ----" +echo "$GIT_TAG" >packaging/version +git add packaging/version + +echo "---- GENERATE CHANGELOG -----" +./.travis/generate_changelog_for_release.sh +git add CHANGELOG.md + +echo "---- COMMIT AND PUSH CHANGES ----" +git commit -m "[ci skip] release $GIT_TAG" +git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER" +git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')" +git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')" --tags +# After those operations output of command `git describe` should be identical with a value of GIT_TAG diff --git a/.travis/generate_changelog.sh b/.travis/generate_changelog_for_nightlies.sh index e48b42a66..763acc16b 100755 --- a/.travis/generate_changelog.sh +++ b/.travis/generate_changelog_for_nightlies.sh @@ -31,8 +31,13 @@ if [ -z ${GIT_TAG+x} ]; then else OPTS="--future-release ${GIT_TAG}" fi - echo "We got $COMMITS_SINCE_RELEASE changes since $LAST_TAG, re-generating changelog" + +if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then + echo "Beta mode on ${TRAVIS_REPO_SLUG}, nothing else to do here" + exit 0 +fi + git config user.email "${GIT_MAIL}" git config user.name "${GIT_USER}" git checkout master diff --git a/.travis/generate_changelog_for_release.sh b/.travis/generate_changelog_for_release.sh index 4ae69f1c7..de5d3e702 100755 --- a/.travis/generate_changelog_for_release.sh +++ b/.travis/generate_changelog_for_release.sh @@ -11,13 +11,17 @@ ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}') PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}') GIT_MAIL=${GIT_MAIL:-"bot@netdata.cloud"} GIT_USER=${GIT_USER:-"netdatabot"} - if [ -z ${GIT_TAG+x} ]; then OPTS="" else OPTS="--future-release ${GIT_TAG}" fi +if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then + echo "Beta mode on ${TRAVIS_REPO_SLUG}, nothing else to do" + exit 0 +fi + echo "--- Creating changelog ---" git checkout master git pull @@ -30,4 +34,3 @@ docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest --unreleased-label "**Next release**" \ --exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \ --no-compare-link ${OPTS} - diff --git a/.travis/nightlies.sh b/.travis/nightlies.sh index 0d9fe036a..188b37da0 100755 --- a/.travis/nightlies.sh +++ b/.travis/nightlies.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# This is the nightlies orchastration script -# It runs the following activities in order: -# 1) Generate changelog -# 2) Build docker images -# 3) Publish docker images -# 4) Generate the rest of the artifacts (Source code .tar.gz file and makeself binary generation) +# This is the nightly changelog generation script +# It is responsible for two major activities: +# 1) Update packaging/version with the current nightly version +# 2) Generate the changelog for the mentioned version # # Copyright: SPDX-License-Identifier: GPL-3.0-or-later # @@ -34,14 +32,12 @@ if [ "${COMMITS_SINCE_RELEASE}" == "${PREVIOUS_NIGHTLY_COUNT}" ]; then exit 0 fi -echo "--- Running Changelog generation ---" -.travis/generate_changelog.sh "${LAST_TAG}" "${COMMITS_SINCE_RELEASE}" || echo "Changelog generation has failed, this is a soft error, process continues" - -echo "--- Build && publish docker images ---" -# Do not fail artifacts creation if docker fails. We will be restructuring this on a follow up PR -packaging/docker/build.sh && packaging/docker/publish.sh || echo "Failed to build and publish docker images" +if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then + echo "Beta mode -- nothing to do for ${TRAVIS_REPO_SLUG} on the nightlies script, bye" + exit 0 +fi -echo "--- Build artifacts ---" -.travis/create_artifacts.sh +echo "--- Running Changelog generation ---" +.travis/generate_changelog_for_nightlies.sh "${LAST_TAG}" "${COMMITS_SINCE_RELEASE}" || echo "Changelog generation has failed, this is a soft error, process continues" exit "${FAIL}" diff --git a/.travis/releaser.sh b/.travis/releaser.sh deleted file mode 100755 index c82687dfb..000000000 --- a/.travis/releaser.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: MIT -# Copyright (C) 2018 Pawel Krupa (@paulfantom) - All Rights Reserved -# Permission to copy and modify is granted under the MIT license -# -# Original script is available at https://github.com/paulfantom/travis-helper/blob/master/releasing/releaser.sh -# -# Script to automatically do a couple of things: -# - generate a new tag according to semver (https://semver.org/) -# - generate CHANGELOG.md by using https://github.com/skywinder/github-changelog-generator -# - create draft of GitHub releases by using https://github.com/github/hub -# -# Tags are generated by searching for a keyword in last commit message. Keywords are: -# - [patch] or [fix] to bump patch number -# - [minor], [feature] or [feat] to bump minor number -# - [major] or [breaking change] to bump major number -# All keywords MUST be surrounded with square braces. -# -# Script uses git mechanisms for locking, so it can be used in parallel builds -# -# Requirements: -# - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo -# - docker - -set -e - -if [ ! -f .gitignore ]; then - echo "Run as ./travis/$(basename "$0") from top level directory of git repository" - exit 1 -fi - -export GIT_MAIL="bot@netdata.cloud" -export GIT_USER="netdatabot" -echo "--- Initialize git configuration ---" -git config user.email "${GIT_MAIL}" -git config user.name "${GIT_USER}" -git checkout master -git pull - -echo "---- FIGURING OUT TAGS ----" -# tagger.sh is sourced since we need environment variables it sets -#shellcheck source=/dev/null -source .travis/tagger.sh || exit 0 -# variable GIT_TAG is produced by tagger.sh script - -echo "---- UPDATE VERSION FILE ----" -echo "$GIT_TAG" >packaging/version -git add packaging/version - -echo "---- GENERATE CHANGELOG -----" -./.travis/generate_changelog_for_release.sh -git add CHANGELOG.md - -echo "---- COMMIT AND PUSH CHANGES ----" -git commit -m "[ci skip] release $GIT_TAG" -git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER" -git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')" -git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')" --tags -# After those operations output of command `git describe` should be identical with a value of GIT_TAG - -if [[ $(git describe) =~ -rc* ]]; then - echo "This is a release candidate tag, exiting without artifact building" - exit 0 -fi - -echo "---- CREATING TAGGED DOCKER CONTAINERS ----" -./packaging/docker/build.sh -./packaging/docker/publish.sh - -echo "---- CREATING RELEASE ARTIFACTS -----" -# Artifacts are stored in `artifacts/` directory -./.travis/create_artifacts.sh - -echo "---- CREATING RELEASE DRAFT WITH ASSETS -----" -# Download hub -HUB_VERSION=${HUB_VERSION:-"2.5.1"} -wget "https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-linux-amd64-${HUB_VERSION}.tgz" -O "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz" -tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz" -export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin" - -# Create a release draft -if [ -z ${GIT_TAG+x} ]; then - echo "Variable GIT_TAG is not set. Something went terribly wrong! Exiting." - exit 1 -fi -if [ "${GIT_TAG}" != "$(git tag --points-at)" ]; then - echo "ERROR! Current commit is not tagged. Stopping release creation." - exit 1 -fi -until hub release create --draft \ - -a "artifacts/netdata-${GIT_TAG}.tar.gz" \ - -a "artifacts/netdata-${GIT_TAG}.gz.run" \ - -a "artifacts/sha256sums.txt" \ - -m "${GIT_TAG}" "${GIT_TAG}"; do - sleep 5 -done diff --git a/.travis/run_install_with_dist_file.sh b/.travis/run_install_with_dist_file.sh new file mode 100755 index 000000000..ccad627cc --- /dev/null +++ b/.travis/run_install_with_dist_file.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# +# This script is evaluating netdata installation with the source from make dist +# +# Copyright: SPDX-License-Identifier: GPL-3.0-or-later +# +# Author : Pavlos Emm. Katsoulakis <paul@netdata.cloud) +# +set -e + +# If we are not in netdata git repo, at the top level directory, fail +TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)") +CWD=$(git rev-parse --show-cdup || echo "") +if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then + echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository" + echo "Changelog generation process aborted" + exit 1 +fi + +echo "Initiating dist archive contents validation" +DIST_FILE_FROM_GIT="netdata-$(git describe).tar.gz" +DIST_FILE_FROM_FILE="netdata-$(tr -d '\n' < packaging/version).tar.bgz" +if [ -f ${DIST_FILE_FROM_GIT} ]; then + DIST_FILE="${DIST_FILE_FROM_GIT}" +elif [ -f ${DIST_FILE_FROM_FILE} ]; then + DIST_FILE="${DIST_FILE_FROM_FILE}" +else + echo "I could not find netdata distfile. Nor ${DIST_FILE_FROM_GIT} or ${DIST_FILE_FROM_FILE} exist" + exit 1 +fi + +echo "Opening dist archive ${DIST_FILE}" +tar -xovf "${DIST_FILE}" +NETDATA_DIST_FOLDER=$(echo ${DIST_FILE} | cut -d. -f1,2,3) +if [ ! -d ${NETDATA_DIST_FOLDER} ]; then + echo "I could not locate folder ${NETDATA_DIST_FOLDER}, something went wrong failing the test" + exit 1 +fi + +echo "Entering ${NETDATA_DIST_FOLDER} and starting docker compilation" +cd ${NETDATA_DIST_FOLDER} +docker run -it -v "${PWD}:/code:rw" -w /code "netdata/os-test:centos7" /bin/bash -c "./netdata-installer.sh --dont-wait --install /tmp && echo \"Validating netdata instance is running\" && wget -O'-' 'http://127.0.0.1:19999/api/v1/info' | grep version" + +echo "Installation completed with no errors! Removing temporary folders" + +# TODO: Travis give me a permission denied on some files here, i made it a soft error until i figure out what is wrong +cd - +rm -rf ${NETDATA_DIST_FOLDER} || echo "I could not remove temporary directory, make sure you delete ${NETDATA_DIST_FOLDER} by yourself if this wasn't run over ephemeral storage" diff --git a/.travis/tagger.sh b/.travis/tagger.sh index e72c5721c..adac35b48 100755 --- a/.travis/tagger.sh +++ b/.travis/tagger.sh @@ -1,7 +1,4 @@ #!/bin/bash -# SPDX-License-Identifier: MIT -# Copyright (C) 2018 Pawel Krupa (@paulfantom) - All Rights Reserved -# Permission to copy and modify is granted under the MIT license # # Original script is available at https://github.com/paulfantom/travis-helper/blob/master/releasing/releaser.sh # @@ -14,20 +11,35 @@ # Requirements: # - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo # - git-semver python package (pip install git-semver) - -# exported variables are needed by releaser.sh +# +# Note: Exported variables needed by .travis/draft_release.sh +# +# Original script is available at https://github.com/paulfantom/travis-helper/blob/master/releasing/releaser.sh +# +# Copyright: SPDX-License-Identifier: GPL-3.0-or-later +# +# Author : Pawel Krupa (paulfantom) +# Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud) set -e -if [ ! -f .gitignore ]; then - echo "Run as ./travis/$(basename "$0") from top level directory of git repository" - exit 1 + +# If we are not in netdata git repo, at the top level directory, fail +TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)") +CWD=$(git rev-parse --show-cdup || echo "") +if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then + echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository" + echo "Changelog generation process aborted" + exit 1 fi + # Figure out what will be new release candidate tag based only on previous ones. # This assumes that RELEASES are in format of "v0.1.2" and prereleases (RCs) are using "v0.1.2-rc0" -function release_candidate() { +function set_tag_release_candidate() { LAST_TAG=$(git semver) + echo "Last tag found is: ${LAST_TAG}" + if [[ $LAST_TAG =~ -rc* ]]; then VERSION=$(echo "$LAST_TAG" | cut -d'-' -f 1) LAST_RC=$(echo "$LAST_TAG" | cut -d'c' -f 2) @@ -35,25 +47,31 @@ function release_candidate() { else VERSION="$(git semver --next-minor)" RC=0 + echo "Warning: Will set version to ${VERSION} (Last tag: ${LAST_TAG}) while tagged for release candidate generation" fi - GIT_TAG="v$VERSION-rc$RC" + GIT_TAG="v${VERSION}-rc${RC}" } +echo "Determining TAG" + # Check if current commit is tagged or not GIT_TAG=$(git tag --points-at) + if [ -z "${GIT_TAG}" ]; then git semver # Figure out next tag based on commit message - echo "Last commit message: $TRAVIS_COMMIT_MESSAGE" + echo "Last commit message: ${TRAVIS_COMMIT_MESSAGE}" case "${TRAVIS_COMMIT_MESSAGE}" in *"[netdata patch release]"*) GIT_TAG="v$(git semver --next-patch)" ;; *"[netdata minor release]"*) GIT_TAG="v$(git semver --next-minor)" ;; *"[netdata major release]"*) GIT_TAG="v$(git semver --next-major)" ;; - *"[netdata release candidate]"*) release_candidate ;; + *"[netdata release candidate]"*) set_tag_release_candidate ;; *) echo "Keyword not detected. Exiting..." exit 0 ;; esac fi + +echo "Setting up GIT_TAG to ${GIT_TAG}" export GIT_TAG |