Skip to content

Commit 0f8d777

Browse files
committed
fix(integ-tests): add integ tests for the toolkit library
Signed-off-by: github-actions <github-actions@github.com>
2 parents dede397 + 257f7ce commit 0f8d777

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+891
-586
lines changed

.github/workflows/integ.yml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ const cliInteg = configureProject(
15631563
'sinon@^9',
15641564
'ts-mock-imports@^1',
15651565
'yaml@1',
1566-
'yargs@^17',
1566+
'yargs@^16',
15671567
// Jest is a runtime dependency here!
15681568
'jest@^29',
15691569
'jest-junit@^15',
@@ -1572,8 +1572,9 @@ const cliInteg = configureProject(
15721572
],
15731573
devDeps: [
15741574
yarnCling,
1575+
toolkitLib,
15751576
'@types/semver@^7',
1576-
'@types/yargs@^15',
1577+
'@types/yargs@^16',
15771578
'@types/fs-extra@^9',
15781579
'@types/glob@^7',
15791580
],
@@ -1589,17 +1590,20 @@ const cliInteg = configureProject(
15891590
compilerOptions: {
15901591
...defaultTsOptions,
15911592
esModuleInterop: false,
1593+
target: 'es2022',
1594+
lib: ['es2022', 'esnext.disposable', 'dom'],
1595+
module: 'NodeNext',
15921596
},
15931597
include: ['**/*.ts'],
15941598
exclude: ['resources/**/*'],
15951599
},
15961600
jestOptions: jestOptionsForProject({
15971601
jestConfig: {
15981602
coverageThreshold: {
1599-
statements: 40,
1600-
lines: 40,
1603+
statements: 25,
1604+
lines: 25,
16011605
functions: 10,
1602-
branches: 40,
1606+
branches: 25,
16031607
},
16041608
},
16051609
}),
@@ -1610,6 +1614,8 @@ const cliInteg = configureProject(
16101614
);
16111615
cliInteg.eslint?.addIgnorePattern('resources/**/*.ts');
16121616

1617+
cliInteg.deps.addDependency('@aws-cdk/toolkit-lib', pj.DependencyType.OPTIONAL);
1618+
16131619
const compiledDirs = ['tests', 'test', 'lib'];
16141620
for (const compiledDir of compiledDirs) {
16151621
cliInteg.gitignore.addPatterns(`${compiledDir}/**/*.js`);

packages/@aws-cdk-testing/cli-integ/.projen/deps.json

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/cli-integ/.projen/tasks.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/cli-integ/README.md

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,55 +35,39 @@ Each subdirectory contains one test **suite**, and in the development pipeline e
3535

3636
Test suites are written as a collection of Jest tests, and they are run using Jest, using the code in the `lib/` directory as helpers.
3737

38-
### Setup
38+
### Components under test
3939

40-
Building the @aws-cdk-testing package is not very different from building the rest of the CDK. However, If you are having issues with the tests, you can ensure your environment is built properly by following the steps below:
40+
The tests have their own version, and can test other components at multiple versions. The following components can be injected,
41+
and will default to the latest published version if not supplied.
4142

42-
```shell
43-
yarn install # Install dependencies
44-
npx lerna run build --scope=aws-cdk # Build the CDK cli
45-
yarn build # Build the @aws-cdk-testing/cli-integ package
46-
../../../scripts/align-version.sh # Align the versions of CDK packages
47-
```
43+
Because many tests are very different, there is no generalized mechanism to
44+
inject these dependencies into tests. Users can specify component versions, but
45+
Test Authors are responsible for taking these parameters and using it to set up
46+
the right environment for the tests.
4847

49-
### Running tests with debugger
50-
51-
```json
52-
{
53-
"version": "0.2.0",
54-
"configurations": [
55-
{
56-
"type": "node",
57-
"request": "launch",
58-
"args": ["-a", "cli-integ-tests", "-t", "context in stage propagates to top"],
59-
"name": "debug integ tests",
60-
"program": "~/aws-cdk/packages/@aws-cdk-testing/cli-integ/bin/run-suite",
61-
"console": "integratedTerminal",
62-
"sourceMaps": true,
63-
"skipFiles": [ "<node_internals>/**/*" ],
64-
"stopOnEntry": false
65-
}
66-
]
67-
}
68-
```
69-
70-
1. Assuming you checked out the `aws-cdk` repository in your `~` directory, use the above `launch.json`.
71-
2. In the `"args"` value after `"-t"`, place the name of the test that you'd like to run.
72-
3. Press the VS code green arrow to launch the debugger.
48+
| Component | Command-line argument | Default | Treatment by runner | Treatment in test |
49+
|-----------------------|--------------------------------------|-------------|----------------------------|-----------------------------------------------|
50+
| CDK Construct Library | `--framework-version=VERSION` | Latest | Nothing | `npm install` into temporary project dir. |
51+
| CDK CLI | `--cli-version=VERSION` | Auto source | `npm install` into tempdir | Add to `$PATH`. |
52+
| | `--cli-source=ROOT` or `auto` | Auto source | | Add `<ROOT>/packages/aws-cdk/bin` to `$PATH`. |
53+
| Toolkit Library | `--toolkit-lib-version=VERSION` | Devdep | Install into its own deps | Nothing
7354

7455
### Running a test suite
7556

7657
You run a suite using the `bin/run-suite` tool. You must select either a version of the CLI and framework which can be `npm install`ed, or point to the root of the source tree:
7758

7859
```shell
79-
# Use the given source tree
80-
$ bin/run-suite --use-source=/path/to/repo-root <SUITE_NAME>
81-
8260
# Automatically determine the source tree root
83-
$ bin/run-suite -a <SUITE_NAME>
61+
$ bin/run-suite <SUITE_NAME>
62+
63+
# Use the CLI from the given repo
64+
$ bin/run-suite --cli-source=/path/to/repo-root <SUITE_NAME>
8465

8566
# Run against a released version
86-
$ bin/run-suite --use-cli-release=2.34.5 <SUITE_NAME>
67+
$ bin/run-suite --cli-version=2.34.5 <SUITE_NAME>
68+
69+
# Run against a specific framework version
70+
$ bin/run-suite --framework-version=2.34.5 <SUITE_NAME>
8771
```
8872

8973
To run a specific test, add `-t` and a substring of the test name. For example:
@@ -94,10 +78,10 @@ bin/run-suite -a cli-integ-tests -t 'load old assemblies'
9478

9579
### Running a test suite against binaries
9680

97-
Some test suites require package binaries stages in CodeArtifact repositories to run. This requires you to do a full build, then create a CodeArtifact repository in your own account, uploading the packages there, and then running the tests in a shell configured to have NPM, Pip, Maven etc look for those packages in CodeArtifact.
81+
The test suites that run the "init tests" require actual packages staged in CodeArtifact repositories to run. This requires you to do a full build, then create a CodeArtifact repository in your own account, uploading the packages there, and then running the tests in a shell configured to have NPM, Pip, Maven etc look for those packages in CodeArtifact.
9882

9983
```shell
100-
# Build and pack all of CDK (will take ~an hour)
84+
# Build and pack all of CDK (in the `aws-cdk` repo, will take ~an hour)
10185
$ ./build.sh
10286
$ ./pack.sh
10387

@@ -115,6 +99,31 @@ $ bin/run-suite --use-cli-release=0.0.0 <SUITE_NAME>
11599
$ publib-ca delete
116100
```
117101

102+
### Running tests with debugger
103+
104+
```json
105+
{
106+
"version": "0.2.0",
107+
"configurations": [
108+
{
109+
"type": "node",
110+
"request": "launch",
111+
"args": ["-a", "cli-integ-tests", "-t", "context in stage propagates to top"],
112+
"name": "debug integ tests",
113+
"program": "~/aws-cdk/packages/@aws-cdk-testing/cli-integ/bin/run-suite",
114+
"console": "integratedTerminal",
115+
"sourceMaps": true,
116+
"skipFiles": [ "<node_internals>/**/*" ],
117+
"stopOnEntry": false
118+
}
119+
]
120+
}
121+
```
122+
123+
1. Assuming you checked out the `aws-cdk` repository in your `~` directory, use the above `launch.json`.
124+
2. In the `"args"` value after `"-t"`, place the name of the test that you'd like to run.
125+
3. Press the VS code green arrow to launch the debugger.
126+
118127
## Tools
119128

120129
There are a number of tools in the `bin/` directory. They are:

packages/@aws-cdk-testing/cli-integ/jest.config.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)