自己紹介
● RubyKaigi 2019 Speaker
○ Best practices in web API client development
○ https://rubykaigi.org/2019/presentations/sue445.html
● RubyKaigi 2020 Speaker
○ Ruby on CI
○ https://rubykaigi.org/2020/presentations/sue445.html
○ しかし中止(◞‸◟)
複数リポジトリのCI設定の共通化(CI as a CI)
● アプリケーションコードと同様CIの設定も継続的にメンテしていく
○ みんなリファクタリング大好きだよね?
● 複数リポジトリメンテしてるとリポジトリによって設定が違うと大変なので極
力統一したい
● 同一yamlを複数リポジトリでコピペして使い回すのが理想だがgemに
よってサポートしてるrubyのバージョンが変わったりするので厳しい
○ とはいえ8割方一緒なので共通化できる
Slide 81
Slide 81 text
というわけでCI as a CIした
● https://github.com/sue445/ci-config-itamae
● RailsのmigrationとAnsibleのplaybookがあわさった感じ
● Itamaeを活用したマイグレーションシステム
● 自分の作業を効率化することに特化してるので汎用化はあまり考えられ
ていない
Slide 82
Slide 82 text
Usage (Generate a migration file)
$ ./bin/generate --template=github_actions some_migration
Write to
/path/to/ci-config-itamae/cookbooks/migrate/github_actions/202
00311232827_some_migration.rb
Slide 83
Slide 83 text
Usage (Edit a migration)
file "#{node[:repo]}/.github/workflows/test.yml" do
action :edit
block do |content|
next if content.include?("centos:8")
content.gsub!(<<-YAML, <<-YAML)
- centos:7
YAML
- centos:7
- centos:8
YAML
end
only_if "ls #{node[:repo]}/.github/workflows/test.yml"
end
Slide 84
Slide 84 text
Usage (Apply to a repo)
# dry run結果が問題なければ--dry-runを外して実行
$ ./bin/migrate
--recipe=cookbooks/migrate/github_actions/20200311232827_som
e_migration.rb -m "This is commit message"
--repo=github.com/sue445/rubicure --dry-run
Slide 85
Slide 85 text
Usage (Apply to multiple repos)
# dry run結果が問題なければ--dry-runを外して実行
$ ./bin/migrate
--recipe=cookbooks/migrate/github_actions/20200311232827_som
e_migration.rb -m "This is commit message" --include=gem
--dry-run