|
19 | 19 | '--path-to-changelog' => __DIR__ . '/../Stubs/base-changelog.md', |
20 | 20 | '--release-date' => '2021-02-01', |
21 | 21 | ]) |
22 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog.md')) |
23 | | - ->assertSuccessful(); |
| 22 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog.md')) |
| 23 | + ->assertSuccessful(); |
24 | 24 | }); |
25 | 25 |
|
26 | 26 | it('outputs RELEASE_COMPARE_URL and UNRELEASED_COMPARE_URL for GitHub Actions in CI environment', function () { |
|
41 | 41 | '--release-date' => '2021-02-01', |
42 | 42 | '--github-actions-output' => true, |
43 | 43 | ]) |
44 | | - ->expectsOutputToContain(sprintf("::set-output name=%s::%s", 'RELEASE_COMPARE_URL', 'https://github.com/org/repo/compare/v0.1.0...v1.0.0')) |
45 | | - ->expectsOutputToContain(sprintf("::set-output name=%s::%s", 'RELEASE_URL_FRAGMENT', '#v100---2021-02-01')) |
46 | | - ->expectsOutputToContain(sprintf("::set-output name=%s::%s", 'UNRELEASED_COMPARE_URL', 'https://github.com/org/repo/compare/v1.0.0...HEAD')) |
47 | | - ->assertSuccessful(); |
| 44 | + ->expectsOutputToContain(sprintf("::set-output name=%s::%s", 'RELEASE_COMPARE_URL', 'https://github.com/org/repo/compare/v0.1.0...v1.0.0')) |
| 45 | + ->expectsOutputToContain(sprintf("::set-output name=%s::%s", 'RELEASE_URL_FRAGMENT', '#v100---2021-02-01')) |
| 46 | + ->expectsOutputToContain(sprintf("::set-output name=%s::%s", 'UNRELEASED_COMPARE_URL', 'https://github.com/org/repo/compare/v1.0.0...HEAD')) |
| 47 | + ->assertSuccessful(); |
| 48 | +})->skip(function () { |
| 49 | + return now()->year > 2022; |
| 50 | +}); |
| 51 | + |
| 52 | +it('outputs RELEASE_COMPARE_URL and UNRELEASED_COMPARE_URL to GITHUB_OUTPUT environment', function () { |
| 53 | + $this->artisan('update', [ |
| 54 | + '--release-notes' => <<<MD |
| 55 | + ### Added |
| 56 | + - New Feature A |
| 57 | + - New Feature B |
| 58 | +
|
| 59 | + ### Changed |
| 60 | + - Update Feature C |
| 61 | +
|
| 62 | + ### Removes |
| 63 | + - Remove Feature D |
| 64 | + MD, |
| 65 | + '--latest-version' => 'v1.0.0', |
| 66 | + '--path-to-changelog' => __DIR__ . '/../Stubs/base-changelog.md', |
| 67 | + '--release-date' => '2021-02-01', |
| 68 | + '--github-actions-output' => true, |
| 69 | + ])->assertSuccessful(); |
| 70 | + |
| 71 | + $this->assertGitHubOutputContains('RELEASE_COMPARE_URL', 'https://github.com/org/repo/compare/v0.1.0...v1.0.0'); |
| 72 | + $this->assertGitHubOutputContains('RELEASE_URL_FRAGMENT', '#v100---2021-02-01'); |
| 73 | + $this->assertGitHubOutputContains('UNRELEASED_COMPARE_URL', 'https://github.com/org/repo/compare/v1.0.0...HEAD'); |
48 | 74 | }); |
49 | 75 |
|
50 | 76 | it('throws error if latest-version is missing', function () { |
51 | 77 | $this->artisan('update', [ |
52 | 78 | '--release-notes' => '::release-notes::', |
53 | | - ]) |
54 | | - ->assertFailed(); |
| 79 | + ]) |
| 80 | + ->assertFailed(); |
55 | 81 | })->throws(InvalidArgumentException::class, 'No latest-version option provided. Abort.'); |
56 | 82 |
|
57 | 83 | it('uses current date for release date if no option is provieded', function () { |
|
73 | 99 | '--latest-version' => 'v1.0.0', |
74 | 100 | '--path-to-changelog' => __DIR__ . '/../Stubs/base-changelog.md', |
75 | 101 | ]) |
76 | | - ->expectsOutput($expectedOutput) |
77 | | - ->assertSuccessful(); |
| 102 | + ->expectsOutput($expectedOutput) |
| 103 | + ->assertSuccessful(); |
78 | 104 | }); |
79 | 105 |
|
80 | 106 | it('uses current date for release date if option is empty', function () { |
|
97 | 123 | '--path-to-changelog' => __DIR__ . '/../Stubs/base-changelog.md', |
98 | 124 | '--release-date' => '', |
99 | 125 | ]) |
100 | | - ->expectsOutput($expectedOutput) |
101 | | - ->assertSuccessful(); |
| 126 | + ->expectsOutput($expectedOutput) |
| 127 | + ->assertSuccessful(); |
102 | 128 | }); |
103 | 129 |
|
104 | 130 | it('places given release notes in correct position in given markdown changelog when no unreleased heading is available', function () { |
|
118 | 144 | '--path-to-changelog' => __DIR__ . '/../Stubs/base-changelog-without-unreleased.md', |
119 | 145 | '--release-date' => '2021-02-01', |
120 | 146 | ]) |
121 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-without-unreleased.md')) |
122 | | - ->assertSuccessful(); |
| 147 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-without-unreleased.md')) |
| 148 | + ->assertSuccessful(); |
123 | 149 | }); |
124 | 150 |
|
125 | 151 | it('places given release notes in correct position in given markdown changelog when no heading is available', function () { |
|
139 | 165 | '--path-to-changelog' => __DIR__ . '/../Stubs/base-changelog-without-headings.md', |
140 | 166 | '--release-date' => '2021-02-01', |
141 | 167 | ]) |
142 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-without-headings.md')) |
143 | | - ->assertSuccessful(); |
| 168 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-without-headings.md')) |
| 169 | + ->assertSuccessful(); |
144 | 170 | }); |
145 | 171 |
|
146 | 172 | it('places given release notes in correct position even if changelog is empty besides an unreleased heading', function () { |
|
160 | 186 | '--path-to-changelog' => __DIR__ . '/../Stubs/base-changelog-empty-with-unreleased.md', |
161 | 187 | '--release-date' => '2021-02-01', |
162 | 188 | ]) |
163 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-empty-with-unreleased.md')) |
164 | | - ->assertSuccessful(); |
| 189 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-empty-with-unreleased.md')) |
| 190 | + ->assertSuccessful(); |
165 | 191 | }); |
166 | 192 |
|
167 | 193 | it('uses compare-url-target option in unreleased heading url', function () { |
|
182 | 208 | '--release-date' => '2021-02-01', |
183 | 209 | '--compare-url-target-revision' => '1.x', |
184 | 210 | ]) |
185 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-custom-compare-url-target.md')) |
186 | | - ->assertSuccessful(); |
| 211 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-custom-compare-url-target.md')) |
| 212 | + ->assertSuccessful(); |
187 | 213 | }); |
188 | 214 |
|
189 | 215 | it('shows warning if version already exists in the changelog', function () { |
|
204 | 230 | '--release-date' => '2021-02-01', |
205 | 231 | '--compare-url-target-revision' => '1.x', |
206 | 232 | ]) |
207 | | - ->expectsOutput('CHANGELOG was not updated as release notes for v0.1.0 already exist.') |
208 | | - ->assertSuccessful(); |
| 233 | + ->expectsOutput('CHANGELOG was not updated as release notes for v0.1.0 already exist.') |
| 234 | + ->assertSuccessful(); |
209 | 235 | }); |
210 | 236 |
|
211 | 237 | it('uses existing content between unreleased and previous version heading as release notes if release notes are empty', function () { |
|
216 | 242 | '--release-date' => '2021-02-01', |
217 | 243 | '--compare-url-target-revision' => '1.x', |
218 | 244 | ]) |
219 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-unreleased-notes.md')) |
220 | | - ->assertSuccessful(); |
| 245 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-unreleased-notes.md')) |
| 246 | + ->assertSuccessful(); |
221 | 247 | }); |
222 | 248 |
|
223 | 249 | it('uses existing content between unreleased and previous version heading as release notes if release notes option is not provided', function () { |
|
227 | 253 | '--release-date' => '2021-02-01', |
228 | 254 | '--compare-url-target-revision' => '1.x', |
229 | 255 | ]) |
230 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-unreleased-notes.md')) |
231 | | - ->assertSuccessful(); |
| 256 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-unreleased-notes.md')) |
| 257 | + ->assertSuccessful(); |
232 | 258 | }); |
233 | 259 |
|
234 | 260 | it('nothing happens if no release notes have been given and no unreleased heading can be found', function () { |
|
238 | 264 | '--release-date' => '2021-02-01', |
239 | 265 | '--compare-url-target-revision' => '1.x', |
240 | 266 | ]) |
241 | | - ->expectsOutput('Release Notes were not provided. Pass them through the `--release-notes`-option.') |
242 | | - ->assertFailed(); |
| 267 | + ->expectsOutput('Release Notes were not provided. Pass them through the `--release-notes`-option.') |
| 268 | + ->assertFailed(); |
243 | 269 | }); |
244 | 270 |
|
245 | 271 | test('it shows warning if changelog is empty and content can not be placed', function () { |
|
259 | 285 | '--path-to-changelog' => __DIR__ . '/../Stubs/empty-changelog.md', |
260 | 286 | '--compare-url-target-revision' => 'HEAD', |
261 | 287 | ]) |
262 | | - ->expectsOutput('Release notes could not be placed. Is the CHANGELOG empty? Does it contain at least one heading?') |
263 | | - ->assertFailed(); |
| 288 | + ->expectsOutput('Release notes could not be placed. Is the CHANGELOG empty? Does it contain at least one heading?') |
| 289 | + ->assertFailed(); |
264 | 290 | }); |
265 | 291 |
|
266 | 292 | test('it automatically shifts heading levels to be level 3 headings to fit into the existing changelog', function ($releaseNotes) { |
|
270 | 296 | '--path-to-changelog' => __DIR__ . '/../Stubs/base-changelog.md', |
271 | 297 | '--release-date' => '2021-02-01', |
272 | 298 | ]) |
273 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-shifted-headings.md')) |
274 | | - ->assertSuccessful(); |
| 299 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-shifted-headings.md')) |
| 300 | + ->assertSuccessful(); |
275 | 301 | })->with([ |
276 | 302 | 'starts with h1' => <<<MD |
277 | 303 | # Added |
|
315 | 341 | '--release-date' => '2021-02-01', |
316 | 342 | '--heading-text' => '::heading-text::', |
317 | 343 | ]) |
318 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-heading-text.md')) |
319 | | - ->assertSuccessful(); |
| 344 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-with-heading-text.md')) |
| 345 | + ->assertSuccessful(); |
320 | 346 | }); |
321 | 347 |
|
322 | 348 | it('heading-text option allows user to use different heading text than latest-version when changelog does not contain unreleased heading', function () { |
|
337 | 363 | '--release-date' => '2021-02-01', |
338 | 364 | '--heading-text' => '::heading-text::', |
339 | 365 | ]) |
340 | | - ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-without-unreleased-with-heading-text.md')) |
341 | | - ->assertSuccessful(); |
| 366 | + ->expectsOutput(file_get_contents(__DIR__ . '/../Stubs/expected-changelog-without-unreleased-with-heading-text.md')) |
| 367 | + ->assertSuccessful(); |
342 | 368 | }); |
343 | 369 |
|
344 | 370 | it('allows release date to be in any given format', function () { |
|
0 commit comments