Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add nodejs22.x support #696

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Changes from 1 commit
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
Next Next commit
feat: Add nodejs22.x support
hnnasit committed Oct 21, 2024
commit ce073a3664820462fc4a2411966ddddf4b70bad9
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ jobs:
python-version: ${{ matrix.python }}
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- if: ${{ matrix.npm }}
run: npm install -g npm@${{ matrix.npm }}
- run: npm --version
@@ -133,7 +133,7 @@ jobs:
python-version: ${{ matrix.python }}
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- if: ${{ matrix.npm }}
run: npm install -g npm@${{ matrix.npm }}
- run: npm --version
1 change: 1 addition & 0 deletions aws_lambda_builders/validator.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
"nodejs16.x": [ARM64, X86_64],
"nodejs18.x": [ARM64, X86_64],
"nodejs20.x": [ARM64, X86_64],
"nodejs22.x": [ARM64, X86_64],
"python3.8": [ARM64, X86_64],
"python3.9": [ARM64, X86_64],
"python3.10": [ARM64, X86_64],
50 changes: 26 additions & 24 deletions tests/integration/workflows/nodejs_npm/test_nodejs_npm.py
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ def tearDown(self):
shutil.rmtree(self.dependencies_dir)
shutil.rmtree(self.temp_dir)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_without_dependencies(self, runtime):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-deps")

@@ -75,7 +75,7 @@ def test_builds_project_without_manifest(self, runtime):
mock_warning.assert_called_once_with("package.json file not found. Continuing the build without dependencies.")
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_and_excludes_hidden_aws_sam(self, runtime):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "excluded-files")

@@ -91,7 +91,7 @@ def test_builds_project_and_excludes_hidden_aws_sam(self, runtime):
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_remote_dependencies(self, runtime):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps")

@@ -111,7 +111,7 @@ def test_builds_project_with_remote_dependencies(self, runtime):
output_modules = set(os.listdir(os.path.join(self.artifacts_dir, "node_modules")))
self.assertEqual(expected_modules, output_modules)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_npmrc(self, runtime):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "npmrc")

@@ -137,12 +137,14 @@ def test_builds_project_with_npmrc(self, runtime):
("nodejs16.x", "package-lock"),
("nodejs18.x", "package-lock"),
("nodejs20.x", "package-lock"),
("nodejs22.x", "package-lock"),
("nodejs16.x", "shrinkwrap"),
("nodejs18.x", "shrinkwrap"),
("nodejs20.x", "shrinkwrap"),
("nodejs16.x", "package-lock-and-shrinkwrap"),
("nodejs22.x", "shrinkwrap")("nodejs16.x", "package-lock-and-shrinkwrap"),
("nodejs18.x", "package-lock-and-shrinkwrap"),
("nodejs20.x", "package-lock-and-shrinkwrap"),
("nodejs22.x", "package-lock-and-shrinkwrap"),
]
)
def test_builds_project_with_lockfile(self, runtime, dir_name):
@@ -169,7 +171,7 @@ def test_builds_project_with_lockfile(self, runtime, dir_name):

self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_fails_if_npm_cannot_resolve_dependencies(self, runtime):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "broken-deps")

@@ -184,7 +186,7 @@ def test_fails_if_npm_cannot_resolve_dependencies(self, runtime):

self.assertIn("No matching version found for [email protected]", str(ctx.exception))

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_remote_dependencies_without_download_dependencies_with_dependencies_dir(self, runtime):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps")

@@ -202,7 +204,7 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_remote_dependencies_with_download_dependencies_and_dependencies_dir(self, runtime):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps")

@@ -232,7 +234,7 @@ def test_builds_project_with_remote_dependencies_with_download_dependencies_and_
output_dependencies_files = set(os.listdir(os.path.join(self.dependencies_dir)))
self.assertNotIn(expected_dependencies_files, output_dependencies_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_remote_dependencies_without_download_dependencies_without_dependencies_dir(
self, runtime
):
@@ -253,7 +255,7 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_without_combine_dependencies(self, runtime):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps")

@@ -280,7 +282,7 @@ def test_builds_project_without_combine_dependencies(self, runtime):
output_dependencies_files = set(os.listdir(os.path.join(self.dependencies_dir)))
self.assertNotIn(expected_dependencies_files, output_dependencies_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_build_in_source_with_download_dependencies(self, runtime):
source_dir = os.path.join(self.temp_testdata_dir, "npm-deps")

@@ -309,7 +311,7 @@ def test_build_in_source_with_download_dependencies(self, runtime):
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_build_in_source_with_removed_dependencies(self, runtime):
# run a build with default requirements and confirm dependencies are downloaded
source_dir = os.path.join(self.temp_testdata_dir, "npm-deps")
@@ -349,7 +351,7 @@ def test_build_in_source_with_removed_dependencies(self, runtime):
self.assertIn(".package-lock.json", set(os.listdir(source_node_modules)))
self.assertNotIn("minimal-request-promise", set(os.listdir(source_node_modules)))

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_build_in_source_with_download_dependencies_local_dependency(self, runtime):
source_dir = os.path.join(self.temp_testdata_dir, "with-local-dependency")

@@ -378,7 +380,7 @@ def test_build_in_source_with_download_dependencies_local_dependency(self, runti
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_build_in_source_with_download_dependencies_and_dependencies_dir(self, runtime):
source_dir = os.path.join(self.temp_testdata_dir, "npm-deps")

@@ -413,7 +415,7 @@ def test_build_in_source_with_download_dependencies_and_dependencies_dir(self, r
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_build_in_source_with_download_dependencies_and_dependencies_dir_without_combine_dependencies(
self, runtime
):
@@ -446,7 +448,7 @@ def test_build_in_source_with_download_dependencies_and_dependencies_dir_without
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_build_in_source_reuse_saved_dependencies_dir(self, runtime):
source_dir = os.path.join(self.temp_testdata_dir, "npm-deps")

@@ -502,7 +504,7 @@ def test_build_in_source_reuse_saved_dependencies_dir(self, runtime):
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_manifest_outside_root(self, runtime):
base_dir = os.path.join(self.temp_testdata_dir, "manifest-outside-root")
source_dir = os.path.join(base_dir, "src")
@@ -525,7 +527,7 @@ def test_builds_project_with_manifest_outside_root(self, runtime):
output_modules = set(os.listdir(os.path.join(self.artifacts_dir, "node_modules")))
self.assertEqual(expected_modules, output_modules)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_manifest_outside_root_with_reuse_saved_dependencies_dir(self, runtime):
base_dir = os.path.join(self.temp_testdata_dir, "manifest-outside-root")
source_dir = os.path.join(base_dir, "src")
@@ -572,7 +574,7 @@ def test_builds_project_with_manifest_outside_root_with_reuse_saved_dependencies
output_modules = set(os.listdir(os.path.join(self.artifacts_dir, "node_modules")))
self.assertEqual(expected_modules, output_modules)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_manifest_outside_root_with_dependencies_dir_and_not_combine(self, runtime):
base_dir = os.path.join(self.temp_testdata_dir, "manifest-outside-root")
source_dir = os.path.join(base_dir, "src")
@@ -597,7 +599,7 @@ def test_builds_project_with_manifest_outside_root_with_dependencies_dir_and_not
dependencies_dir_modules = set(os.listdir(os.path.join(self.dependencies_dir, "node_modules")))
self.assertEqual(expected_modules, dependencies_dir_modules)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_manifest_outside_root_with_dependencies_dir_and_combine(self, runtime):
base_dir = os.path.join(self.temp_testdata_dir, "manifest-outside-root")
source_dir = os.path.join(base_dir, "src")
@@ -626,7 +628,7 @@ def test_builds_project_with_manifest_outside_root_with_dependencies_dir_and_com
dependencies_dir_modules = set(os.listdir(os.path.join(self.dependencies_dir, "node_modules")))
self.assertEqual(expected_modules, dependencies_dir_modules)

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_manifest_outside_root_and_local_dependencies(self, runtime):
base_dir = os.path.join(self.temp_testdata_dir, "manifest-outside-root-with-local-dependency")
source_dir = os.path.join(base_dir, "src")
@@ -654,7 +656,7 @@ def test_builds_project_with_manifest_outside_root_and_local_dependencies(self,
source_modules = set(os.listdir(os.path.join(source_dir, "node_modules")))
self.assertTrue(all(expected_module in source_modules for expected_module in expected_modules))

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_manifest_outside_root_and_local_dependencies_with_reuse_saved_dependencies_dir(
self, runtime
):
@@ -709,7 +711,7 @@ def test_builds_project_with_manifest_outside_root_and_local_dependencies_with_r
source_modules = set(os.listdir(os.path.join(source_dir, "node_modules")))
self.assertTrue(all(expected_module in source_modules for expected_module in expected_modules))

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_manifest_outside_root_and_local_dependencies_with_dependencies_dir_and_not_combine(
self, runtime
):
@@ -741,7 +743,7 @@ def test_builds_project_with_manifest_outside_root_and_local_dependencies_with_d
source_modules = set(os.listdir(os.path.join(source_dir, "node_modules")))
self.assertTrue(all(expected_module in source_modules for expected_module in expected_modules))

@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",)])
@parameterized.expand([("nodejs16.x",), ("nodejs18.x",), ("nodejs20.x",), ("nodejs22.x",)])
def test_builds_project_with_manifest_outside_root_and_local_dependencies_with_dependencies_dir_and_combine(
self, runtime
):
Loading