From 041bb54143424510c01c9a2aae07b2204bb79be4 Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Sun, 7 Aug 2022 19:34:03 -0300 Subject: [PATCH] build: add workflow to label flaky-test platform This workflow adds platform labels on `flaky-test` issues to make it easier and more reliable for someone to use labels to (for example) find all flaky tests on SmartOS or all flaky tests on FreeBSD. PR-URL: https://github.com/nodejs/node/pull/44042 Fixes: https://github.com/nodejs/node/issues/43854 Reviewed-By: Paolo Insogna Reviewed-By: Rich Trott --- .github/workflows/label-flaky-test-issue.yml | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/label-flaky-test-issue.yml diff --git a/.github/workflows/label-flaky-test-issue.yml b/.github/workflows/label-flaky-test-issue.yml new file mode 100644 index 00000000000000..490d0826fb53aa --- /dev/null +++ b/.github/workflows/label-flaky-test-issue.yml @@ -0,0 +1,50 @@ +name: Label Flaky Test Issues + +on: + issues: + types: [opened, labeled] + +jobs: + label: + if: github.event.label.name == 'flaky-test' + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Extract labels + id: extract-labels + env: + BODY: ${{ github.event.issue.body }} + run: | + BODY="${BODY//$'\n'/'\n'}" + + declare -A platform2label + + platform2label["AIX"]="aix"; + platform2label["FreeBSD"]="freebsd"; + platform2label["Linux ARM64"]="linux"; + platform2label["Linux ARMv7"]="arm"; + platform2label["Linux PPC64LE"]="ppc"; + platform2label["Linux s390x"]="s390"; + platform2label["Linux x64"]="linux"; + platform2label["macOS ARM64"]="macos"; + platform2label["macOS x64"]="macos"; + platform2label["SmartOS"]="smartos"; + platform2label["Windows"]="windows"; + + # sed is cleaning up the edges + PLATFORMS=$(echo $BODY | sed 's/^.*Platform\\n\\n//' | sed 's/\(, Other\)\?\\n\\n.*$//') 2> /dev/null + readarray -d , -t list <<< "$PLATFORMS" + labels= + for row in "${list[@]}"; do \ + platform=$(echo $row | xargs); \ + labels="${labels}${platform2label[$platform]},"; \ + done; + + echo "::set-output name=LABELS::${labels::-1}" + + - name: Add labels + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NUMBER: ${{ github.event.issue.number }} + run: gh issue edit "$NUMBER" --repo ${{ github.repository }} --add-label "${{ steps.extract-labels.outputs.LABELS }}"