aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.55k stars 3.87k forks source link

integ-runner: --watch flag creates a cdk.context.json with `watch` field #30485

Open dontirun opened 3 months ago

dontirun commented 3 months ago

Describe the bug

integ runner creates a cdk.context.json file with the watch field if the the context file does not exist, when it actually needs a cdk.json with the watch field.

Expected Behavior

Create a cdk.json with the watch field if it doesn't exist

Current Behavior

integ runner creates a cdk.context.json file with the watch field if the the context file does not exist

Reproduction Steps

  1. Create a new application
mkdir bug
cdk init app --language=typescript
  1. Add integ-runner and integ-tests-alpha to the package.json

    "dependencies": {
    "aws-cdk-lib": "2.144.0",
    "constructs": "^10.0.0",
    "@aws-cdk/integ-runner": "2.144.0-alpha.0",
    "@aws-cdk/integ-tests-alpha": "2.144.0-alpha.0",
    "source-map-support": "^0.5.21"
    }
    }
  2. npm install

  3. create the following test/integ.example.test.ts file

    
    import * as integ from '@aws-cdk/integ-tests-alpha';
    import * as cdk from 'aws-cdk-lib';
    import { Construct } from "constructs";

const app = new cdk.App();

class TestStack extends cdk.Stack { constructor(scope: Construct, id: string) { super(scope, id); new cdk.CfnWaitConditionHandle(this, 'NullResource'); } } const stack = new TestStack(app, 'TestStack'); new integ.IntegTest(app, 'integration-test', { testCases: [stack], });


5. Optional: delete the `cdk.json` file (doesn't matter)
5. npx integ-runner test/integ.example.test.ts --watch

### Possible Solution

1. Don't create a `cdk.context.json`
2. create a /update  the existing `cdk.json` with the `watch` field 

### Additional Information/Context

The documentation needs to be update to reflect this

### CDK CLI Version

2.144.0 (build 5fb15bc)

### Framework Version

_No response_

### Node.js Version

v18.15.0

### OS

Osx

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_
karmabadger commented 3 months ago

@dontirun what's the content of the cdk.context.json? I feel like it's for a different purpose than the cdk.json. I'm pretty sure cdk allows you to run without a cdk.json as long as you give it a --app so you can run it without having to be in a project directory. So in that sense I'm not sure if it makes sense necessarily to have a cdk.json autogenerated?

dontirun commented 3 months ago

It just has the watch property and nothing else. The watch property should be in the cdk.json

karmabadger commented 3 months ago

It just has the watch property and nothing else. The watch property should be in the cdk.json

yeah that seems a bit weird.

pahud commented 3 months ago

Yes it does create cdk.context.json with an empty watch. Looks like a bug to me.

{
  "watch": {}
}