-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathrelease_notes_test.ts
218 lines (204 loc) · 6.59 KB
/
release_notes_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env node
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
import * as util from './util';
import {OctokitGetCommit, RepoCommits} from './util';
const fakeCommitContributors: {[key: string]: string;} = {
'sha1': 'fakecontributor1',
'sha2': 'fakecontributor2',
'sha3': 'fakecontributor3'
};
const missingAuthorLoginFake = {
name: 'example',
email: 'example@example.com'
};
const fakeOctokit: OctokitGetCommit = {
repos: {
getCommit: (config: {owner: string, repo: string, sha: string}) => {
return {
data: {
author: {
login: fakeCommitContributors[config.sha],
},
commit: {
author: {
name: missingAuthorLoginFake.name,
email: missingAuthorLoginFake.email
}
}
}
};
}
}
};
describe('getReleaseNotesDraft', () => {
it('Basic draft written', done => {
const repoCommits: RepoCommits[] = [{
repo: {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'},
startVersion: '0.9.0',
endVersion: '0.10.0',
startCommit: 'fakecommit',
commits: [{
subject: 'Add tf.toPixels. (#900)',
body: `
tf.toPixels is the inverse of tf.fromPixels.
FEATURE
`,
authorEmail: 'test@google.com',
sha: 'sha1'
}]
}];
util.getReleaseNotesDraft(fakeOctokit, repoCommits).then(notes => {
expect(notes).toEqual([
'## Core (0.9.0 ==> 0.10.0)', '', '### Features',
'- Add tf.toPixels. ([#900]' +
'(https://github.com/tensorflow/tfjs/pull/900)).'
].join('\n'));
done();
});
});
it('Basic draft external contributor thanks them', done => {
const repoCommits: RepoCommits[] = [{
repo: {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'},
startVersion: '0.9.0',
endVersion: '0.10.0',
startCommit: 'fakecommit',
commits: [{
subject: 'Add tf.toPixels. (#900)',
body: `
tf.toPixels is the inverse of tf.fromPixels.
FEATURE
`,
authorEmail: 'test@gmail.com',
sha: 'sha1'
}]
}];
util.getReleaseNotesDraft(fakeOctokit, repoCommits).then(notes => {
expect(notes).toEqual([
'## Core (0.9.0 ==> 0.10.0)', '', '### Features',
'- Add tf.toPixels. ([#900]' +
'(https://github.com/tensorflow/tfjs/pull/900)).' +
' Thanks, @fakecontributor1.'
].join('\n'));
done();
});
});
it('Complex draft', done => {
const repoCommits: RepoCommits[] = [
{
repo: {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'},
startVersion: '0.9.0',
endVersion: '0.10.0',
startCommit: 'fakecommit',
commits: [
{
subject: 'Add tf.toPixels. (#900)',
body: `
tf.toPixels is the inverse of tf.fromPixels.
`,
authorEmail: 'test@gmail.com',
sha: 'sha1'
},
{
subject: 'Improvements to matMul. (#901)',
body: `
Makes matmul better overall.
FEATURE Adds transpose bit.
PERF Improves speed of matMul by 100%.
`,
authorEmail: 'test@gmail.com',
sha: 'sha2'
}
]
},
{
repo: {name: 'Layers', identifier: 'tfjs', path: 'tfjs-layers'},
startVersion: '0.4.0',
endVersion: '0.5.1',
startCommit: 'fakecommit2',
commits: [{
subject: 'Change API of layers. (#100)',
body: `
tf.toPixels is the inverse of tf.fromPixels.
BREAKING
DOC Update docstrings of tf.layers.dense.
FEATURE Add automatic argument parsing.
`,
authorEmail: 'test@gmail.com',
sha: 'sha1'
}]
}
];
util.getReleaseNotesDraft(fakeOctokit, repoCommits).then(notes => {
expect(notes).toEqual([
'## Core (0.9.0 ==> 0.10.0)',
'',
'### Features',
'- Adds transpose bit. [Improvements to matMul.] ([#901]' +
'(https://github.com/tensorflow/tfjs/pull/901)).' +
' Thanks, @fakecontributor2.',
'### Performance',
'- Improves speed of matMul by 100%. [Improvements to matMul.]' +
' ([#901](https://github.com/tensorflow/tfjs/pull/901)).' +
' Thanks, @fakecontributor2.',
'### Misc',
'- Add tf.toPixels. ([#900]' +
'(https://github.com/tensorflow/tfjs/pull/900)).' +
' Thanks, @fakecontributor1.',
'',
'## Layers (0.4.0 ==> 0.5.1)',
'',
'### Features',
'- Add automatic argument parsing. [Change API of layers.] ' +
'([#100](https://github.com/tensorflow/tfjs/pull/100)).' +
' Thanks, @fakecontributor1.',
'### Breaking changes',
'- Change API of layers. ' +
'([#100](https://github.com/tensorflow/tfjs/pull/100)).' +
' Thanks, @fakecontributor1.',
'### Documentation',
'- Update docstrings of tf.layers.dense. [Change API of layers.] ' +
'([#100](https://github.com/tensorflow/tfjs/pull/100)).' +
' Thanks, @fakecontributor1.',
].join('\n'));
done();
});
});
it('Subject has no pull request number', done => {
const repoCommits: RepoCommits[] = [{
repo: {name: 'Core', identifier: 'tfjs', path: 'tfjs-core'},
startVersion: '0.9.0',
endVersion: '0.10.0',
startCommit: 'fakecommit',
commits: [{
subject: 'Add tf.toPixels.',
body: `
tf.toPixels is the inverse of tf.fromPixels.
FEATURE
`,
authorEmail: 'test@google.com',
sha: 'sha1'
}]
}];
util.getReleaseNotesDraft(fakeOctokit, repoCommits).then(notes => {
expect(notes).toEqual([
'## Core (0.9.0 ==> 0.10.0)', '', '### Features', '- Add tf.toPixels.'
].join('\n'));
done();
});
});
});