Skip to content

Commit

Permalink
Add GitHub Actions workflow to Rails
Browse files Browse the repository at this point in the history
This PR adds the necessary workflow to use GitHub Actions on the
Rails repo. There are a couple of things missing but the majority of
tests are passing for Linux. 🎉

The changes to ActionPack and Railties are due to other CI's pretending
they are a tty, but Actions doesn't act as a tty so we need to handle
these differently.

Co-Authored-By: John Hawthorn <john@hawthorn.email>
Co-Authored-By: Aaron Patterson <aaron.patterson@gmail.com>
Co-Authored-By: Edward Thomson <ethomson@edwardthomson.com>
  • Loading branch information
3 people authored and eileencodes committed Aug 8, 2019
1 parent 6170a2a commit a0ae624
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 122 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/workflow.yml
@@ -0,0 +1,111 @@
on:
push:
branches:
- master
pull_request:
branches:
- master

name: Rails CI
jobs:
run:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
memcached:
image: memcached
ports:
- 11211:11211
postgres:
image: postgres:10.8
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: ""
mysql:
image: mysql:5.7
ports:
- 99:3306
env:
MYSQL_ROOT_PASSWORD: secret
strategy:
matrix:
ruby_version: [2.6.x]
gem:
- activesupport
- actionmailer
- activemodel
- actiontext
- actionmailbox
- actionview
- actionpack
- actioncable
- activejob
- activestorage
- activerecord:postgresql
- activerecord:sqlite3
- activerecord:sqlite3_mem
- activerecord:mysql2
- guides
- railties
name: ${{ matrix.gem }}
steps:
- name: Install libraries
run: |
sudo apt-get update
sudo apt-get install -y default-mysql-client libmysqlclient-dev postgresql-client libpq-dev sqlite3 libsqlite3-dev redis-tools ffmpeg mupdf mupdf-tools poppler-utils
- name: Configure databases
run: |
echo "Redis"
redis-cli config set stop-writes-on-bgsave-error no
redis-cli config set save ""
echo "Postgres"
psql -h localhost -c "create database activerecord_unittest;" -U postgres
psql -h localhost -c "create database activerecord_unittest2;" -U postgres
echo "MySQL"
mysql --user=root --password=secret --host=127.0.0.1 --port=99 -e "create user rails;"
mysql --user=root --password=secret --host=127.0.0.1 --port=99 -e "grant all privileges on activerecord_unittest.* to rails;"
mysql --user=root --password=secret --host=127.0.0.1 --port=99 -e "grant all privileges on activerecord_unittest2.* to rails;"
mysql --user=root --password=secret --host=127.0.0.1 --port=99 -e "grant all privileges on inexistent_activerecord_unittest.* to rails;"
mysql --user=root --password=secret --host=127.0.0.1 --port=99 -e "create database activerecord_unittest default character set utf8mb4;"
mysql --user=root --password=secret --host=127.0.0.1 --port=99 -e "create database activerecord_unittest2 default character set utf8mb4;"
- name: Install Node
uses: actions/setup-node@v1
with:
version: 10.x
- name: Install NPM
run: |
npm install
- name: Checkout
uses: actions/checkout@master
- name: Update Ruby and Dependencies
run: |
sudo apt-get update
sudo apt-get install -y bison ruby ruby-dev libffi-dev libgdbm-dev libgmp-dev libjemalloc-dev libncurses5-dev libncursesw5-dev libreadline6-dev libssl-dev libyaml-dev openssl zlib1g-dev libmysqlclient-dev libpq-dev sqlite3 libsqlite3-dev redis-tools curl libxml2-dev tzdata
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo gem install bundler -v '1.17.3'
- name: Install dependencies
run: |
sudo gem install bundler -v '1.17.3'
bundle install -j8
- name: Run tests
run: |
IFS=: read -a GEM <<<"${{ matrix.gem }}"
DATABASE="${GEM[1]}"
export PGHOST=localhost PGUSER=postgres
cd "${GEM[0]}"
if [ -z "$DATABASE" ]
then
bundle exec rake
else
bundle exec rake "test:${GEM[1]}"
fi
env:
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 99
8 changes: 6 additions & 2 deletions actionpack/lib/action_dispatch/routing/inspector.rb
Expand Up @@ -200,6 +200,11 @@ def widths(routes)
end

class Expanded < Base
def initialize(width: IO.console_size.second)
@width = width
super()
end

def section_title(title)
@buffer << "\n#{"[ #{title} ]"}"
end
Expand All @@ -222,9 +227,8 @@ def draw_expanded_section(routes)
end

def route_header(index:)
console_width = IO.console_size.second
header_prefix = "--[ Route #{index} ]"
dash_remainder = [console_width - header_prefix.size, 0].max
dash_remainder = [@width - header_prefix.size, 0].max

"#{header_prefix}#{'-' * dash_remainder}"
end
Expand Down
7 changes: 1 addition & 6 deletions actionpack/test/dispatch/routing/inspector_test.rb
Expand Up @@ -317,9 +317,6 @@ def test_routes_can_be_filtered
end

def test_routes_when_expanded
previous_console_winsize = IO.console.winsize
IO.console.winsize = [0, 23]

engine = Class.new(Rails::Engine) do
def self.inspect
"Blog::Engine"
Expand All @@ -329,7 +326,7 @@ def self.inspect
get "/cart", to: "cart#show"
end

output = draw(formatter: ActionDispatch::Routing::ConsoleFormatter::Expanded.new) do
output = draw(formatter: ActionDispatch::Routing::ConsoleFormatter::Expanded.new(width: 23)) do
get "/custom/assets", to: "custom_assets#show"
get "/custom/furnitures", to: "custom_furnitures#show"
mount engine => "/blog", :as => "blog"
Expand Down Expand Up @@ -357,8 +354,6 @@ def self.inspect
"Verb | GET",
"URI | /cart(.:format)",
"Controller#Action | cart#show"], output
ensure
IO.console.winsize = previous_console_winsize
end

def test_no_routes_matched_filter_when_expanded
Expand Down
6 changes: 6 additions & 0 deletions activerecord/test/config.example.yml
Expand Up @@ -56,6 +56,9 @@ connections:
collation: utf8mb4_unicode_ci
<% if ENV['MYSQL_HOST'] %>
host: <%= ENV['MYSQL_HOST'] %>
<% end %>
<% if ENV['MYSQL_PORT'] %>
port: <%= ENV['MYSQL_PORT'] %>
<% end %>
arunit2:
username: rails
Expand All @@ -64,6 +67,9 @@ connections:
<% if ENV['MYSQL_HOST'] %>
host: <%= ENV['MYSQL_HOST'] %>
<% end %>
<% if ENV['MYSQL_PORT'] %>
port: <%= ENV['MYSQL_PORT'] %>
<% end %>

oracle:
arunit:
Expand Down

0 comments on commit a0ae624

Please sign in to comment.