Skip to content

Commit 48e05d5

Browse files
authored
ci(integration-test-deployment): bootstrap account before deployment (#35799)
### Reason for this change For integration deployment tests, accounts under atmosphere do not have the CDK bootstrap. ### Description of changes Add a bootstrap step to the integration deployment test. ### Describe any new or updated permissions being added No new IAM permissions added. ### Description of how you validated changes Workflow runs successfully under fork: https://github.com/Abogical/aws-cdk/actions/runs/18687737855/job/53284876440 ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 10fcb1b commit 48e05d5

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

tools/@aws-cdk/integration-test-deployment/lib/integration-test-runner.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const deployInegTestsWithAtmosphere = async ({ endpoint, pool }: {endpoin
1818
SOURCE_BRANCH_COMMIT: process.env.SOURCE_BRANCH_COMMIT,
1919
};
2020

21+
await bootstrap(env);
2122
await deployIntegrationTests(env);
2223
outcome = 'success';
2324
} catch (e) {
@@ -31,6 +32,19 @@ export const deployInegTestsWithAtmosphere = async ({ endpoint, pool }: {endpoin
3132
}
3233
};
3334

35+
export const bootstrap = async (env: NodeJS.ProcessEnv) => {
36+
console.log('Bootstrapping AWS account.');
37+
const spawnProcess = spawn('npx', ['cdk', 'bootstrap', ...['us-east-1', 'us-east-2', 'us-west-2'].map((region) => `aws://${env.AWS_ACCOUNT_ID}/${region}`)], {
38+
stdio: ['ignore', 'inherit', 'inherit'],
39+
env,
40+
});
41+
42+
return new Promise<void>((resolve, reject) => spawnProcess.on('close', (code) => {
43+
if (code == 0) resolve();
44+
else reject(new Error(`Account bootstrap failed with exit code ${code}`));
45+
}));
46+
};
47+
3448
export const deployIntegrationTests = async (env: NodeJS.ProcessEnv) => {
3549
const changedSnapshotPaths = await getChangedSnapshots();
3650
console.log(`Detected changed snapshots:\n${changedSnapshotPaths.join('\n')}`);
@@ -39,7 +53,7 @@ export const deployIntegrationTests = async (env: NodeJS.ProcessEnv) => {
3953
throw new Error('No snapshots changed, skipping deployment integ test.');
4054
}
4155

42-
const spawnProcess = spawn('yarn', ['integ-runner', '--directory', 'packages', '--force', ...changedSnapshotPaths], {
56+
const spawnProcess = spawn('yarn', ['integ-runner', '--disable-update-workflow', '--directory', 'packages', '--force', ...changedSnapshotPaths], {
4357
stdio: ['ignore', 'inherit', 'inherit'],
4458
env,
4559
});
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import { describe, expect, jest, test, beforeEach } from '@jest/globals';
22
import { AtmosphereAllocationMock } from './atmosphere-mock';
3-
import { AtmosphereAllocation } from '../lib/atmosphere';
43
import { gitDiffMock } from './git-mock';
5-
import * as utils from '../lib/utils';
4+
import { AtmosphereAllocation } from '../lib/atmosphere';
65
import * as integRunner from '../lib/integration-test-runner';
6+
import * as utils from '../lib/utils';
77

88
jest.mock('../lib/atmosphere');
99

10+
const env = {
11+
AWS_ACCESS_KEY_ID: 'XXXXXXXXXXXXX',
12+
AWS_SECRET_ACCESS_KEY: '123456789',
13+
AWS_SESSION_TOKEN: '123456789',
14+
AWS_REGION: 'us-east-1',
15+
AWS_ACCOUNT_ID: '123456789',
16+
};
17+
1018
describe('Run Inegration Tests with Atmosphere', () => {
1119
let mockAtmosphereAllocation: AtmosphereAllocationMock;
1220

@@ -18,6 +26,7 @@ describe('Run Inegration Tests with Atmosphere', () => {
1826
jest.spyOn(utils, 'gitDiff').mockImplementation(gitDiffMock);
1927
jest.spyOn(mockAtmosphereAllocation, 'release');
2028
jest.spyOn(integRunner, 'deployIntegrationTests').mockImplementation(async () => {});
29+
jest.spyOn(integRunner, 'bootstrap').mockImplementation(async () => {});
2130
});
2231

2332
test('successful integration test', async () => {
@@ -26,13 +35,8 @@ describe('Run Inegration Tests with Atmosphere', () => {
2635

2736
await integRunner.deployInegTestsWithAtmosphere({ endpoint, pool });
2837
expect(AtmosphereAllocation.acquire).toHaveBeenCalled();
29-
expect(integRunner.deployIntegrationTests).toHaveBeenCalledWith(expect.objectContaining({
30-
AWS_ACCESS_KEY_ID: 'XXXXXXXXXXXXX',
31-
AWS_SECRET_ACCESS_KEY: '123456789',
32-
AWS_SESSION_TOKEN: '123456789',
33-
AWS_REGION: 'us-east-1',
34-
AWS_ACCOUNT_ID: '123456789',
35-
}));
38+
expect(integRunner.bootstrap).toHaveBeenCalledWith(expect.objectContaining(env));
39+
expect(integRunner.deployIntegrationTests).toHaveBeenCalledWith(expect.objectContaining(env));
3640
expect(mockAtmosphereAllocation.release).toHaveBeenCalled();
3741
});
3842

@@ -49,13 +53,8 @@ describe('Run Inegration Tests with Atmosphere', () => {
4953
);
5054

5155
expect(AtmosphereAllocation.acquire).toHaveBeenCalled();
52-
expect(integRunner.deployIntegrationTests).toHaveBeenCalledWith(expect.objectContaining({
53-
AWS_ACCESS_KEY_ID: 'XXXXXXXXXXXXX',
54-
AWS_SECRET_ACCESS_KEY: '123456789',
55-
AWS_SESSION_TOKEN: '123456789',
56-
AWS_REGION: 'us-east-1',
57-
AWS_ACCOUNT_ID: '123456789',
58-
}));
56+
expect(integRunner.bootstrap).toHaveBeenCalledWith(expect.objectContaining(env));
57+
expect(integRunner.deployIntegrationTests).toHaveBeenCalledWith(expect.objectContaining(env));
5958
expect(mockAtmosphereAllocation.release).toHaveBeenCalled();
6059
});
6160
});

0 commit comments

Comments
 (0)