.circleci/config.yml
---
version: 2.1
defaults: &defaults
working_directory: ~/healthcheck-endpoint
docker:
- image: cimg/ruby:<< parameters.ruby-version >>
orbs:
ruby: circleci/ruby@2.3.0
references:
bundle_install: &bundle_install
run:
name: Installing gems
command: |
bundle config set --local path '~/vendor/bundle'
bundle install
install_linters: &install_linters
run:
name: Installing bunch of linters
command: |
curl -1sLf 'https://dl.cloudsmith.io/public/evilmartians/lefthook/setup.deb.sh' | sudo -E bash
sudo apt-get update -y
sudo apt-get install -y lefthook shellcheck yamllint
npm install --prefix='~/.local' --global --save-dev git+https://github.com/streetsidesoftware/cspell-cli markdownlint-cli
cp .circleci/linter_configs/.fasterer.yml .fasterer.yml
cp .circleci/linter_configs/.lefthook.yml lefthook.yml
install_codeclimate_reporter: &install_codeclimate_reporter
run:
name: Installing CodeClimate test reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
use_latest_bundler: &use_latest_bundler
run:
name: Using latest bundler
command: gem install bundler
use_latest_gemspec: &use_latest_gemspec
run:
name: Using latest gemspec
command: cp .circleci/gemspecs/latest healthcheck_endpoint.gemspec
use_compatible_gemspec: &use_compatible_gemspec
run:
name: Using compatible gemspec
command: cp .circleci/gemspecs/compatible healthcheck_endpoint.gemspec
jobs:
linters-ruby:
parameters:
ruby-version:
type: string
<<: *defaults
steps:
- checkout
- <<: *use_latest_bundler
- <<: *use_latest_gemspec
- <<: *bundle_install
- <<: *install_linters
- run:
name: Running commit linters
command: lefthook run commit-linters
- run:
name: Running code style linters
command: lefthook run code-style-linters
- run:
name: Running code performance linters
command: lefthook run code-performance-linters
- run:
name: Running code vulnerability linters
command: lefthook run code-vulnerability-linters
- run:
name: Running code documentation linters
command: lefthook run code-documentation-linters
- run:
name: Running release linters
command: lefthook run release-linters
tests-ruby:
parameters:
ruby-version:
type: string
<<: *defaults
steps:
- checkout
- <<: *use_latest_bundler
- <<: *use_latest_gemspec
- <<: *bundle_install
- <<: *install_codeclimate_reporter
- run:
name: Running RSpec
command: |
./cc-test-reporter before-build
bundle exec rspec
- run:
name: Creating CodeClimate test coverage report
command: |
./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
- store_artifacts:
name: Saving Simplecov coverage artifacts
path: ~/healthcheck-endpoint/coverage
destination: coverage
- deploy:
name: Uploading CodeClimate test coverage report
command: |
./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
compatibility-ruby:
parameters:
ruby-version:
type: string
<<: *defaults
steps:
- checkout
- <<: *use_compatible_gemspec
- ruby/install-deps:
bundler-version: "2.3.26"
with-cache: false
path: '~/vendor/custom_bundle'
- run:
name: Running compatibility tests
command: bundle exec rspec
rubygems-deps-ruby:
parameters:
ruby-version:
type: string
<<: *defaults
steps:
- checkout
- run:
name: Building rubygems dependencies from default gemspec on minimal Ruby version
command: bundle install
releasing-gem-from-ruby:
parameters:
ruby-version:
type: string
<<: *defaults
steps:
- checkout
- add_ssh_keys:
fingerprints:
- "SHA256:eJhlVtu2gws5rDavHcqZ5GJF/aS8kCctMprdC+Twlns"
- run:
name: Publishing new release
command: ./.circleci/scripts/release.sh
workflows:
build_test_deploy:
jobs:
- linters-ruby:
matrix:
parameters:
ruby-version: ["3.3-node"]
- tests-ruby:
matrix:
parameters:
ruby-version: ["3.3"]
- compatibility-ruby:
matrix:
parameters:
ruby-version: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2"]
- rubygems-deps-ruby:
matrix:
parameters:
ruby-version: ["2.5"]
- releasing-gem-from-ruby:
requires:
- linters-ruby
- tests-ruby
- compatibility-ruby
- rubygems-deps-ruby
matrix:
parameters:
ruby-version: ["2.5"]
filters:
branches:
only: master