CI for Ruby on Rails on Hosted Agents
Build, lint, audit, run static analysis, and test a Ruby on Rails application using Bundler, RuboCop, Bundler-audit, Brakeman, and RSpec.
Use template →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
# Use caching on hosted agents cache: paths: - "vendor/bundle" # Cache this directory env: BUNDLE_PATH: vendor/bundle # Tell bundler where gems are steps: - label: ":ruby: Install gems" command: "bundle install --deployment" # Install gems to vendor/bundle key: "gems" # All other steps depend on this one plugins: - docker#v5.9.0: image: "ruby:3.2.2" environment: - BUNDLE_PATH # Pass this env var to docker volumes: - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker - label: ":rubocop: Run rubocop" commands: - bundle check || bundle install --deployment - bundle exec rubocop" depends_on: "gems" plugins: - docker#v5.9.0: image: "ruby:3.2.2" environment: - BUNDLE_PATH # Pass this env var to docker volumes: - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker - label: ":brakeman: Run brakeman" commands: - bundle check || bundle install --deployment - bundle exec brakeman --force" depends_on: "gems" plugins: - docker#v5.9.0: image: "ruby:3.2.2" environment: - BUNDLE_PATH # Pass this env var to docker volumes: - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker - label: ":fsociety: Run bundler-audit" commands: - bundle check || bundle install --deployment - bundle exec bundle-audit check --update depends_on: "gems" plugins: - docker#v5.9.0: image: "ruby:3.2.2" environment: - BUNDLE_PATH # Pass this env var to docker volumes: - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker - label: ":rspec: Run rspec" commands: - bundle check || bundle install --deployment - bundle exec rspec depends_on: "gems" plugins: - docker#v5.9.0: image: "ruby:3.2.2" environment: - BUNDLE_PATH # Pass this env var to docker volumes: - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker
- Languages
- Ruby
- Use cases
- Continuous integration, Web application
- Platforms
- Docker, Hosted Agents
- Tools
- Bundler, RuboCop, Bundler-audit, Brakeman, RSpec
CI for Ruby on Rails on Hosted Agents
Build, lint, audit, run static analysis, and test a Ruby on Rails application using Bundler, RuboCop, Bundler-audit, Brakeman, and RSpec.
Use template →CI for Ruby on Rails on Hosted Agents
This template gives you a continuous integration (CI) pipeline that builds, lints, audits, runs static analysis, and tests a Ruby on Rails application.
At a glance:
- For Ruby on Rails applications
- Uses Bundler
- Requires Docker
- Lints code with RuboCop
- Audits gems with Bundler-audit
- Runs static analysis with Brakeman
- Tests code using RSpec
How it works
This template:
- Installs ruby gems using bundler, caching the result.
- Lints your Ruby code with RuboCop.
- Audits your gems with Bundler-audit.
- Performs static analysis of your code with Brakeman.
- Runs tests with RSpec.
The first step installs gems and caches them for the following steps. The remaining steps run in parallel. The runtime environment uses a Docker image with the latest version of Ruby.
Next steps
After you select Use template, you’ll:
- Connect the Git repository with your RoR application.
- Modify the commands if necessary.
- Configure the pipeline cluster to use hosted agents.
- Enable Git mirror in Hosted agents - Cache Storage - Settings. This will speed up git checkout.
- Run the pipeline.
You can then play around with the pipeline settings. For example, run the pipeline locally while you iterate on the definition or set a schedule to trigger a nightly build.
If you need help, please check our documentation, raise an issue , or reach out to support.