@cryptotaxi247 / netdata-1 / commits / 0cb72d21e

auto-label PRs and minor cleanup (#4795)

Paweł Krupa committed Nov 30, 2018 at 11:01 UTC 0cb72d21e879c96a02bcd450c5b61e9cc3a611d9
3 files changed +71 -25
.travis.yml
+5 -5
@@ -53,7 +53,11 @@ jobs:
53 depth: false
54
55 - stage: nightlies
56 - name: tarball and self-extractor build
56 + name: docker images
57 + install: sudo apt update -y && sudo apt install -y --only-upgrade docker-ce && docker info
58 + script: "packaging/docker/build.sh"
59 + env: REPOSITORY="netdata/netdata"
60 + - name: tarball and self-extractor build
61 install: sudo apt-get install -y gnupg libcap2-bin zlib1g-dev uuid-dev fakeroot
62 script: ".travis/create_artifacts.sh"
63 deploy:
@@ -66,10 +70,6 @@ jobs:
70 skip_cleanup: true
71 file_glob: true
72 file: "netdata*.tar.gz"
69 - - name: docker images
70 - install: sudo apt update -y && sudo apt install -y --only-upgrade docker-ce && docker info
71 - script: "packaging/docker/build.sh"
72 - env: REPOSITORY="netdata/netdata"
73 - name: changelog generation
74 script: ".travis/generate_changelog.sh"
75 env: COMMIT_AND_PUSH=1
.travis/labeler.sh
+65 -19
@@ -4,30 +4,76 @@
4 # It will soon be deprecated by GitHub Actions so no futher development on it is planned.
5
6 if [ "$GITHUB_TOKEN" == "" ]; then
7 - echo "GITHUB_TOKEN is needed"
8 - exit 1
7 + echo "GITHUB_TOKEN is needed"
8 + exit 1
9 fi
10
11 # Download hub
12 -HUB_VERSION=${HUB_VERSION:-"2.5.1"}
13 -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"
14 -tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz" &>/dev/null
15 -export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
12 +if ! [ -x "$(command -v hub)" ]; then
13 + HUB_VERSION=${HUB_VERSION:-"2.5.1"}
14 + 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"
15 + tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz" &>/dev/null
16 + export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
17 +fi
18
19 echo "Looking up available labels"
18 -LABELS_FILE=/tmp/exclude_labels
19 -hub issue labels > $LABELS_FILE
20 +LABELS_FILE=/tmp/labels
21 +hub issue labels >$LABELS_FILE
22
23 for STATE in "open" "closed"; do
22 - for ISSUE in $(hub issue -f "%I %l%n" -s "$STATE" -d "$(date +%F -d '1 day ago')" | grep -v -f $LABELS_FILE); do
23 - echo "Processing $STATE issue no. $ISSUE"
24 - URL="https://api.github.com/repos/netdata/netdata/issues/$ISSUE"
25 - BODY="$(curl "${URL}" | jq .body 2>/dev/null)"
26 - case "${BODY}" in
27 - *"# Question summary"* ) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["question"]}' -X PATCH "${URL}" ;;
28 - *"# Bug report summary"* ) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["needs triage","bug"]}' -X PATCH "${URL}" ;;
29 - *"# Feature idea summary"* ) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["needs triage","feature request"]}' -X PATCH "${URL}" ;;
30 - * ) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["needs triage"]}' -X PATCH "${URL}" ;;
31 - esac
32 - done
24 + for ISSUE in $(hub issue -f "%I %l%n" -s "$STATE" -d "$(date +%F -d '1 day ago')" | grep -v -f $LABELS_FILE); do
25 + echo "Processing $STATE issue no. $ISSUE"
26 + URL="https://api.github.com/repos/netdata/netdata/issues/$ISSUE"
27 + BODY="$(curl "${URL}" 2>/dev/null | jq .body)"
28 + case "${BODY}" in
29 + *"# Question summary"*) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["question"]}' -X PATCH "${URL}" ;;
30 + *"# Bug report summary"*) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["needs triage","bug"]}' -X PATCH "${URL}" ;;
31 + *"# Feature idea summary"*) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["needs triage","feature request"]}' -X PATCH "${URL}" ;;
32 + *) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["needs triage"]}' -X PATCH "${URL}" ;;
33 + esac
34 + done
35 +done
36 +
37 +NEW_LABELS=/tmp/new_labels
38 +for PR in $(hub pr list -s all -f "%I %l%n" -L 10); do
39 + echo "-------------------------------------------------------"
40 + echo "Processing PR #$PR"
41 + echo "" >$NEW_LABELS
42 + NEW_SET=""
43 + URL="https://api.github.com/repos/netdata/netdata/issues/$PR"
44 + DIFF_URL="https://github.com/netdata/netdata/pull/$PR.diff"
45 + for FILE in $(curl -L "${DIFF_URL}" 2>/dev/null | grep "diff --git a/" | cut -d' ' -f3 | sort | uniq); do
46 + LABEL=""
47 + case "${FILE}" in
48 + *".md") AREA="docs" ;;
49 + *"/collectors/python.d.plugin/"*) AREA="external/python" ;;
50 + *"/collectors/charts.d.plugin/"*) AREA="external" ;;
51 + *"/collectors/node.d.plugin/"*) AREA="external" ;;
52 + *"/.travis"*) AREA="ci" ;;
53 + *"/.github/"*) AREA="ci" ;;
54 + *"/build/"*) AREA="packaging" ;;
55 + *"/contrib/"*) AREA="packaging" ;;
56 + *"/diagrams/"*) AREA="docs" ;;
57 + *"/installer/"*) AREA="packaging" ;;
58 + *"/makeself/"*) AREA="packaging" ;;
59 + *"/system/"*) AREA="packaging" ;;
60 + *"/netdata-installer.sh"*) AREA="packaging" ;;
61 + *) AREA=$(echo "$FILE" | cut -d'/' -f2) ;;
62 + esac
63 + LABEL="area/$AREA"
64 + echo "Selecting $LABEL due to $FILE"
65 + if grep "$LABEL" "$LABELS_FILE"; then
66 + echo "$LABEL" >>$NEW_LABELS
67 + if [[ $LABEL =~ "external" ]]; then
68 + echo "area/collectors" >>$NEW_LABELS
69 + fi
70 + else
71 + echo "Label '$LABEL' not available"
72 + fi
73 + done
74 + NEW_SET=$(sort $NEW_LABELS | uniq | grep -v "^$" | sed -e 's/^/"/g;s/$/",/g' | tr -d '\n' | sed 's/.\{1\}$//')
75 + if [ ! -z "$NEW_SET" ]; then
76 + echo "Assigning labels: ${NEW_SET}"
77 + curl -H "Authorization: token $GITHUB_TOKEN" -d "{\"labels\":[${NEW_SET}]}" -X PATCH "${URL}" &>/dev/null
78 + fi
79 done
installer/netdata-updater.sh
+1 -1
@@ -22,7 +22,7 @@ source installer/.environment.sh || exit 1
22 UID="$(id -u)"
23 if [ "${INSTALL_UID}" != "${UID}" ]
24 then
25 - echo >&2 "This script should be run as user with uid ${INSTALL_UID} but it now runs with uid ${UID}"
25 + echo >&2 "You are running this script as user with uid ${UID}. We recommend to run this script as root (user with uid 0)"
26 exit 1
27 fi
28