Skip to content

Commit

Permalink
integ and snapshots with MOCK
Browse files Browse the repository at this point in the history
  • Loading branch information
go-to-k committed Feb 12, 2025
1 parent d8e43ca commit 01adcec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
},
"Configuration": {
"ConnectionArn": "MOCK",
"FullRepositoryId": "go-to-k/cdk-codepipeline-demo-1",
"FullRepositoryId": "MOCK/MOCK",
"BranchName": "master"
},
"Name": "CodeStarConnectionsSourceAction",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,40 @@ import { ExpectedResult, IntegTest, Match } from '@aws-cdk/integ-tests-alpha';

/*
* To run this integ test, the following steps are required.
* 1. Create a test repository on GitHub (in the code below, it is 'cdk-codepipeline-demo-1')
* 2. Create a Dockerfile with any content at the path `./my-dir/Dockerfile`
* 3. Set the `owner` and `repo` of `CodeStarConnectionsSourceAction` to your GitHub account name and repository name
* 4. Create a Connections in the CodePipeline management console that accesses your GitHub account
* 5. Set the ARN of that Connections to the `CONNECTION_ARN` environment variable in the integ test execution environment
* 6. After running the integ test, replace the value of CONNECTION_ARN written in the file generated in CloudAssembly (integ.pipeline-ecr-build-and-publish.js.snapshot/*) with the string `MOCK`
*
* 1. Create a test repository with any repository name on your GitHub account
* 2. Create a Dockerfile with any content at the path `./my-dir/Dockerfile` in the repository, and push it to the repository
* 3. Create a Connections in the CodePipeline management console that accesses your GitHub account
* 4. Set the ARN of that Connections to the `CONNECTION_ARN` environment variable in the integ test execution environment
* 5. Set your GitHub account name and the repository name to the `REPO_OWNER` and `REPO_NAME` environment variables in the integ test execution environment
* 6. After running the integ test, replace the value of `CONNECTION_ARN`, `REPO_OWNER`, and `REPO_NAME` written in the file generated in CloudAssembly (integ.THIS_FILE.js.snapshot/*) with the string `MOCK`
*/

const app = new cdk.App();

const stack = new cdk.Stack(app, 'codepipeline-ecr-build-and-publish');

// Make sure you specify a valid connection ARN.
// Make sure you specify your connection ARN, your repository owner and name.
const connectionArn = process.env.CONNECTION_ARN || 'MOCK';
const owner = process.env.REPO_OWNER || 'MOCK';
const repo = process.env.REPO_NAME || 'MOCK';
if (connectionArn === 'MOCK') {
cdk.Annotations.of(stack).addWarningV2('integ:connection-arn', 'You must specify a valid connection ARN in the CONNECTION_ARN environment variable');
cdk.Annotations.of(stack).addWarningV2('integ:connection-arn', 'You must specify your connection ARN in the CONNECTION_ARN environment variable');
}
if (owner === 'MOCK') {
cdk.Annotations.of(stack).addWarningV2('integ:repo-owner', 'You must specify your repository owner in the REPO_OWNER environment variable');
}
if (repo === 'MOCK') {
cdk.Annotations.of(stack).addWarningV2('integ:repo-name', 'You must specify your repository name in the REPO_NAME environment variable');
}

const sourceOutput = new codepipeline.Artifact();
const sourceAction = new cpactions.CodeStarConnectionsSourceAction({
actionName: 'CodeStarConnectionsSourceAction',
output: sourceOutput,
connectionArn,
// Please change the owner and repo if you execute this test
owner: 'go-to-k',
repo: 'cdk-codepipeline-demo-1',
owner,
repo,
});

const repository = new ecr.Repository(stack, 'Repository', {
Expand Down

0 comments on commit 01adcec

Please sign in to comment.