1. sul-dlss/ruby-rails@4.5.0

sul-dlss/ruby-rails@4.5.0

Sections
An orb for building Ruby / Rails projects. It is optimized for the tooling / practices of the DLSS Infrastructure team.
Created: January 10, 2022Version Published: February 8, 2025Releases: 20
Org Usage:
< 25
Categories:

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: ruby-rails: sul-dlss/ruby-rails@4.5.0

Use ruby-rails elements in your existing workflows and jobs.

Opt-in to use of uncertified orbs on your organization’s Security settings page.

Usage Examples

gem

Gem.

1 2 3 4 5 6 7 8 9 10 11 12 version: '2.1' orbs: ruby-rails: sul-dlss/ruby-rails@x.y.z workflows: build: jobs: - ruby-rails/lint-gem: context: dlss name: lint - ruby-rails/test-gem: context: dlss name: test

rails_api

Rails application (API).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 version: '2.1' orbs: ruby-rails: sul-dlss/ruby-rails@x.y.z workflows: build: jobs: - ruby-rails/validate-api: name: validate - ruby-rails/lint: context: dlss name: lint - ruby-rails/test-rails: api-only: true context: dlss name: test - ruby-rails/docker-publish: context: dlss filters: branches: only: - main image: suldlss/your-app name: publish-latest requires: - validate - lint - test

rails_web

Rails application (web).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 version: '2.1' orbs: ruby-rails: sul-dlss/ruby-rails@x.y.z workflows: build: jobs: - ruby-rails/lint: context: dlss name: lint - ruby-rails/lint-erb - ruby-rails/lint-js - ruby-rails/test-rails: context: dlss install-chrome: true name: test

Jobs

docker-publish

Build and deploy a Docker image.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
docker-password
Name of environment variable storing your Docker password
No
DOCKER_PASS
env_var_name
docker-username
Name of environment variable storing your Docker username
No
DOCKER_USER
env_var_name
dockerfile
Name of dockerfile to use, defaults to Dockerfile
No
Dockerfile
string
extra_build_args
Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build
No
''
string
image
Name of image to build
Yes
-
string
tag
Comma-separated list of image tags, defaults to latest
No
latest
string

lint

Perform rubocop linting.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
executor
Executor to use for this job, defaults to ruby executor
No
ruby
executor

lint-erb

Perform erb linting.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
executor
Executor to use for this job, defaults to ruby executor
No
ruby
executor

lint-gem

Perform rubocop linting for gems

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
executor
Executor to use for this job, defaults to ruby executor
No
ruby
executor

lint-js

Perform javascript linting.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
executor
Executor to use for this job, defaults to node executor
No
node/default
executor

test-gem

Perform rspec testing without a database.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
before-test
Optional steps to run before running rspec
No
[]
steps
executor
Executor to use for this job, defaults to ruby executor
No
ruby
executor
use-codecov
True if project uses CodeCov instead of CodeClimate.
No
false
boolean

test-rails

Perform rspec testing of a Rails application.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
api-only
True if this is an API only Rails app.
No
false
boolean
before-test
Optional steps to run before running rspec
No
[]
steps
db-prepare-command
Database prepare command
No
db:test:prepare
string
executor
Executor to use for this job, defaults to ruby-postgres executor
No
ruby-postgres
executor
install-chrome
True to install Chrome
No
false
boolean
install-firefox
True to install Firefox
No
false
boolean
install-java
True to install Java
No
false
boolean
use-codecov
True if project uses CodeCov instead of CodeClimate.
No
false
boolean

validate-api

Validate openapi specification.

Show job Source

Commands

gem-install-deps

Install dependencies without using deployment mode (suitable for gems).

Show command Source

rubocop-with-caching

Runs rubocop with cache restore and save

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
cache-version
A prefix to the cache key for versioning
No
v1
string
path
The path of the rubocop cache
No
../.cache/rubocop_cache
string

test

Runs rspec wrapped with code coverage.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
cc-test-reporter-id
Name of environment variable storing your Code Climate reporter test id
No
CC_TEST_REPORTER_ID
env_var_name
codecov-token
Name of environment variable storing your CodeCov token
No
CODECOV_TOKEN
env_var_name
use-codecov
True if project uses CodeCov instead of CodeClimate.
No
false
boolean

validate-api

Validate openapi specification.

Show command Source

Executors

ruby

Ruby-only executor.

Show executor Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
ruby-tag
The `cimg/ruby` Docker image version tag.
No
3.4.1
string

ruby-postgres

Ruby and postgres-only executor.

Show executor Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
postgres-tag
The `cimg/postgres` Docker image version tag.
No
'12.9'
string
ruby-tag
The `cimg/ruby` Docker image version tag.
No
3.4.1
string

ruby-postgres-redis

Ruby, postgres, and redis-only executor.

Show executor Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
postgres-tag
The `cimg/postgres` Docker image version tag.
No
'12.9'
string
ruby-tag
The `cimg/ruby` Docker image version tag.
No
3.4.1
string

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/ja/orbs/licensing version: 2.1 description: | An orb for building Ruby / Rails projects. It is optimized for the tooling / practices of the DLSS Infrastructure team. display: home_url: https://github.com/sul-dlss/ruby-rails-orb source_url: https://github.com/sul-dlss/ruby-rails-orb orbs: browser-tools: circleci/browser-tools@1.5.2 codecov: codecov/codecov@5.2.0 docker: circleci/docker@2.8.2 node: circleci/node@7.1.0 ruby: circleci/ruby@2.4.0 commands: gem-install-deps: description: | Install dependencies without using deployment mode (suitable for gems). steps: - run: command: bundle check || bundle install name: Bundle Install rubocop-with-caching: description: Runs rubocop with cache restore and save parameters: cache-version: default: v1 description: A prefix to the cache key for versioning type: string path: default: ../.cache/rubocop_cache description: The path of the rubocop cache type: string steps: - restore_cache: keys: - << parameters.cache-version >>-rubocop-cache-{{ checksum ".rubocop.yml" }}-{{ .Branch }} - << parameters.cache-version >>-rubocop-cache-{{ checksum ".rubocop.yml" }}-main - << parameters.cache-version >>-rubocop-cache-{{ checksum ".rubocop.yml" }} - ruby/rubocop-check - save_cache: key: << parameters.cache-version >>-rubocop-cache-{{ checksum ".rubocop.yml" }}-{{ .Branch }}-{{ epoch }} paths: - << parameters.path >> test: description: | Runs rspec wrapped with code coverage. parameters: cc-test-reporter-id: default: CC_TEST_REPORTER_ID description: | Name of environment variable storing your Code Climate reporter test id type: env_var_name codecov-token: default: CODECOV_TOKEN description: | Name of environment variable storing your CodeCov token type: env_var_name use-codecov: default: false description: True if project uses CodeCov instead of CodeClimate. type: boolean steps: - unless: condition: << parameters.use-codecov >> steps: - run: command: | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter chmod +x ./cc-test-reporter ./cc-test-reporter before-build name: Setup Code Climate test-reporter - run: command: gem install rspec_junit_formatter name: Install Rspec Junit Formatter gem - ruby/rspec-test: rerun-fail: true - when: condition: << parameters.use-codecov >> steps: - codecov/upload - unless: condition: << parameters.use-codecov >> steps: - run: command: ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $? -r $<< parameters.cc-test-reporter-id >> name: upload test coverage report to Code Climate - store_artifacts: path: tmp/capybara validate-api: description: | Validate openapi specification. steps: - run: command: | npm install openapi-enforcer-cli result=$(npx openapi-enforcer validate openapi.yml) [[ $result =~ "Document is valid" ]] && { echo "Validation good" exit 0 } || { echo $result exit 1 } name: Validate API specification executors: ruby: description: | Ruby-only executor. docker: - environment: BUNDLE_JOBS: "3" BUNDLE_RETRY: "3" PAGER: cat RAILS_ENV: test TZ: America/Los_Angeles image: cimg/ruby:<< parameters.ruby-tag >>-node parameters: ruby-tag: default: 3.4.1 description: The `cimg/ruby` Docker image version tag. type: string ruby-postgres: description: | Ruby and postgres-only executor. docker: - environment: BUNDLE_JOBS: "3" BUNDLE_RETRY: "3" PAGER: cat RAILS_ENV: test TZ: America/Los_Angeles image: cimg/ruby:<< parameters.ruby-tag >>-node - environment: POSTGRES_PASSWORD: sekret POSTGRES_USER: postgres image: cimg/postgres:<< parameters.postgres-tag >> parameters: postgres-tag: default: "12.9" description: The `cimg/postgres` Docker image version tag. type: string ruby-tag: default: 3.4.1 description: The `cimg/ruby` Docker image version tag. type: string ruby-postgres-redis: description: | Ruby, postgres, and redis-only executor. docker: - environment: BUNDLE_JOBS: "3" BUNDLE_RETRY: "3" PAGER: cat RAILS_ENV: test TZ: America/Los_Angeles image: cimg/ruby:<< parameters.ruby-tag >>-node - environment: POSTGRES_PASSWORD: sekret POSTGRES_USER: postgres image: cimg/postgres:<< parameters.postgres-tag >> - image: cimg/redis:6.2 parameters: postgres-tag: default: "12.9" description: The `cimg/postgres` Docker image version tag. type: string ruby-tag: default: 3.4.1 description: The `cimg/ruby` Docker image version tag. type: string jobs: docker-publish: description: | Build and deploy a Docker image. executor: docker/machine parameters: docker-password: default: DOCKER_PASS description: | Name of environment variable storing your Docker password type: env_var_name docker-username: default: DOCKER_USER description: | Name of environment variable storing your Docker username type: env_var_name dockerfile: default: Dockerfile description: Name of dockerfile to use, defaults to Dockerfile type: string extra_build_args: default: "" description: | Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build type: string image: description: Name of image to build type: string tag: default: latest description: Comma-separated list of image tags, defaults to latest type: string steps: - checkout - docker/check: docker-password: << parameters.docker-password >> docker-username: << parameters.docker-username >> - docker/build: dockerfile: << parameters.dockerfile >> extra_build_args: << parameters.extra_build_args >> image: << parameters.image >> tag: << parameters.tag >> - docker/push: image: << parameters.image >> tag: << parameters.tag >> lint: description: | Perform rubocop linting. executor: << parameters.executor >> parameters: executor: default: ruby description: Executor to use for this job, defaults to ruby executor type: executor steps: - checkout - ruby/install-deps - rubocop-with-caching lint-erb: description: | Perform erb linting. executor: << parameters.executor >> parameters: executor: default: ruby description: Executor to use for this job, defaults to ruby executor type: executor steps: - checkout - ruby/install-deps - run: command: bundle exec erb_lint --lint-all --format compact name: Lint ERBs lint-gem: description: | Perform rubocop linting for gems executor: << parameters.executor >> parameters: executor: default: ruby description: Executor to use for this job, defaults to ruby executor type: executor steps: - checkout - gem-install-deps - rubocop-with-caching lint-js: description: | Perform javascript linting. executor: << parameters.executor >> parameters: executor: default: node/default description: Executor to use for this job, defaults to node executor type: executor steps: - checkout - node/install-packages: pkg-manager: yarn - run: command: yarn run lint name: Lint JavaScript test-gem: description: | Perform rspec testing without a database. executor: << parameters.executor >> parameters: before-test: default: [] description: Optional steps to run before running rspec type: steps executor: default: ruby description: Executor to use for this job, defaults to ruby executor type: executor use-codecov: default: false description: True if project uses CodeCov instead of CodeClimate. type: boolean steps: - checkout - gem-install-deps - run: command: bundle add rspec_junit_formatter name: Install rspec_junit_formatter - when: condition: << parameters.before-test >> steps: << parameters.before-test >> - test: use-codecov: << parameters.use-codecov >> test-rails: description: | Perform rspec testing of a Rails application. executor: << parameters.executor >> parameters: api-only: default: false description: True if this is an API only Rails app. type: boolean before-test: default: [] description: Optional steps to run before running rspec type: steps db-prepare-command: default: db:test:prepare description: Database prepare command type: string executor: default: ruby-postgres description: Executor to use for this job, defaults to ruby-postgres executor type: executor install-chrome: default: false description: True to install Chrome type: boolean install-firefox: default: false description: True to install Firefox type: boolean install-java: default: false description: True to install Java type: boolean use-codecov: default: false description: True if project uses CodeCov instead of CodeClimate. type: boolean steps: - checkout - ruby/install-deps - when: condition: << parameters.install-chrome >> steps: - browser-tools/install-chrome - when: condition: << parameters.install-firefox >> steps: - browser-tools/install-firefox - when: condition: << parameters.install-java >> steps: - run: command: sudo apt install openjdk-11-jdk name: Install Java - unless: condition: << parameters.api-only >> steps: - node/install-packages: pkg-manager: yarn - run: command: dockerize -wait tcp://localhost:5432 -timeout 1m name: Wait for DB - run: command: bin/rails << parameters.db-prepare-command >> name: Test prepare - when: condition: << parameters.before-test >> steps: << parameters.before-test >> - test: use-codecov: << parameters.use-codecov >> validate-api: description: | Validate openapi specification. executor: node/default steps: - checkout - validate-api examples: gem: description: | Gem. usage: version: "2.1" orbs: ruby-rails: sul-dlss/ruby-rails@x.y.z workflows: build: jobs: - ruby-rails/lint-gem: context: dlss name: lint - ruby-rails/test-gem: context: dlss name: test rails_api: description: | Rails application (API). usage: version: "2.1" orbs: ruby-rails: sul-dlss/ruby-rails@x.y.z workflows: build: jobs: - ruby-rails/validate-api: name: validate - ruby-rails/lint: context: dlss name: lint - ruby-rails/test-rails: api-only: true context: dlss name: test - ruby-rails/docker-publish: context: dlss filters: branches: only: - main image: suldlss/your-app name: publish-latest requires: - validate - lint - test rails_web: description: | Rails application (web). usage: version: "2.1" orbs: ruby-rails: sul-dlss/ruby-rails@x.y.z workflows: build: jobs: - ruby-rails/lint: context: dlss name: lint - ruby-rails/lint-erb - ruby-rails/lint-js - ruby-rails/test-rails: context: dlss install-chrome: true name: test
開発者向け最新情報
ビルド最適化のためのヒントを手に入れましょう。
または、リサーチパネルに参加して フィードバックをお寄せください。
このフォームを送信することで、当社の利用規約およびプライバシーポリシーに同意したものと見なされます。