From 908c11d7a478af3ff62a856eff42385ed683f685 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 2 Jun 2023 15:28:18 +0800 Subject: [PATCH] GitHubCI: improve nodejs update mechanism We found this easier method in StackOverflow [1]. The regression we were getting in the SanityCheck job was: ``` + npx commitlint --version @commitlint/cli@17.6.5 + npx commitlint --from HEAD~1 --to HEAD --verbose /__w/conventions/conventions/node_modules/typescript/lib/typescript.js:139 for (let i = startIndex ?? 0; i < array.length; i++) { ^ SyntaxError: Unexpected token '?' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at attemptRequireWithV8CompileCache (/__w/conventions/conventions/node_modules/ts-node/dist/util.js:104:16) at loadCompiler (/__w/conventions/conventions/node_modules/ts-node/dist/configuration.js:237:56) at resolveAndLoadCompiler (/__w/conventions/conventions/node_modules/ts-node/dist/configuration.js:226:16) ``` [1] https://stackoverflow.com/a/74217960/544947 --- .github/workflows/CI.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0397f6c3..7e55a164 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -74,11 +74,11 @@ jobs: apt install --yes sudo sudo apt install --yes --no-install-recommends git ca-certificates - sudo apt install --yes --no-install-recommends curl - # can't install ubuntu's default nodejs version because we would get this error: + sudo apt install --yes --no-install-recommends npm curl + # need to update nodejs because with ubuntu's default nodejs version we would get this error: # error @jest/core@29.4.1: The engine "node" is incompatible with this module. Expected version "^14.15.0 || ^16.10.0 || >=18.0.0". Got "12.22.9" - curl --show-error --location https://deb.nodesource.com/setup_14.x | sudo --preserve-env bash - - sudo DEBIAN_FRONTEND=noninteractive apt install --yes --no-install-recommends nodejs + sudo npm install --global n + sudo n lts - name: Print versions run: | git --version @@ -115,7 +115,21 @@ jobs: run: | apt update && apt install --yes sudo sudo apt install --yes --no-install-recommends git - sudo DEBIAN_FRONTEND=noninteractive apt install --yes --no-install-recommends npm + + sudo apt install --yes --no-install-recommends npm curl + # need to update nodejs because with ubuntu's default nodejs version we would get this error: + # ``` + # + npx commitlint --from HEAD~1 --to HEAD --verbose + # /__w/conventions/conventions/node_modules/typescript/lib/typescript.js:139 + # for (let i = startIndex ?? 0; i < array.length; i++) { + # ^ + # + # SyntaxError: Unexpected token '?' + # at wrapSafe (internal/modules/cjs/loader.js:915:16) + # ... + # ``` + sudo npm install --global n + sudo n lts - uses: actions/checkout@v2 with: submodules: recursive