Page MenuHomePhabricator

[ci deps] Bump node to 20
ClosedPublic

Authored by bytesofman on Feb 13 2024, 10:05.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC8f8e8b1d18b8: [ci deps] Bump node to 20
Summary

CI tests using nodejs are currently run in node 16. Cashtab is now on node 20.

Other apps that have not yet migrated to node 20 need to do so, as node 16 is past end of life.

So, if this ends up causing issues with other node projects -- they will need to be udpated to accomodate this version.

Test Plan

./contrib/teamcity/build-configurations.py cashtab-tests

can also run

wget https://deb.nodesource.com/setup_20.x > nodesetup.sh
echo "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 nodesetup.sh" | sha256sum -c

locally, confirm output nodesetup.sh: OK

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien added inline comments.
contrib/utils/install-dependencies-bullseye.sh
161 ↗(On Diff #45176)

while you're at it, can you check the checksum of the file so we don't blindly run a script downloaded from the internet ?

checksum before installing node 20

contrib/utils/install-dependencies-bullseye.sh
163 ↗(On Diff #45194)

here is the file at https://deb.nodesource.com/setup_20.x with this checksum

#!/bin/bash

# Logger Function
log() {
  local message="$1"
  local type="$2"
  local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
  local color
  local endcolor="\033[0m"

  case "$type" in
    "info") color="\033[38;5;79m" ;;
    "success") color="\033[1;32m" ;;
    "error") color="\033[1;31m" ;;
    *) color="\033[1;34m" ;;
  esac

  echo -e "${color}${timestamp} - ${message}${endcolor}"
}

# Error handler function  
handle_error() {
  local exit_code=$1
  local error_message="$2"
  log "Error: $error_message (Exit Code: $exit_code)" "error"
  exit $exit_code
}

# Function to check for command availability
command_exists() {
  command -v "$1" &> /dev/null
}

check_os() {
    if ! [ -f "/etc/debian_version" ]; then
        echo "Error: This script is only supported on Debian-based systems."
        exit 1
    fi
}

# Function to Install the script pre-requisites
install_pre_reqs() {
    log "Installing pre-requisites" "info"

    # Run 'apt-get update'
    if ! apt-get update -y; then
        handle_error "$?" "Failed to run 'apt-get update'"
    fi

    # Run 'apt-get install'
    if ! apt-get install -y apt-transport-https ca-certificates curl gnupg; then
        handle_error "$?" "Failed to install packages"
    fi

    mkdir -p /usr/share/keyrings
    rm -f /usr/share/keyrings/nodesource.gpg
    rm -f /etc/apt/sources.list.d/nodesource.list

    # Run 'curl' and 'gpg'
    if ! curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg; then
      handle_error "$?" "Failed to download and import the NodeSource signing key"
    fi
}

# Function to configure the Repo
configure_repo() {
    local node_version=$1

    arch=$(dpkg --print-architecture)
    if [ "$arch" != "amd64" ] && [ "$arch" != "arm64" ] && [ "$arch" != "armhf" ]; then
      handle_error "1" "Unsupported architecture: $arch. Only amd64, arm64, and armhf are supported."
    fi

    echo "deb [arch=$arch signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$node_version nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null

    # N|solid Config
    echo "Package: nsolid" | tee /etc/apt/preferences.d/nsolid > /dev/null
    echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nsolid > /dev/null
    echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nsolid > /dev/null

    # Nodejs Config
    echo "Package: nodejs" | tee /etc/apt/preferences.d/nodejs > /dev/null
    echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nodejs > /dev/null
    echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nodejs > /dev/null

    # Run 'apt-get update'
    if ! apt-get update -y; then
        handle_error "$?" "Failed to run 'apt-get update'"
    else
        log "Repository configured successfully. To install Node.js, run: apt-get install nodejs -y" "success"
    fi
}

# Define Node.js version
NODE_VERSION="20.x"

# Check OS
check_os

# Main execution
install_pre_reqs || handle_error $? "Failed installing pre-requisites"
configure_repo "$NODE_VERSION" || handle_error $? "Failed configuring repository"
Fabien requested changes to this revision.Feb 13 2024, 20:01
Fabien added inline comments.
contrib/utils/install-dependencies-bullseye.sh
173 ↗(On Diff #45194)

This is too complicated for no reason, see what's done for corrosion below and use the same sha256sum -c form

This revision now requires changes to proceed.Feb 13 2024, 20:01

gotta be able to make this work with a variable to store the curl output instead of the file

use wget, do not create the file before you wget it

Fabien added inline comments.
contrib/utils/install-dependencies-bullseye.sh
161 ↗(On Diff #45204)
This revision is now accepted and ready to land.Feb 14 2024, 08:25
This revision was automatically updated to reflect the committed changes.