LocalCI
Run your CI suite locally
LocalCI is a tool for running your Continuous Integration (CI) both locally and on CI platforms.
Usage Locally
If you don't have a Gemfile you should run bundle init before running
bundle add local_ci --group development,testing --source https://rubygems.org.
In your Rakefile add the following:
require "local_ci"
LocalCI::Rake.setup(self)
setup do
job "Run before everything", "echo 'Run before everything'"
end
teardown do
job "Run after everything", "echo 'Run after everything'"
end
flow "Example flow" do
setup do
job "Run before everything in this flow" do
run "echo 'Run before everything in this flow'"
end
end
teardown do
job "Run after everything in this flow" do
run "echo 'Run after everything in this flow'"
end
end
job "Some Job" do
run "echo 'do something here'"
end
job "Some Other Job" do
run "echo 'do something here'"
end
endTest it by running bunde exec rake ci and you should see output similar to
this.
Usage on CI Platforms
Buildkite
In your Buildkite project settings, go to the "Steps" and define the "YAML Steps" like this:
steps:
- label: ":pipeline: Pipeline upload"
commands:
- bundle check &> /dev/null || bundle install
- bundle exec rake ci:generate:buildkite | buildkite-agent pipeline uploadThis will automatically generate a Buildkite pipeline for
you from your Rakefile.
SemaphoreCI
In your project run bundle exec rake ci:generate:semaphore_ci, this will
create a .semaphore/semaphore.yml file for you.
Warning
You will need to keep this is sync with your Rakefile. I recommend setting
up a pre-push git hook that checks to see if the file has changed.
task "pre-push:semaphore:check" => "ci:generate:semaphore_ci"
task "pre-push:semaphore:check" do
puts "=== Checking there would be no changes to `.semaphore/semaphore.yml` ==="
sh "git diff -s --exit-code .semaphore/semaphore.yml"
puts "[✓] No changes"
rescue RuntimeError
puts "[x] Changes detected, check `git diff`"
exit 1
end