Skip to content
Merged
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
26 changes: 24 additions & 2 deletions .github/actions/pr-sizer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ inputs:
description: 'Label for extra large PRs'
required: false
default: 'size/xl'
xl_max_size:
description: 'Maximum number of lines changed for XL'
required: false
default: '10000'
xxl_label:
description: 'Label for extra extra large PRs'
required: false
default: 'size/xxl'
fail_if_xl:
description: 'Fail the action if the PR is XL'
required: false
default: 'false'
fail_if_xxl:
description: 'Fail the action if the PR is XXL'
required: false
default: 'false'
files_to_ignore:
description: 'Files to ignore (newline or space separated)'
required: false
Expand Down Expand Up @@ -75,7 +87,10 @@ runs:
const l_label = '${{ inputs.l_label }}';
const l_max_size = parseInt('${{ inputs.l_max_size }}');
const xl_label = '${{ inputs.xl_label }}';
const xl_max_size = parseInt('${{ inputs.xl_max_size }}');
const xxl_label = '${{ inputs.xxl_label }}';
const fail_if_xl = '${{ inputs.fail_if_xl }}' === 'true';
const fail_if_xxl = '${{ inputs.fail_if_xxl }}' === 'true';
const ignore_line_deletions = '${{ inputs.ignore_line_deletions }}' === 'true';
const ignore_file_deletions = '${{ inputs.ignore_file_deletions }}' === 'true';

Expand Down Expand Up @@ -140,14 +155,16 @@ runs:
newLabel = m_label;
} else if (totalChanges <= l_max_size) {
newLabel = l_label;
} else {
} else if (totalChanges <= xl_max_size) {
newLabel = xl_label;
} else {
newLabel = xxl_label;
}

console.log(`Assigning label: ${newLabel}`);

// Get all size labels
const allSizeLabels = [xs_label, s_label, m_label, l_label, xl_label];
const allSizeLabels = [xs_label, s_label, m_label, l_label, xl_label, xxl_label];

// Get current labels on the PR
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
Expand Down Expand Up @@ -190,3 +207,8 @@ runs:
if (newLabel === xl_label && fail_if_xl) {
core.setFailed(`PR is too large (${totalChanges} changes). Please consider breaking it up into smaller PRs.`);
}

// Fail if XXL and configured to do so
if (newLabel === xxl_label && fail_if_xxl) {
core.setFailed(`PR is too large (${totalChanges} changes). Please consider breaking it up into smaller PRs.`);
}
6 changes: 3 additions & 3 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ pull_request_rules:
- workflow: test.yml
ref: "{{ head }}"

- name: Comment when size/xl label is added
- name: Comment when size/xxl label is added
conditions:
- label=size/xl
- label=size/xxl
actions:
comment:
message: |
> [!WARNING]
> #### This PR exceeds the recommended limit of 1,000 lines.
> #### This PR exceeds the recommended limit of 10,000 lines.
>
> Large PRs are difficult to review and may be rejected due to their size.
>
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/pr-size-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ jobs:
s_label: "size/s"
s_max_size: "100"
m_label: "size/m"
m_max_size: "500"
m_max_size: "1000"
l_label: "size/l"
l_max_size: "1000"
l_max_size: "5000"
xl_label: "size/xl"
xl_max_size: "10000"
xxl_label: "size/xxl"
fail_if_xl: "false"
fail_if_xxl: "false"
files_to_ignore: |
package-lock.json
yarn.lock
Expand Down
Loading