Switch PR labeling to use GitHub Actions. (#7630)
This decouples the PR labeling process from the main CI process, allowing them to run completely independenly of each other. The new labeling configuration is based on copying, extending, and correcting the existing labeling rules in the `labeler.sh` script which the commit is removing. Labeling is configured through `.github/labeler.yml` file. Check there for info on the exact format. The exact configuration being used will update labels on PR's whenever one is opened, updated, reopened, or marked ready for review. It will not remove existing labels from the PR, only add new ones.
Austin S. Hemmelgarn committed
Jan 8, 2020 at 06:22 UTC
7597c80d2706f058d609b4d839100faa70654f4d
4 files changed
+109
-89
.github/labeler.yml
new
+91
@@ -0,0 +1,91 @@
1
+# This configures label matching for PR's.
2
+#
3
+# The keys are labels, and the values are lists of minimatch patterns
4
+# to which those labels apply.
5
+#
6
+# NOTE: This can only add labels, not remove them.
7
+# NOTE: Due to YAML syntax limitations, patterns or labels which start
8
+# with a character that is part of the standard YAML syntax must be
9
+# quoted.
10
+#
11
+# Please keep the labels sorted and deduplicated.
12
+
13
+area/backends:
14
+ - backends/*
15
+ - backends/**
16
+ - exporting/*
17
+ - exporting/**/*
18
+
19
+area/ci:
20
+ - .travis/*
21
+ - .travis/**/*
22
+ - .github/*
23
+ - .github/**/*
24
+
25
+area/collectors:
26
+ - collectors/*
27
+ - collectors/**/*
28
+
29
+area/daemon:
30
+ - daemon/*
31
+ - daemon/**/*
32
+
33
+area/database:
34
+ - database/*
35
+ - database/**/*
36
+
37
+area/docs:
38
+ - "**/*.md"
39
+ - diagrams/*
40
+ - diagrams/**/*
41
+ - netlify.toml
42
+
43
+area/external/python:
44
+ - collectors/python.d.plugin/*
45
+ - collectors/python.d.plugin/**/*
46
+
47
+area/external:
48
+ - collectors/charts.d.plugin/*
49
+ - collectors/charts.d.plugin/**/*
50
+ - collectors/node.d.plugin/*
51
+ - collectors/node.d.plugin/**/*
52
+
53
+area/health:
54
+ - health/*
55
+ - health/**/*
56
+
57
+area/packaging:
58
+ - build/*
59
+ - build/**/*
60
+ - contrib/*
61
+ - contrib/**/*
62
+ - packaging/*
63
+ - packaging/**/*
64
+ - system/*
65
+ - system/**/*
66
+ - netdata-installer.sh
67
+ - CMakeLists.txt
68
+ - configure.ac
69
+ - Makefile.am
70
+ - "**/Makefile.am"
71
+ - netdata.spec.in
72
+
73
+area/registry:
74
+ - registry/*
75
+ - registry/**/*
76
+
77
+area/streaming:
78
+ - streaming/*
79
+ - streaming/**/*
80
+
81
+area/tests:
82
+ - tests/*
83
+ - tests/**/*
84
+ - daemon/unit_test*
85
+ - coverity-scan.sh
86
+ - cppcheck.sh
87
+ - netdata.cppcheck
88
+
89
+area/web:
90
+ - web/*
91
+ - web/**/*
.github/workflows/labeler.yml
new
+17
@@ -0,0 +1,17 @@
1
+---
2
+# Handles labelling of PR's.
3
+name: Pull Request Labeler
4
+on:
5
+ pull_request:
6
+ types:
7
+ - opened
8
+ - synchronized
9
+ - reopened
10
+ - ready_for_review
11
+jobs:
12
+ labeler:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/labeler@v2
16
+ with:
17
+ repo-token: "${{ secrets.GITHUB_TOKEN }}"
.travis.yml
+1
-7
@@ -250,10 +250,7 @@ jobs:
250
251
252
- stage: Support activities on main branch
253
- name: Run labeler on github issues
254
- script: .travis/labeler.sh # labeler should be replaced with GitHub Actions when they hit GA
255
-
256
- - name: Generate changelog for release (only on special and tagged commit msg)
253
+ name: Generate changelog for release (only on special and tagged commit msg)
254
before_script: post_message "TRAVIS_MESSAGE" "Support activities on main branch initiated" "${NOTIF_CHANNEL}"
255
script:
256
- echo "GIT Branch:" && git branch
@@ -543,9 +540,6 @@ jobs:
540
- name: Kickstart files integrity testing (extended)
541
script: ./tests/installer/checksums.sh
542
546
- - name: Run labeler on github issues
547
- script: .travis/labeler.sh # labeler should be replaced with GitHub Actions when they hit GA
548
-
543
# This is generating the changelog for nightly release and publish it
544
- name: Generate nightly changelog
545
before_script: post_message "TRAVIS_MESSAGE" "Starting changelog generation for nightlies" "${NOTIF_CHANNEL}"
.travis/labeler.sh
deleted
-82
@@ -1,82 +0,0 @@
1
-#!/bin/bash
2
-
3
-# This is a simple script which should apply labels to unlabelled issues from last 3 days.
4
-# It will soon be deprecated by GitHub Actions so no futher development on it is planned.
5
-
6
-# Previously this was using POST to only add labels. But this method seems to be failing with larger number of requests
7
-new_labels() {
8
- ISSUE="$1"
9
- URL="https://api.github.com/repos/netdata/netdata/issues/$ISSUE/labels"
10
- # deduplicate array and add quotes
11
- SET=( $(for i in "${@:2}"; do [ "$i" != "" ] && echo "\"$i\""; done | sort -u) )
12
- # implode array to string
13
- LABELS="${SET[*]}"
14
- # add commas between quotes (replace spaces)
15
- LABELS="${LABELS//\" \"/\",\"}"
16
- # remove duplicate quotes in case parameters were already quoted
17
- LABELS="${LABELS//\"\"/\"}"
18
- echo "-------- Assigning labels to #${ISSUE}: ${LABELS} --------"
19
- curl -H "Authorization: token $GITHUB_TOKEN" -d "{\"labels\":[${LABELS}]}" -X PUT "${URL}" &>/dev/null
20
-}
21
-
22
-if [ "$GITHUB_TOKEN" == "" ]; then
23
- echo "GITHUB_TOKEN is needed"
24
- exit 1
25
-fi
26
-
27
-if ! [ -x "$(command -v hub)" ]; then
28
- echo "===== Download HUB ====="
29
- HUB_VERSION=${HUB_VERSION:-"2.5.1"}
30
- 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"
31
- tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz" &>/dev/null
32
- export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
33
-fi
34
-
35
-echo "===== Looking up available labels ====="
36
-LABELS_FILE=/tmp/labels
37
-hub issue labels >$LABELS_FILE
38
-
39
-# Change all 'area' labels assigned to PR saving non-area labels.
40
-echo "===== Categorizing PRs ====="
41
-NEW_LABELS=/tmp/new_labels
42
-for PR in $(hub pr list -s all -f "%I%n" -L 10); do
43
- echo "----- Processing PR #$PR -----"
44
- echo "" >$NEW_LABELS
45
- NEW_SET=""
46
- DIFF_URL="https://github.com/netdata/netdata/pull/$PR.diff"
47
- for FILE in $(curl -L "${DIFF_URL}" 2>/dev/null | grep "diff --git a/" | cut -d' ' -f3 | sort | uniq); do
48
- LABEL=""
49
- case "${FILE}" in
50
- *".md") AREA="docs" ;;
51
- *"/collectors/python.d.plugin/"*) AREA="external/python" ;;
52
- *"/collectors/charts.d.plugin/"*) AREA="external" ;;
53
- *"/collectors/node.d.plugin/"*) AREA="external" ;;
54
- *"/.travis"*) AREA="ci" ;;
55
- *"/.github/*.md"*) AREA="docs" ;;
56
- *"/.github/"*) AREA="ci" ;;
57
- *"/build/"*) AREA="packaging" ;;
58
- *"/contrib/"*) AREA="packaging" ;;
59
- *"/diagrams/"*) AREA="docs" ;;
60
- *"/installer/"*) AREA="packaging" ;;
61
- *"/makeself/"*) AREA="packaging" ;;
62
- *"/system/"*) AREA="packaging" ;;
63
- *"/netdata-installer.sh"*) AREA="packaging" ;;
64
- *) AREA=$(echo "$FILE" | cut -d'/' -f2) ;;
65
- esac
66
- LABEL="area/$AREA"
67
- echo "Selecting $LABEL due to $FILE"
68
- if grep "$LABEL" "$LABELS_FILE"; then
69
- echo "$LABEL" >>$NEW_LABELS
70
- if [[ $LABEL =~ "external" ]]; then
71
- echo "area/collectors" >>$NEW_LABELS
72
- fi
73
- else
74
- echo "-------- Label '$LABEL' not available --------"
75
- fi
76
- done
77
- NEW_SET=$(sort $NEW_LABELS | uniq)
78
- if [ ! -z "$NEW_SET" ]; then
79
- PREV=$(curl -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/netdata/netdata/issues/$PR/labels" 2>/dev/null | jq '.[].name' | grep -v "area")
80
- new_labels "$PR" ${NEW_SET} "${PREV[*]}"
81
- fi
82
-done