Skip to content

Commit 134ca02

Browse files
authored
fix(scripts): update release PR and process (#554)
1 parent 1deea5f commit 134ca02

File tree

10 files changed

+200
-116
lines changed

10 files changed

+200
-116
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ runs:
7878
shell: bash
7979
run: |
8080
previousCommit=${{ github.event.before }}
81-
baseRef=${{ inputs.workflow_name == 'process-release' && 'main' || github.base_ref }}
81+
baseRef=${{ github.base_ref }}
8282
origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" )
8383
8484
yarn workspace scripts setRunVariables "$origin"

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ jobs:
230230
run: yarn cli cts run ${{ matrix.client.language }}
231231

232232
- name: Zip artifact before storing
233-
run: zip -q -r clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} ${{ matrix.client.testsOutputPath }} -x "${{ matrix.client.path }}/node_modules/.**"
233+
run: zip -r -y clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} ${{ matrix.client.testsOutputPath }} -x "**/node_modules/**" "**/node_modules/.**" "clients/algoliasearch-client-javascript/.yarn/**"
234234

235235
- name: Store ${{ matrix.client.language }} clients
236236
uses: actions/upload-artifact@v3

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"github-actions:lint": "eslint --ext=yml .github/",
2525
"postinstall": "husky install && yarn workspace eslint-plugin-automation-custom build",
2626
"playground:browser": "yarn workspace javascript-browser-playground start",
27-
"release": "yarn workspace scripts createReleaseIssue",
27+
"release": "yarn workspace scripts createReleasePR",
2828
"scripts:lint": "eslint --ext=ts scripts/",
2929
"scripts:test": "yarn workspace scripts test",
3030
"specs:fix": "eslint --ext=yml specs/$0 --fix",

scripts/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export function ensureGitHubToken(): string {
272272
export function getOctokit(): Octokit {
273273
const token = ensureGitHubToken();
274274
return new Octokit({
275-
auth: `token ${token}`,
275+
auth: token,
276276
});
277277
}
278278

scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scripts": {
55
"cleanGeneratedBranch": "ts-node ci/codegen/cleanGeneratedBranch.ts",
66
"createMatrix": "ts-node ci/githubActions/createMatrix.ts",
7-
"createReleaseIssue": "ts-node release/create-release-issue.ts",
7+
"createReleasePR": "ts-node release/createReleasePR.ts",
88
"pre-commit": "./ci/husky/pre-commit.js",
99
"pushGeneratedCode": "ts-node ci/codegen/pushGeneratedCode.ts",
1010
"renovateWeeklyPR": "ts-node ci/githubActions/renovateWeeklyPR.ts",

scripts/release/__tests__/create-release-issue.test.ts renamed to scripts/release/__tests__/createReleasePR.test.ts

Lines changed: 126 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
getSkippedCommitsText,
66
decideReleaseStrategy,
77
readVersions,
8-
} from '../create-release-issue';
8+
} from '../createReleasePR';
99

10-
describe('create release issue', () => {
10+
describe('createReleasePR', () => {
1111
it('reads versions of the current language', () => {
1212
expect(readVersions()).toEqual({
1313
java: {
@@ -92,10 +92,10 @@ describe('create release issue', () => {
9292
},
9393
})
9494
).toMatchInlineSnapshot(`
95-
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
96-
- java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
97-
- php: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**"
98-
`);
95+
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
96+
- java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
97+
- php: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**"
98+
`);
9999
});
100100

101101
it('generates text for version changes with a language with no commit', () => {
@@ -118,10 +118,10 @@ describe('create release issue', () => {
118118
},
119119
})
120120
).toMatchInlineSnapshot(`
121-
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
122-
- java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
123-
- ~php: 0.0.1 (no commit)~"
124-
`);
121+
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
122+
- java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
123+
- ~php: 0.0.1 (no commit)~"
124+
`);
125125
});
126126

127127
it('generates text for version changes with a language to skip', () => {
@@ -144,11 +144,11 @@ describe('create release issue', () => {
144144
},
145145
})
146146
).toMatchInlineSnapshot(`
147-
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
148-
- ~java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**~
149-
- No \`feat\` or \`fix\` commit, thus unchecked by default.
150-
- php: 0.0.1 -> **\`minor\` _(e.g. 0.1.0)_**"
151-
`);
147+
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
148+
- ~java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**~
149+
- No \`feat\` or \`fix\` commit, thus unchecked by default.
150+
- php: 0.0.1 -> **\`minor\` _(e.g. 0.1.0)_**"
151+
`);
152152
});
153153
});
154154

@@ -363,47 +363,117 @@ describe('create release issue', () => {
363363
});
364364
});
365365

366-
it('generates text for skipped commits', () => {
367-
expect(
368-
getSkippedCommitsText({
369-
commitsWithoutLanguageScope: [],
370-
commitsWithUnknownLanguageScope: [],
371-
})
372-
).toMatchInlineSnapshot(`"_(None)_"`);
373-
374-
expect(
375-
getSkippedCommitsText({
376-
commitsWithoutLanguageScope: [
377-
'abcdefg fix: something',
378-
'abcdefg fix: somethin2',
379-
],
366+
describe('getSkippedCommitsText', () => {
367+
it('does not generate text if there is no commits', () => {
368+
expect(
369+
getSkippedCommitsText({
370+
commitsWithoutLanguageScope: [],
371+
commitsWithUnknownLanguageScope: [],
372+
})
373+
).toMatchInlineSnapshot(`"_(None)_"`);
374+
});
380375

381-
commitsWithUnknownLanguageScope: [
382-
'abcdef2 fix(pascal): what',
383-
'abcdef2 fix(pascal): what is that',
384-
],
385-
})
386-
).toMatchInlineSnapshot(`
387-
"</p>
388-
<p>It doesn't mean these commits are being excluded from the release. It means they're not taken into account when the release process figured out the next version number, and updated the changelog.</p>
389-
390-
<details>
391-
<summary>
392-
<i>Commits without language scope:</i>
393-
</summary>
394-
395-
- abcdefg fix: something
396-
- abcdefg fix: somethin2
397-
</details>
398-
399-
<details>
400-
<summary>
401-
<i>Commits with unknown language scope:</i>
402-
</summary>
403-
404-
- abcdef2 fix(pascal): what
405-
- abcdef2 fix(pascal): what is that
406-
</details>"
407-
`);
376+
it('generates text for skipped commits', () => {
377+
expect(
378+
getSkippedCommitsText({
379+
commitsWithoutLanguageScope: [
380+
'abcdefg fix: something',
381+
'abcdefg fix: somethin2',
382+
],
383+
384+
commitsWithUnknownLanguageScope: [
385+
'abcdef2 fix(pascal): what',
386+
'abcdef2 fix(pascal): what is that',
387+
],
388+
})
389+
).toMatchInlineSnapshot(`
390+
"
391+
<p>It doesn't mean these commits are being excluded from the release. It means they're not taken into account when the release process figured out the next version number, and updated the changelog.</p>
392+
393+
<details>
394+
<summary>
395+
<i>Commits without language scope:</i>
396+
</summary>
397+
398+
- abcdefg fix: something
399+
- abcdefg fix: somethin2
400+
</details>
401+
402+
<details>
403+
<summary>
404+
<i>Commits with unknown language scope:</i>
405+
</summary>
406+
407+
- abcdef2 fix(pascal): what
408+
- abcdef2 fix(pascal): what is that
409+
</details>"
410+
`);
411+
});
412+
413+
it('limits the size of the commits to 15 if there is too many', () => {
414+
const fakeCommitsWithoutLanguageScope: string[] = [];
415+
const fakeCommitsWithUnknownLanguageScope: string[] = [];
416+
417+
for (let i = 0; i < 100; i++) {
418+
fakeCommitsWithoutLanguageScope.push(`abcdefg${i} fix: something`);
419+
fakeCommitsWithUnknownLanguageScope.push(
420+
`abcdefg${i} fix(pascal): something`
421+
);
422+
}
423+
424+
expect(
425+
getSkippedCommitsText({
426+
commitsWithoutLanguageScope: fakeCommitsWithoutLanguageScope,
427+
commitsWithUnknownLanguageScope: fakeCommitsWithUnknownLanguageScope,
428+
})
429+
).toMatchInlineSnapshot(`
430+
"
431+
<p>It doesn't mean these commits are being excluded from the release. It means they're not taken into account when the release process figured out the next version number, and updated the changelog.</p>
432+
433+
<details>
434+
<summary>
435+
<i>Commits without language scope:</i>
436+
</summary>
437+
438+
- abcdefg0 fix: something
439+
- abcdefg1 fix: something
440+
- abcdefg2 fix: something
441+
- abcdefg3 fix: something
442+
- abcdefg4 fix: something
443+
- abcdefg5 fix: something
444+
- abcdefg6 fix: something
445+
- abcdefg7 fix: something
446+
- abcdefg8 fix: something
447+
- abcdefg9 fix: something
448+
- abcdefg10 fix: something
449+
- abcdefg11 fix: something
450+
- abcdefg12 fix: something
451+
- abcdefg13 fix: something
452+
- abcdefg14 fix: something
453+
</details>
454+
455+
<details>
456+
<summary>
457+
<i>Commits with unknown language scope:</i>
458+
</summary>
459+
460+
- abcdefg0 fix(pascal): something
461+
- abcdefg1 fix(pascal): something
462+
- abcdefg2 fix(pascal): something
463+
- abcdefg3 fix(pascal): something
464+
- abcdefg4 fix(pascal): something
465+
- abcdefg5 fix(pascal): something
466+
- abcdefg6 fix(pascal): something
467+
- abcdefg7 fix(pascal): something
468+
- abcdefg8 fix(pascal): something
469+
- abcdefg9 fix(pascal): something
470+
- abcdefg10 fix(pascal): something
471+
- abcdefg11 fix(pascal): something
472+
- abcdefg12 fix(pascal): something
473+
- abcdefg13 fix(pascal): something
474+
- abcdefg14 fix(pascal): something
475+
</details>"
476+
`);
477+
});
408478
});
409479
});

scripts/release/__tests__/process-release.test.ts renamed to scripts/release/__tests__/updateAPIVersions.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getVersionChangesText } from '../create-release-issue';
2-
import { getVersionsToRelease } from '../process-release';
1+
import { getVersionChangesText } from '../createReleasePR';
32
import TEXT from '../text';
3+
import { getVersionsToRelease } from '../updateAPIVersions';
44

5-
describe('process release', () => {
5+
describe('updateAPIversions', () => {
66
it('gets versions to release', () => {
77
const versions = getVersionsToRelease(`
88
## Version Changes
@@ -20,8 +20,8 @@ describe('process release', () => {
2020
expect(versions.php?.releaseType).toEqual('patch');
2121
});
2222

23-
it('parses issue body correctly', () => {
24-
// This test is a glue between create-release-issue and process-release.
23+
it('correctly reads clients version and their next release type', () => {
24+
// This test is a glue between createReleasePR and updateAPIVersions.
2525
const issueBody = [
2626
TEXT.versionChangeHeader,
2727
getVersionChangesText({

0 commit comments

Comments
 (0)