Skip to content

Commit 97ef371

Browse files
authored
fix(cli): "fancy" progress reporting not disabled on all CI systems (#9516)
Fixes: #8696 #8893 Detects whether the `CI` environment variable is set and reverts output to `standard` behavior. The fancy output was especially broken on CircleCI. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent c570d9c commit 97ef371

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

packages/aws-cdk/bin/cdk.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function parseCommandLineArguments() {
8282
.option('build-exclude', { type: 'array', alias: 'E', nargs: 1, desc: 'Do not rebuild asset with the given ID. Can be specified multiple times.', default: [] })
8383
.option('exclusively', { type: 'boolean', alias: 'e', desc: 'Only deploy requested stacks, don\'t include dependencies' })
8484
.option('require-approval', { type: 'string', choices: [RequireApproval.Never, RequireApproval.AnyChange, RequireApproval.Broadening], desc: 'What security-sensitive changes need manual approval' })
85-
.option('ci', { type: 'boolean', desc: 'Force CI detection (deprecated)', default: process.env.CI !== undefined })
85+
.option('ci', { type: 'boolean', desc: 'Force CI detection', default: process.env.CI !== undefined })
8686
.option('notification-arns', { type: 'array', desc: 'ARNs of SNS topics that CloudFormation will notify with stack related events', nargs: 1, requiresArg: true })
8787
.option('tags', { type: 'array', alias: 't', desc: 'Tags to add to the stack (KEY=VALUE)', nargs: 1, requiresArg: true })
8888
.option('execute', { type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)', default: true })
@@ -279,6 +279,7 @@ async function initCommandLine() {
279279
parameters: parameterMap,
280280
usePreviousParameters: args['previous-parameters'],
281281
outputsFile: args.outputsFile,
282+
ci: args.ci,
282283
});
283284

284285
case 'destroy':

packages/aws-cdk/lib/api/cloudformation-deployments.ts

+8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ export interface DeployStackOptions {
8888
* @default true
8989
*/
9090
usePreviousParameters?: boolean;
91+
92+
/**
93+
* Whether we are on a CI system
94+
*
95+
* @default false
96+
*/
97+
readonly ci?: boolean;
9198
}
9299

93100
export interface DestroyStackOptions {
@@ -156,6 +163,7 @@ export class CloudFormationDeployments {
156163
force: options.force,
157164
parameters: options.parameters,
158165
usePreviousParameters: options.usePreviousParameters,
166+
ci: options.ci,
159167
});
160168
}
161169

packages/aws-cdk/lib/api/deploy-stack.ts

+7
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ export interface DeployStackOptions {
158158
* @default false
159159
*/
160160
force?: boolean;
161+
162+
/**
163+
* Whether we are on a CI system
164+
*
165+
* @default false
166+
*/
167+
readonly ci?: boolean;
161168
}
162169

163170
const LARGE_TEMPLATE_SIZE_KB = 50;

packages/aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ export interface StackActivityMonitorProps {
3535
* @default - Use value from logging.logLevel
3636
*/
3737
readonly logLevel?: LogLevel;
38+
39+
/**
40+
* Whether we are on a CI system
41+
*
42+
* If so, disable the "optimized" stack monitor.
43+
*
44+
* @default false
45+
*/
46+
readonly ci?: boolean;
3847
}
3948

4049
export class StackActivityMonitor {
@@ -79,7 +88,10 @@ export class StackActivityMonitor {
7988

8089
const isWindows = process.platform === 'win32';
8190
const verbose = options.logLevel ?? logLevel;
82-
const fancyOutputAvailable = !isWindows && stream.isTTY;
91+
// On some CI systems (such as CircleCI) output still reports as a TTY so we also
92+
// need an individual check for whether we're running on CI.
93+
// see: https://discuss.circleci.com/t/circleci-terminal-is-a-tty-but-term-is-not-set/9965
94+
const fancyOutputAvailable = !isWindows && stream.isTTY && !options.ci;
8395

8496
this.printer = fancyOutputAvailable && !verbose
8597
? new CurrentActivityPrinter(props)

packages/aws-cdk/lib/cdk-toolkit.ts

+8
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export class CdkToolkit {
190190
force: options.force,
191191
parameters: Object.assign({}, parameterMap['*'], parameterMap[stack.stackName]),
192192
usePreviousParameters: options.usePreviousParameters,
193+
ci: options.ci,
193194
});
194195

195196
const message = result.noOp
@@ -583,6 +584,13 @@ export interface DeployOptions {
583584
* @default - Outputs are not written to any file
584585
*/
585586
outputsFile?: string;
587+
588+
/**
589+
* Whether we are on a CI system
590+
*
591+
* @default false
592+
*/
593+
readonly ci?: boolean;
586594
}
587595

588596
export interface DestroyOptions {

0 commit comments

Comments
 (0)