mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(patch workflow): Ensure that the environment is listed on patch comments (#12538)
This commit is contained in:
@@ -118,6 +118,7 @@ jobs:
|
||||
GITHUB_RUN_ID: '${{ github.run_id }}'
|
||||
LOG_CONTENT: '${{ env.LOG_CONTENT }}'
|
||||
TARGET_REF: '${{ github.event.inputs.ref }}'
|
||||
ENVIRONMENT: '${{ github.event.inputs.environment }}'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
git checkout "${TARGET_REF}"
|
||||
|
||||
@@ -46,6 +46,11 @@ async function main() {
|
||||
description: 'The GitHub workflow run ID',
|
||||
type: 'string',
|
||||
})
|
||||
.option('environment', {
|
||||
choices: ['prod', 'dev'],
|
||||
type: 'string',
|
||||
default: process.env.ENVIRONMENT || 'prod',
|
||||
})
|
||||
.option('test', {
|
||||
description: 'Test mode - validate logic without GitHub API calls',
|
||||
type: 'boolean',
|
||||
@@ -75,6 +80,7 @@ async function main() {
|
||||
: parseInt(process.env.EXIT_CODE || '1');
|
||||
const commit = argv.commit || process.env.COMMIT;
|
||||
const channel = argv.channel || process.env.CHANNEL;
|
||||
const environment = argv.environment;
|
||||
const repository =
|
||||
argv.repository || process.env.REPOSITORY || 'google-gemini/gemini-cli';
|
||||
const runId = argv.runId || process.env.GITHUB_RUN_ID || '0';
|
||||
@@ -210,6 +216,7 @@ A patch branch [\`${branch}\`](https://github.com/${repository}/tree/${branch})
|
||||
commentBody = `🚀 **Patch PR Created!**
|
||||
|
||||
**📋 Patch Details:**
|
||||
- **Environment**: \`${environment}\`
|
||||
- **Channel**: \`${channel}\` → will publish to npm tag \`${npmTag}\`
|
||||
- **Commit**: \`${commit}\`
|
||||
- **Hotfix Branch**: [\`${branch}\`](https://github.com/${repository}/tree/${branch})
|
||||
@@ -265,6 +272,7 @@ ${hasConflicts ? '4' : '3'}. You'll receive updates here when the release comple
|
||||
commentBody = `🚀 **Patch PR Created!**
|
||||
|
||||
**📋 Patch Details:**
|
||||
- **Environment**: \`${environment}\`
|
||||
- **Channel**: \`${channel}\` → will publish to npm tag \`${npmTag}\`
|
||||
- **Commit**: \`${commit}\`
|
||||
- **Hotfix Branch**: [\`${branch}\`](https://github.com/${repository}/tree/${branch})
|
||||
|
||||
@@ -18,7 +18,6 @@ function runPatchCreateComment(args, env = {}) {
|
||||
);
|
||||
const fullEnv = {
|
||||
...process.env,
|
||||
TEST_MODE: 'true', // Always run in test mode to avoid GitHub API calls
|
||||
...env,
|
||||
};
|
||||
|
||||
@@ -39,18 +38,63 @@ function runPatchCreateComment(args, env = {}) {
|
||||
}
|
||||
|
||||
describe('patch-create-comment', () => {
|
||||
let originalEnv;
|
||||
|
||||
beforeEach(() => {
|
||||
// Save original environment
|
||||
originalEnv = { ...process.env };
|
||||
vi.stubEnv();
|
||||
// Always run in test mode to avoid GitHub API calls
|
||||
vi.stubEnv('TEST_MODE', 'true');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Restore original environment
|
||||
process.env = originalEnv;
|
||||
vi.clearAllMocks();
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
describe('Environment flag', () => {
|
||||
it('can be overridden with a flag', () => {
|
||||
vi.stubEnv('ENVIRONMENT', 'dev');
|
||||
const result = runPatchCreateComment(
|
||||
'--original-pr 8655 --exit-code 0 --environment prod --commit abc1234 --channel preview --repository google-gemini/gemini-cli --test',
|
||||
);
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.stdout).toContain('🚀 **Patch PR Created!**');
|
||||
expect(result.stdout).toContain('Environment**: `prod`');
|
||||
});
|
||||
|
||||
it('reads from the ENVIRONMENT env variable', () => {
|
||||
vi.stubEnv('ENVIRONMENT', 'dev');
|
||||
const result = runPatchCreateComment(
|
||||
'--original-pr 8655 --exit-code 0 --commit abc1234 --channel preview --repository google-gemini/gemini-cli --test',
|
||||
);
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.stdout).toContain('🚀 **Patch PR Created!**');
|
||||
expect(result.stdout).toContain('Environment**: `dev`');
|
||||
});
|
||||
|
||||
it('fails if the ENVIRONMENT is bogus', () => {
|
||||
vi.stubEnv('ENVIRONMENT', 'totally-bogus');
|
||||
const result = runPatchCreateComment(
|
||||
'--original-pr 8655 --exit-code 0 --commit abc1234 --channel preview --repository google-gemini/gemini-cli --test',
|
||||
);
|
||||
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.stderr).toContain(
|
||||
'Argument: environment, Given: "totally-bogus", Choices: "prod", "dev"',
|
||||
);
|
||||
});
|
||||
|
||||
it('defaults to prod if not specified', () => {
|
||||
const result = runPatchCreateComment(
|
||||
'--original-pr 8655 --exit-code 0 --commit abc1234 --channel preview --repository google-gemini/gemini-cli --test',
|
||||
);
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.stdout).toContain('🚀 **Patch PR Created!**');
|
||||
expect(result.stdout).toContain('Environment**: `prod`');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Environment Variable vs File Reading', () => {
|
||||
it('should prefer LOG_CONTENT environment variable over file', () => {
|
||||
const result = runPatchCreateComment(
|
||||
|
||||
Reference in New Issue
Block a user