Circle CI - custom workflow

Business requirements

home:
title:
en: MyApp Dashboard
ch: # not set
sw: # not set

Setting up custom workflows..

  • Run test suite (rspec or minitest)
  • Run rubocop (coding standards)
  • Run translations checks..
workflows:
commit:
jobs:
- environment-setup
- coding-standards:
requires:
- environment-setup
- test-suit:
requires:
- environment-setup
- translations:
requires:
- environment-setup
---------------------------------------
executors:
rails-app:
docker:
- image: circleci/ruby:2.5.x
environment:
RAILS_ENV: test
- image: circleci/mysql
working_directory: *working_directory
---------------------------------------
jobs:
environment-setup:
executor: rails-app
steps:
- run: sudo apt-get update
.....
coding-standards:
executor: rails-app
steps:
- prepare_workspace
- run:
name: Coding standards
command: bundle exec rubocop
translations:
executor: rails-app
steps:
- prepare_workspace
- run:
name: Translations
command: bundle exec rake myapp:translations
test-suit:
executor: rails-app
parallelism: 10
steps:
- prepare_workspace
- run: sudo apt-get update
- run:
name: Setup database.yml
command: |
---------------------------------------
namespace :myapp do
task :translations do
puts "> Loading i18n files..."
require_relative 'lib/myapp_i18n_check'
MyAppI18nCheck.new.run
end
end
class MyAppI18nCheck
def initialize
@files = []
end
def run
scan_i18n_files
validate_and_exit
end
def scan_i18n_files
Dir.glob('config/locales/*.yml').sort.each do |folder|
folder.files.each do |file|
# if a target path has been passed in, only process that one
file = File.read(path)
if file.missing_translation?
@files << path
end
end
end
end
def validate_and_exit
if @files.blank?
exit 0 # successful exit
else
@files.each. { |file|
puts "File: #{file}"
}
exit 1 # error exit
end
end
end

--

--

--

I am rails developer, also leading development team to build application to serve customers from multiple regions.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to think like a programmer — lessons in problem solving

How to Remove Completed from your List of Coding Challenges.

My First Real-World Experience Coding for a Non-Profit

For the want of a nail, the shoe was lost

Java static blocks vs constructor vs empty constructor.

Monitoring Nodeless Kubernetes with Prometheus and Grafana

How to set up a HIPAA compliant server in less than an hour on GCP

How to create a Python package and upload it to PyPI

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arun Kumar

Arun Kumar

I am rails developer, also leading development team to build application to serve customers from multiple regions.

More from Medium

Top 30 Git Commands You Should Know To Master Git CLI

API & Web Architecture — Security Best Practices

Why you need to use DTO’s in your REST API