Skip to content

Commit

Permalink
Simplify PR size labeling workflow
Browse files Browse the repository at this point in the history
- Replace pr-size-labeler with custom labeler script
- Remove redundant labeler_v2 workflow file
- Enhance labeler script to clean up existing size labels before adding new ones
  • Loading branch information
mastercactapus committed Sep 3, 2024
1 parent c513dba commit 8a36670
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 55 deletions.
41 changes: 7 additions & 34 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,11 @@ jobs:
if: github.event.pull_request.draft == false
name: Label the PR size
steps:
- uses: mastercactapus/pr-size-labeler@eb6a25f40d6a3327581aca35839b60d419e8019a # https://github.com/CodelyTV/pr-size-labeler/pull/61, updated with latest from main
- uses: actions/checkout@v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_label: 'size/xs'
xs_max_size: '15'
s_label: 'size/s'
s_max_size: '100'
m_label: 'size/m'
m_max_size: '250'
l_label: 'size/l'
l_max_size: '500'
xl_label: 'size/xl'
fail_if_xl: 'true'
ignore_deleted: 'true'
message_if_xl: >
This PR exceeds the recommended size of 500 lines.
Please make sure you are NOT addressing multiple issues with one PR.
Note this PR might be rejected due to its size.
files_to_ignore: |
"*.lock"
"graphql2/generated.go"
"graphql2/maplimit.go"
"graphql2/mapconfig.go"
"graphql2/models_gen.go"
"pkg/sysapi/*.pb.go"
"swo/swodb/*.go"
"web/src/*.d.ts"
"Makefile.binaries.mk"
"gadb/*.go"
"migrate/schema.sql"
"go.mod"
"go.sum"
".yarn/releases/*"
"devtools/pgdump-lite/pgd/*"
"timezone/*.txt"
fetch-depth: 0
- name: Run labeler script
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
run: ./devtools/scripts/github-set-pr-label.sh
20 changes: 0 additions & 20 deletions .github/workflows/labeler_v2.yml

This file was deleted.

10 changes: 9 additions & 1 deletion devtools/scripts/github-set-pr-label.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ fi

LABEL=$(./devtools/scripts/git-diff-label-calc.sh --debug)

gh pr edit "$PR_NUMBER" --add-label "test/$LABEL"
# Remove any existing test/* labels
for label in $(gh pr view "$PR_NUMBER" --json labels --jq '.labels[] | select(.name | startswith("size/")) | .name'); do
if [ "$label" == "$LABEL" ]; then
continue # Skip the label we want to add
fi
gh pr edit "$PR_NUMBER" --remove-label "$label"
done

gh pr edit "$PR_NUMBER" --add-label "$LABEL"

0 comments on commit 8a36670

Please sign in to comment.