chore: Upgrade Node.js to v20 (#7759)

Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Shivam Mishra
2023-08-28 20:50:35 +07:00
committed by GitHub
parent 57feedbf25
commit e2a6dc3e04
11 changed files with 50 additions and 36 deletions

View File

@@ -15,9 +15,9 @@ defaults: &defaults
- image: cimg/postgres:15.3 - image: cimg/postgres:15.3
- image: cimg/redis:6.2.6 - image: cimg/redis:6.2.6
environment: environment:
- RAILS_LOG_TO_STDOUT: false - RAILS_LOG_TO_STDOUT: false
- COVERAGE: true - COVERAGE: true
- LOG_LEVEL: warn - LOG_LEVEL: warn
parallelism: 4 parallelism: 4
resource_class: large resource_class: large
@@ -46,7 +46,7 @@ jobs:
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install v16 nvm install v20
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
@@ -64,7 +64,6 @@ jobs:
- ~/.bundle - ~/.bundle
key: chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-v20220524-{{ checksum "Gemfile.lock" }} key: chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-v20220524-{{ checksum "Gemfile.lock" }}
# Only necessary if app uses webpacker or yarn in some other way # Only necessary if app uses webpacker or yarn in some other way
- restore_cache: - restore_cache:
keys: keys:
@@ -82,7 +81,7 @@ jobs:
- ~/.cache/yarn - ~/.cache/yarn
- run: - run:
name: Download cc-test-reporter name: Download cc-test-reporter
command: | command: |
mkdir -p ~/tmp mkdir -p ~/tmp
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter
@@ -182,7 +181,7 @@ jobs:
- attach_workspace: - attach_workspace:
at: ~/build at: ~/build
- run: - run:
name: Download cc-test-reporter name: Download cc-test-reporter
command: | command: |
mkdir -p ~/tmp mkdir -p ~/tmp
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter
@@ -204,4 +203,4 @@ workflows:
- build - build
- upload-coverage: - upload-coverage:
requires: requires:
- build - build

View File

@@ -52,7 +52,8 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 20
cache: yarn
- name: yarn - name: yarn
run: yarn install run: yarn install
@@ -75,6 +76,8 @@ jobs:
- name: Run backend tests - name: Run backend tests
run: | run: |
bundle exec rspec --profile=10 --format documentation bundle exec rspec --profile=10 --format documentation
env:
NODE_OPTIONS: --openssl-legacy-provider
- name: Upload rails log folder - name: Upload rails log folder
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3

View File

@@ -51,7 +51,8 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 20
cache: yarn
- name: yarn - name: yarn
run: yarn install run: yarn install

View File

@@ -21,7 +21,8 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 20
cache: 'yarn'
- name: yarn - name: yarn
run: yarn install run: yarn install
@@ -30,9 +31,11 @@ jobs:
run: | run: |
rm -rf enterprise rm -rf enterprise
rm -rf spec/enterprise rm -rf spec/enterprise
- name: Run asset compile - name: Run asset compile
run: bundle exec rake assets:precompile run: bundle exec rake assets:precompile
env:
NODE_OPTIONS: --openssl-legacy-provider
- name: Size Check - name: Size Check
run: yarn run size run: yarn run size

2
.nvmrc
View File

@@ -1 +1 @@
16.20.1 20.5.1

View File

@@ -1,4 +1,4 @@
backend: bin/rails s -p 3000 backend: bin/rails s -p 3000
frontend: bin/webpack-dev-server frontend: export NODE_OPTIONS=--openssl-legacy-provider && bin/webpack-dev-server
# https://github.com/mperham/sidekiq/issues/3090#issuecomment-389748695 # https://github.com/mperham/sidekiq/issues/3090#issuecomment-389748695
worker: dotenv bundle exec sidekiq -C config/sidekiq.yml worker: dotenv bundle exec sidekiq -C config/sidekiq.yml

View File

@@ -60,6 +60,9 @@
], ],
"stack": "heroku-20", "stack": "heroku-20",
"buildpacks": [ "buildpacks": [
{
"url": "heroku/nodejs"
},
{ {
"url": "heroku/ruby" "url": "heroku/ruby"
} }

View File

@@ -172,7 +172,7 @@ EOF
function install_dependencies() { function install_dependencies() {
apt update && apt upgrade -y apt update && apt upgrade -y
apt install -y curl apt install -y curl
curl -sL https://deb.nodesource.com/setup_16.x | bash - curl -sL https://deb.nodesource.com/setup_20.x | bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
@@ -349,7 +349,7 @@ function setup_chatwoot() {
sed -i -e '/RAILS_ENV/ s/=.*/=$RAILS_ENV/' .env sed -i -e '/RAILS_ENV/ s/=.*/=$RAILS_ENV/' .env
echo -en "\nINSTALLATION_ENV=linux_script" >> ".env" echo -en "\nINSTALLATION_ENV=linux_script" >> ".env"
rake assets:precompile RAILS_ENV=production rake assets:precompile RAILS_ENV=production NODE_OPTIONS=--openssl-legacy-provider
EOF EOF
} }

View File

@@ -1,5 +1,5 @@
# pre-build stage # pre-build stage
FROM ruby:3.2.2-alpine3.16 AS pre-builder FROM ruby:3.2.2-alpine3.18 AS pre-builder
# ARG default to production settings # ARG default to production settings
# For development docker-compose file overrides ARGS # For development docker-compose file overrides ARGS
@@ -13,18 +13,21 @@ ENV RAILS_SERVE_STATIC_FILES ${RAILS_SERVE_STATIC_FILES}
ARG RAILS_ENV=production ARG RAILS_ENV=production
ENV RAILS_ENV ${RAILS_ENV} ENV RAILS_ENV ${RAILS_ENV}
ARG NODE_OPTIONS="--openssl-legacy-provider"
ENV NODE_OPTIONS ${NODE_OPTIONS}
ENV BUNDLE_PATH="/gems" ENV BUNDLE_PATH="/gems"
RUN apk update && apk add --no-cache \ RUN apk update && apk add --no-cache \
openssl \ openssl \
tar \ tar \
build-base \ build-base \
tzdata \ tzdata \
postgresql-dev \ postgresql-dev \
postgresql-client \ postgresql-client \
nodejs \ nodejs-current \
yarn \ yarn \
git \ git \
&& mkdir -p /var/app \ && mkdir -p /var/app \
&& gem install bundler && gem install bundler
@@ -70,7 +73,7 @@ RUN rm -rf /gems/ruby/3.2.0/cache/*.gem \
&& rm .gitignore && rm .gitignore
# final build stage # final build stage
FROM ruby:3.2.2-alpine3.16 FROM ruby:3.2.2-alpine3.18
ARG BUNDLE_WITHOUT="development:test" ARG BUNDLE_WITHOUT="development:test"
@@ -92,12 +95,12 @@ ENV BUNDLE_PATH="/gems"
RUN apk update && apk add --no-cache \ RUN apk update && apk add --no-cache \
build-base \ build-base \
openssl \ openssl \
tzdata \ tzdata \
postgresql-client \ postgresql-client \
imagemagick \ imagemagick \
git \ git \
vips \ vips \
&& gem install bundler && gem install bundler
RUN if [ "$RAILS_ENV" != "production" ]; then \ RUN if [ "$RAILS_ENV" != "production" ]; then \

View File

@@ -2,6 +2,7 @@
# https://github.com/rails/rails/issues/43906#issuecomment-1099992310 # https://github.com/rails/rails/issues/43906#issuecomment-1099992310
task before_assets_precompile: :environment do task before_assets_precompile: :environment do
# run a command which starts your packaging # run a command which starts your packaging
ENV['NODE_OPTIONS'] = '--openssl-legacy-provider'
system('yarn') system('yarn')
end end

View File

@@ -18,7 +18,8 @@
"prepare": "husky install", "prepare": "husky install",
"size": "size-limit" "size": "size-limit"
}, },
"size-limit": [{ "size-limit": [
{
"path": "public/packs/js/widget-*.js", "path": "public/packs/js/widget-*.js",
"limit": "270 KB" "limit": "270 KB"
}, },
@@ -146,9 +147,9 @@
"webpack-dev-server": "^3" "webpack-dev-server": "^3"
}, },
"engines": { "engines": {
"node": ">=10.x", "node": "20.x",
"npm": ">=6.x", "npm": ">=6.x",
"yarn": ">=1.x" "yarn": "1.22.x"
}, },
"husky": { "husky": {
"hooks": { "hooks": {