Skip to content

Commit 73de0ff

Browse files
authored
Merge pull request #2498 from ViewComponent/2476-support-rails-81-for-viewcomponent-v3
Support Rails 8.1 for ViewComponent v3
2 parents 9f3f4fd + 1171574 commit 73de0ff

22 files changed

+118
-85
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ jobs:
6565
- ruby_version: "3.4"
6666
rails_version: "8.0"
6767
mode: "capture_patch_enabled"
68+
- ruby_version: "3.4"
69+
rails_version: "8.1"
70+
mode: "capture_patch_disabled"
71+
- ruby_version: "3.4"
72+
rails_version: "8.1"
73+
mode: "capture_patch_enabled"
6874
- ruby_version: "3.4"
6975
rails_version: "main"
7076
mode: "capture_patch_disabled"
@@ -77,6 +83,12 @@ jobs:
7783
- ruby_version: "3.5"
7884
rails_version: "8.0"
7985
mode: "capture_patch_enabled"
86+
- ruby_version: "3.5"
87+
rails_version: "8.1"
88+
mode: "capture_patch_disabled"
89+
- ruby_version: "3.5"
90+
rails_version: "8.1"
91+
mode: "capture_patch_enabled"
8092
env:
8193
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails_version }}.gemfile
8294
steps:
@@ -105,38 +117,6 @@ jobs:
105117
name: simplecov-resultset-rails${{matrix.rails_version}}-ruby${{matrix.ruby_version}}-${{matrix.mode}}
106118
path: coverage
107119
include-hidden-files: true
108-
primer_view_components_compatibility:
109-
name: Test compatibility with Primer ViewComponents (main)
110-
runs-on: ubuntu-latest
111-
steps:
112-
- uses: actions/[email protected]
113-
with:
114-
repository: 'primer/view_components'
115-
path: 'primer_view_components'
116-
- uses: actions/[email protected]
117-
with:
118-
path: 'view_component'
119-
- name: Setup Ruby
120-
uses: ruby/setup-ruby@v1
121-
with:
122-
ruby-version: 3.4
123-
bundler-cache: true
124-
working-directory: 'view_component'
125-
- uses: actions/setup-node@v4
126-
with:
127-
node-version: 20
128-
cache: 'npm'
129-
cache-dependency-path: 'primer_view_components/package-lock.json'
130-
- name: Build and test with Rake
131-
run: |
132-
cd primer_view_components
133-
npm ci
134-
cd demo && npm ci && cd ..
135-
bundle && bundle exec rake
136-
env:
137-
VIEW_COMPONENT_PATH: ../view_component
138-
RAILS_VERSION: '7.1.1'
139-
PARALLEL_WORKERS: '1'
140120
coverage:
141121
needs: test
142122
runs-on: ubuntu-latest

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby 3.4.3
1+
ruby 3.4.7

Appraisals

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
appraise "rails-6.1" do
4-
gem "rails", "~> 6.1"
4+
gem "rails", "~> 6.1.0"
55
gem "tailwindcss-rails", "~> 2.0"
66
gem "sprockets-rails", "~> 3.4.2"
77
gem "concurrent-ruby", "1.3.4"
@@ -14,27 +14,33 @@ appraise "rails-6.1" do
1414
end
1515

1616
appraise "rails-7.0" do
17-
gem "rails", "~> 7.0"
17+
gem "rails", "~> 7.0.0"
1818
gem "tailwindcss-rails", "~> 2.0"
1919
gem "turbo-rails", "~> 1"
2020
gem "sprockets-rails", "~> 3.4.2"
2121
end
2222

2323
appraise "rails-7.1" do
24-
gem "rails", "~> 7.1"
24+
gem "rails", "~> 7.1.0"
2525
gem "tailwindcss-rails", "~> 2.0"
2626
gem "turbo-rails", "~> 1"
2727
gem "sprockets-rails", "~> 3.4.2"
2828
end
2929

3030
appraise "rails-7.2" do
31-
gem "rails", "~> 7.2"
31+
gem "rails", "~> 7.2.0"
3232
gem "tailwindcss-rails", "~> 2.0"
3333
gem "sprockets-rails", "~> 3.4.2"
3434
end
3535

3636
appraise "rails-8.0" do
37-
gem "rails", "~> 8.0"
37+
gem "rails", "~> 8.0.0"
38+
gem "tailwindcss-rails", "~> 2.0"
39+
gem "propshaft", "~> 1.1.0"
40+
end
41+
42+
appraise "rails-8.1" do
43+
gem "rails", "~> 8.1.0"
3844
gem "tailwindcss-rails", "~> 2.0"
3945
gem "propshaft", "~> 1.1.0"
4046
end

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ gem "rails", (rails_version == "main") ? {git: "https://github.com/rails/rails",
88

99
ruby_version = (ENV["RUBY_VERSION"] || "~> 3.4").to_s
1010
ruby ruby_version
11+
12+
group :development, :test do
13+
gem "appraisal-run", "~> 1.0"
14+
end

Gemfile.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PATH
22
remote: .
33
specs:
44
view_component (3.23.2)
5-
activesupport (>= 5.2.0, < 8.1)
5+
activesupport (>= 5.2.0, < 8.2)
66
concurrent-ruby (~> 1)
77
method_source (~> 1.0)
88

@@ -88,6 +88,7 @@ GEM
8888
bundler
8989
rake
9090
thor (>= 0.14.0)
91+
appraisal-run (1.1.0)
9192
ast (2.4.3)
9293
base64 (0.2.0)
9394
benchmark (0.4.0)
@@ -375,6 +376,7 @@ PLATFORMS
375376
DEPENDENCIES
376377
allocation_stats (~> 0.1.5)
377378
appraisal (~> 2.4)
379+
appraisal-run (~> 1.0)
378380
base64
379381
benchmark-ips (~> 2.13.0)
380382
better_html

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ nav_order: 6
1010

1111
## main
1212

13+
* Add Rails 8.1 support to ViewComponent v3.
14+
15+
*Hans Lemuet*
16+
1317
## 3.23.2
1418

1519
* Include .tt files in published gem. Fixes templates not being available when using generators.

docs/CONTRIBUTING.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,26 @@ The codespace environment includes a minimal Rails app with ViewComponent instal
4343
2. Expose the port when prompted by the Visual Studio Code Web Editor.
4444
3. Add the external URL to the config block in `config/application.rb` as prompted by the error.
4545

46+
## Running tests with Appraisal
47+
48+
This project uses [appraisal](https://github.com/thoughtbot/appraisal) to run tests for various versions of Ruby and Rails, and [appraisal-run](https://github.com/camertron/appraisal-run) to run them in Docker containers.
49+
50+
1. Install the dependencies: `bundle`
51+
2. Make sure the tests pass: `appraisal-run gemfiles/*.gemfile -- bundle exec rake`
52+
53+
When a new version of Rails is released:
54+
55+
1. Add a new `appraise` block in `Appraisals`.
56+
2. Run `bundle exec appraisal generate`
57+
3. Update the gemfiles locks `appraisal-run gemfiles/*.gemfile -- bundle lock`
58+
4. Make sure the tests pass: `appraisal-run gemfiles/*.gemfile -- bundle exec rake`
59+
5. Commit and push the changes.
60+
6. Release a new version.
61+
4662
## Submitting a pull request
4763

4864
1. [Fork](https://github.com/viewcomponent/view_component/fork) and clone the repository.
49-
1. Configure and install the dependencies: `bundle exec appraisal install`.
50-
2. Make sure the tests pass: `bundle exec appraisal rake` (see below for specific cases).
65+
2. Make sure the tests pass: `appraisal-run gemfiles/*.gemfile -- bundle exec rake`.
5166
3. Create a new branch: `git checkout -b my-branch-name`.
5267
4. Add tests, make the change, and make sure the tests still pass.
5368
5. Add an entry to the top of `docs/CHANGELOG.md` for the changes, no matter how small.

gemfiles/rails_6.1.gemfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
source "https://rubygems.org"
44

5-
gem "rails", "~> 6.1"
5+
gem "rails", "~> 6.1.0"
66
gem "tailwindcss-rails", "~> 2.0"
7+
gem "sprockets-rails", "~> 3.4.2"
8+
gem "concurrent-ruby", "1.3.4"
79
gem "net-smtp", require: false
810
gem "net-imap", require: false
911
gem "net-pop", require: false
1012
gem "turbo-rails", "~> 1"
11-
gem "sprockets-rails", "~> 3.4.2"
12-
gem "concurrent-ruby", "1.3.4"
13+
14+
group :development, :test do
15+
gem "appraisal-run", "~> 1.0"
16+
end
1317

1418
gemspec path: "../"

gemfiles/rails_7.0.gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
source "https://rubygems.org"
44

5-
gem "rails", "~> 7.0"
5+
gem "rails", "~> 7.0.0"
66
gem "tailwindcss-rails", "~> 2.0"
77
gem "turbo-rails", "~> 1"
88
gem "sprockets-rails", "~> 3.4.2"
99

10+
group :development, :test do
11+
gem "appraisal-run", "~> 1.0"
12+
end
13+
1014
gemspec path: "../"

gemfiles/rails_7.1.gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
source "https://rubygems.org"
44

5-
gem "rails", "~> 7.1"
5+
gem "rails", "~> 7.1.0"
66
gem "tailwindcss-rails", "~> 2.0"
77
gem "turbo-rails", "~> 1"
88
gem "sprockets-rails", "~> 3.4.2"
99

10+
group :development, :test do
11+
gem "appraisal-run", "~> 1.0"
12+
end
13+
1014
gemspec path: "../"

0 commit comments

Comments
 (0)