Skip to content

Commit 7779531

Browse files
authored
feat(integ-runner): publish integ-runner cli (#20477)
This PR switches the `integ-runner` package from private to public. ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 953afa9 commit 7779531

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

packages/@aws-cdk/integ-runner/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
## Overview
2121

22+
This tool has been created to be used initially by this repo (aws/aws-cdk). Long term the goal is
23+
for this tool to be a general tool that can be used for running CDK integration tests. We are
24+
publishing this tool so that it can be used by the community and we would love to receive feedback
25+
on use cases that the tool should support, or issues that prevent the tool from being used in your
26+
library.
27+
28+
This tool is meant to be used with the [integ-tests](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/integ-tests) library.
2229

2330
## Usage
2431

packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ export abstract class IntegRunner {
129129

130130
protected readonly profile?: string;
131131

132-
protected readonly cdkExecutable: string;
133-
134132
protected _destructiveChanges?: DestructiveChange[];
135133
private legacyContext?: Record<string, any>;
136134

@@ -153,9 +151,7 @@ export abstract class IntegRunner {
153151
this.sourceFilePath = path.join(this.directory, parsed.base);
154152
this.cdkContextPath = path.join(this.directory, 'cdk.context.json');
155153

156-
this.cdkExecutable = require.resolve('aws-cdk/bin/cdk');
157154
this.cdk = options.cdk ?? new CdkCliWrapper({
158-
cdkExecutable: this.cdkExecutable,
159155
directory: this.directory,
160156
env: {
161157
...options.env,

packages/@aws-cdk/integ-runner/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@aws-cdk/integ-runner",
33
"description": "CDK Integration Testing Tool",
44
"version": "0.0.0",
5-
"private": true,
5+
"private": false,
66
"main": "lib/index.js",
77
"types": "lib/index.d.ts",
88
"bin": {

packages/cdk-cli-wrapper/lib/cdk-wrapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ export class CdkCliWrapper implements ICdk {
109109
this.directory = options.directory;
110110
this.env = options.env;
111111
try {
112-
this.cdk = options.cdkExecutable ?? require.resolve('aws-cdk/bin/cdk');
112+
this.cdk = options.cdkExecutable ?? 'cdk';
113113
} catch (e) {
114-
throw new Error(`could not resolve path to cdk executable: "${options.cdkExecutable}"`);
114+
throw new Error(`could not resolve path to cdk executable: "${options.cdkExecutable ?? 'cdk'}"`);
115115
}
116116
}
117117

packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test('default deploy', () => {
3232

3333
// THEN
3434
expect(spawnSyncMock).toHaveBeenCalledWith(
35-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
35+
expect.stringMatching(/cdk/),
3636
['deploy', '--app', 'node bin/my-app.js', 'test-stack1'],
3737
expect.objectContaining({
3838
env: expect.anything(),
@@ -86,7 +86,7 @@ test('deploy with all arguments', () => {
8686

8787
// THEN
8888
expect(spawnSyncMock).toHaveBeenCalledWith(
89-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
89+
expect.stringMatching(/cdk/),
9090
expect.arrayContaining([
9191
'deploy',
9292
'--no-strict',
@@ -146,7 +146,7 @@ test('can parse boolean arguments', () => {
146146

147147
// THEN
148148
expect(spawnSyncMock).toHaveBeenCalledWith(
149-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
149+
expect.stringMatching(/cdk/),
150150
[
151151
'deploy',
152152
'--app',
@@ -179,7 +179,7 @@ test('can parse parameters', () => {
179179

180180
// THEN
181181
expect(spawnSyncMock).toHaveBeenCalledWith(
182-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
182+
expect.stringMatching(/cdk/),
183183
[
184184
'deploy',
185185
'--parameters', 'myparam=test',
@@ -211,7 +211,7 @@ test('can parse context', () => {
211211

212212
// THEN
213213
expect(spawnSyncMock).toHaveBeenCalledWith(
214-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
214+
expect.stringMatching(/cdk/),
215215
[
216216
'deploy',
217217
'--app',
@@ -243,7 +243,7 @@ test('can parse array arguments', () => {
243243

244244
// THEN
245245
expect(spawnSyncMock).toHaveBeenCalledWith(
246-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
246+
expect.stringMatching(/cdk/),
247247
[
248248
'deploy',
249249
'--notification-arns', 'arn:aws:us-east-1:1111111111:some:resource',
@@ -274,7 +274,7 @@ test('can provide additional environment', () => {
274274

275275
// THEN
276276
expect(spawnSyncMock).toHaveBeenCalledWith(
277-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
277+
expect.stringMatching(/cdk/),
278278
['deploy', '--app', 'node bin/my-app.js', 'test-stack1'],
279279
expect.objectContaining({
280280
env: expect.objectContaining({
@@ -300,7 +300,7 @@ test('default synth', () => {
300300

301301
// THEN
302302
expect(spawnSyncMock).toHaveBeenCalledWith(
303-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
303+
expect.stringMatching(/cdk/),
304304
['synth', '--app', 'node bin/my-app.js', 'test-stack1'],
305305
expect.objectContaining({
306306
env: expect.objectContaining({
@@ -326,7 +326,7 @@ test('synth arguments', () => {
326326

327327
// THEN
328328
expect(spawnSyncMock).toHaveBeenCalledWith(
329-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
329+
expect.stringMatching(/cdk/),
330330
['destroy', '--app', 'node bin/my-app.js', 'test-stack1'],
331331
expect.objectContaining({
332332
env: expect.objectContaining({
@@ -354,7 +354,7 @@ test('destroy arguments', () => {
354354

355355
// THEN
356356
expect(spawnSyncMock).toHaveBeenCalledWith(
357-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
357+
expect.stringMatching(/cdk/),
358358
['destroy', '--force', '--no-exclusively', '--app', 'node bin/my-app.js', 'test-stack1'],
359359
expect.objectContaining({
360360
env: expect.objectContaining({
@@ -380,7 +380,7 @@ test('default ls', () => {
380380

381381
// THEN
382382
expect(spawnSyncMock).toHaveBeenCalledWith(
383-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
383+
expect.stringMatching(/cdk/),
384384
['ls', '--app', 'node bin/my-app.js', '*'],
385385
expect.objectContaining({
386386
env: expect.objectContaining({
@@ -415,7 +415,7 @@ test('ls arguments', () => {
415415

416416
// THEN
417417
expect(spawnSyncMock).toHaveBeenCalledWith(
418-
expect.stringMatching(/aws-cdk\/bin\/cdk/),
418+
expect.stringMatching(/cdk/),
419419
['ls', '--long', '--app', 'node bin/my-app.js', '*'],
420420
expect.objectContaining({
421421
env: expect.objectContaining({

0 commit comments

Comments
 (0)