Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(scripts): correctly check for release commit #769

Merged
merged 1 commit into from
Jun 30, 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
4 changes: 2 additions & 2 deletions scripts/ci/codegen/pushGeneratedCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ensureGitHubToken, MAIN_BRANCH, run } from '../../common';
import { configureGitHubAuthor } from '../../release/common';
import { getNbGitDiff } from '../utils';

import text from './text';
import text, { commitStartPrepareRelease } from './text';

const PR_NUMBER = parseInt(process.env.PR_NUMBER || '0', 10);

Expand All @@ -25,7 +25,7 @@ export async function pushGeneratedCode(): Promise<void> {
const baseBranch = await run('git branch --show-current');
const isMainBranch = baseBranch === MAIN_BRANCH;
const IS_RELEASE_COMMIT = (await run('git log -1 --format="%s"')).startsWith(
text.commitPrepareReleaseMessage
commitStartPrepareRelease
);
console.log(`Checking codegen status on '${baseBranch}'.`);

Expand Down
10 changes: 4 additions & 6 deletions scripts/ci/codegen/spreadGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
import type { Language } from '../../types';
import { getNbGitDiff } from '../utils';

import text from './text';
import text, { commitStartRelease } from './text';

export function decideWhereToSpread(commitMessage: string): Language[] {
if (commitMessage.startsWith(text.commitReleaseMessage)) {
if (commitMessage.startsWith(commitStartRelease)) {
return LANGUAGES;
}

Expand All @@ -40,7 +40,7 @@ export function cleanUpCommitMessage(
commitMessage: string,
version: string
): string {
if (commitMessage.startsWith(text.commitReleaseMessage)) {
if (commitMessage.startsWith(commitStartRelease)) {
return `chore: release ${version}`;
}

Expand Down Expand Up @@ -86,9 +86,7 @@ async function spreadGeneration(): Promise<void> {
.map((coAuthor) => coAuthor.trim())
.filter(Boolean);

const IS_RELEASE_COMMIT = lastCommitMessage.startsWith(
text.commitReleaseMessage
);
const IS_RELEASE_COMMIT = lastCommitMessage.startsWith(commitStartRelease);
const langs = decideWhereToSpread(lastCommitMessage);
console.log(
'Spreading code to the following repositories:',
Expand Down
7 changes: 5 additions & 2 deletions scripts/ci/codegen/text.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { MAIN_BRANCH, REPO_URL, TODAY } from '../../common';

export const commitStartPrepareRelease = 'chore: prepare release';
export const commitStartRelease = 'chore: release';

export default {
commitStartMessage: 'chore: generated code for commit',
commitPrepareReleaseMessage: `chore: prepare release ${TODAY}`,
commitReleaseMessage: `chore: release ${TODAY}`,
commitPrepareReleaseMessage: `${commitStartPrepareRelease} ${TODAY}`,
commitReleaseMessage: `${commitStartRelease} ${TODAY}`,
notification: {
header: '### 🔨 The codegen job will run at the end of the CI.',
body: (): string =>
Expand Down