@cryptotaxi247 / netdata-1 / commits / 1856a50b8

netdata/packaging/ci: Make Travis CI more strict on nightlies run (#5708)

* netdata/packaging/ci: Make nightlies fail hard on all errors except changelog (#5580) 1) Add the necessary comments for documentation 2) Reinstate set -e to fail hard on errors 3) When changelog generation fails, just report a log entry and continue so that we dont break the release These changes are temporary, we are following up with more aggressive changes that re-distribute processing * netdata/packaging/nightlies: Clean up nightlies, round one of many 1) Move ALL changelog generation related code, to generate changelog script 2) Remove that || logic from everywherem, except the part we execute changelog generation. We have said its optional, so do not fail nightlies if this script fails, just report the problem 3) change the gitignore change and use the more stable logic that monitors folder path utilizing git 4) Add a bit more verbosity everywhere so we can tell what is going on 5) Adjust generate changelog script, based on the newly migrated code. a) Variable declarations to the top, so that if something wrong with the generated ones we break early and avoid the mess b) put all that github handling, right after markmandel's changelog generation c) Gently handle github commands, add enough verbosity to identify where we broke and also check in the end what happened and clean-up github before you bail out 6) A couple of renames for variables here and there, for clarity and readability * netdata/packaging/ci: nits and fixes 1) Make sure nightlies still dont run when no changes are seen since last nightly 2) Artifacts creation should happen even if docker breaks. Ensure that and on the next iteration we will restructure the pipeline to a more productive layout 3) settle a couple of shellcheck warnings * netdata/packaging/docker: build and publish are using a BASH v4 capability. Make sure you break early with a message if we ever run on a different bash by accident

Paul Katsoulakis committed Mar 29, 2019 at 14:53 UTC 1856a50b8355e94fd33ecabc9ae50f2c3650df2b
4 files changed +91 -47
.travis/generate_changelog.sh
+41 -9
@@ -1,29 +1,46 @@
1 #!/bin/bash
2 -
2 +#
3 +# Changelog generation scriptlet.
4 +#
5 +# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
6 +#
7 +# Author : Pawel Krupa (paulfantom)
8 +# Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud)
9 set -e
10
5 -if [ ! -f .gitignore ]; then
6 - echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
7 - exit 1
11 +# If we are not in netdata git repo, at the top level directory, fail
12 +TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
13 +CWD=$(git rev-parse --show-cdup || echo "")
14 +if [ -n "$CWD" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
15 + echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
16 + echo "Changelog generation process aborted"
17 + exit 1
18 fi
19
10 -ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
11 -PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
20 +LAST_TAG="$1"
21 +COMMITS_SINCE_RELEASE="$2"
22 +ORG=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f1)
23 +PROJECT=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 2)
24 GIT_MAIL=${GIT_MAIL:-"bot@netdata.cloud"}
25 GIT_USER=${GIT_USER:-"netdatabot"}
14 -
26 +PUSH_URL=$(git config --get remote.origin.url | sed -e 's/^https:\/\///')
27 +FAIL=0
28 if [ -z ${GIT_TAG+x} ]; then
29 OPTS=""
30 else
31 OPTS="--future-release ${GIT_TAG}"
32 fi
33
21 -echo "--- Creating changelog ---"
34 +echo "We got $COMMITS_SINCE_RELEASE changes since $LAST_TAG, re-generating changelog"
35 +git config user.email "${GIT_MAIL}"
36 +git config user.name "${GIT_USER}"
37 git checkout master
38 git pull
39 +
40 +echo "Running project markmandel for github changelog generation"
41 #docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator:1.14.3 \
42 docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest \
26 - --user "${ORGANIZATION}" \
43 + --user "${ORG}" \
44 --project "${PROJECT}" \
45 --token "${GITHUB_TOKEN}" \
46 --since-tag "v1.10.0" \
@@ -31,3 +48,18 @@ docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest
48 --exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \
49 --no-compare-link ${OPTS}
50
51 +echo "Changelog created! Adding packaging/version and CHANGELOG.md to the repository"
52 +echo "$LAST_TAG-$((COMMITS_SINCE_RELEASE + 1))-nightly" > packaging/version
53 +git add packaging/version && echo "1) Added packaging/version to repository" || FAIL=1
54 +git add CHANGELOG.md && echo "2) Added changelog file to repository" || FAIL=1
55 +git commit -m '[ci skip] create nightly packages and update changelog' && echo "3) Committed changes to repository" || FAIL=1
56 +git push "https://${GITHUB_TOKEN}:@${PUSH_URL}" && echo "4) Pushed changes to remote ${PUSH_URL}" || FAIL=1
57 +
58 +# In case of a failure, wrap it up and bail out cleanly
59 +if [ $FAIL -eq 1 ]; then
60 + git clean -xfd
61 + echo "Changelog generation failed during github UPDATE!"
62 + exit 1
63 +fi
64 +
65 +echo "Changelog generation completed successfully!"
.travis/nightlies.sh
+38 -36
@@ -1,45 +1,47 @@
1 #!/bin/bash
2 -
3 -BAD_THING_HAPPENED=0
4 -
5 -if [ ! -f .gitignore ]; then
6 - echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
7 - exit 1
2 +#
3 +# This is the nightlies orchastration script
4 +# It runs the following activities in order:
5 +# 1) Generate changelog
6 +# 2) Build docker images
7 +# 3) Publish docker images
8 +# 4) Generate the rest of the artifacts (Source code .tar.gz file and makeself binary generation)
9 +#
10 +# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
11 +#
12 +# Author : Pawel Krupa (paulfantom)
13 +# Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud)
14 +set -e
15 +
16 +FAIL=0
17 +
18 +# If we are not in netdata git repo, at the top level directory, fail
19 +TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
20 +CWD=$(git rev-parse --show-cdup || echo "")
21 +if [ -n "$CWD" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
22 + echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
23 + echo "Changelog generation process aborted"
24 + exit 1
25 fi
26
10 -export GIT_MAIL="bot@netdata.cloud"
11 -export GIT_USER="netdatabot"
12 -echo "--- Initialize git configuration ---"
13 -git config user.email "${GIT_MAIL}"
14 -git config user.name "${GIT_USER}"
15 -
16 -echo "--- UPDATE VERSION FILE ---"
27 LAST_TAG=$(git describe --abbrev=0 --tags)
18 -NO_COMMITS=$(git rev-list "$LAST_TAG"..HEAD --count)
19 -if [ "$NO_COMMITS" == "$(rev <packaging/version | cut -d- -f 2 | rev)" ]; then
20 - echo "Nothing changed since last nightly build"
28 +COMMITS_SINCE_RELEASE=$(git rev-list "$LAST_TAG"..HEAD --count)
29 +PREVIOUS_NIGHTLY_COUNT="$(rev <packaging/version | cut -d- -f 2 | rev)"
30 +
31 +# If no commits since release, just stop
32 +if [ "$COMMITS_SINCE_RELEASE" == "${PREVIOUS_NIGHTLY_COUNT}" ]; then
33 + echo "No changes since last nighthly release"
34 exit 0
35 fi
23 -echo "$LAST_TAG-$((NO_COMMITS + 1))-nightly" >packaging/version
24 -git add packaging/version || exit 1
25 -
26 -echo "--- GENERATE CHANGELOG ---"
27 -if .travis/generate_changelog.sh; then
28 - git add CHANGELOG.md
29 -
30 - echo "--- UPLOAD FILE CHANGES ---"
31 - git commit -m '[ci skip] create nightly packages and update changelog'
32 - git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
33 -else
34 - git clean -xfd
35 - BAD_THING_HAPPENED=1
36 -fi
36
38 -echo "--- BUILD & PUBLISH DOCKER IMAGES ---"
39 -packaging/docker/build.sh || BAD_THING_HAPPENED=1
40 -packaging/docker/publish.sh || BAD_THING_HAPPENED=1
37 +echo "--- Running Changelog generation ---"
38 +.travis/generate_changelog.sh "$LAST_TAG" "$COMMITS_SINCE_RELEASE" || echo "Changelog generation has failed, this is a soft error, process continues"
39 +
40 +echo "--- Build && publish docker images ---"
41 +# Do not fail artifacts creation if docker fails. We will be restructuring this on a follow up PR
42 +packaging/docker/build.sh && packaging/docker/publish.sh || echo "Failed to build and publish docker images"
43
42 -echo "--- BUILD ARTIFACTS ---"
43 -.travis/create_artifacts.sh || BAD_THING_HAPPENED=1
44 +echo "--- Build artifacts ---"
45 +.travis/create_artifacts.sh
46
45 -exit "${BAD_THING_HAPPENED}"
47 +exit "${FAIL}"
packaging/docker/build.sh
+6 -1
@@ -8,6 +8,11 @@
8
9 set -e
10
11 +if [ "${BASH_VERSINFO[0]}" -lt "4" ]; then
12 + echo "This mechanism currently can only run on BASH version 4 and above"
13 + exit 1
14 +fi
15 +
16 VERSION="$1"
17 REPOSITORY="${REPOSITORY:-netdata}"
18 declare -A ARCH_MAP
@@ -40,7 +45,7 @@ fi
45 echo "Docker image build in progress.."
46 echo "Version : ${VERSION}"
47 echo "Repository : ${REPOSITORY}"
43 -echo "Architectures : ${ARCHS}"
48 +echo "Architectures : ${ARCHS[*]}"
49
50 docker run --rm --privileged multiarch/qemu-user-static:register --reset
51
packaging/docker/publish.sh
+6 -1
@@ -8,6 +8,11 @@
8
9 set -e
10
11 +if [ "${BASH_VERSINFO[0]}" -lt "4" ]; then
12 + echo "This mechanism currently can only run on BASH version 4 and above"
13 + exit 1
14 +fi
15 +
16 WORKDIR="$(mktemp -d)" # Temporary folder, removed after script is done
17 VERSION="$1"
18 REPOSITORY="${REPOSITORY:-netdata}"
@@ -49,7 +54,7 @@ fi
54 echo "Docker image publishing in progress.."
55 echo "Version : ${VERSION}"
56 echo "Repository : ${REPOSITORY}"
52 -echo "Architectures : ${ARCHS}"
57 +echo "Architectures : ${ARCHS[*]}"
58 echo "Manifest list : ${MANIFEST_LIST}"
59
60 # Create temporary docker CLI config with experimental features enabled (manifests v2 need it)