Skip to content
This repository was archived by the owner on May 15, 2021. It is now read-only.

Commit 343de70

Browse files
chore: code formattings
1 parent d16b1e1 commit 343de70

11 files changed

+323
-328
lines changed

__tests__/fixtures/workflow-run.get.error.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642",
1111
"html_url": "https://github.com/octo-org/octo-repo/actions/runs/30433642",
1212
"pull_requests": [
13-
1413
],
1514
"created_at": "2020-01-22T19:33:08Z",
1615
"updated_at": "2020-01-22T19:33:08Z",

__tests__/fixtures/workflow-run.get.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642",
1111
"html_url": "https://github.com/octo-org/octo-repo/actions/runs/30433642",
1212
"pull_requests": [
13-
1413
],
1514
"created_at": "2020-01-22T19:33:08Z",
1615
"updated_at": "2020-01-22T19:33:08Z",

__tests__/fixtures/workflow-run.list.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642",
1414
"html_url": "https://github.com/octo-org/octo-repo/actions/runs/30433642",
1515
"pull_requests": [
16-
1716
],
1817
"created_at": "2020-01-22T19:33:08Z",
1918
"updated_at": "2020-01-22T19:33:08Z",
@@ -186,7 +185,6 @@
186185
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433643",
187186
"html_url": "https://github.com/octo-org/octo-repo/actions/runs/30433643",
188187
"pull_requests": [
189-
190188
],
191189
"created_at": "2020-01-23T19:33:08Z",
192190
"updated_at": "2020-01-23T19:33:08Z",
@@ -359,7 +357,6 @@
359357
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433644",
360358
"html_url": "https://github.com/octo-org/octo-repo/actions/runs/30433644",
361359
"pull_requests": [
362-
363360
],
364361
"created_at": "2020-01-24T19:33:08Z",
365362
"updated_at": "2020-01-24T19:33:08Z",
@@ -532,7 +529,6 @@
532529
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433645",
533530
"html_url": "https://github.com/octo-org/octo-repo/actions/runs/30433645",
534531
"pull_requests": [
535-
536532
],
537533
"created_at": "2020-01-24T19:33:08Z",
538534
"updated_at": "2020-01-24T19:33:08Z",

__tests__/process.test.ts

Lines changed: 127 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import { resolve } from 'path';
33
import nock from 'nock';
44
import {
5-
testEnv,
6-
spyOnStdout,
7-
getOctokit,
8-
generateContext,
9-
stdoutCalledWith,
10-
disableNetConnect,
11-
getApiFixture,
5+
testEnv,
6+
spyOnStdout,
7+
getOctokit,
8+
generateContext,
9+
stdoutCalledWith,
10+
disableNetConnect,
11+
getApiFixture,
1212
} from '@technote-space/github-action-test-helper';
1313
import { Logger } from '@technote-space/github-action-helper';
1414
import { execute } from '../src/process';
@@ -17,127 +17,127 @@ const rootDir = resolve(__dirname, '..');
1717
const fixturesDir = resolve(__dirname, 'fixtures');
1818

1919
beforeEach(() => {
20-
Logger.resetForTesting();
20+
Logger.resetForTesting();
2121
});
2222

2323
describe('execute', () => {
24-
disableNetConnect(nock);
25-
testEnv(rootDir);
26-
27-
it('should do nothing 1', async() => {
28-
process.env.INPUT_EXCLUDE_MERGED = 'true';
29-
30-
const mockStdout = spyOnStdout();
31-
32-
await execute(new Logger(), getOctokit(), generateContext({owner: 'hello', repo: 'world', event: 'push'}, {
33-
payload: {
34-
'head_commit': {
35-
message: 'Merge pull request #260 from test',
36-
},
37-
},
38-
}));
39-
40-
stdoutCalledWith(mockStdout, [
41-
'> This is not target context.',
42-
]);
43-
});
44-
45-
it('should do nothing 2', async() => {
46-
process.env.GITHUB_RUN_ID = '123';
47-
48-
const mockStdout = spyOnStdout();
49-
nock('https://api.github.com')
50-
.get('/repos/hello/world/actions/runs/123')
51-
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.get'))
52-
.get('/repos/hello/world/actions/workflows/30433642/runs?status=in_progress&branch=release%2Fv1.2.3&event=pull_request')
53-
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.list'));
54-
55-
await execute(new Logger(), getOctokit(), generateContext({owner: 'hello', repo: 'world', event: 'pull_request'}, {
56-
payload: {
57-
'pull_request': {
58-
head: {
59-
ref: 'release/v1.2.3',
60-
},
61-
},
62-
},
63-
}));
64-
65-
stdoutCalledWith(mockStdout, [
66-
'> run id: 123',
67-
'> workflow id: 30433642',
68-
'target event: \x1b[32;40;0mpull_request\x1b[0m',
69-
'target branch: \x1b[32;40;0mrelease/v1.2.3\x1b[0m',
70-
'',
71-
'> \x1b[33;40;0mcurrent run not found\x1b[0m',
72-
]);
73-
});
74-
75-
it('should do nothing 3', async() => {
76-
process.env.GITHUB_RUN_ID = '30433643';
77-
78-
const mockStdout = spyOnStdout();
79-
nock('https://api.github.com')
80-
.get('/repos/hello/world/actions/runs/30433643')
81-
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.get'))
82-
.get('/repos/hello/world/actions/workflows/30433642/runs?status=in_progress&branch=release%2Fv1.2.3&event=pull_request')
83-
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.list'));
84-
85-
await execute(new Logger(), getOctokit(), generateContext({owner: 'hello', repo: 'world', event: 'pull_request'}, {
86-
payload: {
87-
'pull_request': {
88-
head: {
89-
ref: 'release/v1.2.3',
90-
},
91-
},
92-
},
93-
}));
94-
95-
stdoutCalledWith(mockStdout, [
96-
'> run id: 30433643',
97-
'> workflow id: 30433642',
98-
'target event: \x1b[32;40;0mpull_request\x1b[0m',
99-
'target branch: \x1b[32;40;0mrelease/v1.2.3\x1b[0m',
100-
'',
101-
'> \x1b[33;40;0mnewer job exists\x1b[0m',
102-
]);
103-
});
104-
105-
it('should cancel jobs', async() => {
106-
process.env.INPUT_EXCLUDE_MERGED = 'true';
107-
process.env.GITHUB_RUN_ID = '30433645';
108-
109-
const mockStdout = spyOnStdout();
110-
nock('https://api.github.com')
111-
.get('/repos/hello/world/actions/runs/30433645')
112-
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.get'))
113-
.get('/repos/hello/world/actions/workflows/30433642/runs?status=in_progress&branch=release%2Fv1.2.3&event=pull_request')
114-
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.list'))
115-
.post('/repos/hello/world/actions/runs/30433643/cancel')
116-
.reply(202)
117-
.post('/repos/hello/world/actions/runs/30433642/cancel')
118-
.reply(202);
119-
120-
await execute(new Logger(), getOctokit(), generateContext({owner: 'hello', repo: 'world', event: 'pull_request'}, {
121-
payload: {
122-
'pull_request': {
123-
head: {
124-
ref: 'release/v1.2.3',
125-
},
126-
},
127-
},
128-
}));
129-
130-
stdoutCalledWith(mockStdout, [
131-
'> run id: 30433645',
132-
'> workflow id: 30433642',
133-
'target event: \x1b[32;40;0mpull_request\x1b[0m',
134-
'target branch: \x1b[32;40;0mrelease/v1.2.3\x1b[0m',
135-
'',
136-
'::group::Cancelling...',
137-
'cancel: 30433642',
138-
'cancel: 30433643',
139-
'> total: 2',
140-
'::endgroup::',
141-
]);
142-
});
24+
disableNetConnect(nock);
25+
testEnv(rootDir);
26+
27+
it('should do nothing 1', async() => {
28+
process.env.INPUT_EXCLUDE_MERGED = 'true';
29+
30+
const mockStdout = spyOnStdout();
31+
32+
await execute(new Logger(), getOctokit(), generateContext({owner: 'hello', repo: 'world', event: 'push'}, {
33+
payload: {
34+
'head_commit': {
35+
message: 'Merge pull request #260 from test',
36+
},
37+
},
38+
}));
39+
40+
stdoutCalledWith(mockStdout, [
41+
'> This is not target context.',
42+
]);
43+
});
44+
45+
it('should do nothing 2', async() => {
46+
process.env.GITHUB_RUN_ID = '123';
47+
48+
const mockStdout = spyOnStdout();
49+
nock('https://api.github.com')
50+
.get('/repos/hello/world/actions/runs/123')
51+
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.get'))
52+
.get('/repos/hello/world/actions/workflows/30433642/runs?status=in_progress&branch=release%2Fv1.2.3&event=pull_request')
53+
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.list'));
54+
55+
await execute(new Logger(), getOctokit(), generateContext({owner: 'hello', repo: 'world', event: 'pull_request'}, {
56+
payload: {
57+
'pull_request': {
58+
head: {
59+
ref: 'release/v1.2.3',
60+
},
61+
},
62+
},
63+
}));
64+
65+
stdoutCalledWith(mockStdout, [
66+
'> run id: 123',
67+
'> workflow id: 30433642',
68+
'target event: \x1b[32;40;0mpull_request\x1b[0m',
69+
'target branch: \x1b[32;40;0mrelease/v1.2.3\x1b[0m',
70+
'',
71+
'> \x1b[33;40;0mcurrent run not found\x1b[0m',
72+
]);
73+
});
74+
75+
it('should do nothing 3', async() => {
76+
process.env.GITHUB_RUN_ID = '30433643';
77+
78+
const mockStdout = spyOnStdout();
79+
nock('https://api.github.com')
80+
.get('/repos/hello/world/actions/runs/30433643')
81+
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.get'))
82+
.get('/repos/hello/world/actions/workflows/30433642/runs?status=in_progress&branch=release%2Fv1.2.3&event=pull_request')
83+
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.list'));
84+
85+
await execute(new Logger(), getOctokit(), generateContext({owner: 'hello', repo: 'world', event: 'pull_request'}, {
86+
payload: {
87+
'pull_request': {
88+
head: {
89+
ref: 'release/v1.2.3',
90+
},
91+
},
92+
},
93+
}));
94+
95+
stdoutCalledWith(mockStdout, [
96+
'> run id: 30433643',
97+
'> workflow id: 30433642',
98+
'target event: \x1b[32;40;0mpull_request\x1b[0m',
99+
'target branch: \x1b[32;40;0mrelease/v1.2.3\x1b[0m',
100+
'',
101+
'> \x1b[33;40;0mnewer job exists\x1b[0m',
102+
]);
103+
});
104+
105+
it('should cancel jobs', async() => {
106+
process.env.INPUT_EXCLUDE_MERGED = 'true';
107+
process.env.GITHUB_RUN_ID = '30433645';
108+
109+
const mockStdout = spyOnStdout();
110+
nock('https://api.github.com')
111+
.get('/repos/hello/world/actions/runs/30433645')
112+
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.get'))
113+
.get('/repos/hello/world/actions/workflows/30433642/runs?status=in_progress&branch=release%2Fv1.2.3&event=pull_request')
114+
.reply(200, () => getApiFixture(fixturesDir, 'workflow-run.list'))
115+
.post('/repos/hello/world/actions/runs/30433643/cancel')
116+
.reply(202)
117+
.post('/repos/hello/world/actions/runs/30433642/cancel')
118+
.reply(202);
119+
120+
await execute(new Logger(), getOctokit(), generateContext({owner: 'hello', repo: 'world', event: 'pull_request'}, {
121+
payload: {
122+
'pull_request': {
123+
head: {
124+
ref: 'release/v1.2.3',
125+
},
126+
},
127+
},
128+
}));
129+
130+
stdoutCalledWith(mockStdout, [
131+
'> run id: 30433645',
132+
'> workflow id: 30433642',
133+
'target event: \x1b[32;40;0mpull_request\x1b[0m',
134+
'target branch: \x1b[32;40;0mrelease/v1.2.3\x1b[0m',
135+
'',
136+
'::group::Cancelling...',
137+
'cancel: 30433642',
138+
'cancel: 30433643',
139+
'> total: 2',
140+
'::endgroup::',
141+
]);
142+
});
143143
});

0 commit comments

Comments
 (0)