mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
feat: simplify patch release workflow (#8196)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Richie Foreman <richie.foreman@gmail.com>
This commit is contained in:
@@ -7,28 +7,11 @@
|
||||
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
||||
import { getVersion } from '../get-release-version.js';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
vi.mock('node:child_process');
|
||||
vi.mock('node:fs');
|
||||
|
||||
vi.mock('../get-release-version.js', async () => {
|
||||
const actual = await vi.importActual('../get-release-version.js');
|
||||
return {
|
||||
...actual,
|
||||
getVersion: (options) => {
|
||||
if (options.type === 'nightly') {
|
||||
return {
|
||||
releaseTag: 'v0.6.0-nightly.20250911.a1b2c3d',
|
||||
releaseVersion: '0.6.0-nightly.20250911.a1b2c3d',
|
||||
npmTag: 'nightly',
|
||||
previousReleaseTag: 'v0.5.0-nightly.20250910.abcdef',
|
||||
};
|
||||
}
|
||||
return actual.getVersion(options);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe('getReleaseVersion', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
@@ -37,14 +20,37 @@ describe('getReleaseVersion', () => {
|
||||
});
|
||||
|
||||
describe('Nightly Workflow Logic', () => {
|
||||
it('should calculate the next nightly version based on package.json', async () => {
|
||||
const { getVersion } = await import('../get-release-version.js');
|
||||
it('should calculate the next nightly version based on package.json', () => {
|
||||
vi.mocked(readFileSync).mockReturnValue('{"version": "0.5.0"}');
|
||||
vi.mocked(execSync).mockImplementation((command) => {
|
||||
if (command.includes('rev-parse')) return 'a1b2c3d';
|
||||
if (command.includes('release list'))
|
||||
return 'v0.5.0-nightly.20250910.abcdef';
|
||||
return '';
|
||||
});
|
||||
|
||||
const result = getVersion({ type: 'nightly' });
|
||||
|
||||
expect(result.releaseVersion).toBe('0.6.0-nightly.20250911.a1b2c3d');
|
||||
expect(result.npmTag).toBe('nightly');
|
||||
expect(result.previousReleaseTag).toBe('v0.5.0-nightly.20250910.abcdef');
|
||||
});
|
||||
|
||||
it('should default minor to 0 if missing in package.json version', () => {
|
||||
vi.mocked(readFileSync).mockReturnValue('{"version": "0"}');
|
||||
vi.mocked(execSync).mockImplementation((command) => {
|
||||
if (command.includes('rev-parse')) return 'a1b2c3d';
|
||||
if (command.includes('release list'))
|
||||
return 'v0.0.0-nightly.20250910.abcdef';
|
||||
return '';
|
||||
});
|
||||
|
||||
const result = getVersion({ type: 'nightly' });
|
||||
|
||||
expect(result.releaseVersion).toBe('0.1.0-nightly.20250911.a1b2c3d');
|
||||
expect(result.npmTag).toBe('nightly');
|
||||
expect(result.previousReleaseTag).toBe('v0.0.0-nightly.20250910.abcdef');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Promote Workflow Logic', () => {
|
||||
@@ -82,4 +88,39 @@ describe('getReleaseVersion', () => {
|
||||
expect(result.previousReleaseTag).toBe(latestPreview);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Patch Workflow Logic', () => {
|
||||
it('should calculate the next patch version for a stable release', () => {
|
||||
const latestStable = 'v0.5.1';
|
||||
vi.mocked(execSync).mockReturnValue(latestStable);
|
||||
|
||||
const result = getVersion({ type: 'patch', patchFrom: 'stable' });
|
||||
|
||||
expect(result.releaseVersion).toBe('0.5.2');
|
||||
expect(result.npmTag).toBe('latest');
|
||||
expect(result.previousReleaseTag).toBe(latestStable);
|
||||
});
|
||||
|
||||
it('should calculate the next patch version for a preview release', () => {
|
||||
const latestPreview = 'v0.6.0-preview';
|
||||
vi.mocked(execSync).mockReturnValue(latestPreview);
|
||||
|
||||
const result = getVersion({ type: 'patch', patchFrom: 'preview' });
|
||||
|
||||
expect(result.releaseVersion).toBe('0.6.1-preview');
|
||||
expect(result.npmTag).toBe('preview');
|
||||
expect(result.previousReleaseTag).toBe(latestPreview);
|
||||
});
|
||||
|
||||
it('should default patch to 0 if missing in stable release', () => {
|
||||
const latestStable = 'v0.5';
|
||||
vi.mocked(execSync).mockReturnValue(latestStable);
|
||||
|
||||
const result = getVersion({ type: 'patch', patchFrom: 'stable' });
|
||||
|
||||
expect(result.releaseVersion).toBe('0.5.1');
|
||||
expect(result.npmTag).toBe('latest');
|
||||
expect(result.previousReleaseTag).toBe(latestStable);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user