Skip to content

Commit

Permalink
chore: prepare support for Node 18 [HEAD-497] (#4882)
Browse files Browse the repository at this point in the history
* feat: add support for Node 18

* chore(gha): add workflow dispatch trigger

* feat: pkg tool uses Node 18

* feat: upadate Dockerfile Node version to 18

* chore: pkg uses Node version from .nvmrc file

* fix: use correct Node version for binary smoke test

* chore: adding additional log message to test setup

* fix: filter OPENSSL_CONF from child process

* revert: use Node 16 for build step

* revert: fix excluded Node version for smoke test

* refactor: concise log message when building Snyk binaries

---------

Co-authored-by: Peter Schäfer <[email protected]>
  • Loading branch information
Cata and PeterSchafer authored Oct 2, 2023
1 parent 06546c6 commit 3c35ba8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
types: [published]
schedule:
- cron: '0 23 * * *'
workflow_dispatch:

jobs:
smoke_test:
Expand All @@ -17,7 +18,7 @@ jobs:
matrix:
os: [ubuntu, macos, windows]
snyk_install_method: [binary, npm, yarn, brew]
node_version: [14, 16]
node_version: [14, 16, 18]
exclude:
# Skip yarn for Windows, as it's a bit crazy to get it working in CI environment. Unless we see evidence we need it, I'd avoid it
- snyk_install_method: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk-protect-production-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
node_version: [14, 16]
node_version: [14, 16, 18]
runs-on: ${{ matrix.os }}-latest
steps:
# Avoid modifying line endings in fixtures.
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export SHELL=/bin/bash
WORKING_DIR = $(CURDIR)
PKG := npx pkg ./ --compress Brotli
PKG_NODE_VERSION := $(shell head -1 .nvmrc | cut -f1 -d '.')
BINARY_WRAPPER_DIR = ts-binary-wrapper
EXTENSIBLE_CLI_DIR = cliv2
BINARY_RELEASES_FOLDER_TS_CLI = binary-releases
Expand Down Expand Up @@ -63,6 +64,7 @@ endif
.INTERMEDIATE: prepack
.SECONDARY: prepack
prepack: $(BINARY_OUTPUT_FOLDER)/version
@echo 'Initiating build for Snyk binaries with Node version: node$(PKG_NODE_VERSION)'
@echo "'make prepack' was run. Run 'make clean-prepack' to rollback your package.json changes and this file." > prepack
npm version "$(shell cat $(BINARY_RELEASES_FOLDER_TS_CLI)/version)" --no-git-tag-version --workspaces --include-workspace-root
cd $(BINARY_WRAPPER_DIR); npm version "$(shell cat $(WORKING_DIR)/$(BINARY_RELEASES_FOLDER_TS_CLI)/version)" --no-git-tag-version --include-workspace-root
Expand Down Expand Up @@ -114,27 +116,27 @@ $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-protect.tgz: prepack | $(BINARY_RELEASES_F
mv $(shell npm pack --workspace '@snyk/protect') $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-protect.tgz

$(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-alpine: prepack | $(BINARY_RELEASES_FOLDER_TS_CLI)
$(PKG) -t node16-alpine-x64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-alpine
$(PKG) -t node$(PKG_NODE_VERSION)-alpine-x64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-alpine
$(MAKE) $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-alpine.sha256

$(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-linux: prepack | $(BINARY_RELEASES_FOLDER_TS_CLI)
$(PKG) -t node16-linux-x64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-linux
$(PKG) -t node$(PKG_NODE_VERSION)-linux-x64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-linux
$(MAKE) $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-linux.sha256

# Why `--no-bytecode` for Linux/arm64:
# arm64 bytecode generation requires various build tools on an x64 build
# environment. So disabling until we can support it. It's an optimisation.
# https://github.com/vercel/pkg#targets
$(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-linux-arm64: prepack | $(BINARY_RELEASES_FOLDER_TS_CLI)
$(PKG) -t node16-linux-arm64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-linux-arm64 --no-bytecode
$(PKG) -t node$(PKG_NODE_VERSION)-linux-arm64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-linux-arm64 --no-bytecode
$(MAKE) $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-linux-arm64.sha256

$(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-macos: prepack | $(BINARY_RELEASES_FOLDER_TS_CLI)
$(PKG) -t node16-macos-x64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-macos
$(PKG) -t node$(PKG_NODE_VERSION)-macos-x64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-macos
$(MAKE) $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-macos.sha256

$(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-win.exe: prepack | $(BINARY_RELEASES_FOLDER_TS_CLI)
$(PKG) -t node16-win-x64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-win.exe
$(PKG) -t node$(PKG_NODE_VERSION)-win-x64 -o $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-win.exe
powershell $(WORKING_DIR)/cliv2/scripts/sign_windows.ps1 $(BINARY_RELEASES_FOLDER_TS_CLI) snyk-win.exe
$(MAKE) $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-win.exe.sha256

Expand Down
1 change: 1 addition & 0 deletions cliv2/internal/cliv2/cliv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ func PrepareV1EnvironmentVariables(
constants.SNYK_NPM_HTTP_PROXY_ENV,
constants.SNYK_NPM_PROXY_ENV,
constants.SNYK_NPM_ALL_PROXY,
constants.SNYK_OPENSSL_CONF,
}

for _, key := range blackList {
Expand Down
1 change: 1 addition & 0 deletions cliv2/internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const SNYK_CA_CERTIFICATE_LOCATION_ENV = "NODE_EXTRA_CA_CERTS"
const SNYK_INTERNAL_NO_PROXY = "localhost,127.0.0.1,::1"
const SNYK_OAUTH_ACCESS_TOKEN_ENV = "SNYK_OAUTH_TOKEN"
const SNYK_ANALYTICS_DISABLED_ENV = "SNYK_DISABLE_ANALYTICS"
const SNYK_OPENSSL_CONF = "OPENSSL_CONF"

const SNYK_HTTPS_PROXY_ENV_SYSTEM = "SNYK_SYSTEM_HTTPS_PROXY"
const SNYK_HTTP_PROXY_ENV_SYSTEM = "SNYK_SYSTEM_HTTP_PROXY"
Expand Down
6 changes: 6 additions & 0 deletions test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ module.exports = async function() {
if (process.env.TEST_SNYK_TOKEN !== undefined) {
await runSnykCLI(`config set api=${process.env.TEST_SNYK_TOKEN}`);
}

console.error(
'\n------------------------------------------------------------' +
'\n Environment successfully setup! Starting to run tests now!' +
'\n------------------------------------------------------------',
);
};
2 changes: 1 addition & 1 deletion test/smoke/docker-root/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:18

COPY ./smoke/ /snyk/smoke/
COPY ./fixtures/ /snyk/fixtures/
Expand Down

0 comments on commit 3c35ba8

Please sign in to comment.