83 lines
2.3 KiB
YAML
83 lines
2.3 KiB
YAML
name: Ruby on Rails Test
|
|
run-name: Deploy to ${{ inputs.deploy_target }} by @${{ github.actor }} 🚀
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- develop
|
|
|
|
jobs:
|
|
rails-test:
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
RAILS_ENV: test
|
|
# SQLite does not require these variables, but you can keep them for consistency
|
|
DB_TEST_ADAPTER: "sqlite3"
|
|
DB_TEST_DATABASE: "data/test.sqlite" # Default SQLite database file path
|
|
DB_TEST_USERNAME: "root"
|
|
DB_TEST_PASSWORD: "root"
|
|
RUNNER_TOOL_CACHE: /toolcache # Optional, for caching
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Ruby
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: .ruby-version # Not needed with a .ruby-version, .tool-versions or mise.toml
|
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: "22"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
echo "📦 Installing dependencies..."
|
|
gem install bundler
|
|
bundle install --jobs 4 --retry 3
|
|
npm install -g yarn
|
|
yarn install
|
|
echo "📦 Dependencies installed!"
|
|
|
|
- name: Cache bundle
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
/usr/local/bundle
|
|
key: ${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}
|
|
restore-keys: |-
|
|
${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}
|
|
|
|
- name: Cache node_modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/node_modules
|
|
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |-
|
|
${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
- name: Run migrations
|
|
run: |
|
|
echo "🔄 Running migrations..."
|
|
bundle exec rails db:drop
|
|
bundle exec rails db:setup
|
|
bundle exec rails db:migrate
|
|
echo "🔄 Migrations complete!"
|
|
|
|
- name: Run tests
|
|
run: |
|
|
echo "🧪 Running tests..."
|
|
bundle exec rails test
|
|
echo "🧪 Tests complete!"
|
|
|
|
- name: Run linter
|
|
run: |
|
|
echo "🚫 Running linter..."
|
|
bundle exec rubocop
|
|
echo "🚫 Linter complete!"
|