Skip to content

Commit 123fd08

Browse files
authored
Merge pull request osulp#120 from osulp/infra/cluster
Infra/cluster
2 parents 8bc75e2 + 8fa11b2 commit 123fd08

33 files changed

+1106
-118
lines changed

.circleci/config.yml

+165-19
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,186 @@
1-
version: 2
1+
version: 2.1
2+
orbs:
3+
docker: circleci/[email protected]
24
jobs:
3-
build:
5+
checkout_code:
46
docker:
5-
- image: circleci/ruby:2.5.1
7+
- image: circleci/ruby:2.5
68
working_directory: ~/app
79
steps:
10+
- restore_cache:
11+
name: Restore code from cache
12+
keys:
13+
- v1-source-{{ .Branch }}-{{ .Revision }}
14+
- checkout
15+
- save_cache:
16+
name: Save code cache
17+
key: v1-source-{{ .Branch }}-{{ .Revision }}
18+
paths:
19+
- '.git'
20+
- persist_to_workspace:
21+
root: ~/
22+
paths:
23+
- app/*
24+
- app/**/*
25+
bundle:
26+
docker:
27+
- image: circleci/ruby:2.5-stretch-node-browsers
28+
environment:
29+
BUNDLE_PATH: vendor/bundle
30+
working_directory: ~/app
31+
steps:
32+
- attach_workspace:
33+
at: ~/
34+
- run:
35+
name: Update Debian Packages for Building
36+
command: |
37+
sudo apt-get install -y software-properties-common build-essential make apt-utils
38+
- restore_cache:
39+
name: Restore bundle from cache
40+
keys:
41+
- v2-bundle-{{ checksum "Gemfile.lock" }}
42+
- run:
43+
name: Update bundler
44+
command: gem install bundler -v 2.1.4
45+
- run:
46+
name: Install dependencies
47+
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 --binstubs
48+
- save_cache:
49+
name: Save bundle cache
50+
key: v2-bundle-{{ checksum "Gemfile.lock" }}
51+
paths:
52+
- ~/app/vendor/bundle
53+
- persist_to_workspace:
54+
root: ~/
55+
paths:
56+
- app/*
57+
- app/**/*
58+
# lint:
59+
# docker:
60+
# - image: circleci/ruby:2.5-stretch-node-browsers
61+
# environment:
62+
# BUNDLE_PATH: vendor/bundle
63+
# working_directory: ~/app
64+
# steps:
65+
# - attach_workspace:
66+
# at: ~/
67+
# - run:
68+
# name: Update bundler
69+
# command: gem install bundler -v 2.1.4 && bundle install --binstubs
70+
# - run:
71+
# name: Run Rubocop
72+
# command: bundle exec rubocop
73+
test:
74+
docker:
75+
- image: circleci/ruby:2.5-stretch-node-browsers
76+
environment:
77+
HONEYCOMB_DATASET: api-test
78+
HONEYCOMB_DEBUG: 'true'
79+
HONEYCOMB_WRITEKEY: buzzzzzzzzzzzzzzzz
80+
HONEYCOMB_SERVICE: api-test
81+
RAILS_ENV: test
82+
- image: circleci/mysql:5.7.22
83+
environment:
84+
MYSQL_ROOT_PASSWORD: monkeys
85+
MYSQL_USER: monkeys
86+
MYSQL_PASSWORD: monkeys
87+
MYSQL_DATABASE: api_test
88+
working_directory: ~/app
89+
steps:
90+
- attach_workspace:
91+
at: ~/
892
- run:
993
name: Update Debian Packages
1094
command: |
11-
echo "deb http://http.debian.net/debian stretch-backports main" | sudo tee -a /etc/apt/sources.list
1295
sudo apt-get update -qq
1396
sudo apt-get upgrade -qq
1497
sudo apt-get install -y -f software-properties-common build-essential default-libmysqlclient-dev nodejs make apt-utils
15-
- checkout
16-
- restore_cache:
17-
key: gemfile-{{ checksum "Gemfile.lock" }}
1898
- run:
19-
name: Install Ruby Dependencies
20-
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
21-
- save_cache:
22-
key: gemfile-{{ checksum "Gemfile.lock" }}
23-
paths:
24-
- vendor/bundle
25-
- tmp/zips
99+
name: Wait for DB
100+
command: dockerize -wait tcp://localhost:3306 -timeout 1m
101+
- run:
102+
name: Update bundler srsly again
103+
command: gem install --force bundler
104+
- run:
105+
name: Bundle update srsly again
106+
command: bundle check --without production staging --path=vendor/bundle || bundle install --without production staging --path=vendor/bundle --jobs=4 --retry=3 --binstubs
107+
- run:
108+
command: bundle check --without production staging --path=vendor/bundle || bundle install --without production staging --path=vendor/bundle --jobs=4 --retry=3 --binstubs
26109
- run:
27-
name: Create DB
110+
name: Create and load MySQL data
28111
command: bundle exec rake db:create db:schema:load --trace
29112
- run:
30113
name: Run Tests
31114
command: |
32115
bundle exec rspec --profile 10 \
116+
--format RspecJunitFormatter \
33117
--out /tmp/test-results/rspec.xml \
34118
--format progress \
35119
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
36-
- store_artifacts:
37-
path: coverage
38-
destination: coverage
39120
- store_test_results:
40-
path: /tmp/circle-junit
121+
path: /tmp/test-results
122+
- store_artifacts:
123+
path: /tmp/test-results
124+
destination: test-results
125+
- store_artifacts:
126+
path: ./tmp/screenshots
127+
- store_artifacts:
128+
path: ./tmp/capybara
129+
build_and_push_beavernetes:
130+
parameters:
131+
repo:
132+
type: string
133+
default: ''
134+
environment:
135+
type: string
136+
default: 'production'
137+
executor:
138+
name: 'docker/docker'
139+
environment:
140+
DOCKER_LOGIN: admin
141+
DOCKER_PASSWORD: admin
142+
working_directory: ~/app
143+
steps:
144+
- attach_workspace:
145+
at: ~/
146+
- run:
147+
name: Generate deployed version
148+
command: |
149+
export GIT_SHORT_HASH=$(git rev-parse --short HEAD)
150+
export DATETIME=$(date "+%Y%m%d%H%M%S")
151+
echo export TAG="$DATETIME-$GIT_SHORT_HASH" >> $BASH_ENV
152+
echo export DEPLOYED_VERSION="$DATETIME-$GIT_SHORT_HASH" >> $BASH_ENV
153+
- setup_remote_docker
154+
- docker/check:
155+
registry: registry.library.oregonstate.edu
156+
- docker/build:
157+
registry: registry.library.oregonstate.edu
158+
image: osulp-api
159+
tag: $TAG
160+
extra_build_args: --build-arg RAILS_ENV=<< parameters.environment >> --build-arg DEPLOYED_VERSION=$DEPLOYED_VERSION
161+
- docker/push:
162+
registry: registry.library.oregonstate.edu
163+
image: osulp-api
164+
tag: $TAG
165+
workflows:
166+
ci:
167+
jobs:
168+
- checkout_code
169+
- bundle:
170+
requires:
171+
- checkout_code
172+
# - lint:
173+
# requires:
174+
# - bundle
175+
- test:
176+
requires:
177+
- bundle
178+
# - lint
179+
- build_and_push_beavernetes:
180+
name: build_and_push_beavernetes
181+
requires:
182+
- test
183+
filters:
184+
branches:
185+
only: master
186+
repo: osulp-api

.version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM ruby:2.5.1
22
RUN apt-get update -qq && \
33
apt-get install -y build-essential libpq-dev mysql-client && \
4+
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && \
45
rm -rf /var/lib/apt/lists/*
56
# Necessary for bundler to properly install some gems
67
ENV LANG C.UTF-8
@@ -9,8 +10,8 @@ RUN mkdir /data
910
WORKDIR /data
1011
ADD Gemfile /data/Gemfile
1112
ADD Gemfile.lock /data/Gemfile.lock
12-
RUN gem install bundler
13-
RUN bundle install
13+
RUN gem install bundler && bundle install
1414
ADD . /data
15+
RUN cd /data && rm -f Dockerfile build.sh docker-compose* log/*
1516
#RUN bundle exec rake assets:precompile
1617
EXPOSE 3000

Gemfile

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
ruby '2.5.1'
4+
#ruby '2.5.1'
55

66
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
77
gem 'rails', '~> 5.2.4.6'
@@ -38,11 +38,18 @@ gem 'capistrano-rbenv'
3838
gem 'capistrano3-puma'
3939
gem "loofah", ">= 2.3.1"
4040

41+
# Honeycomb
42+
gem 'honeycomb-beeline', '>= 2.4.0'
43+
gem 'libhoney', '>= 1.18.0'
44+
4145
group :development, :test do
4246
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
4347
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
4448
gem 'rspec'
4549
gem 'rspec-rails'
50+
gem 'rspec_junit_formatter'
51+
gem 'rubocop', '= 0.73.0'
52+
gem 'rubocop-rspec', '= 1.34.0'
4653
end
4754

4855
group :test do

0 commit comments

Comments
 (0)