Skip to content

Commit

Permalink
feat(node)!: default to node16 and do not use jsii/superchain image…
Browse files Browse the repository at this point in the history
… in workflows

BREAKING CHANGE: default to node16
To use any other Node version, explicitly provide the desired version number

BREAKING CHANGE: remove `jsii/superchain` image from AwsCdkConstructLibrary workflows
Using `jsii/superchain` provides no tangible benefit over installing dependencies with GitHub Actions.
However because AWS CDK Constructs often require to run docker commands, with image GitHub Action workflows end up attempting to run Docker in Docker.
This is not trivial to achieve (see #2094 & aws/aws-cdk#8799).
Additionally the existing build and package workflows had an inconsistent usage of the image, causing further problems.

To restore the old behavior, set `options.workflowContainerImage` to the desired image.

Fixes #2094
Closes #1065
  • Loading branch information
mrgrain committed Mar 15, 2023
1 parent e9919f9 commit 35a3221
Show file tree
Hide file tree
Showing 31 changed files with 158 additions and 190 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml

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

12 changes: 6 additions & 6 deletions .github/workflows/release.yml

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

2 changes: 1 addition & 1 deletion .github/workflows/upgrade-main.yml

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

2 changes: 1 addition & 1 deletion .projen/deps.json

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

4 changes: 2 additions & 2 deletions .projenrc.js
Expand Up @@ -62,8 +62,8 @@ const project = new cdk.JsiiProject({

projenDevDependency: false, // because I am projen
releaseToNpm: true,
minNodeVersion: "14.0.0",
workflowNodeVersion: "14.18.0", // required by eslint-import-resolver-typescript@3.5.0
minNodeVersion: "16.0.0",
workflowNodeVersion: "16.13.0",

codeCov: true,
prettier: true,
Expand Down
18 changes: 9 additions & 9 deletions docs/api/API.md

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

14 changes: 7 additions & 7 deletions docs/awscdk.md
Expand Up @@ -72,7 +72,7 @@ new AwsCdkConstructLibrary({
// ...
lambdaOptions: {
// target node.js runtime
runtime: awscdk.LambdaRuntime.NODEJS_14_X,
runtime: awscdk.LambdaRuntime.NODEJS_18_X,

bundlingOptions: {
// list of node modules to exclude from the bundle
Expand Down Expand Up @@ -259,12 +259,12 @@ the captured snapshot. The build will fail if the output differs.

For each integration test, the following set of tasks are created:

|Task|Description|
|----|-----------|
|`integ:NAME:deploy`|Deploys & destroys the test app and updates the snapshot.|
|`integ:NAME:assert`|Synthesizes the test app and compares it with the snapshot (this is the task that runs during build)|
|`integ:NAME:snapshot`|Synthesizes the test app and updates the snapshot (not recommended to use because it bypasses deployment).|
|`integ:NAME:destroy`|Destroys a previously deployed test app.|
| Task | Description |
| --------------------- | ---------------------------------------------------------------------------------------------------------- |
| `integ:NAME:deploy` | Deploys & destroys the test app and updates the snapshot. |
| `integ:NAME:assert` | Synthesizes the test app and compares it with the snapshot (this is the task that runs during build) |
| `integ:NAME:snapshot` | Synthesizes the test app and updates the snapshot (not recommended to use because it bypasses deployment). |
| `integ:NAME:destroy` | Destroys a previously deployed test app. |

### Writing test assertions

Expand Down
2 changes: 1 addition & 1 deletion docs/bundling.md
Expand Up @@ -19,7 +19,7 @@ To add bundles, call `bundler.addBundle()`:
```ts
project.bundler.addBundle('name-of-bundle', {
entrypoint: 'src/foo.ts',
target: 'node14',
target: 'node18',
platform: 'node',
bundlingOptions: {
externals: ['aws-sdk'], // modules not to include in bundles
Expand Down
4 changes: 2 additions & 2 deletions package.json

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

32 changes: 1 addition & 31 deletions src/awscdk/awscdk-construct.ts
Expand Up @@ -78,10 +78,7 @@ export class AwsCdkConstructLibrary extends ConstructLibrary {
pinnedDevDependency: false,
}
: undefined,
workflowContainerImage: determineWorkflowContainerImage(
options,
cdkMajorVersion
),
workflowContainerImage: options.workflowContainerImage,
...options,
});

Expand Down Expand Up @@ -141,33 +138,6 @@ export class AwsCdkConstructLibrary extends ConstructLibrary {
}
}

function determineWorkflowContainerImage(
options: AwsCdkConstructLibraryOptions,
cdkMajorVersion: number | undefined
): string | undefined {
// if the user specifies the workflow container image explicitly, use that
if (options.workflowContainerImage) {
return options.workflowContainerImage;
}

// if the user specifies minimum node version, then JsiiProject will take care of
// determining the workflow container image from that, so we return "undefined"
if (options.minNodeVersion) {
return undefined;
}

// otherwise, choose a workflow container image based on the CDK version
if (cdkMajorVersion === 1) {
return "jsii/superchain:1-buster-slim";
}

if (cdkMajorVersion === 2) {
return "jsii/superchain:1-buster-slim-node14";
}

return undefined;
}

/** @deprecated use `AwsCdkConstructLibraryOptions` */
export interface ConstructLibraryAwsOptions
extends AwsCdkConstructLibraryOptions {}
Expand Down
6 changes: 4 additions & 2 deletions src/awscdk/lambda-function.ts
Expand Up @@ -20,7 +20,7 @@ export interface LambdaFunctionCommonOptions {
/**
* The node.js version to target.
*
* @default Runtime.NODEJS_14_X
* @default Runtime.NODEJS_16_X
*/
readonly runtime?: LambdaRuntime;

Expand Down Expand Up @@ -134,7 +134,7 @@ export class LambdaFunction extends Component {
);
}

const runtime = options.runtime ?? LambdaRuntime.NODEJS_14_X;
const runtime = options.runtime ?? LambdaRuntime.NODEJS_16_X;

// allow Lambda handler code to import dev-deps since they are only needed
// during bundling
Expand Down Expand Up @@ -311,6 +311,7 @@ export class LambdaRuntime {

/**
* Node.js 12.x
* @deprecated NodeJS12 has been deprecated
*/
public static readonly NODEJS_12_X = new LambdaRuntime(
"nodejs12.x",
Expand All @@ -320,6 +321,7 @@ export class LambdaRuntime {

/**
* Node.js 14.x
* @deprecated NodeJS14 has been deprecated
*/
public static readonly NODEJS_14_X = new LambdaRuntime(
"nodejs14.x",
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/jsii-project.ts
Expand Up @@ -408,7 +408,7 @@ export class JsiiProject extends TypeScriptProject {
runsOn: ["ubuntu-latest"],
permissions: {},
tools: {
node: { version: this.nodeVersion ?? "14.x" },
node: { version: this.nodeVersion ?? "16.x" },
...pacmak.publishTools,
},
steps: pacmak.prePublishSteps ?? [],
Expand Down
4 changes: 2 additions & 2 deletions src/cli/index.ts
Expand Up @@ -58,9 +58,9 @@ async function main() {
}

const nodeVersion = getNodeMajorVersion();
if (nodeVersion && nodeVersion < 14) {
if (nodeVersion && nodeVersion < 16) {
logging.warn(
`WARNING: You are using Node v${nodeVersion}, which reaches end of life on April 30, 2022. Support for EOL Node releases may be dropped by projen in the future. Please consider upgrading to Node >= 14 as soon as possible.`
`WARNING: You are using Node v${nodeVersion}, which reaches end of life on April 30, 2023. Support for EOL Node releases may be dropped by projen in the future. Please consider upgrading to Node >= 16 as soon as possible.`
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/release/publisher.ts
Expand Up @@ -66,7 +66,7 @@ export interface PublisherOptions {
* are needed. For example `publib`, the CLI projen uses to publish releases,
* is an npm library.
*
* @default 14.x
* @default 16.x
*/
readonly workflowNodeVersion?: string;

Expand Down Expand Up @@ -156,7 +156,7 @@ export class Publisher extends Component {
this.jsiiReleaseVersion = this.publibVersion;
this.condition = options.condition;
this.dryRun = options.dryRun ?? false;
this.workflowNodeVersion = options.workflowNodeVersion ?? "14.x";
this.workflowNodeVersion = options.workflowNodeVersion ?? "16.x";

this.failureIssue = options.failureIssue ?? false;
this.failureIssueLabel = options.failureIssueLabel ?? "failed-release";
Expand Down
2 changes: 1 addition & 1 deletion src/release/release.ts
Expand Up @@ -245,7 +245,7 @@ export interface ReleaseOptions extends ReleaseProjectOptions {
* are needed. For example `publib`, the CLI projen uses to publish releases,
* is an npm library.
*
* @default 14.x
* @default 16.x
*/
readonly workflowNodeVersion?: string;

Expand Down
2 changes: 1 addition & 1 deletion src/typescript/typescript.ts
Expand Up @@ -362,7 +362,7 @@ export class TypeScriptProject extends NodeProject {
// Additionally, we default to tracking the 12.x line, as the current earliest LTS release of
// node is 12.x, so this is what corresponds to the broadest compatibility with supported node
// runtimes.
`@types/node@^${semver.major(this.package.minNodeVersion ?? "14.0.0")}`
`@types/node@^${semver.major(this.package.minNodeVersion ?? "16.0.0")}`
);

// generate sample code in `src` and `lib` if these directories are empty or non-existent.
Expand Down

0 comments on commit 35a3221

Please sign in to comment.