From 9bc9a7f9399e3eb1815dd007f5f631b69a9f9958 Mon Sep 17 00:00:00 2001 From: Travis Scrimshaw Date: Thu, 4 Jul 2024 12:35:05 +0900 Subject: [PATCH] Removing the automatic size labeler. --- .ci/set_labels_by_changes.sh | 71 -------------------------------- .github/workflows/pr-labeler.yml | 51 ----------------------- 2 files changed, 122 deletions(-) delete mode 100644 .ci/set_labels_by_changes.sh delete mode 100644 .github/workflows/pr-labeler.yml diff --git a/.ci/set_labels_by_changes.sh b/.ci/set_labels_by_changes.sh deleted file mode 100644 index d71444014dc..00000000000 --- a/.ci/set_labels_by_changes.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env bash - -# cd to the PR directory -cd $PR_MOUNT_DIR -PR_BASE_SHA=$(git merge-base $BASE_SHA $PR_HEAD_SHA) - -echo "set_labels_by_changes.sh called with environment:" -echo "BASE SHA: $PR_BASE_SHA" -echo "HEAD SHA: $PR_HEAD_SHA" -echo "SMALL THRESHOLD $SMALL_THRESHOLD" -echo "MODERATE THERESHOLD: $MODERATE_THRESHOLD" -echo "LARGE THRESHOLD: $LARGE_THRESHOLD" - -# get all the changes made and changed files -CHANGES=$(git diff --ignore-all-space $PR_BASE_SHA $PR_HEAD_SHA) - -# ignore blank lines -CHANGES=$(echo "$CHANGES" | grep -vE '^[\+\-]\s*$') - -# ignore non necessary lines from git diff -CHANGES=$(echo "$CHANGES" | grep -E '^[+\-]' | grep -vE '^\+\+\+|^\-\-\-') - -# count total no of lines -CHANGES=$(echo "$CHANGES" | wc -l) - -echo "CHANGES MADE: $CHANGES" - -AUTH_HEADER="Authorization: Bearer $GITHUB_TOKEN" - -MINIMAL="v: minimal" -SMALL="v: small" -MODERATE="v: moderate" -LARGE="v: large" - -DELETE_LABELS=("$MINIMAL" "$SMALL" "$MODERATE" "$LARGE") - -if [ "$CHANGES" -gt "$LARGE_THRESHOLD" ]; then - SIZE_LABEL="$LARGE" -elif [ "$CHANGES" -gt "$MODERATE_THRESHOLD" ]; then - SIZE_LABEL="$MODERATE" -elif [ "$CHANGES" -gt "$SMALL_THRESHOLD" ]; then - SIZE_LABEL="$SMALL" -else - SIZE_LABEL="$MINIMAL" -fi - -DELETE_LABELS=("${DELETE_LABELS[@]//${SIZE_LABEL}/}") - -# API for adding labels on the Pull Request -API_URL="https://api.github.com/repos/$REPOSITORY/issues/$PR_NUMBER/labels" - -echo "Adding label: ${SIZE_LABEL[@]}" -for LABEL in "${SIZE_LABEL[@]}"; do - curl -X POST \ - -H "$AUTH_HEADER" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "{\"labels\":[\"$LABEL\"]}" \ - "$API_URL" >/dev/null -done - -echo "Deleting Labels:" - -for DELETE_LABEL in "${DELETE_LABELS[@]}"; do - ENCODED_LABEL=$(echo "$DELETE_LABEL" | sed 's/ /%20/g') - curl -X DELETE \ - -H "Accept: application/vnd.github+json" \ - -H "$AUTH_HEADER" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "$API_URL/$ENCODED_LABEL" >/dev/null -done diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml deleted file mode 100644 index 63f70bb6531..00000000000 --- a/.github/workflows/pr-labeler.yml +++ /dev/null @@ -1,51 +0,0 @@ -# This action automatically labels Pull-Requests -# based on files edited and no of lines changed. -name: Size Labeler / Checker -on: - pull_request_target: - types: - - opened - - reopened - - synchronize - - ready_for_review - - review_requested - - edited -jobs: - label-changes: - if: vars.SMALL_THRESHOLD && vars.MODERATE_THRESHOLD && vars.LARGE_THRESHOLD && github.event.pull_request.draft == false - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - # checkout the .ci directory of the develop branch of the main repository sagemath/sage - - name: Checkout the main repo - uses: actions/checkout@v4 - with: - sparse-checkout: | - .ci - # Check out the pull request repository and mount it at path / - - name: Checkout the pull request repo - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - repository: ${{ github.event.pull_request.head.repo.full_name }} - path: ${{ github.event.pull_request.head.repo.name }} - - - name: Add labels based on size - run: | - git fetch origin $BASE_REF - chmod a+x .ci/set_labels_by_changes.sh - .ci/set_labels_by_changes.sh - env: - BASE_REF: ${{ github.base_ref }} - PR_MOUNT_DIR: ${{ github.event.pull_request.head.repo.name }} - BASE_SHA: ${{ github.event.pull_request.base.sha }} - PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPOSITORY: ${{ github.repository }} - PR_REPO: ${{ github.event.pull_request.head.repo.name }} - PR_NUMBER: ${{ github.event.pull_request.number}} - SMALL_THRESHOLD: ${{ vars.SMALL_THRESHOLD }} - MODERATE_THRESHOLD: ${{ vars.MODERATE_THRESHOLD }} - LARGE_THRESHOLD: ${{ vars.LARGE_THRESHOLD }}