CodelyTV / pr-size-labeler

🏷 Visualize and optionally limit the size of your Pull Requests
https://github.com/marketplace/actions/pull-request-size-labeler
MIT License
336 stars 58 forks source link

Not working anymore #40

Closed apomalyn closed 1 year ago

apomalyn commented 2 years ago

Hi! First of all, thank you for this action!

So here is our issue, it seems like the label isn't applied anymore. Here you can find the logs:

2022-04-26T20:28:48.7798250Z Total modifications (additions + deletions): 1973
2022-04-26T20:28:48.7799291Z Ignoring files (if present): 
2022-04-26T20:28:48.7809902Z Labeling pull request with size: XL
2022-04-26T20:28:49.1872778Z Final labels: "size: XL"
2022-04-26T20:28:49.8593456Z {
2022-04-26T20:28:49.8594306Z   "message": "Invalid request.\n\nFor 'links/0/schema', nil is not an object.",
2022-04-26T20:28:49.8595189Z   "documentation_url": "https://docs.github.com/rest/reference/issues#create-an-issue-comment"
2022-04-26T20:28:49.8595980Z }

Here is our call to the action:

name: Dev tools workflow
on:
  pull_request:

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  determine_pr_size:
    name: Determine the size of the PR
    runs-on: ubuntu-latest
    steps:
      - uses: codelytv/pr-size-labeler@v1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          xs_label: 'size: XS'
          xs_max_size: '30'
          s_label: 'size: S'
          s_max_size: '100'
          m_label: 'size: M'
          m_max_size: '500'
          l_label: 'size: L'
          l_max_size: '1000'
          xl_label: 'size: XL'
          fail_if_xl: 'false'
          message_if_xl: >
            'This PR exceeds the recommended size of 1000 lines.
            Please make sure you are NOT addressing multiple issues with one PR.
            Note this PR might be rejected due to its size.’
          github_api_url: 'api.github.com'

Thank you in advance and don't hesitate if you need anything else.

sergiocampama commented 2 years ago

I'm also seeing this error:

/src/github.sh: line 15: null: unbound variable
Total modifications (additions + deletions): 
/src/labeler.sh: line 49: [: : integer expression expected
/src/labeler.sh: line 51: [: : integer expression expected
/src/labeler.sh: line 53: [: : integer expression expected
/src/labeler.sh: line 55: [: : integer expression expected
Ignoring files (if present): 
Labeling pull request with XL
jq: error (at <stdin>:1): Cannot iterate over null (null)
Final labels: "XL"
{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/issues#create-an-issue-comment"
}
sergiocampama commented 2 years ago

My setup is

  pr-size-label:
    runs-on: ubuntu-latest
    steps:
    - name: pr-size-label
      uses: codelytv/pr-size-labeler@v1
      with:
        xs_label: XS
        xs_max_size: '10'
        s_label: S
        s_max_size: '100'
        m_label: M
        m_max_size: '500'
        l_label: L
        l_max_size: '1000'
        xl_label: XL
        fail_if_xl: 'false'
        github_api_url: 'api.github.com'
        files_to_ignore: ''
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
anarian commented 2 years ago

Also seeing the same error in a private repo

jobs:
  labeler:
    runs-on: ubuntu-latest
    name: Label the PR size
    permissions:
      pull-requests: write
      issues: write
    steps:
      - uses: codelytv/pr-size-labeler@v1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          xs_label: 'size/xs'
          xs_max_size: 10
          s_label: 'size/s'
          s_max_size: 100
          m_label: 'size/m'
          m_max_size: 500
          l_label: 'size/l'
          l_max_size: 1000
          xl_label: 'size/xl'
          fail_if_xl: false
          message_if_xl: >
            'This PR exceeds the recommended size of 1000 lines.
            Please make sure you are NOT addressing multiple issues with one PR.
            Note this PR might be rejected due to its size.’
          github_api_url: 'api.github.com'

/src/github.sh: line 15: null: unbound variable
Total modifications (additions + deletions): 
Ignoring files (if present): 
/src/labeler.sh: line 49: [: : integer expression expected
/src/labeler.sh: line 51: [: : integer expression expected
/src/labeler.sh: line 53: [: : integer expression expected
/src/labeler.sh: line 55: [: : integer expression expected
Labeling pull request with size/xl
jq: error (at <stdin>:1): Cannot iterate over null (null)
Final labels: "size/xl"
{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/issues#create-an-issue-comment"
}
togiles commented 2 years ago

Trying to add this for the first time, and it isn't working for me, however not seeing the same issues as shown above.

Here is my labeler.yml:

name: labeler

on: [pull_request]

jobs:
  labeler:
    runs-on: ubuntu-latest
    name: Label the PR size
    steps:
      - uses: codelytv/pr-size-labeler@v1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          xs_label: 'size/XS'
          xs_max_size: '10'
          s_label: 'size/S'
          s_max_size: '100'
          m_label: 'size/M'
          m_max_size: '500'
          l_label: 'size/L'
          l_max_size: '1000'
          xl_label: 'size/XL'
          fail_if_xl: 'false'
          message_if_xl: >
            This PR exceeds the recommended size of 1000 lines and
            will be reviewed at a "best effort" SLO. Please try to 
            break it up into smaller PRs. 
          github_api_url: 'api.github.com'
          files_to_ignore: 'deps.bzl go.mod yarn.lock'

Here is the output from the run:

with:
    GITHUB_TOKEN: ***
    xs_label: size/XS
    xs_max_size: 10
    s_label: size/S
    s_max_size: 100
    m_label: size/M
    m_max_size: 500
    l_label: size/L
    l_max_size: 1000
    xl_label: size/XL
    fail_if_xl: false
    message_if_xl: This PR exceeds the recommended size of 1000 lines and will be reviewed at a "best effort" SLO. Please try to  break it up into smaller PRs. 

    github_api_url: api.github.com
    files_to_ignore: deps.bzl go.mod yarn.lock
/usr/bin/docker run --name b[3](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:3)12c[4](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:4)d9eeb11a44fec94f424d60f028290_49a6e4 --label 294b31 --workdir /github/workspace --rm -e INPUT_GITHUB_TOKEN -e INPUT_XS_LABEL -e INPUT_XS_MAX_SIZE -e INPUT_S_LABEL -e INPUT_S_MAX_SIZE -e INPUT_M_LABEL -e INPUT_M_MAX_SIZE -e INPUT_L_LABEL -e INPUT_L_MAX_SIZE -e INPUT_XL_LABEL -e INPUT_FAIL_IF_XL -e INPUT_MESSAGE_IF_XL -e INPUT_GITHUB_API_URL -e INPUT_FILES_TO_IGNORE -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/central/central":"/github/workspace" 294b31:2c4d9eeb11a44fec94f424d60f028290  "--github_token=***" "--github_api_url=api.github.com" "--xs_label=size/XS" "--xs_max_size=10" "--s_label=size/S" "--s_max_size=100" "--m_label=size/M" "--m_max_size=[5](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:5)00" "--l_label=size/L" "--l_max_size=1000" "--xl_label=size/XL" "--fail_if_xl=false" "--message_if_xl=\"This PR exceeds the recommended size of 1000 lines and will be reviewed at a \"best effort\" SLO. Please try to  break it up into smaller PRs. 
\"" "--files_to_ignore=deps.bzl go.mod yarn.lock"
GNU bash, version 5.1.1[6](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:6)(1)-release (x86_64-alpine-linux-musl)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
parse error: Invalid numeric literal at line 1, column 4
BusyBox v1.34.1 (2022-04-04 10:19:2[7](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:7) UTC) multi-call binary.

Usage: basename FILE [SUFFIX]

Strip directory path and .SUFFIX from FILE
parse error: Invalid numeric literal at line 1, column 4
BusyBox v1.34.1 (2022-04-04 10:1[9](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:9):27 UTC) multi-call binary.

Usage: basename FILE [SUFFIX]

Strip directory path and .SUFFIX from FILE
parse error: Invalid numeric literal at line 1, column 4
BusyBox v1.34.1 (2022-04-04 [10](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:10):[19](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:19):27 UTC) multi-call binary.

Usage: basename FILE [SUFFIX]

Strip directory path and .SUFFIX from FILE
parse error: Invalid numeric literal at line 1, column 4
/src/github.sh: line 29: ((: changes += : syntax error: operand expected (error token is "+= ")
parse error: Invalid numeric literal at line 1, column 6
BusyBox v1.34.1 ([20](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:20)[22](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:22)-04-04 10:19:[27](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:27) UTC) multi-call binary.

Usage: basename FILE [SUFFIX]

Strip directory path and .SUFFIX from FILE
parse error: Invalid numeric literal at line 1, column 6
BusyBox v1.34.1 (2022-04-04 10:19:27 UTC) multi-call binary.

Usage: basename FILE [SUFFIX]

Strip directory path and .SUFFIX from FILE
parse error: Invalid numeric literal at line 1, column 6
BusyBox v1.34.1 (2022-04-04 10:19:27 UTC) multi-call binary.

Usage: basename FILE [SUFFIX]

Strip directory path and .SUFFIX from FILE
parse error: Invalid numeric literal at line 1, column 6
/src/github.sh: line [29](https://github.com/VideoAmp/central/runs/6215713526?check_suite_focus=true#step:3:29): ((: changes += : syntax error: operand expected (error token is "+= ")
Total modifications (additions + deletions): 0
Ignoring files (if present): deps.bzl go.mod yarn.lock
Labeling pull request with size/XS
jq: error (at <stdin>:1): Cannot iterate over null (null)
Final labels: "size/XS"
littlebtc commented 2 years ago

We also hit /src/github.sh: line 15: null: unbound variable issue.

In our case, we are working on private repository, and it seems GitHub had somehow changed permission on getting the PR information with the GitHub Actions GITHUB_TOKEN, since printing the result from PR API showed Not Found.

hagayl commented 2 years ago

Also seeing the error

parse error: Invalid numeric literal at line 1, column 4
Final labels: "size/xs"

But no label appears

morey-tech commented 2 years ago

I was running into this issue, specifically:

parse error: Invalid numeric literal at line 1, column 4
/src/github.sh: line 29: ((: changes += : syntax error: operand expected (error token is "+= ")
parse error: Invalid numeric literal at line 1, column 6

Omitting the github_api_url parameter fixed it (thanks to https://github.com/CodelyTV/pr-size-labeler/issues/27#issuecomment-1102806189 for sharing their experience).

labeler.yml ``` name: labeler on: [pull_request] jobs: labeler: runs-on: ubuntu-latest name: Label the PR size steps: - uses: codelytv/pr-size-labeler@v1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} xs_label: 'size/xs' xs_max_size: '10' s_label: 'size/s' s_max_size: '100' m_label: 'size/m' m_max_size: '500' l_label: 'size/l' l_max_size: '1000' xl_label: 'size/xl' fail_if_xl: 'false' message_if_xl: > This PR exceeds the recommended max size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. files_to_ignore: 'package-lock.json' ```
AlmogBaku commented 1 year ago

In my case-

  1. I don't have the github_api_url parameter
  2. Doesn't get any exception/relevant-log
bhack commented 1 year ago

As we redirect all to /dev/null it is hard to debug: https://github.com/CodelyTV/pr-size-labeler/blob/54ef36785e9f4cb5ecf1949cfc9b00dbb621d761/src/github.sh#L59

AlmogBaku commented 1 year ago

adding permission to the issues, as specified in #47, actually solved my issue!

dbelyaev commented 1 year ago

@rgomezcasas This issue has been fixed and works fine in the latest available version (v1.8.1) -- can be closed.