You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Getting Started] Rewrite Continiouus Integration section to use bin/ci
With Rails 8.1, we have introduced `bin/ci` as the starter to CI pipelines.
Currently, the guide focused on GitHub Actions as the starter which is tied
to the specific platform.
This change rewrites the Continuous Integration section in Getting Started guide
to use `bin/ci` as the main example, making it platform-agnostic, emphasizing
local execution and introducing the recent capabilities of `bin/ci`.
Copy file name to clipboardExpand all lines: guides/source/getting_started.md
+110-7Lines changed: 110 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2961,16 +2961,119 @@ No warnings found
2961
2961
2962
2962
Learn more about [Securing Rails Applications](security.html)
2963
2963
2964
-
Continuous Integration with GitHub Actions
2964
+
Continuous Integration with `bin/ci`
2965
2965
------------------------------------------
2966
2966
2967
-
Rails apps generate a `.github` folder that includes a prewritten GitHub Actions
2968
-
configuration that runs rubocop, brakeman, and our test suite.
2967
+
Rails applications include a `bin/ci` script that runs all essential checks for
2968
+
your app: setup, code style (RuboCop), security audits, and tests. The steps
2969
+
are defined in `config/ci.rb` and can be customized for your project.
2969
2970
2970
-
When we push our code to a GitHub repository with GitHub Actions enabled, it
2971
-
will automatically run these steps and report back success or failure for each.
2972
-
This allows us to monitor our code changes for defects and issues and ensure
2973
-
consistent quality for our work.
2971
+
This script prints each step as it runs, showing ✅ for success and ❌ for
2972
+
failures. If any step fails, `bin/ci` exits with a nonzero status.
2973
+
2974
+
To use a CI Provider, point your pipeline to `bin/ci`. This ensures consistent
2975
+
checks locally and in CI.
2976
+
2977
+
To run it locally, call the script from your command line:
2978
+
2979
+
```bash
2980
+
$ bin/ci
2981
+
Continuous Integration
2982
+
Running tests, style checks, and security audits
2983
+
2984
+
2985
+
Setup
2986
+
bin/setup --skip-server
2987
+
2988
+
== Installing dependencies ==
2989
+
The Gemfile's dependencies are satisfied
2990
+
2991
+
== Preparing database ==
2992
+
2993
+
== Removing old logs and tempfiles ==
2994
+
2995
+
✅ Setup passed in 2.11s
2996
+
2997
+
2998
+
Style: Ruby
2999
+
bin/rubocop
3000
+
3001
+
Inspecting 25 files
3002
+
.........................
3003
+
3004
+
25 files inspected, no offenses detected
3005
+
3006
+
✅ Style: Ruby passed in 1.17s
3007
+
# ...
3008
+
✅ Continuous Integration passed in 8.91s
3009
+
```
3010
+
3011
+
### CI Steps DSL
3012
+
3013
+
The file is written in a DSL that makes it straightforward to manage steps, here
3014
+
we add another step to check to make sure we don't leave any TODOs behind in
3015
+
the code in`config/ci.rb`:
3016
+
3017
+
```ruby#6-7
3018
+
# config/ci.rb
3019
+
CI.run do
3020
+
step "Setup", "bin/setup --skip-server"
3021
+
3022
+
step "Style: Ruby", "bin/rubocop"
3023
+
step "Check: No TODOs",
3024
+
"if grep -r TODO app/; then exit 1; fi"
3025
+
# ...
3026
+
end
3027
+
```
3028
+
3029
+
To test this out, I added a todo comment at the start of a random file, here
3030
+
the `ApplicationController`:
3031
+
3032
+
```ruby
3033
+
# app/controllers/application_controller.rb
3034
+
# TODO: Remove this todo
3035
+
class ApplicationController < ActionController::Base
3036
+
# ...
3037
+
```
3038
+
3039
+
Now when I run it on the CI:
3040
+
3041
+
```bash
3042
+
$ bin/ci
3043
+
# ...
3044
+
Check: No TODOs
3045
+
if grep -r TODO app/;thenexit 1;fi
3046
+
3047
+
app/controllers/application_controller.rb:# TODO: Remove this todo
3048
+
3049
+
❌ Check: No TODOs failed in 0.01s
3050
+
# ...
3051
+
❌ Continuous Integration failed in 9.09s
3052
+
```
3053
+
3054
+
To verify, remove the comment:
3055
+
3056
+
```ruby
3057
+
# app/controllers/application_controller.rb
3058
+
class ApplicationController < ActionController::Base
3059
+
# ...
3060
+
```
3061
+
3062
+
and `bin/ci` should now pass:
3063
+
3064
+
```bash
3065
+
$ bin/ci
3066
+
# ...
3067
+
Check: No TODOs
3068
+
if grep -r TODO app/;thenexit 1;fi
3069
+
3070
+
3071
+
✅ Check: No TODOs passed in 0.01s
3072
+
# ...
3073
+
✅ Continuous Integration passed in 8.91s
3074
+
```
3075
+
3076
+
To learn more about the DSL, read the documentation for [ActiveSupport::ContinuousIntegration](https://www.rubydoc.info/github/rails/rails/main/ActiveSupport/ContinuousIntegration).
0 commit comments