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# Use caching on hosted agents
2cache:
3 paths:
4 - "vendor/bundle" # Cache this directory
5
6env:
7 BUNDLE_PATH: vendor/bundle # Tell bundler where gems are
8
9steps:
10 - label: ":ruby: Install gems"
11 command: "bundle install --deployment" # Install gems to vendor/bundle
12 key: "gems" # All other steps depend on this one
13 plugins:
14 - docker#v5.9.0:
15 image: "ruby:3.2.2"
16 environment:
17 - BUNDLE_PATH # Pass this env var to docker
18 volumes:
19 - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker
20
21 - label: ":rubocop: Run rubocop"
22 commands:
23 - bundle check || bundle install --deployment
24 - bundle exec rubocop"
25 depends_on: "gems"
26 plugins:
27 - docker#v5.9.0:
28 image: "ruby:3.2.2"
29 environment:
30 - BUNDLE_PATH # Pass this env var to docker
31 volumes:
32 - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker
33
34
35 - label: ":brakeman: Run brakeman"
36 commands:
37 - bundle check || bundle install --deployment
38 - bundle exec brakeman --force"
39 depends_on: "gems"
40 plugins:
41 - docker#v5.9.0:
42 image: "ruby:3.2.2"
43 environment:
44 - BUNDLE_PATH # Pass this env var to docker
45 volumes:
46 - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker
47
48 - label: ":fsociety: Run bundler-audit"
49 commands:
50 - bundle check || bundle install --deployment
51 - bundle exec bundle-audit check --update
52 depends_on: "gems"
53 plugins:
54 - docker#v5.9.0:
55 image: "ruby:3.2.2"
56 environment:
57 - BUNDLE_PATH # Pass this env var to docker
58 volumes:
59 - "./vendor/bundle:/workdir/vendor/bundle" # Mount the cached gems in docker
60
61 - label: ":rspec: Run rspec"
62 commands:
63 - bundle check || bundle install --deployment
64 - bundle exec rspec
65 depends_on: "gems"
66 plugins:
67 - docker#v5.9.0:
68 image: "ruby:3.2.2"
69 environment:
70 - BUNDLE_PATH # Pass this env var to docker
71 volumes:
72 - "./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.