Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add workflow to label flaky-test platform #44042

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/label-flaky-test-issue.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should set permissions for the workflow. (cf #43743, /cc @varunsh-coder)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it different from:

    ...
    permissions:
      issues: write
    steps:
      ...

?

It's already set in the workflow (job scoped)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aduh95 Should this conversation be marked as resolved or is there something to add to the workflow?

NUMBER: ${{ github.event.issue.number }}
run: gh issue edit "$NUMBER" --repo ${{ github.repository }} --add-label "${{ steps.extract-labels.outputs.LABELS }}"