Skip to content

Commit

Permalink
chore: mitigate intermitent failure of ci build (#1333)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxkane committed May 22, 2024
1 parent b06ca38 commit cdcc60b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml

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

4 changes: 4 additions & 0 deletions .projenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,10 @@ project.buildWorkflow.workflow.file?.addOverride(
'jobs.build.env.JEST_MAX_WORKERS',
'${{ vars.JEST_MAX_WORKERS || \'auto\' }}',
);
project.buildWorkflow.workflow.file?.addOverride(
'jobs.build.env.DISABLE_V8_COMPILE_CACHE',
'1',
);
project.buildWorkflow.preBuildSteps.push({
name: 'Configure AWS Credentials',
if: '${{ env.iam_role_to_assume != \'\' }}',
Expand Down
28 changes: 21 additions & 7 deletions src/private/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { POWERTOOLS_ENVS } from '@aws/clickstream-base-lib';
import { CfnResource, RemovalPolicy } from 'aws-cdk-lib';
import { Architecture, Runtime } from 'aws-cdk-lib/aws-lambda';
import { NodejsFunction, NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs';
import { BundlingOptions, NodejsFunction, NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs';
import { LogGroup, LogGroupClass, RetentionDays } from 'aws-cdk-lib/aws-logs';
import { Construct } from 'constructs';
import { addCfnNagSuppressRules, ruleToSuppressCloudWatchLogEncryption } from '../common/cfn-nag';
Expand All @@ -32,12 +32,7 @@ export class SolutionNodejsFunction extends NodejsFunction {
constructor(scope: Construct, id: string, props?: SolutionNodejsFunctionProps) {
super(scope, id, {
...props,
bundling: props?.bundling ? {
...props.bundling,
externalModules: props.bundling.externalModules?.filter(p => p === '@aws-sdk/*') ?? [],
} : {
externalModules: [],
},
bundling: _buildBundlingConfig(props?.bundling),
runtime: Runtime.NODEJS_20_X,
architecture: Architecture.ARM_64,
environment: {
Expand All @@ -51,6 +46,25 @@ export class SolutionNodejsFunction extends NodejsFunction {
}
}

function _buildBundlingConfig(bundling?: BundlingOptions) {
const esbuildOptions = {
environment: {
NODE_ENV: 'production',
},
esbuildArgs: { // Pass additional arguments to esbuild
'--log-limit': '3000',
},
};
return bundling ? {
...bundling,
externalModules: bundling.externalModules?.filter(p => p === '@aws-sdk/*') ?? [],
...esbuildOptions,
} : {
externalModules: [],
...esbuildOptions,
};
}

function getLogGroup(scope: Construct, id: string, logConf?: {
retention?: RetentionDays;
removalPolicy?: RemovalPolicy;
Expand Down

0 comments on commit cdcc60b

Please sign in to comment.