Skip to content

Commit

Permalink
fix: replace Webpacker with Shakapacker (#1622)
Browse files Browse the repository at this point in the history
Support shakapacker 8.0.0
package.json - update shakapacker to v8 + add "packageManager"

Co-authored-by: Judah Meek
  • Loading branch information
adriangohjw authored Jun 28, 2024
1 parent 76c6b50 commit e99f0be
Show file tree
Hide file tree
Showing 51 changed files with 571 additions and 415 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ on:

jobs:
examples:
env:
SKIP_YARN_COREPACK_CHECK: 0
strategy:
fail-fast: false
matrix:
versions: ['oldest', 'newest']
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Get changed files
id: changed-files-specific
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
Expand All @@ -26,7 +32,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }}
bundler: 2.5.9
- name: Setup Node
uses: actions/setup-node@v3
Expand All @@ -41,6 +47,9 @@ jobs:
echo "Node version: "; node -v
echo "Yarn version: "; yarn --version
echo "Bundler version: "; bundle --version
- name: run conversion script to support shakapacker v6
if: matrix.versions == 'oldest'
run: script/convert
- name: Save root node_modules to cache
uses: actions/cache@v3
with:
Expand All @@ -50,13 +59,12 @@ jobs:
uses: actions/cache@v3
with:
path: vendor/bundle
key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
- id: get-sha
run: echo "::set-output name=sha::$(git rev-parse HEAD)"
- name: Install Node modules with Yarn for renderer package
run: |
yarn install --no-progress --no-emoji
yarn run eslint -v
sudo yarn global add yalc
- name: yalc publish for react-on-rails
run: yalc publish
Expand All @@ -78,7 +86,7 @@ jobs:
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Main CI
if: steps.changed-files.outputs.any_changed == 'true'
run: bundle exec rake run_rspec:examples
run: bundle exec rake run_rspec:${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer_examples
- name: Store test results
uses: actions/upload-artifact@v3
with:
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/lint-js-and-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ on:

jobs:
build:
strategy:
matrix:
ruby: [3]
node: [20]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -21,12 +17,12 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
ruby-version: 3
bundler: 2.5.9
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
node-version: 20
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
Expand All @@ -45,12 +41,10 @@ jobs:
uses: actions/cache@v3
with:
path: vendor/bundle
key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest
- name: Install Node modules with Yarn for renderer package
run: |
yarn install --no-progress --no-emoji
yarn run eslint -v
sudo yarn global add yalc
- name: Install Ruby Gems for package
run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
- name: Linting of Ruby
Expand Down
54 changes: 33 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ jobs:
build-dummy-app-webpack-test-bundles:
strategy:
matrix:
ruby: [3.0, 3.3]
node: [16, 20]
versions: ['oldest', 'newest']
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -20,7 +19,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }}
bundler: 2.5.9
# libyaml-dev is needed for psych v5
# this gem depends on sdoc which depends on rdoc which depends on psych
Expand All @@ -29,7 +28,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
Expand All @@ -39,6 +38,9 @@ jobs:
echo "Node version: "; node -v
echo "Yarn version: "; yarn --version
echo "Bundler version: "; bundle --version
- name: run conversion script to support shakapacker v6
if: matrix.versions == 'oldest'
run: script/convert
- name: Save root node_modules to cache
uses: actions/cache@v3
with:
Expand All @@ -47,15 +49,14 @@ jobs:
- name: Install Node modules with Yarn for renderer package
run: |
yarn install --no-progress --no-emoji
yarn run eslint -v
sudo yarn global add yalc
- name: yalc publish for react-on-rails
run: yalc publish
- name: Save spec/dummy/node_modules to cache
uses: actions/cache@v3
with:
path: spec/dummy/node_modules
key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }}
key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }}
- name: yalc add react-on-rails
run: cd spec/dummy && yalc add react-on-rails
- name: Install Node modules with Yarn for dummy app
Expand All @@ -64,27 +65,27 @@ jobs:
uses: actions/cache@v3
with:
path: spec/dummy/vendor/bundle
key: v5-dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}
key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
- name: Install Ruby Gems for dummy app
run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
- name: generate file system-based packs
run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs
- name: Build test bundles for dummy app
run: cd spec/dummy && yarn run build:test
run: cd spec/dummy && rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer
- id: get-sha
run: echo "::set-output name=sha::$(git rev-parse HEAD)"
- name: Save test webpack bundles to cache (for build number checksum used by rspec job)
uses: actions/cache/save@v3
with:
path: spec/dummy/public/webpack
key: v5-dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}
key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }}

main:
dummy-app-integration-tests:
needs: build-dummy-app-webpack-test-bundles
strategy:
fail-fast: false
matrix:
ruby: [3.0, 3.3]
node: [16, 20]
versions: ['oldest', 'newest']
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -93,12 +94,12 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }}
bundler: 2.5.9
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
Expand All @@ -108,6 +109,9 @@ jobs:
echo "Node version: "; node -v
echo "Yarn version: "; yarn --version
echo "Bundler version: "; bundle --version
- name: run conversion script to support shakapacker v6
if: matrix.versions == 'oldest'
run: script/convert
- name: Save root node_modules to cache
uses: actions/cache@v3
with:
Expand All @@ -117,33 +121,34 @@ jobs:
uses: actions/cache@v3
with:
path: vendor/bundle
key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
- name: Save dummy app ruby gems to cache
uses: actions/cache@v3
with:
path: spec/dummy/vendor/bundle
key: v5-dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}
key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
- name: Save spec/dummy/node_modules to cache
uses: actions/cache@v3
with:
path: spec/dummy/node_modules
key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }}
key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }}
- id: get-sha
run: echo "::set-output name=sha::$(git rev-parse HEAD)"
- name: Save test webpack bundles to cache (for build number checksum used by rspec job)
uses: actions/cache@v3
with:
path: spec/dummy/public/webpack
key: v5-dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}
- name: Install Node modules with Yarn for renderer package
key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }}
- name: Install Node modules with Yarn
run: |
yarn install --no-progress --no-emoji
yarn run eslint -v
sudo yarn global add yalc
- name: yalc publish for react-on-rails
run: yalc publish
- name: yalc add react-on-rails
run: cd spec/dummy && yalc add react-on-rails
- name: Install Node modules with Yarn for dummy app
run: cd spec/dummy && yarn install --no-progress --no-emoji
- name: Install Ruby Gems for package
run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
- name: Install Ruby Gems for dummy app
Expand All @@ -164,8 +169,15 @@ jobs:
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: generate file system-based packs
run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs
- name: Git Stuff
if: matrix.versions == 'oldest'
run: |
git config user.email "[email protected]"
git config user.name "Your Name"
git commit -am "stop generators from complaining about uncommitted code"
- run: cd spec/dummy && bundle info shakapacker
- name: Main CI
run: bundle exec rake run_rspec:all_but_examples
run: bundle exec rake run_rspec:all_dummy
- name: Store test results
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package-js-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
strategy:
matrix:
node: [16, 20]
versions: ['oldest', 'newest']
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/rspec-package-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
pull_request:

jobs:
build:
rspec-package-tests:
strategy:
fail-fast: false
matrix:
ruby: [3.0, 3.3]
node: [16, 20]
versions: ['oldest', 'newest']
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }}
bundler: 2.5.9
- name: Print system information
run: |
Expand All @@ -31,13 +31,22 @@ jobs:
echo "Node version: "; node -v
echo "Yarn version: "; yarn --version
echo "Bundler version: "; bundle --version
- name: run conversion script to support shakapacker v6
if: matrix.versions == 'oldest'
run: script/convert
- name: Save root ruby gems to cache
uses: actions/cache@v3
with:
path: vendor/bundle
key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }}
- name: Install Ruby Gems for package
run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
- name: Git Stuff
if: matrix.versions == 'oldest'
run: |
git config user.email "[email protected]"
git config user.name "Your Name"
git commit -am "stop generators from complaining about uncommitted code"
- name: Run rspec tests
run: bundle exec rspec spec/react_on_rails
- name: Store test results
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ Changes since the last non-beta release.
#### Fixed
- Address a number of typos and grammar mistakes [PR 1631](https://github.com/shakacode/react_on_rails/pull/1631) by [G-Rath](https://github.com/G-Rath)

#### Added

- Adds an adapter module & improves test suite to support all versions of Shakapacker. [PR 1622](https://github.com/shakacode/react_on_rails/pull/1622) by [adriangohjw](https://github.com/adriangohjw)

### [14.0.2] - 2024-06-11

#### Fixed
- Project initialization with Shakapacker v8+ fixed [PR 1629](https://github.com/shakacode/react_on_rails/pull/1629) by [vaukalak](https://github.com/vaukalak)
- Generator errors with Shakapacker v8+ fixed [PR 1629](https://github.com/shakacode/react_on_rails/pull/1629) by [vaukalak](https://github.com/vaukalak)

### [14.0.1] - 2024-05-16

Expand Down
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,22 @@ spec/dummy.


```sh
# Optionally change default selenium_firefox driver
# Optionally change default capybara driver
export DRIVER=selenium_firefox
cd react_on_rails/
yarn run dummy:spec
```

To convert the development environment over to Shakapacker v6 instead of the default Shakapacker v8:

```sh
# Optionally change default capybara driver
export DRIVER=selenium_firefox
cd react_on_rails/
script/convert
yarn run dummy:spec
```

### Run NPM JS tests

```sh
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.development_dependencies
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

gem "shakapacker", "7.2.1"
gem "shakapacker", "8.0.0"
gem "bootsnap", require: false
gem "rails", "~> 7.1"

Expand Down
Loading

0 comments on commit e99f0be

Please sign in to comment.