Skip to content

Commit

Permalink
Improve CircleCI integration
Browse files Browse the repository at this point in the history
* Update CircelCI config
* Use a docker image with RVM for CircleCI
* Use WWTD for running tests with multiple Ruby/Rails versions
  • Loading branch information
finalwharf committed Oct 24, 2018
1 parent 818f1df commit 7dd889e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 34 deletions.
94 changes: 70 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,127 @@
version: 2

defaults: &defaults
docker:
- image: quay.io/fundingcircle/centos-ruby:ci-rvm
auth:
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
environment:
RACK_ENV: test
VAULT_VERSION: 0.10.4

jobs:
tests:
docker:
- image: ruby:2.4.4-alpine
environment:
RACK_ENV: test
VAULT_VERSION: 0.10.0
<<: *defaults

steps:
- checkout
- run: apk add --no-cache build-base sqlite-dev tzdata
- run: yum -y install wget unzip sqlite
- run: yum clean all

- run:
name: Install Vault
command: |
wget -O vault.zip -q https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
unzip vault.zip
mv vault /usr/local/bin/
- restore_cache:
keys:
- vault-rails-{{checksum "fc-vault-rails.gemspec" }}
- run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle
- vault-rails-{{checksum "fc-vault-rails.gemspec" }}-{{checksum ".travis.yml" }}

- run:
shell: /bin/bash -l
command: |
rvm use --default 2.5.1
bundle check --path=/usr/local/rvm/gems || bundle install --path=/usr/local/rvm/gems
- run:
shell: /bin/bash -l
command: |
bundle exec rake app:db:create
bundle exec rake app:db:schema:load
bundle exec rake app:db:test:prepare
bundle exec wwtd
- save_cache:
key: vault-rails-{{checksum "fc-vault-rails.gemspec" }}
key: vault-rails-{{checksum "fc-vault-rails.gemspec" }}-{{checksum ".travis.yml" }}
paths:
- vendor/bundle
- run: bundle exec rake app:db:create
- run: bundle exec rake app:db:schema:load
- run: bundle exec rake app:db:test:prepare
- run: bundle exec rspec
- /usr/local/rvm/gems

publish-pre-release:
docker:
- image: ruby:2.4.4-alpine
<<: *defaults

steps:
- checkout
- run:
name: Install cURL
command: apk add --no-cache curl
- run: yum -y install curl
- run: yum clean all

- run:
name: Login to JFrog
command: |
mkdir -p ~/.gem
curl --user "$ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD" https://fundingcircle.jfrog.io/fundingcircle/api/gems/rubygems/api/v1/api_key.yaml > ~/.gem/credentials
chmod 600 ~/.gem/credentials
- run:
shell: /bin/bash -l
command: |
rvm use --default 2.5.1
- run:
name: Install Gem Versioner
shell: /bin/bash -l
command: gem install gem-versioner --version '~> 1.0' --no-document

- run:
name: Build gem
shell: /bin/bash -l
command: |
PRE_RELEASE="$CIRCLE_BRANCH" gem build fc-vault-rails.gemspec
- run:
name: Publish gem
shell: /bin/bash -l
command: |
package=$(ls -t1 fc-vault-rails-*.gem | head -1)
gem push "$package" --host https://fundingcircle.jfrog.io/fundingcircle/api/gems/rubygems-pre-releases
publish-release:
docker:
- image: ruby:2.4.4-alpine
<<: *defaults

steps:

- checkout
- run:
name: Install cURL
command: apk add --no-cache curl git
- run: yum -y install curl
- run: yum clean all

- run:
name: Login to JFrog
command: |
mkdir -p ~/.gem
curl --user "$ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD" https://fundingcircle.jfrog.io/fundingcircle/api/gems/rubygems/api/v1/api_key.yaml > ~/.gem/credentials
chmod 600 ~/.gem/credentials
- run:
shell: /bin/bash -l
command: |
rvm use --default 2.5.1
- run:
name: Install Gem Versioner
shell: /bin/bash -l
command: gem install gem-versioner --version '~> 1.0' --no-document

- run:
name: Build gem
shell: /bin/bash -l
command: |
gem build fc-vault-rails.gemspec
- run:
name: Publish gem
shell: /bin/bash -l
command: |
package=$(ls -t1 fc-vault-rails-*.gem | head -1)
gem push "$package" --host https://fundingcircle.jfrog.io/fundingcircle/api/gems/rubygems-local
Expand All @@ -88,9 +132,11 @@ workflows:
test-and-release:
jobs:
- tests:
context: org-global
filters:
tags:
only: /.*/

- publish-pre-release:
context: org-global
filters:
Expand Down
17 changes: 7 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ cache: bundler
dist: trusty
sudo: false

env:
- VAULT_VERSION=0.10.4
- VAULT_VERSION=0.9.6
- VAULT_VERSION=0.8.3
- VAULT_VERSION=0.7.3

gemfile:
- Gemfile
- gemfiles/rails_4.2.gemfile
Expand All @@ -25,14 +19,17 @@ branches:
- master

rvm:
- 2.2.8
- 2.3.5
- 2.4.2
- 2.2.10
- 2.3.7
- 2.4.4
- 2.5.1

matrix:
exclude:
# Json 1.8.3 cannot build json gem dependency any longer with Ruby 2.4
- rvm: 2.4.2
- rvm: 2.4.4
gemfile: gemfiles/rails_4.2.gemfile
- rvm: 2.5.1
gemfile: gemfiles/rails_4.2.gemfile

before_script:
Expand Down
1 change: 1 addition & 0 deletions fc-vault-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Gem::Specification.new do |s|
s.add_development_dependency "rake", "~> 10.0"
s.add_development_dependency "rspec", "~> 3.2"
s.add_development_dependency "sqlite3"
s.add_development_dependency "wwtd"
end
2 changes: 2 additions & 0 deletions gemfiles/rails_4.2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ GEM
thread_safe (~> 0.1)
vault (0.12.0)
aws-sigv4
wwtd (1.3.0)

PLATFORMS
ruby
Expand All @@ -142,6 +143,7 @@ DEPENDENCIES
rake (~> 10.0)
rspec (~> 3.2)
sqlite3
wwtd

BUNDLED WITH
1.16.2

0 comments on commit 7dd889e

Please sign in to comment.