Skip to content

Commit

Permalink
ci: Refactor CI workflow with build matrix (#173)
Browse files Browse the repository at this point in the history
* feat: Accept argument for `build_multi` task

Sample command:

```
rake 'build_multi[7.0,7.1]'
```

* refactor: Fetch rails tags inside the loop

* cI: Build build_multi matrix

- refactor: Loop versions in bash script

* ci: Build YJIT enabled matrix

- Remove `doc-build-latest-with-yjit` since it's covered by matrix
- switch YJIT using `RUBY_YJIT_ENABLE`
  • Loading branch information
toshimaru authored Nov 24, 2024
1 parent 9227538 commit a38bd38
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
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

0 comments on commit a38bd38

Please sign in to comment.