Skip to content

Commit c56f052

Browse files
authored
Use Github Actions (#504)
* Create test.yml * remove mini_racer * update specs & other dependencies
1 parent 7feaf74 commit c56f052

22 files changed

Lines changed: 327 additions & 266 deletions

.github/workflows/test.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# This workflow uses actions that are not certified by GitHub. They are
2+
# provided by a third-party and are governed by separate terms of service,
3+
# privacy policy, and support documentation.
4+
#
5+
# This workflow will install a prebuilt Ruby version, install dependencies, and
6+
# run tests and linters.
7+
name: "Ruby on Rails CI"
8+
on:
9+
push:
10+
branches: [ "master" ]
11+
pull_request:
12+
branches: [ "master" ]
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
services:
19+
postgres:
20+
image: postgres:11-alpine
21+
ports:
22+
- "5432:5432"
23+
env:
24+
POSTGRES_DB: rails_test
25+
POSTGRES_USER: rails
26+
POSTGRES_PASSWORD: password
27+
env:
28+
RAILS_ENV: test
29+
NODE_ENV: test
30+
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
31+
DRIVER: selenium_chrome
32+
CHROME_BIN: /usr/bin/google-chrome
33+
USE_COVERALLS: true
34+
steps:
35+
- name: Install Chrome
36+
uses: browser-actions/setup-chrome@latest
37+
38+
- name: Check Chrome version
39+
run: chrome --version
40+
41+
- name: Check Chrome version
42+
run: google-chrome --version
43+
44+
- name: Set Display environment variable
45+
run: "export DISPLAY=:99"
46+
47+
- name: Checkout code
48+
uses: actions/checkout@v3
49+
50+
- name: Install Ruby and gems
51+
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
52+
with:
53+
ruby: 3.x
54+
bundler-cache: true
55+
56+
- name: Use Node.js 16.x
57+
uses: actions/setup-node@v3
58+
with:
59+
node-version: 16.x
60+
- name: Install Node Packages
61+
run: npm install --legacy-peer-deps
62+
63+
- name: Set up database schema
64+
run: bin/rails db:schema:load
65+
66+
- name: Build i18n libraries
67+
run: bundle exec rake react_on_rails:locale
68+
69+
- name: Build webpacker chunks
70+
run: NODE_ENV=development bundle exec bin/webpacker
71+
72+
- name: Run tests with xvfb
73+
uses: GabrielBB/xvfb-action@v1
74+
with:
75+
run: bundle exec rake
76+
working-directory: ./ #optional
77+
options: ":99 -ac -screen scn 1600x1200x16"

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12
1+
16

Gemfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ gem "sdoc", group: :doc
4141
# Use Rails Html Sanitizer for HTML sanitization
4242
gem "rails-html-sanitizer"
4343

44-
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
45-
# mini_racer is probably faster than therubyracer
46-
gem "mini_racer", platforms: :ruby
47-
4844
gem "autoprefixer-rails"
4945

5046
gem "awesome_print"
@@ -97,7 +93,7 @@ end
9793
group :test do
9894
gem "capybara"
9995
gem "capybara-screenshot"
100-
gem "coveralls", require: false
96+
gem 'coveralls_reborn', '~> 0.25.0', require: false
10197
gem "database_cleaner"
10298
gem "generator_spec"
10399
gem "launchy"

Gemfile.lock

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,11 @@ GEM
100100
coffee-script-source (1.12.2)
101101
concurrent-ruby (1.1.9)
102102
connection_pool (2.2.5)
103-
coveralls (0.8.23)
104-
json (>= 1.8, < 3)
105-
simplecov (~> 0.16.1)
106-
term-ansicolor (~> 1.3)
107-
thor (>= 0.19.4, < 2.0)
108-
tins (~> 1.6)
103+
coveralls_reborn (0.25.0)
104+
simplecov (>= 0.18.1, < 0.22.0)
105+
term-ansicolor (~> 1.6)
106+
thor (>= 0.20.3, < 2.0)
107+
tins (~> 1.16)
109108
crass (1.0.6)
110109
database_cleaner (2.0.1)
111110
database_cleaner-active_record (~> 2.0.0)
@@ -140,7 +139,6 @@ GEM
140139
json (2.6.1)
141140
launchy (2.5.0)
142141
addressable (~> 2.7)
143-
libv8-node (16.10.0.0)
144142
listen (3.7.0)
145143
rb-fsevent (~> 0.10, >= 0.10.3)
146144
rb-inotify (~> 0.9, >= 0.9.10)
@@ -154,8 +152,6 @@ GEM
154152
method_source (1.0.0)
155153
mini_mime (1.1.2)
156154
mini_portile2 (2.6.1)
157-
mini_racer (0.6.0)
158-
libv8-node (~> 16.10.0.0)
159155
minitest (5.15.0)
160156
nio4r (2.5.8)
161157
nokogiri (1.12.5)
@@ -310,11 +306,12 @@ GEM
310306
rack-proxy (>= 0.6.1)
311307
railties (>= 5.2)
312308
semantic_range (>= 2.3.0)
313-
simplecov (0.16.1)
309+
simplecov (0.21.2)
314310
docile (~> 1.1)
315-
json (>= 1.8, < 3)
316-
simplecov-html (~> 0.10.0)
317-
simplecov-html (0.10.2)
311+
simplecov-html (~> 0.11)
312+
simplecov_json_formatter (~> 0.1)
313+
simplecov-html (0.12.3)
314+
simplecov_json_formatter (0.1.4)
318315
spring (4.0.0)
319316
spring-commands-rspec (1.0.4)
320317
spring (>= 0.9.1)
@@ -330,7 +327,7 @@ GEM
330327
tins (~> 1.0)
331328
thor (1.2.1)
332329
tilt (2.0.10)
333-
tins (1.30.0)
330+
tins (1.31.1)
334331
sync
335332
tzinfo (2.0.4)
336333
concurrent-ruby (~> 1.0)
@@ -372,15 +369,14 @@ DEPENDENCIES
372369
capybara
373370
capybara-screenshot
374371
coffee-rails
375-
coveralls
372+
coveralls_reborn (~> 0.25.0)
376373
database_cleaner
377374
factory_bot_rails
378375
foreman
379376
generator_spec
380377
jbuilder
381378
launchy
382379
listen
383-
mini_racer
384380
pg
385381
pry
386382
pry-byebug

app/models/git_commit_sha.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.current_sha
99
end
1010

1111
def self.reset_current_sha
12-
self.current_sha = nil
12+
@current_sha = nil
1313
end
1414

1515
# Assumes the git CLI is available. This is not the case in production on Heroku.

app/views/comments/index.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919
<tr>
2020
<td><%= comment.author %></td>
2121
<td><%= comment.text %></td>
22+
</tr>
23+
<tr>
2224
<td><%= link_to 'Show', comment %></td>
2325
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
24-
<td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
26+
</tr>
27+
<tr>
28+
<td><%= link_to 'Destroy', comment, method: :delete, data: { method: :delete, confirm: 'Are you sure?' } %></td>
2529
</tr>
2630
<% end %>
2731
</tbody>

client/app/bundles/comments/startup/ClientRouterApp.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ import ReactOnRails from 'react-on-rails';
55
import { BrowserRouter } from 'react-router-dom';
66
import routes from '../routes/routes.jsx';
77

8-
function ClientRouterApp(_props, _railsContext) {
8+
function ClientRouterApp(_props) {
99
const store = ReactOnRails.getStore('routerCommentsStore');
1010

1111
// eslint-disable-next-line react/display-name
12-
return function () {
13-
return (
14-
<Provider store={store}>
15-
<BrowserRouter>{routes}</BrowserRouter>
16-
</Provider>
17-
);
18-
};
12+
return (
13+
<Provider store={store}>
14+
<BrowserRouter>{routes}</BrowserRouter>
15+
</Provider>
16+
);
1917
}
2018

2119
export default ClientRouterApp;

client/app/bundles/comments/startup/NavigationBarApp.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,16 @@ function NavigationBarApp(_props, railsContext) {
2323
} else if (pathname === paths.NO_ROUTER_PATH) {
2424
store = ReactOnRails.getStore('commentsStore', false);
2525
} else {
26-
return <NavigationBar {...{ pathname }} />;
26+
return () => <NavigationBar {...{ pathname }} />;
2727
}
2828

2929
// eslint interprets the return as a new component definition, which is not the case
3030
// eslint-disable-next-line react/display-name, react/no-unstable-nested-components
31-
return function () {
32-
return (
33-
<Provider store={store}>
34-
<NavigationBarContainer />
35-
</Provider>
36-
);
37-
};
31+
return () => (
32+
<Provider store={store}>
33+
<NavigationBarContainer />
34+
</Provider>
35+
);
3836
}
3937

4038
export default NavigationBarApp;

client/app/bundles/comments/startup/ServerRouterApp.jsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ function ServerRouterApp(_props, railsContext) {
2525

2626
// Important that you don't do this if you are redirecting or have an error.
2727
// eslint-disable-next-line react/display-name
28-
return function () {
29-
return (
30-
<Provider store={store}>
31-
<StaticRouter location={location} context={context}>
32-
{routes}
33-
</StaticRouter>
34-
</Provider>
35-
);
36-
};
28+
return () => (
29+
<Provider store={store}>
30+
<StaticRouter location={location} context={context}>
31+
{routes}
32+
</StaticRouter>
33+
</Provider>
34+
);
3735
}
3836

3937
export default ServerRouterApp;

client/app/packs/bootstrap.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)