Skip to content

Commit

Permalink
Test improvements
Browse files Browse the repository at this point in the history
* restrict style-loader version in rspec examples
* update dummy lockfiles
* move generator tests to separate jobpec
* move squlite to dev_dependencies
  • Loading branch information
Judahmeek authored Apr 22, 2024
1 parent 493a2f5 commit 3627488
Show file tree
Hide file tree
Showing 6 changed files with 279 additions and 17 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Generator tests

on:
push:
branches:
- 'master'
pull_request:

jobs:
examples:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Get changed files
id: changed-files-specific
uses: tj-actions/changed-files@v44
with:
files: |
lib/generators/**
rakelib/example_type.rb
rakelib/example_config.yml
rakelib/examples.rake
rakelib/run_rspec.rake
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
bundler: 2.5.3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
echo "Current user: "; whoami
echo "Current directory: "; pwd
echo "Ruby version: "; ruby -v
echo "Node version: "; node -v
echo "Yarn version: "; yarn --version
echo "Bundler version: "; bundle --version
- name: Save root node_modules to cache
uses: actions/cache@v3
with:
path: node_modules
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
- 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') }}
- 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
- name: Install Ruby Gems for package
run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
- name: Ensure minimum required Chrome version
run: |
echo -e "Already installed $(google-chrome --version)\n"
MINIMUM_REQUIRED_CHROME_VERSION=75
INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)"
if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
echo -e "\nInstalled $(google-chrome --version)"
fi
- name: Increase the amount of inotify watchers
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
- name: Store test results
uses: actions/upload-artifact@v3
with:
name: main-rspec
path: ~/rspec
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ jobs:
matrix:
ruby: [3.0, 3.3]
node: [16, 20]
rake_task: ['run_rspec:all_but_examples', 'run_rspec:examples']
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -161,14 +160,12 @@ jobs:
sudo apt-get install google-chrome-stable
echo -e "\nInstalled $(google-chrome --version)"
fi
- name: Install yalc globally
run: sudo yarn global add yalc
- name: Increase the amount of inotify watchers
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: Main CI
run: bundle exec rake ${{ matrix.rake_task }}
run: bundle exec rake run_rspec:all_but_examples
- name: Store test results
uses: actions/upload-artifact@v3
with:
Expand Down
9 changes: 1 addition & 8 deletions lib/generators/react_on_rails/base_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,7 @@ def add_yarn_dependencies

puts "Adding CSS handlers"

# css_minimizer_webpack_plugin version 6 only supports Nodejs v18+
# When we bump our minimum Nodejs version to 18, we can remove this logic
# and install css_minimizer_webpack_plugin directly.
node_major_version = `node -v`.match(/^v(\d{,2})\./)[1]&.to_i
css_minimizer_webpack_plugin_version = node_major_version >= 18 ? "" : "@<6.0.0"
css_minimizer_webpack_plugin = "css-minimizer-webpack-plugin#{css_minimizer_webpack_plugin_version}"

run "yarn add 'css-loader@<7.0.0' '#{css_minimizer_webpack_plugin}' mini-css-extract-plugin style-loader"
run "yarn add css-loader css-minimizer-webpack-plugin mini-css-extract-plugin style-loader@"

puts "Adding dev dependencies"
run "yarn add -D @pmmmwh/react-refresh-webpack-plugin react-refresh"
Expand Down
1 change: 1 addition & 0 deletions react_on_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Gem::Specification.new do |s|
s.add_dependency "rainbow", "~> 3.0"

s.add_development_dependency "gem-release"
s.add_development_dependency "sqlite3", "~> 1.6"
s.post_install_message = '
--------------------------------------------------------------------------------
Checkout https://www.shakacode.com/react-on-rails-pro for information about
Expand Down
6 changes: 3 additions & 3 deletions spec/dummy/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ GEM
rspec-support (3.12.1)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.59.0)
rubocop (1.61.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
Expand Down Expand Up @@ -408,7 +408,7 @@ DEPENDENCIES
rspec-rails
rspec-retry
rspec_junit_formatter
rubocop (~> 1.59)
rubocop (= 1.61.0)
rubocop-performance (~> 1.20.0)
rubocop-rspec (~> 2.26)
sass-rails (~> 6.0)
Expand Down
Loading

0 comments on commit 3627488

Please sign in to comment.