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!"