Skip to content
Closed
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"component/server":
- "fdbserver/**/*"

"component/client":
- "fdbclient/**/*"

"component/flow":
- "flow/**/*"

"component/rpc":
- "fdbrpc/**/*"

"component/test":
- "tests/**/*"
- "fdbserver/workloads/**/*"
- "bindings/c/test/**/*"

"component/bindings":
- "bindings/**/*"

"component/documentation":
- "documentation/**/*"
- "**/*.md"
47 changes: 47 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
- name: "size/XS"
color: "3cbf46"
description: "XS Pull Request (<10 lines change)"

- name: "size/S"
color: "5cd667"
description: "S Pull Request (10-49 lines change)"

- name: "size/M"
color: "ffc107"
description: "M Pull Request (50-199 lines change)"

- name: "size/L"
color: "fd7e14"
description: "L Pull Request (200-499 lines change)"

- name: "size/XL"
color: "dc3545"
description: "XL Pull Request (>=500 lines change)"

- name: "component/server"
color: "007bff"
description: "Server-side modifications (fdbserver)"

- name: "component/client"
color: "17a2b8"
description: "Client-side modifications (fdbclient)"

- name: "component/flow"
color: "6f42c1"
description: "Flow asynchronous framework changes"

- name: "component/rpc"
color: "e83e8c"
description: "RPC / network protocol changes"

- name: "component/test"
color: "20c997"
description: "Tests and simulation workload changes"

- name: "component/bindings"
color: "6610f2"
description: "Language binding changes"

- name: "component/documentation"
color: "6c757d"
description: "Documentation changes"
26 changes: 26 additions & 0 deletions .github/workflows/label-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Label Sync"

on:
push:
branches:
- main
paths:
- '.github/labels.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Sync GitHub Labels
uses: crazy-max/ghaction-github-labeler@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
skip-delete: false # Set to true if you don't want to delete manually created labels that are missing from labels.yml
112 changes: 112 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: PR Label Analysis

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
analyze:
name: Analyze PR for labeling
runs-on: ubuntu-latest

steps:
- name: Save PR metadata
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
mkdir -p ./pr-metadata
echo "${PR_NUMBER}" > ./pr-metadata/pr-number.txt

- name: Upload PR metadata as artifact
uses: actions/upload-artifact@v4
with:
name: pr-metadata-${{ github.event.pull_request.number }}
path: pr-metadata/
retention-days: 1

---

name: PR Label Apply

on:
workflow_run:
workflows: ["PR Label Analysis"]
types:
- completed

permissions:
contents: read

jobs:
apply-labels:
name: Apply labels to PR
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download PR metadata artifact
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
pattern: pr-metadata-*
merge-multiple: true

- name: Read PR number
id: pr-number
run: |
PR_NUMBER=$(cat "pr-number.txt")
echo "number=${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "PR Number: ${PR_NUMBER}"

- name: Apply Path-Based Labels
uses: actions/labeler@v5
with:
pr-number: ${{ steps.pr-number.outputs.number }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml
sync-labels: true

- name: Calculate and Apply Size Label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.pr-number.outputs.number }}
run: |
PR_DATA=$(curl -s -H "Authorization: token $GH_TOKEN" \
https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER)

ADDITIONS=$(echo "$PR_DATA" | jq '.additions')
DELETIONS=$(echo "$PR_DATA" | jq '.deletions')
TOTAL=$((ADDITIONS + DELETIONS))

if [ $TOTAL -lt 10 ]; then
SIZE_LABEL="size/XS"
elif [ $TOTAL -lt 50 ]; then
SIZE_LABEL="size/S"
elif [ $TOTAL -lt 200 ]; then
SIZE_LABEL="size/M"
elif [ $TOTAL -lt 500 ]; then
SIZE_LABEL="size/L"
else
SIZE_LABEL="size/XL"
fi

CURRENT_LABELS=$(echo "$PR_DATA" | jq -r '.labels[].name')

for label in $CURRENT_LABELS; do
if [[ "$label" =~ ^size/ ]] && [ "$label" != "$SIZE_LABEL" ]; then
gh pr edit $PR_NUMBER --remove-label "$label" || true
fi
done

if ! echo "$CURRENT_LABELS" | grep -q "^$SIZE_LABEL$"; then
gh pr edit $PR_NUMBER --add-label "$SIZE_LABEL"
fi