Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scripts): update release PR and process #554

Merged
merged 3 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ runs:
shell: bash
run: |
previousCommit=${{ github.event.before }}
baseRef=${{ inputs.workflow_name == 'process-release' && 'main' || github.base_ref }}
baseRef=${{ github.base_ref }}
origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" )

yarn workspace scripts setRunVariables "$origin"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ jobs:
run: yarn cli cts run ${{ matrix.client.language }}

- name: Zip artifact before storing
run: zip -q -r clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} ${{ matrix.client.testsOutputPath }} -x "${{ matrix.client.path }}/node_modules/.**"
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/**"

- name: Store ${{ matrix.client.language }} clients
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"github-actions:lint": "eslint --ext=yml .github/",
"postinstall": "husky install && yarn workspace eslint-plugin-automation-custom build",
"playground:browser": "yarn workspace javascript-browser-playground start",
"release": "yarn workspace scripts createReleaseIssue",
"release": "yarn workspace scripts createReleasePR",
"scripts:lint": "eslint --ext=ts scripts/",
"scripts:test": "yarn workspace scripts test",
"specs:fix": "eslint --ext=yml specs/$0 --fix",
Expand Down
2 changes: 1 addition & 1 deletion scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export function ensureGitHubToken(): string {
export function getOctokit(): Octokit {
const token = ensureGitHubToken();
return new Octokit({
auth: `token ${token}`,
auth: token,
});
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"cleanGeneratedBranch": "ts-node ci/codegen/cleanGeneratedBranch.ts",
"createMatrix": "ts-node ci/githubActions/createMatrix.ts",
"createReleaseIssue": "ts-node release/create-release-issue.ts",
"createReleasePR": "ts-node release/createReleasePR.ts",
"pre-commit": "./ci/husky/pre-commit.js",
"pushGeneratedCode": "ts-node ci/codegen/pushGeneratedCode.ts",
"renovateWeeklyPR": "ts-node ci/githubActions/renovateWeeklyPR.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
getSkippedCommitsText,
decideReleaseStrategy,
readVersions,
} from '../create-release-issue';
} from '../createReleasePR';

describe('create release issue', () => {
describe('createReleasePR', () => {
it('reads versions of the current language', () => {
expect(readVersions()).toEqual({
java: {
Expand Down Expand Up @@ -92,10 +92,10 @@ describe('create release issue', () => {
},
})
).toMatchInlineSnapshot(`
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
- java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
- php: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**"
`);
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
- java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
- php: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**"
`);
});

it('generates text for version changes with a language with no commit', () => {
Expand All @@ -118,10 +118,10 @@ describe('create release issue', () => {
},
})
).toMatchInlineSnapshot(`
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
- java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
- ~php: 0.0.1 (no commit)~"
`);
"- javascript: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
- java: 0.0.1 -> **\`patch\` _(e.g. 0.0.2)_**
- ~php: 0.0.1 (no commit)~"
`);
});

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

Expand Down Expand Up @@ -363,47 +363,117 @@ describe('create release issue', () => {
});
});

it('generates text for skipped commits', () => {
expect(
getSkippedCommitsText({
commitsWithoutLanguageScope: [],
commitsWithUnknownLanguageScope: [],
})
).toMatchInlineSnapshot(`"_(None)_"`);

expect(
getSkippedCommitsText({
commitsWithoutLanguageScope: [
'abcdefg fix: something',
'abcdefg fix: somethin2',
],
describe('getSkippedCommitsText', () => {
it('does not generate text if there is no commits', () => {
expect(
getSkippedCommitsText({
commitsWithoutLanguageScope: [],
commitsWithUnknownLanguageScope: [],
})
).toMatchInlineSnapshot(`"_(None)_"`);
});

commitsWithUnknownLanguageScope: [
'abcdef2 fix(pascal): what',
'abcdef2 fix(pascal): what is that',
],
})
).toMatchInlineSnapshot(`
"</p>
<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>

<details>
<summary>
<i>Commits without language scope:</i>
</summary>

- abcdefg fix: something
- abcdefg fix: somethin2
</details>

<details>
<summary>
<i>Commits with unknown language scope:</i>
</summary>

- abcdef2 fix(pascal): what
- abcdef2 fix(pascal): what is that
</details>"
`);
it('generates text for skipped commits', () => {
expect(
getSkippedCommitsText({
commitsWithoutLanguageScope: [
'abcdefg fix: something',
'abcdefg fix: somethin2',
],

commitsWithUnknownLanguageScope: [
'abcdef2 fix(pascal): what',
'abcdef2 fix(pascal): what is that',
],
})
).toMatchInlineSnapshot(`
"
<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>

<details>
<summary>
<i>Commits without language scope:</i>
</summary>

- abcdefg fix: something
- abcdefg fix: somethin2
</details>

<details>
<summary>
<i>Commits with unknown language scope:</i>
</summary>

- abcdef2 fix(pascal): what
- abcdef2 fix(pascal): what is that
</details>"
`);
});

it('limits the size of the commits to 15 if there is too many', () => {
const fakeCommitsWithoutLanguageScope: string[] = [];
const fakeCommitsWithUnknownLanguageScope: string[] = [];

for (let i = 0; i < 100; i++) {
fakeCommitsWithoutLanguageScope.push(`abcdefg${i} fix: something`);
fakeCommitsWithUnknownLanguageScope.push(
`abcdefg${i} fix(pascal): something`
);
}

expect(
getSkippedCommitsText({
commitsWithoutLanguageScope: fakeCommitsWithoutLanguageScope,
commitsWithUnknownLanguageScope: fakeCommitsWithUnknownLanguageScope,
})
).toMatchInlineSnapshot(`
"
<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>

<details>
<summary>
<i>Commits without language scope:</i>
</summary>

- abcdefg0 fix: something
- abcdefg1 fix: something
- abcdefg2 fix: something
- abcdefg3 fix: something
- abcdefg4 fix: something
- abcdefg5 fix: something
- abcdefg6 fix: something
- abcdefg7 fix: something
- abcdefg8 fix: something
- abcdefg9 fix: something
- abcdefg10 fix: something
- abcdefg11 fix: something
- abcdefg12 fix: something
- abcdefg13 fix: something
- abcdefg14 fix: something
</details>

<details>
<summary>
<i>Commits with unknown language scope:</i>
</summary>

- abcdefg0 fix(pascal): something
- abcdefg1 fix(pascal): something
- abcdefg2 fix(pascal): something
- abcdefg3 fix(pascal): something
- abcdefg4 fix(pascal): something
- abcdefg5 fix(pascal): something
- abcdefg6 fix(pascal): something
- abcdefg7 fix(pascal): something
- abcdefg8 fix(pascal): something
- abcdefg9 fix(pascal): something
- abcdefg10 fix(pascal): something
- abcdefg11 fix(pascal): something
- abcdefg12 fix(pascal): something
- abcdefg13 fix(pascal): something
- abcdefg14 fix(pascal): something
</details>"
`);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getVersionChangesText } from '../create-release-issue';
import { getVersionsToRelease } from '../process-release';
import { getVersionChangesText } from '../createReleasePR';
import TEXT from '../text';
import { getVersionsToRelease } from '../updateAPIVersions';

describe('process release', () => {
describe('updateAPIversions', () => {
it('gets versions to release', () => {
const versions = getVersionsToRelease(`
## Version Changes
Expand All @@ -20,8 +20,8 @@ describe('process release', () => {
expect(versions.php?.releaseType).toEqual('patch');
});

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