-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
194 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Test Generators | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'lib/generators/**' | ||
- '.github/workflows/generators.yml' | ||
- 'lib/inertia_rails/generators/**' | ||
pull_request: | ||
paths: | ||
- 'lib/generators/**' | ||
- '.github/workflows/generators.yml' | ||
- 'lib/inertia_rails/generators/**' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
framework: [react, vue, svelte] | ||
typescript: [true, false] | ||
tailwind: [true, false] | ||
ruby: ['3.3'] | ||
node: ['22'] | ||
|
||
name: ${{ matrix.framework }} (TS:${{ matrix.typescript }}, TW:${{ matrix.tailwind }}) | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
bundler-cache: true | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
cache: 'npm' | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
tmp/bundle_cache | ||
tmp/npm_cache | ||
key: ${{ runner.os }}-deps-${{ matrix.framework }}-${{ hashFiles('**/Gemfile.lock', '**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-deps-${{ matrix.framework }}- | ||
- name: Install Rails | ||
run: gem install rails | ||
|
||
- name: Run test script | ||
run: | | ||
ts_flag=${{ matrix.typescript && '--typescript' || '--no-typescript' }} | ||
tw_flag=${{ matrix.tailwind && '--tailwind' || '--no-tailwind' }} | ||
bin/generate_scaffold_example --framework=${{ matrix.framework }} $ts_flag $tw_flag | ||
- name: Upload test artifacts | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-output-${{ matrix.framework }}-ts${{ matrix.typescript }}-tw${{ matrix.tailwind }} | ||
path: | | ||
tmp/scaffold_example/log | ||
tmp/scaffold_example/tmp/screenshots | ||
if-no-files-found: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
/.cache/ | ||
/Gemfile.lock | ||
|
||
/spec/dummy/db/*.sqlite3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'fileutils' | ||
require 'optparse' | ||
|
||
# Parse command line options | ||
options = { | ||
framework: 'react', | ||
typescript: true, | ||
tailwind: true, | ||
} | ||
|
||
OptionParser.new do |opts| | ||
opts.banner = "Usage: #{$0} [options]" | ||
|
||
opts.on('--framework FRAMEWORK', %w[react vue svelte], | ||
'Choose framework (react/vue/svelte)') do |f| | ||
options[:framework] = f | ||
end | ||
|
||
opts.on('--[no-]typescript', 'Enable/disable TypeScript') do |t| | ||
options[:typescript] = t | ||
end | ||
|
||
opts.on('--[no-]tailwind', 'Enable/disable Tailwind') do |t| | ||
options[:tailwind] = t | ||
end | ||
end.parse! | ||
|
||
# Build generator args string | ||
generator_args = "--framework=#{options[:framework]}" | ||
generator_args += ' --typescript' if options[:typescript] | ||
generator_args += ' --install-vite' | ||
generator_args += ' --install-tailwind' if options[:tailwind] | ||
|
||
# Setup paths relative to project root | ||
project_root = File.expand_path('../..', __FILE__) | ||
working_dir = File.join(project_root, 'tmp') | ||
gem_cache = File.join(working_dir, 'bundle_cache') | ||
npm_cache = File.join(working_dir, 'npm_cache') | ||
|
||
# Create cache directories if they don't exist | ||
[gem_cache, npm_cache, working_dir].each do |dir| | ||
FileUtils.mkdir_p(dir) unless File.directory?(dir) | ||
end | ||
|
||
# Clean working directory | ||
FileUtils.rm_r(working_dir) if File.directory?(working_dir) | ||
FileUtils.mkdir_p(working_dir) | ||
|
||
# Generate a new Rails app | ||
app_name = 'scaffold_example' | ||
app_dir = File.join(working_dir, app_name) | ||
system("rails new #{app_dir} -J") | ||
|
||
# Install and configure with caching | ||
Dir.chdir(app_dir) do | ||
# Configure bundler to use cache in project root | ||
system("bundle config set --local path '#{gem_cache}'") | ||
|
||
# Configure npm to use cache in project root | ||
system("npm config set cache '#{npm_cache}'") | ||
|
||
# Install dependencies | ||
system('bundle add inertia_rails --path ../../') | ||
system('bundle add bcrypt') | ||
system('bin/rails active_storage:install') | ||
|
||
# Run install generator with configured options | ||
system("bin/rails g inertia:install --no-interactive --force #{generator_args}") | ||
|
||
# Generate a scaffold | ||
system('bin/rails g inertia:scaffold post title:string content:text published:boolean') | ||
|
||
# Run migrations | ||
system('bin/rails db:migrate') | ||
|
||
# Run tests | ||
system('bin/rails test') | ||
|
||
# Run system tests | ||
system('bin/rails test:system') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.