Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fc8e95404 | ||
|
|
4201bc965e | ||
|
|
b7db7811d4 | ||
|
|
b411752612 | ||
|
|
20f27b6edf | ||
|
|
5a72f4d0c8 | ||
|
|
e911afe7f6 | ||
|
|
d3a8e83a95 | ||
|
|
335c06af7a | ||
|
|
8a720f9642 | ||
|
|
3ac946712b |
+196
-112
@@ -1,117 +1,117 @@
|
|||||||
version: 2.1
|
version: 2.1
|
||||||
orbs:
|
orbs:
|
||||||
node: circleci/node@6.1.0
|
node: circleci/node@6.1.0
|
||||||
|
ruby: circleci/ruby@2.1.0
|
||||||
|
|
||||||
defaults: &defaults
|
executors:
|
||||||
working_directory: ~/build
|
app-executor:
|
||||||
machine:
|
machine:
|
||||||
image: ubuntu-2204:2024.05.1
|
image: ubuntu-2204:2024.05.1
|
||||||
resource_class: large
|
resource_class: large
|
||||||
environment:
|
environment:
|
||||||
RAILS_LOG_TO_STDOUT: false
|
RAILS_LOG_TO_STDOUT: false
|
||||||
COVERAGE: true
|
COVERAGE: true
|
||||||
LOG_LEVEL: warn
|
LOG_LEVEL: warn
|
||||||
parallelism: 4
|
|
||||||
|
|
||||||
jobs:
|
commands:
|
||||||
build:
|
setup_dependencies:
|
||||||
<<: *defaults
|
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
|
||||||
|
# Setup Node with caching
|
||||||
- node/install:
|
- node/install:
|
||||||
node-version: '23.7'
|
node-version: '23.7'
|
||||||
- node/install-pnpm
|
- node/install-pnpm
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- pnpm-deps-v1-{{ checksum "pnpm-lock.yaml" }}
|
||||||
- node/install-packages:
|
- node/install-packages:
|
||||||
pkg-manager: pnpm
|
pkg-manager: pnpm
|
||||||
override-ci-command: pnpm i
|
override-ci-command: pnpm i
|
||||||
- run: node --version
|
- save_cache:
|
||||||
- run: pnpm --version
|
key: pnpm-deps-v1-{{ checksum "pnpm-lock.yaml" }}
|
||||||
|
paths:
|
||||||
|
- node_modules
|
||||||
|
|
||||||
|
# Setup Ruby with caching
|
||||||
|
- ruby/install:
|
||||||
|
version: '3.3.3'
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- gem-cache-v1-{{ checksum "Gemfile.lock" }}
|
||||||
- run:
|
- run:
|
||||||
name: Add PostgreSQL repository and update
|
name: Install Bundler and Gems
|
||||||
command: |
|
command: |
|
||||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
gem install bundler -v 2.5.16
|
||||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
bundle config set --local path 'vendor/bundle'
|
||||||
sudo apt-get update -y
|
bundle install --jobs=4 --retry=3
|
||||||
|
- save_cache:
|
||||||
|
key: gem-cache-v1-{{ checksum "Gemfile.lock" }}
|
||||||
|
paths:
|
||||||
|
- vendor/bundle
|
||||||
|
|
||||||
|
# Install system dependencies using a layer caching approach
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- apt-cache-v1-{{ checksum ".circleci/apt-packages.txt" }}
|
||||||
|
- run:
|
||||||
|
name: Create apt packages list
|
||||||
|
command: |
|
||||||
|
mkdir -p .circleci
|
||||||
|
cat > .circleci/apt-packages.txt \<< EOF
|
||||||
|
libpq-dev
|
||||||
|
redis-server
|
||||||
|
postgresql-common
|
||||||
|
postgresql-16
|
||||||
|
postgresql-16-pgvector
|
||||||
|
build-essential
|
||||||
|
git
|
||||||
|
curl
|
||||||
|
libssl-dev
|
||||||
|
zlib1g-dev
|
||||||
|
libreadline-dev
|
||||||
|
libyaml-dev
|
||||||
|
openjdk-11-jdk
|
||||||
|
jq
|
||||||
|
software-properties-common
|
||||||
|
ca-certificates
|
||||||
|
imagemagick
|
||||||
|
libxml2-dev
|
||||||
|
libxslt1-dev
|
||||||
|
file
|
||||||
|
g++
|
||||||
|
gcc
|
||||||
|
autoconf
|
||||||
|
gnupg2
|
||||||
|
patch
|
||||||
|
ruby-dev
|
||||||
|
liblzma-dev
|
||||||
|
libgmp-dev
|
||||||
|
libncurses5-dev
|
||||||
|
libffi-dev
|
||||||
|
libgdbm6
|
||||||
|
libgdbm-dev
|
||||||
|
libvips
|
||||||
|
EOF
|
||||||
- run:
|
- run:
|
||||||
name: Install System Dependencies
|
name: Install System Dependencies
|
||||||
command: |
|
command: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
|
# Add PostgreSQL repository once
|
||||||
libpq-dev \
|
if [ ! -f /etc/apt/sources.list.d/pgdg.list ]; then
|
||||||
redis-server \
|
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||||
postgresql-common \
|
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||||
postgresql-16 \
|
sudo apt-get update -y
|
||||||
postgresql-16-pgvector \
|
|
||||||
build-essential \
|
|
||||||
git \
|
|
||||||
curl \
|
|
||||||
libssl-dev \
|
|
||||||
zlib1g-dev \
|
|
||||||
libreadline-dev \
|
|
||||||
libyaml-dev \
|
|
||||||
openjdk-11-jdk \
|
|
||||||
jq \
|
|
||||||
software-properties-common \
|
|
||||||
ca-certificates \
|
|
||||||
imagemagick \
|
|
||||||
libxml2-dev \
|
|
||||||
libxslt1-dev \
|
|
||||||
file \
|
|
||||||
g++ \
|
|
||||||
gcc \
|
|
||||||
autoconf \
|
|
||||||
gnupg2 \
|
|
||||||
patch \
|
|
||||||
ruby-dev \
|
|
||||||
liblzma-dev \
|
|
||||||
libgmp-dev \
|
|
||||||
libncurses5-dev \
|
|
||||||
libffi-dev \
|
|
||||||
libgdbm6 \
|
|
||||||
libgdbm-dev \
|
|
||||||
libvips
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Install RVM and Ruby 3.3.3
|
|
||||||
command: |
|
|
||||||
sudo apt-get install -y gpg
|
|
||||||
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
|
|
||||||
\curl -sSL https://get.rvm.io | bash -s stable
|
|
||||||
echo 'source ~/.rvm/scripts/rvm' >> $BASH_ENV
|
|
||||||
source ~/.rvm/scripts/rvm
|
|
||||||
rvm install "3.3.3"
|
|
||||||
rvm use 3.3.3 --default
|
|
||||||
gem install bundler -v 2.5.16
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Install Application Dependencies
|
|
||||||
command: |
|
|
||||||
source ~/.rvm/scripts/rvm
|
|
||||||
bundle install
|
|
||||||
# pnpm install
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Download cc-test-reporter
|
|
||||||
command: |
|
|
||||||
mkdir -p ~/tmp
|
|
||||||
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter
|
|
||||||
chmod +x ~/tmp/cc-test-reporter
|
|
||||||
|
|
||||||
# Swagger verification
|
|
||||||
- run:
|
|
||||||
name: Verify swagger API specification
|
|
||||||
command: |
|
|
||||||
bundle exec rake swagger:build
|
|
||||||
if [[ `git status swagger/swagger.json --porcelain` ]]
|
|
||||||
then
|
|
||||||
echo "ERROR: The swagger.json file is not in sync with the yaml specification. Run 'rake swagger:build' and commit 'swagger/swagger.json'."
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.3.0/openapi-generator-cli-6.3.0.jar > ~/tmp/openapi-generator-cli-6.3.0.jar
|
|
||||||
java -jar ~/tmp/openapi-generator-cli-6.3.0.jar validate -i swagger/swagger.json
|
# Install packages
|
||||||
|
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y $(cat .circleci/apt-packages.txt)
|
||||||
# we remove the FRONTED_URL from the .env before running the tests
|
- save_cache:
|
||||||
|
key: apt-cache-v1-{{ checksum ".circleci/apt-packages.txt" }}
|
||||||
|
paths:
|
||||||
|
- /var/cache/apt
|
||||||
|
|
||||||
|
# Set up database
|
||||||
- run:
|
- run:
|
||||||
name: Database Setup and Configure Environment Variables
|
name: Database Setup and Configure Environment Variables
|
||||||
command: |
|
command: |
|
||||||
@@ -128,39 +128,107 @@ jobs:
|
|||||||
sed -i -e "/POSTGRES_PASSWORD/ s/=.*/=$pg_pass/" .env
|
sed -i -e "/POSTGRES_PASSWORD/ s/=.*/=$pg_pass/" .env
|
||||||
echo -en "\nINSTALLATION_ENV=circleci" >> ".env"
|
echo -en "\nINSTALLATION_ENV=circleci" >> ".env"
|
||||||
|
|
||||||
# Database setup
|
# Download code climate reporter just once and cache it
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- cc-test-reporter-v1
|
||||||
- run:
|
- run:
|
||||||
name: Run DB migrations
|
name: Download cc-test-reporter
|
||||||
command: bundle exec rails db:chatwoot_prepare
|
command: |
|
||||||
|
if [ ! -f ~/tmp/cc-test-reporter ]; then
|
||||||
|
mkdir -p ~/tmp
|
||||||
|
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter
|
||||||
|
chmod +x ~/tmp/cc-test-reporter
|
||||||
|
fi
|
||||||
|
- save_cache:
|
||||||
|
key: cc-test-reporter-v1
|
||||||
|
paths:
|
||||||
|
- ~/tmp/cc-test-reporter
|
||||||
|
|
||||||
# Bundle audit
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build_and_test:
|
||||||
|
jobs:
|
||||||
|
- lint
|
||||||
|
- test-frontend:
|
||||||
|
requires:
|
||||||
|
- lint
|
||||||
|
- test-backend:
|
||||||
|
requires:
|
||||||
|
- lint
|
||||||
|
- report-coverage:
|
||||||
|
requires:
|
||||||
|
- test-frontend
|
||||||
|
- test-backend
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
executor: app-executor
|
||||||
|
steps:
|
||||||
|
- setup_dependencies
|
||||||
|
|
||||||
|
# Swagger verification
|
||||||
|
- run:
|
||||||
|
name: Verify swagger API specification
|
||||||
|
command: |
|
||||||
|
bundle exec rake swagger:build
|
||||||
|
if [[ `git status swagger/swagger.json --porcelain` ]]
|
||||||
|
then
|
||||||
|
echo "ERROR: The swagger.json file is not in sync with the yaml specification. Run 'rake swagger:build' and commit 'swagger/swagger.json'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cache the openapi jar
|
||||||
|
if [ ! -f ~/tmp/openapi-generator-cli-6.3.0.jar ]; then
|
||||||
|
curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.3.0/openapi-generator-cli-6.3.0.jar > ~/tmp/openapi-generator-cli-6.3.0.jar
|
||||||
|
fi
|
||||||
|
java -jar ~/tmp/openapi-generator-cli-6.3.0.jar validate -i swagger/swagger.json
|
||||||
|
|
||||||
|
# Bundle audit - run only in lint job
|
||||||
- run:
|
- run:
|
||||||
name: Bundle audit
|
name: Bundle audit
|
||||||
command: bundle exec bundle audit update && bundle exec bundle audit check -v
|
command: bundle exec bundle audit update && bundle exec bundle audit check -v
|
||||||
|
|
||||||
# Rubocop linting
|
# Rubocop linting
|
||||||
- run:
|
- run:
|
||||||
name: Rubocop
|
name: Rubocop
|
||||||
command: bundle exec rubocop
|
command: bundle exec rubocop
|
||||||
|
|
||||||
# ESLint linting
|
# ESLint
|
||||||
- run:
|
- run:
|
||||||
name: eslint
|
name: eslint
|
||||||
command: pnpm run eslint
|
command: pnpm run eslint
|
||||||
|
|
||||||
|
test-frontend:
|
||||||
|
executor: app-executor
|
||||||
|
steps:
|
||||||
|
- setup_dependencies
|
||||||
|
- run:
|
||||||
|
name: Run DB migrations
|
||||||
|
command: bundle exec rails db:chatwoot_prepare
|
||||||
- run:
|
- run:
|
||||||
name: Run frontend tests
|
name: Run frontend tests
|
||||||
command: |
|
command: |
|
||||||
mkdir -p ~/build/coverage/frontend
|
mkdir -p ~/build/coverage/frontend
|
||||||
~/tmp/cc-test-reporter before-build
|
~/tmp/cc-test-reporter before-build
|
||||||
pnpm run test:coverage
|
pnpm run test:coverage
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Code Climate Test Coverage (Frontend)
|
name: Code Climate Test Coverage (Frontend)
|
||||||
command: |
|
command: |
|
||||||
~/tmp/cc-test-reporter format-coverage -t lcov -o "~/build/coverage/frontend/codeclimate.frontend_$CIRCLE_NODE_INDEX.json"
|
~/tmp/cc-test-reporter format-coverage -t lcov -o "~/build/coverage/frontend/codeclimate.json"
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: ~/build
|
||||||
|
paths:
|
||||||
|
- coverage/frontend
|
||||||
|
|
||||||
# Run backend tests
|
test-backend:
|
||||||
|
executor: app-executor
|
||||||
|
parallelism: 4
|
||||||
|
steps:
|
||||||
|
- setup_dependencies
|
||||||
|
- run:
|
||||||
|
name: Run DB migrations
|
||||||
|
command: bundle exec rails db:chatwoot_prepare
|
||||||
- run:
|
- run:
|
||||||
name: Run backend tests
|
name: Run backend tests
|
||||||
command: |
|
command: |
|
||||||
@@ -174,18 +242,34 @@ jobs:
|
|||||||
--out ~/tmp/test-results/rspec.xml \
|
--out ~/tmp/test-results/rspec.xml \
|
||||||
-- ${TESTFILES}
|
-- ${TESTFILES}
|
||||||
no_output_timeout: 30m
|
no_output_timeout: 30m
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Code Climate Test Coverage (Backend)
|
name: Code Climate Test Coverage (Backend)
|
||||||
command: |
|
command: |
|
||||||
~/tmp/cc-test-reporter format-coverage -t simplecov -o "~/build/coverage/backend/codeclimate.$CIRCLE_NODE_INDEX.json"
|
~/tmp/cc-test-reporter format-coverage -t simplecov -o "~/build/coverage/backend/codeclimate.$CIRCLE_NODE_INDEX.json"
|
||||||
|
|
||||||
- run:
|
|
||||||
name: List coverage directory contents
|
|
||||||
command: |
|
|
||||||
ls -R ~/build/coverage
|
|
||||||
|
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: ~/build
|
root: ~/build
|
||||||
paths:
|
paths:
|
||||||
- coverage
|
- coverage/backend
|
||||||
|
- store_test_results:
|
||||||
|
path: ~/tmp/test-results
|
||||||
|
- store_artifacts:
|
||||||
|
path: ~/tmp/test-artifacts
|
||||||
|
|
||||||
|
report-coverage:
|
||||||
|
executor: app-executor
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: ~/build
|
||||||
|
- run:
|
||||||
|
name: Download cc-test-reporter
|
||||||
|
command: |
|
||||||
|
mkdir -p ~/tmp
|
||||||
|
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter
|
||||||
|
chmod +x ~/tmp/cc-test-reporter
|
||||||
|
- run:
|
||||||
|
name: Upload coverage results to Code Climate
|
||||||
|
command: |
|
||||||
|
# Sum the coverage reports
|
||||||
|
~/tmp/cc-test-reporter sum-coverage ~/build/coverage/**/codeclimate*.json -p 5 -o ~/build/coverage/codeclimate.json
|
||||||
|
# Upload the combined report
|
||||||
|
~/tmp/cc-test-reporter upload-coverage -i ~/build/coverage/codeclimate.json
|
||||||
Reference in New Issue
Block a user