Skip to content

Commit

Permalink
BIB-46: Dual boot Rails 7.0 and 7.1
Browse files Browse the repository at this point in the history
So we can start work on Rails 7.1 upgrade.

What
- Update gemfiles and lock files.
- Ensure CI runs tests for both versions.
- Update incompatible gems.

Jira: https://ombulabs.atlassian.net/browse/BIB-46
  • Loading branch information
torresga authored and fbuys committed Sep 11, 2024
1 parent 073824b commit f9b5d0a
Show file tree
Hide file tree
Showing 5 changed files with 1,232 additions and 2 deletions.
284 changes: 284 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,289 @@ jobs:
path: /tmp/test-results
- store_artifacts:
path: coverage
build_next:
working_directory: ~/bikeindex/bike_index
parallelism: 2
shell: /bin/bash --login
environment:
BUNDLE_GEMFILE: Gemfile.next
RAILS_ENV: test
NODE_ENV: test
RACK_ENV: test
COVERAGE: true
CC_TEST_REPORTER_ID: 04daa6564351115dc1515504790cd379ad8dc25e7778f0641e0f8c63185f887c
TRANSLATION_BRANCH: main
TZ: /usr/share/zoneinfo/America/Chicago
RETRY_FLAKY: true

docker:
- image: cimg/ruby:2.7.8-node
environment:
PGHOST: 127.0.0.1
PGUSER: root
PSQL_PAGER: ""
- image: cimg/postgres:13.5-postgis
environment:
POSTGRES_USER: root
POSTGRES_DB: bikeindex_test
POSTGRES_PASSWORD: ""
- image: redis:7.2.3

# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large

steps:
- add_ssh_keys:
fingerprints:
- "b7:01:89:de:d8:f8:77:cc:9e:5a:ca:ee:0c:24:57:13"

- checkout

- run:
name: "Apt: install system / build dependencies"
command: |
sudo apt-get update
sudo apt-get -y install \
curl \
gettext \
imagemagick \
libcurl4-gnutls-dev \
libexpat1-dev \
libssl-dev \
libz-dev \
postgresql-client \
ripgrep
- run:
name: "Update Node.js and npm"
command: |
curl -sSL "https://nodejs.org/download/release/v16.20.2/node-v16.20.2-linux-x64.tar.xz" | sudo tar --strip-components=2 -xJ -C /usr/local/bin/ node-v16.20.2-linux-x64/bin/node
# curl https://www.npmjs.com/install.sh | sudo bash
- restore_cache:
name: "Dockerize: cache restore"
keys:
- CACHE_V4-dockerize-0.6.1
- CACHE_V4-dockerize-

- run:
name: "Dockerize: install"
environment:
DOCKERIZE_VERSION: v0.6.1
command: |
dockerize_tar=dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz
if [[ ! -f ~/.cache/dockerize/${dockerize_tar} ]]; then
wget https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/${dockerize_tar}
fi
sudo tar -C /usr/local/bin -xzvf ${dockerize_tar}
- type: cache-save
name: "Dockerize: cache save"
key: CACHE_V4-dockerize-0.6.1
paths:
- ~/.cache/dockerize

# Updated all restore_cache to make things more functional when changing a single dependency, see PR#2366
- restore_cache:
name: "Git: cache restore"
keys:
- CACHE_V4-git-2.22.0
- CACHE_V4-git-

- run:
name: "Git: install"
environment:
GIT_VERSION: 2.22.0
command: |
set -x
git_binary=~/.cache/git/git-${GIT_VERSION}/git
if [[ ! -f $git_binary ]]; then
rm -rf ~/.cache/git
mkdir -p ~/.cache/git
cd ~/.cache/git
wget -O git.tgz https://mirrors.edge.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz
tar -xzf git.tgz
cd git-${GIT_VERSION}
export DEFAULT_HELP_FORMAT="man"
autoconf
./configure
sudo make man
sudo make install-man
fi
cd ~/.cache/git/git-${GIT_VERSION}
sudo make prefix=/usr/local all
sudo make install
sudo cp ${git_binary} /usr/local/bin/git
- type: cache-save
name: "Git: cache save"
key: CACHE_V4-git-2.22.0
paths:
- ~/.cache/git/git-2.22.0

- restore_cache:
name: "Hub: cache restore"
keys:
- CACHE_V4-hub-2.12.3
- CACHE_V4-hub-

- run:
name: "Hub: install"
environment:
HUB_VERSION: 2.12.3
command: |
set -x
hub_binary=~/.cache/hub/hub-linux-amd64-${HUB_VERSION}/bin/hub
if [[ ! -f ${hub_binary} ]]; then
rm -rf ~/.cache/hub
mkdir -p ~/.cache/hub
cd ~/.cache/hub
wget -O hub.tgz https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-linux-amd64-${HUB_VERSION}.tgz
tar -xzf hub.tgz
fi
sudo cp ${hub_binary} /usr/local/bin/hub
- restore_cache:
name: "Hub: cache save"
keys:
- CACHE_V4-hub-2.12.3
- CACHE_V4-hub-
paths:
- ~/.cache/hub

- run:
name: "Bundler: install"
command: gem install bundler -v 2.4.22

- restore_cache:
name: "Ruby dependencies: cache restore"
keys:
- CACHE_V4-gems-{{ checksum "Gemfile.lock" }}
- CACHE_V4-gems-

- run:
name: "Ruby dependencies: install"
command: |
set -x
bundle config set --local path '~/.cache/bundle'
bundle install
- type: cache-save
name: "Ruby dependencies: cache save"
key: CACHE_V4-gems-{{ checksum "Gemfile.lock" }}
paths:
- ~/.cache/bundle

- run:
name: Sync translations (only on main by default)
command: bin/check_translations

- restore_cache:
name: "Node dependencies: cache restore"
keys:
- CACHE_V4-yarn-{{ checksum "yarn.lock" }}
- CACHE_V4-yarn-

- run:
name: "Node dependencies: install"
command: |
set -x
[[ -d ~/.cache/yarn ]] && use_local="--prefer-offline"
yarn install --cache-folder ~/.cache/yarn $use_local
- type: cache-save
name: "Node dependencies: cache save"
key: CACHE_V4-yarn-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn

- restore_cache:
name: "Assets: cache restore"
keys:
- CACHE_V4-assets-{{ .Environment.CIRCLE_SHA1 }}
- CACHE_V4-assets-

- run:
name: "Assets: precompile"
command: |
set -x
node --version
bin/webpack
bundle exec rails assets:precompile assets:clean --trace
- type: cache-save
name: "Assets: cache save"
key: CACHE_V4-assets-{{ .Environment.CIRCLE_SHA1 }}
paths:
- .sass-cache
- public/assets
- public/packs
- public/packs-test
- tmp/cache/assets
- tmp/cache/webpacker

- run:
name: Install Code Climate Test Reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: Wait for PostgreSQL to start
command: dockerize -wait tcp://localhost:5432 -timeout 1m

- run:
name: Setup Database
command: |
bundle exec rails db:create --trace
bundle exec rails db:schema:load --trace
- run:
name: RSpec
command: |
mkdir -p /tmp/test-results/rspec coverage
./cc-test-reporter before-build
RSPEC_CMD="bundle exec rspec --profile 10 --order random --format RspecJunitFormatter --out /tmp/test-results/rspec/rspec.xml --format progress --color --require spec_helper"
circleci tests glob "spec/**/*_spec.rb" | circleci tests run --command="xargs $RSPEC_CMD" --verbose --split-by=timings
- run:
name: Save Code Climate Test Coverage
# If there is a codeclimate json file, persist it to the workspace
# If not (e.g. when rerunning failed tests), create a file indicating that (required by persist_to_workspace)
command: |
if [ -f "coverage/codeclimate.$CIRCLE_NODE_INDEX.json" ]; then
./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
else
echo "Coverage file doesn't exist"
touch coverage/codeclimate.no-coverage.json
ls -lah coverage/
fi
- persist_to_workspace:
root: coverage
paths:
- codeclimate.*.json
- run:
name: "Jest: Tests"
command: |
mkdir -p /tmp/test-results/junit
yarn jest --ci --runInBand --reporters=default --reporters=jest-junit
environment:
JEST_JUNIT_OUTPUT: "/tmp/test-results/junit/js-test-results.xml" # This is the env variable for the old version of jest-junit
JEST_JUNIT_OUTPUT_DIR: "/tmp/test-results/junit/"
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: coverage

upload-coverage:
docker:
- image: cimg/ruby:2.7.8-node
Expand Down Expand Up @@ -349,6 +632,7 @@ workflows:
commit:
jobs:
- build
- build_next
- brakeman_scan
- upload-coverage:
requires:
Expand Down
10 changes: 9 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# frozen_string_literal: true

def next?
File.basename(__FILE__) == "Gemfile.next"
end

source "https://rubygems.org"

git_source(:github) { |repo| "https://github.com/#{repo}.git" }
Expand All @@ -9,7 +13,11 @@ git_source(:gitlab) { |repo| "https://gitlab.com/#{repo}.git" }
ruby "2.7.8"
gem "rack", "~> 2.2.3"

gem "rails", "~> 7.0.8.4"
if next?
gem "rails", "~> 7.1.4"
else
gem "rails", "~> 7.0.8.4"
end

gem "puma" # App server
gem "bcrypt", "~> 3.1.7" # encryption
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ GEM
omniauth-oauth (~> 1.1)
rack
parallel (1.22.1)
parallel_tests (2.30.0)
parallel_tests (3.5.2)
parallel
paranoia (2.5.2)
activerecord (>= 5.1, < 7.1)
Expand Down
1 change: 1 addition & 0 deletions Gemfile.next
Loading

0 comments on commit f9b5d0a

Please sign in to comment.