Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cdk/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ const githubTagKeys = [
'ref-type',
'actor',
'head-ref',
'base-ref',
'pr-number',
'run-id',
'run-attempt',
'event',
'workflow',
'repository',
'clean',
] as const;
Expand Down
17 changes: 15 additions & 2 deletions cdk/test/stacks/github-tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ const GITHUB_TAG_KEYS = [
'github:ref-type',
'github:actor',
'github:head-ref',
'github:base-ref',
'github:pr-number',
'github:run-id',
'github:run-attempt',
'github:event',
'github:workflow',
'github:repository',
'github:clean',
] as const;
Expand All @@ -42,7 +46,8 @@ function synthWithTags(context: Record<string, string> = {}): Template {

const githubTagKeys = [
'sha', 'ref', 'ref-type', 'actor', 'head-ref',
'run-id', 'event', 'repository', 'clean',
'base-ref', 'pr-number', 'run-id', 'run-attempt',
'event', 'workflow', 'repository', 'clean',
] as const;

for (const key of githubTagKeys) {
Expand All @@ -65,14 +70,18 @@ describe('github:* resource tags', () => {
'github:ref-type': 'branch',
'github:actor': 'scottschreckengaust',
'github:head-ref': '',
'github:base-ref': 'main',
'github:pr-number': '85',
'github:run-id': '12345678',
'github:run-attempt': '1',
'github:event': 'push',
'github:workflow': 'deploy.yml',
'github:repository': 'aws-samples/sample-autonomous-cloud-coding-agents',
'github:clean': 'true',
});
});

test('all 9 github:* tags default to "none" when no context is provided', () => {
test('all 13 github:* tags default to "none" when no context is provided', () => {
const resources = templateWithDefaults.findResources('AWS::DynamoDB::Table');
const firstResource = Object.values(resources)[0];
const tags: Array<{ Key: string; Value: string }> = firstResource?.Properties?.Tags ?? [];
Expand All @@ -94,8 +103,12 @@ describe('github:* resource tags', () => {
expect(tags.find(t => t.Key === 'github:ref-type')!.Value).toBe('branch');
expect(tags.find(t => t.Key === 'github:actor')!.Value).toBe('scottschreckengaust');
expect(tags.find(t => t.Key === 'github:head-ref')!.Value).toBe('none');
expect(tags.find(t => t.Key === 'github:base-ref')!.Value).toBe('main');
expect(tags.find(t => t.Key === 'github:pr-number')!.Value).toBe('85');
expect(tags.find(t => t.Key === 'github:run-id')!.Value).toBe('12345678');
expect(tags.find(t => t.Key === 'github:run-attempt')!.Value).toBe('1');
expect(tags.find(t => t.Key === 'github:event')!.Value).toBe('push');
expect(tags.find(t => t.Key === 'github:workflow')!.Value).toBe('deploy.yml');
expect(tags.find(t => t.Key === 'github:repository')!.Value).toBe('aws-samples/sample-autonomous-cloud-coding-agents');
expect(tags.find(t => t.Key === 'github:clean')!.Value).toBe('true');
});
Expand Down