Skip to content

Commit d0b5643

Browse files
authored
chore: Ensures that examples compile (#337)
1 parent 2f84f7b commit d0b5643

29 files changed

+213
-190
lines changed

.github/workflows/code-health.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,21 @@ jobs:
8080
echo "::error::Files were changed during build (see build log). If this was triggered from a fork, you will need to update your branch."
8181
cat .repo.patch
8282
exit 1
83+
check-examples:
84+
runs-on: ubuntu-latest
85+
permissions: {}
86+
steps:
87+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
88+
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
89+
with:
90+
node-version: 18.x
91+
- run: yarn install --check-files
92+
- run: npm install -g cdk
93+
- run: npx projen build
94+
- run: npx projen package:js
95+
- run: ./scripts/check-examples.sh
8396
call-package-workflow:
84-
needs: [compile, lint, shellcheck, check-l1-updated]
97+
needs: [compile, lint, shellcheck, check-l1-updated, check-examples]
8598
secrets: inherit
8699
permissions:
87100
contents: write

.gitignore

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

.npmignore

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.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const common_exclude = [
111111
"cdk.context.json",
112112
"yarn-error.log",
113113
"*.DS_Store",
114+
"examples-bin",
114115
];
115116
project.gitignore.exclude(...common_exclude);
116117
project.npmignore.exclude(

API.md

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

examples/l1-resources/alert-configuration.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// This example creates an alert in Atlas using the L1 resources.
22
import * as cdk from 'aws-cdk-lib';
33
import { Construct } from 'constructs';
4-
import { CfnAlertConfiguration, CfnAlertConfigurationPropsEventTypeName,
5-
NotificationViewTypeName, MetricThresholdViewMetricName, MetricThresholdViewOperator,
6-
MetricThresholdViewUnits, MetricThresholdViewMode} from 'awscdk-resources-mongodbatlas';
4+
import {
5+
CfnAlertConfiguration, NotificationViewTypeName, MetricThresholdViewOperator, MetricThresholdViewMode
6+
} from 'awscdk-resources-mongodbatlas';
77

88
interface AtlasStackProps {
99
readonly projectId: string;
@@ -21,7 +21,7 @@ export class CdkTestingStack extends cdk.Stack {
2121
const alert = new CfnAlertConfiguration(this, 'MyAlert', {
2222
profile: atlasProps.profile,
2323
projectId: atlasProps.projectId,
24-
eventTypeName: CfnAlertConfigurationPropsEventTypeName.OUTSIDE_METRIC_THRESHOLD,
24+
eventTypeName: 'OUTSIDE_METRIC_THRESHOLD',
2525
notifications: [{
2626
typeName: NotificationViewTypeName.EMAIL,
2727
delayMin: 0,
@@ -30,10 +30,10 @@ export class CdkTestingStack extends cdk.Stack {
3030
intervalMin: 15
3131
}],
3232
metricThreshold: {
33-
metricName:MetricThresholdViewMetricName.NORMALIZED_SYSTEM_CPU_USER,
33+
metricName: 'NORMALIZED_SYSTEM_CPU_USER',
3434
operator: MetricThresholdViewOperator.GREATER_THAN,
3535
threshold: 5,
36-
units: MetricThresholdViewUnits.RAW,
36+
units: 'RAW',
3737
mode: MetricThresholdViewMode.AVERAGE,
3838
}
3939
});

examples/l1-resources/api-key.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as cdk from "aws-cdk-lib";
22
import { Construct } from 'constructs';
3-
import { CfnApiKey,CfnApiKeyProps,ProjectAssignment,ListOptions} from 'awscdk-resources-mongodbatlas';
3+
import { CfnApiKey, CfnApiKeyProps, ProjectAssignment, ListOptions } from 'awscdk-resources-mongodbatlas';
44

55
const app = new cdk.App();
66

@@ -12,7 +12,7 @@ interface AtlasStackProps {
1212
readonly projectId: string;
1313
}
1414

15-
const Roles = ["ORG_MEMBER","ORG_GROUP_CREATOR"]
15+
const Roles = ["ORG_MEMBER", "ORG_GROUP_CREATOR"]
1616
export class CdkTestingStack extends cdk.Stack {
1717
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
1818
super(scope, id, props);
@@ -23,7 +23,7 @@ export class CdkTestingStack extends cdk.Stack {
2323
orgId: atlasProps.orgId,
2424
description: atlasProps.description,
2525
awsSecretName: atlasProps.awsSecretName,
26-
proAssignments: [{
26+
projectAssignments: [{
2727
projectId: atlasProps.projectId,
2828
"roles": [
2929
"GROUP_READ_ONLY"
@@ -35,23 +35,23 @@ export class CdkTestingStack extends cdk.Stack {
3535

3636
getContextProps(): AtlasStackProps {
3737
const projectId = this.node.tryGetContext('projId');
38-
if (!projectId){
38+
if (!projectId) {
3939
throw "No context value specified for projId. Please specify via the cdk context."
4040
}
4141

4242
const orgId = this.node.tryGetContext('orgId');
43-
if (!orgId){
43+
if (!orgId) {
4444
throw "No context value specified for projId. Please specify via the cdk context."
4545
}
4646
const profile = this.node.tryGetContext('profile') ?? 'default';
4747
const description = this.node.tryGetContext('description');
4848
const awsSecretName = this.node.tryGetContext('awsSecretName');
4949
return {
50-
orgId,
51-
profile,
52-
description,
53-
awsSecretName,
54-
projectId
50+
orgId,
51+
profile,
52+
description,
53+
awsSecretName,
54+
projectId
5555
}
5656
}
57-
}
57+
}

examples/l1-resources/cloud-backup-restore-jobs.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { CfnCloudBackUpRestoreJobsPropsInstanceType } from './../../src/l1-resources/cloud-backup-restore-jobs/index';
21
import * as cdk from 'aws-cdk-lib';
32
import { Construct } from 'constructs';
4-
import { CfnCloudBackUpRestoreJobs, CfnCloudBackUpRestoreJobsPropsDeliveryType } from 'awscdk-resources-mongodbatlas';
3+
import { CfnCloudBackUpRestoreJobs, CfnCloudBackUpRestoreJobsPropsInstanceType, CfnCloudBackUpRestoreJobsPropsDeliveryType } from 'awscdk-resources-mongodbatlas';
54

65
interface AtlasStackProps {
76
readonly projId: string;
@@ -18,7 +17,7 @@ export class CdkTestingStack extends cdk.Stack {
1817

1918
const atlasProps = this.getContextProps();
2019

21-
new CfnCloudBackUpRestoreJobs(this, 'CloudBackupRestoreJobs', {
20+
new CfnCloudBackUpRestoreJobs(this, 'CloudBackupRestoreJobs', {
2221
instanceName: atlasProps.instanceName,
2322
instanceType: CfnCloudBackUpRestoreJobsPropsInstanceType.CLUSTER,
2423
projectId: atlasProps.projId,
@@ -27,14 +26,14 @@ export class CdkTestingStack extends cdk.Stack {
2726
deliveryType: CfnCloudBackUpRestoreJobsPropsDeliveryType.DOWNLOAD,
2827
targetClusterName: atlasProps.targetClusterName,
2928
targetProjectId: atlasProps.targerProjId,
30-
29+
3130
});
3231

3332
}
3433

3534
getContextProps(): AtlasStackProps {
3635
const projId = this.node.tryGetContext('projId');
37-
if (!projId){
36+
if (!projId) {
3837
throw "No context value specified for projId. Please specify via the cdk context."
3938
}
4039
const snapshotId = this.node.tryGetContext('snapshotId');

examples/l1-resources/cloud-backup-schedule.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { CfnCloudBackupSchedule } from 'awscdk-resources-mongodbatlas';
55
interface AtlasStackProps {
66
readonly projId: string;
77
readonly profile: string;
8-
readonly retentionValue: string;
8+
readonly retentionValue: number;
99
readonly clusterName: string;
1010
readonly retentionUnit: string;
11-
readonly frequencyInterval: string;
11+
readonly frequencyInterval: number;
1212
readonly frequencyType: string;
1313
readonly policyId: string;
1414
readonly replicationSpecId: string;
@@ -53,7 +53,7 @@ export class CdkTestingStack extends cdk.Stack {
5353

5454
getContextProps(): AtlasStackProps {
5555
const projId = this.node.tryGetContext('projId');
56-
if (!projId){
56+
if (!projId) {
5757
throw "No context value specified for projId. Please specify via the cdk context."
5858
}
5959
const retentionValue = this.node.tryGetContext('retentionValue');

examples/l1-resources/cloud-backup-snapshot.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as cdk from 'aws-cdk-lib';
22
import { Construct } from 'constructs';
3-
import { CfnCloudBackupSnapshot,CfnCloudBackupSnapshotPropsInstanceType } from 'awscdk-resources-mongodbatlas';
3+
import { CfnCloudBackupSnapshot, CfnCloudBackupSnapshotPropsInstanceType } from 'awscdk-resources-mongodbatlas';
44

55
interface AtlasStackProps {
66
readonly projId: string;
77
readonly profile: string;
8-
readonly retentionInDays: string;
8+
readonly retentionInDays: number;
99
readonly clusterName: string;
1010
}
1111

@@ -16,19 +16,19 @@ export class CdkTestingStack extends cdk.Stack {
1616
const atlasProps = this.getContextProps();
1717

1818
new CfnCloudBackupSnapshot(this, 'CloudBackupSnapshot', {
19-
instanceName: atlasProps.clusterName,
20-
instanceType: CfnCloudBackupSnapshotPropsInstanceType.CLUSTER,
21-
profile: atlasProps.profile,
22-
projectId: atlasProps.projId,
23-
description: 'Snapshot created with CDK',
24-
retentionInDays: atlasProps.retentionInDays,
25-
});
19+
instanceName: atlasProps.clusterName,
20+
instanceType: CfnCloudBackupSnapshotPropsInstanceType.CLUSTER,
21+
profile: atlasProps.profile,
22+
projectId: atlasProps.projId,
23+
description: 'Snapshot created with CDK',
24+
retentionInDays: atlasProps.retentionInDays,
25+
});
2626

2727
}
2828

2929
getContextProps(): AtlasStackProps {
3030
const projId = this.node.tryGetContext('projId');
31-
if (!projId){
31+
if (!projId) {
3232
throw "No context value specified for projId. Please specify via the cdk context."
3333
}
3434
const retentionValue = this.node.tryGetContext('retentionValue');

0 commit comments

Comments
 (0)