Skip to content
This repository was archived by the owner on Jan 22, 2022. It is now read-only.

Commit 007901a

Browse files
committed
Automatically label DISABLED issues with skipped
1 parent a488212 commit 007901a

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/auto-label-bot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as probot from 'probot';
22

3-
const regexToLabel: [RegExp, string][] = [[/rocm/gi, 'module: rocm']];
3+
const regexToLabel: [RegExp, string][] = [[/rocm/gi, 'module: rocm'], [/DISABLED\s+test.*\(.*\)/g, 'skipped']];
44

55
function myBot(app: probot.Application): void {
66
function addLabel(

test/auto-label-bot.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,49 @@ describe('auto-label-bot', () => {
8181

8282
scope.done();
8383
});
84+
85+
test('add skipped label when issue title contains DISABLED test', async () => {
86+
nock('https://api.github.com')
87+
.post('/app/installations/2/access_tokens')
88+
.reply(200, {token: 'test'});
89+
90+
const payload = require('./fixtures/issues.opened');
91+
payload['issue']['title'] = 'DISABLED test_blah (__main__.TestClass)';
92+
payload['issue']['labels'] = [];
93+
94+
const scope = nock('https://api.github.com')
95+
.post(
96+
'/repos/ezyang/testing-ideal-computing-machine/issues/5/labels',
97+
body => {
98+
expect(body).toMatchObject(['skipped']);
99+
return true;
100+
}
101+
)
102+
.reply(200);
103+
104+
await probot.receive({name: 'issues', payload: payload, id: '2'});
105+
106+
scope.done();
107+
});
108+
109+
test('add skipped label when PR title contains DISABLED test', async () => {
110+
nock('https://api.github.com')
111+
.post('/app/installations/2/access_tokens')
112+
.reply(200, {token: 'test'});
113+
114+
const payload = require('./fixtures/pull_request.opened')['payload'];
115+
payload['pull_request']['title'] = 'DISABLED test_blah (__main__.TestClass)';
116+
payload['pull_request']['labels'] = [];
117+
118+
const scope = nock('https://api.github.com')
119+
.post('/repos/zhouzhuojie/gha-ci-playground/issues/31/labels', body => {
120+
expect(body).toMatchObject(['skipped']);
121+
return true;
122+
})
123+
.reply(200);
124+
125+
await probot.receive({name: 'pull_request', payload: payload, id: '2'});
126+
127+
scope.done();
128+
});
84129
});

0 commit comments

Comments
 (0)