Merge pull request #12730 from strapi/chore/update-label-checker

Update label checker to use pr: instead of issue-type
This commit is contained in:
Alexandre BODIN 2022-03-03 12:03:24 +01:00 committed by GitHub
commit 50733c4f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -29,7 +29,7 @@ test('Test missing source label', async () => {
github.context = {
payload: {
pull_request: {
labels: [{ name: 'issue-type: enhancement' }],
labels: [{ name: 'pr: enhancement' }],
},
},
};
@ -48,7 +48,7 @@ test('Test too many source label', async () => {
github.context = {
payload: {
pull_request: {
labels: [{ name: 'source: a' }, { name: 'source: b' }, { name: 'issue-type: enhancement' }],
labels: [{ name: 'source: a' }, { name: 'source: b' }, { name: 'pr: enhancement' }],
},
},
};
@ -63,7 +63,7 @@ test('Test too many source label', async () => {
setFailed.mockRestore();
});
test('Test missing issue-type label', async () => {
test('Test missing pr label', async () => {
github.context = {
payload: {
pull_request: {
@ -77,16 +77,16 @@ test('Test missing issue-type label', async () => {
await action();
expect(setFailed).toHaveBeenCalled();
expect(setFailed.mock.calls[0][0]).toBe(`The PR must have one and only one 'issue-type:' label.`);
expect(setFailed.mock.calls[0][0]).toBe(`The PR must have one and only one 'pr:' label.`);
setFailed.mockRestore();
});
test('Test too many issue-type label', async () => {
test('Test too many pr label', async () => {
github.context = {
payload: {
pull_request: {
labels: [{ name: 'issue-type: a' }, { name: 'issue-type: b' }, { name: 'source: core' }],
labels: [{ name: 'pr: a' }, { name: 'pr: b' }, { name: 'source: core' }],
},
},
};
@ -96,7 +96,7 @@ test('Test too many issue-type label', async () => {
await action();
expect(setFailed).toHaveBeenCalled();
expect(setFailed.mock.calls[0][0]).toBe(`The PR must have one and only one 'issue-type:' label.`);
expect(setFailed.mock.calls[0][0]).toBe(`The PR must have one and only one 'pr:' label.`);
setFailed.mockRestore();
});

File diff suppressed because one or more lines are too long

View File

@ -20,14 +20,14 @@ async function main() {
}
const sourceLabelCount = labels.filter(label => label.name.startsWith('source: ')).length;
const issueLabelCount = labels.filter(label => label.name.startsWith('issue-type: ')).length;
const issueLabelCount = labels.filter(label => label.name.startsWith('pr: ')).length;
if (sourceLabelCount !== 1) {
core.setFailed(`The PR must have one and only one 'source:' label.`);
}
if (issueLabelCount !== 1) {
core.setFailed(`The PR must have one and only one 'issue-type:' label.`);
core.setFailed(`The PR must have one and only one 'pr:' label.`);
}
// NOTE: to avoid manual work, this is commented until we can set the workflow to trigger on pull_request milestone changes.