-
Notifications
You must be signed in to change notification settings - Fork 4
/
.projenrc.js
162 lines (151 loc) · 4.84 KB
/
.projenrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
const { release } = require('os');
const projen = require('projen');
const project = new projen.awscdk.AwsCdkConstructLibrary({
author: 'scott.hsieh',
authorName: 'Shu-Jeng Hsieh',
authorAddress: 'https://fantasticsie.medium.com/',
description: 'A construct for the quick demo of EMR Serverless.',
keywords: [
'aws',
'cdk',
'emr-studio',
'emr',
'delta-lake',
'emr-serverless',
'serverless',
'scott.hsieh',
'emr-notebooks',
'emr-studio',
'aws-service-catalog',
],
cdkVersion: '2.27.0',
constructsVersion: '10.1.35',
majorVersion: 2,
defaultReleaseBranch: 'main',
name: 'cdk-emrserverless-with-delta-lake',
repositoryUrl: 'https://github.com/HsiehShuJeng/cdk-emrserverless-with-delta-lake.git',
deps: [
'aws-cdk-lib',
'constructs@^10.1.35',
],
devDeps: [
'aws-cdk-lib',
'constructs@^10.1.35',
'esbuild',
'source-map-support',
],
jsiiVersion: '5.4.x',
eslint: true,
depsUpgradeOptions: {
workflowOptions: {
labels: ['auto-approve', 'auto-merge'],
},
},
autoApproveOptions: {
secret: 'GITHUB_TOKEN',
allowedUsernames: ['HsiehShuJeng'],
},
releaseToNpm: true,
publishToPypi: {
distName: 'cdk_emrserverless_with_delta_lake',
module: 'cdk_emrserverless_with_delta_lake',
},
publishToMaven: {
mavenGroupId: 'io.github.hsiehshujeng',
mavenArtifactId: 'cdk-emrserverless-quickdemo-with-delta-lake',
javaPackage: 'io.github.hsiehshujeng.cdk.emrserverless.quickdemo',
mavenEndpoint: 'https://s01.oss.sonatype.org', // check https://central.sonatype.org/publish/release/#login-into-ossrh
},
publishToNuget: {
dotNetNamespace: 'ScottHsieh.Cdk',
packageId: 'Emrserverless.With.Delta.Lake',
},
publishToGo: {
moduleName: 'github.com/HsiehShuJeng/cdk-emrserverless-with-delta-lake-go',
},
});
const mavenExclusions = ['public.pem', 'private.pem'];
const pythonDemoExclustions = [
'*.swp',
'package-lock.json',
'__pycache__',
'.pytest_cache',
'.env',
'.venv',
'*.egg-info',
];
const javaDemoExclustions = [
'.classpath.txt',
'target/',
'.classpath',
'.project',
'.idea',
'.settings',
'.vscode/',
'*.iml',
];
const commonExclusions = ['cdk.context.json', 'yarn-error.log', 'cdk.out', '.cdk.staging', '.DS_Store'];
const exclusionLists = [
commonExclusions,
mavenExclusions,
pythonDemoExclustions,
javaDemoExclustions,
];
excludeFilesFrom(project, exclusionLists);
const requiredAwsEnv = {
AWS_REGION: 'ap-northeast-1',
AWS_ACCESS_KEY_ID: '${{ secrets.AWS_ACCESS_KEY_ID }}',
AWS_SECRET_ACCESS_KEY: '${{ secrets.AWS_SECRET_ACCESS_KEY }}',
};
const releaseOverridingSteps = {
'jobs.release.steps.4': {
name: 'release',
run: 'export CDK_DEFAULT_ACCOUNT=$(aws sts get-caller-identity --query \'Account\' | tr -d \'"\')\nexport CDK_DEFAULT_REGION=${AWS_REGION}\nnpx projen release',
},
};
const buildOverridingSteps = {
'jobs.build.steps.2': {
name: 'Install dependencies',
run: 'yarn install --frozen-lockfile',
},
'jobs.build.steps.3': {
name: 'build',
run: 'export CDK_DEFAULT_ACCOUNT=$(aws sts get-caller-identity --query \'Account\' | tr -d \'"\')\nexport CDK_DEFAULT_REGION=${AWS_REGION}\nnpx projen build',
},
};
const approveOverridingSteps = {
'jobs.approve.steps.0.uses': 'hmarr/auto-approve-action@v3.2.1',
};
setupWorkflow('build', requiredAwsEnv, buildOverridingSteps);
setupWorkflow('release', requiredAwsEnv, releaseOverridingSteps);
setupWorkflow('auto-approve', undefined, approveOverridingSteps);
project.package.addPackageResolutions('@types/jest@^27.4.1');
project.synth();
/**
* Exclude files from the project's .npmignore and .gitignore.
*
* @param {Object} pjObject - The project object to apply the exclusions.
* @param {Array<Array<string>>} exclusionList - An array of arrays, where each inner array contains a list of file patterns to exclude.
*/
function excludeFilesFrom(pjObject, exclusionList) {
for (const exclusions of exclusionList) {
pjObject.npmignore.exclude(...exclusions);
pjObject.gitignore.exclude(...exclusions);
}
}
/**
* Set up a GitHub Actions workflow with the specified environment variables and step overrides.
*
* @param {string} workflowName - The name of the workflow to configure.
* @param {Object} [envOverrides] - An object containing environment variables to override in the workflow.
* @param {Object} stepsOverrides - An object where each key is a step identifier (e.g., 'jobs.build.steps.2') and each value is an object containing the step configuration to override.
*/
function setupWorkflow(workflowName, envOverrides, stepsOverrides) {
const workflow = project.github.tryFindWorkflow(workflowName);
for (const [step, override] of Object.entries(stepsOverrides)) {
workflow.file.addOverride(step, override);
}
if (envOverrides) {
workflow.file.addOverride(`jobs.${workflowName}.env`, envOverrides);
}
}