Skip to content

Commit 47943df

Browse files
committed
fix(integ-tests): add integ tests for the toolkit library
1 parent 202ebba commit 47943df

File tree

339 files changed

+22806
-6
lines changed

Some content is hidden

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

339 files changed

+22806
-6
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,11 +1586,16 @@ const cliInteg = configureProject(
15861586
],
15871587
devDeps: [
15881588
yarnCling,
1589+
toolkitLib,
15891590
'@types/semver@^7',
15901591
'@types/yargs@^16',
15911592
'@types/fs-extra@^9',
15921593
'@types/glob@^7',
15931594
],
1595+
peerDeps: [
1596+
// Can't use a '*' because projen special-cases that
1597+
'@aws-cdk/toolkit-lib@>=0',
1598+
],
15941599
bin: {
15951600
'run-suite': 'bin/run-suite',
15961601
'download-and-run-old-tests': 'bin/download-and-run-old-tests',

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

Lines changed: 9 additions & 0 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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ inject these dependencies into tests. Users can specify component versions, but
4545
Test Authors are responsible for taking these parameters and using it to set up
4646
the right environment for the tests.
4747

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`. |
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`. |
5252
| | `--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
5354

5455
### Running a test suite
5556

packages/@aws-cdk-testing/cli-integ/lib/cli/run-suite.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ async function main() {
3434
alias: 'f',
3535
type: 'string',
3636
})
37+
.options('toolkit-lib-version', {
38+
describe: 'Toolkit lib version to use',
39+
alias: 'l',
40+
type: 'string',
41+
})
3742
.option('use-source', {
3843
descripton: 'Use TypeScript packages from the given source repository (or "auto")',
3944
type: 'string',

packages/@aws-cdk-testing/cli-integ/package.json

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
import * as toolkit from '@aws-cdk/toolkit-lib';
3+
import { assemblyFromCdkAppDir } from './toolkit-helpers';
4+
import { integTest, withDefaultFixture } from '../../lib';
5+
6+
integTest(
7+
'toolkit can cdk deploy',
8+
withDefaultFixture(async (fixture) => {
9+
const tk = new toolkit.Toolkit();
10+
11+
const assembly = await assemblyFromCdkAppDir(tk, fixture.integTestDir);
12+
13+
await tk.deploy(assembly);
14+
await tk.destroy(assembly, {
15+
stacks: { strategy: toolkit.StackSelectionStrategy.ALL_STACKS },
16+
});
17+
}),
18+
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { promises as fs } from 'fs';
2+
import * as path from 'path';
3+
import type * as toolkit from '@aws-cdk/toolkit-lib';
4+
5+
/**
6+
* Helper function to convert a CDK app directory into an Assembly Source
7+
*
8+
* This will eventually become part of the toolkit itself, but isn't yet.
9+
*/
10+
export async function assemblyFromCdkAppDir(tk: toolkit.Toolkit, cdkAppDir: string) {
11+
const cdkJson = await JSON.parse(await fs.readFile(path.join(cdkAppDir, 'cdk.json'), 'utf-8'));
12+
const app = cdkJson.app;
13+
14+
return tk.fromCdkApp(app, {
15+
workingDirectory: cdkAppDir,
16+
});
17+
}

packages/@aws-cdk-testing/cli-integ/tsconfig.dev.json

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

0 commit comments

Comments
 (0)