Skip to content

ci: Refactor CI workflow with build matrix #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ on:
jobs:
jekyll-build:
runs-on: ubuntu-latest
name: Jekyll Build
name: Jekyll Build (YJIT_ENABLED ${{ matrix.yjit-enabled }})
strategy:
matrix:
yjit-enabled: [0, 1]
env:
RUBY_YJIT_ENABLE: ${{ matrix.yjit-enabled }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
Expand All @@ -21,25 +26,12 @@ jobs:

doc-build-latest:
runs-on: ubuntu-latest
name: Rails Doc Build (latest)
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: fetch Rails tags
run: cd rails && git fetch --depth=1 origin refs/tags/v7*:refs/tags/v7*
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
bundler-cache: true
- name: Doc Build
run: rake build

doc-build-latest-with-yjit:
runs-on: ubuntu-latest
name: Rails Doc Build (latest, with YJIT enabled)
name: Rails Doc Build (latest, YJIT_ENABLED ${{ matrix.yjit-enabled }})
strategy:
matrix:
yjit-enabled: [0, 1]
env:
RUBY_YJIT_ENABLE: true
RUBY_YJIT_ENABLE: ${{ matrix.yjit-enabled }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -56,15 +48,26 @@ jobs:
doc-build-others:
runs-on: ubuntu-latest
name: Rails Doc Build (older versions)
strategy:
matrix:
include:
- ruby-version: 2.7
build-rails-versions: "5.2,6.0,6.1"
- ruby-version: 3.3
build-rails-versions: "7.0,7.1,7.2"
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: fetch Rails tags
run: cd rails && git fetch --depth=1 origin refs/tags/v7*:refs/tags/v7* refs/tags/v6*:refs/tags/v6* refs/tags/v5*:refs/tags/v5*
working-directory: rails
run: |
for version in $(echo "${{ matrix.build-rails-versions }}" | tr ',' ' '); do
git fetch --depth=1 origin refs/tags/v${version}*:refs/tags/v${version}*
done
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Doc Build
run: rake build_multi
run: rake 'build_multi[${{ matrix.build-rails-versions }}]'
12 changes: 8 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ task :switch_default_rails do
end

desc 'Generate and build documentation for older versions of Rails'
task :build_multi do
# WORKAROUND: use `reverse_each` instead of `each` to avoid nokogiri installation error
config['rails_versions'].reverse_each do |version, detail|
task :build_multi, [:versions] do |_t, args|
rails_versions = config['rails_versions'].reverse_each.to_h # Versions from oldest to newest
unless args[:versions].nil?
versions = args[:versions].split(',')
rails_versions.select! { |version, _| versions.include?(version) }
end
rails_versions.each do |version, detail|
if detail['latest']
puts "=== Skip Rails v#{version} because it's latest version ==="
next
Expand All @@ -39,7 +43,7 @@ task :build_multi do
generate_rails_rdoc
generate_src(target_version: version)
end
puts
puts "=== Build Jekyll site ==="
sh 'bundle exec jekyll build'
end

Expand Down