Skip to content

Commit 9a4aa0f

Browse files
authored
Fix GitHub workflow (#3150)
* fix rubocop.yml * fix compatibility with ruby 2.4 * fix jest Development environment tests * bump jest to current version * fix github workflow files
1 parent b143810 commit 9a4aa0f

File tree

8 files changed

+366
-356
lines changed

8 files changed

+366
-356
lines changed

.github/workflows/jest.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414

1515
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js ${{ matrix.node }}
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: ${{ matrix.node }}
21+
1622
- name: Install yarn maybe
17-
run: which yarn || sudo npm install -g yarn
23+
run: which yarn || npm install -g yarn
1824

19-
- uses: actions/checkout@v2
2025
- name: Get yarn cache directory path
2126
id: yarn-cache-dir-path
2227
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -29,11 +34,6 @@ jobs:
2934
restore-keys: |
3035
${{ runner.os }}-${{ matrix.node }}-yarn-
3136
32-
- name: Use Node.js ${{ matrix.node }}
33-
uses: actions/setup-node@v1
34-
with:
35-
node-version: ${{ matrix.node }}
36-
3737
- name: Install dependencies
3838
run: yarn --frozen-lockfile
3939

.github/workflows/js-lint.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest]
12-
node: [14.x]
12+
node: [14]
1313

1414
runs-on: ${{ matrix.os }}
1515

1616
steps:
17+
- name: Use Node.js ${{ matrix.node }}
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: ${{ matrix.node }}
21+
1722
- name: Install yarn maybe
18-
run: which yarn || sudo npm install -g yarn
23+
run: which yarn || npm install -g yarn
1924

2025
- uses: actions/checkout@v2
2126
- name: Get yarn cache directory path
@@ -30,11 +35,6 @@ jobs:
3035
restore-keys: |
3136
${{ runner.os }}-yarn-
3237
33-
- name: Use Node.js ${{ matrix.node }}
34-
uses: actions/setup-node@v1
35-
with:
36-
node-version: ${{ matrix.node }}
37-
3838
- name: Install dependencies
3939
run: yarn --frozen-lockfile
4040

.github/workflows/ruby.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
os: [ubuntu-latest]
17+
node: [14]
1718
ruby: [
1819
2.4,
1920
2.5,
@@ -55,8 +56,13 @@ jobs:
5556
restore-keys: |
5657
bundle-use-ruby-${{ matrix.ruby }}-${{ matrix.gemfile }}-gems-
5758
59+
- name: Use Node.js ${{ matrix.node }}
60+
uses: actions/setup-node@v1
61+
with:
62+
node-version: ${{ matrix.node }}
63+
5864
- name: Install yarn maybe
59-
run: which yarn || sudo npm install -g yarn
65+
run: which yarn || npm install -g yarn
6066

6167
- uses: ruby/setup-ruby@v1
6268
with:

.rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require: rubocop-performance
22
AllCops:
3-
TargetRubyVersion: 2.4
3+
TargetRubyVersion: 2.7
44
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
55
# to ignore them, so only the ones explicitly set in this file are enabled.
66
DisabledByDefault: true

lib/tasks/yarn.rake

+22-20
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,30 @@
55
namespace :yarn do
66
desc "Install all JavaScript dependencies as specified via Yarn"
77
task :install do
8-
# Install only production deps when for not usual envs.
9-
valid_node_envs = %w[test development production]
10-
node_env = ENV.fetch("NODE_ENV") do
11-
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
12-
end
13-
14-
yarn_flags =
15-
if `#{RbConfig.ruby} "#{Rails.root}/bin/yarn" --version`.start_with?("1")
16-
"--no-progress --frozen-lockfile"
17-
else
18-
"--immutable"
8+
begin
9+
# Install only production deps when for not usual envs.
10+
valid_node_envs = %w[test development production]
11+
node_env = ENV.fetch("NODE_ENV") do
12+
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
1913
end
2014

21-
system(
22-
{ "NODE_ENV" => node_env },
23-
"#{RbConfig.ruby} \"#{Rails.root}/bin/yarn\" install #{yarn_flags}",
24-
exception: true
25-
)
26-
rescue Errno::ENOENT
27-
$stderr.puts "bin/yarn was not found."
28-
$stderr.puts "Please run `bundle exec rails app:update:bin` to create it."
29-
exit 1
15+
yarn_flags =
16+
if `#{RbConfig.ruby} "#{Rails.root}/bin/yarn" --version`.start_with?("1")
17+
"--no-progress --frozen-lockfile"
18+
else
19+
"--immutable"
20+
end
21+
22+
system(
23+
{ "NODE_ENV" => node_env },
24+
"#{RbConfig.ruby} \"#{Rails.root}/bin/yarn\" install #{yarn_flags}",
25+
exception: true
26+
)
27+
rescue Errno::ENOENT
28+
$stderr.puts "bin/yarn was not found."
29+
$stderr.puts "Please run `bundle exec rails app:update:bin` to create it."
30+
exit 1
31+
end
3032
end
3133
end
3234

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"eslint-plugin-import": "^2.24.1",
3838
"eslint-plugin-jsx-a11y": "^6.4.1",
3939
"eslint-plugin-react": "^7.24.0",
40-
"jest": "^27.0.6"
40+
"jest": "^27.1.0"
4141
},
4242
"jest": {
4343
"testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",

package/__tests__/development.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('Development environment', () => {
1414
test('should use development config and environment including devServer if WEBPACK_SERVE', () => {
1515
process.env.RAILS_ENV = 'development'
1616
process.env.NODE_ENV = 'development'
17-
process.env.WEBPACK_DEV_SERVER = 'true'
17+
process.env.WEBPACK_SERVE = 'true'
1818
const { webpackConfig } = require('../index')
1919

2020
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
@@ -31,7 +31,7 @@ describe('Development environment', () => {
3131
test('should use development config and environment if WEBPACK_SERVE', () => {
3232
process.env.RAILS_ENV = 'development'
3333
process.env.NODE_ENV = 'development'
34-
process.env.WEBPACK_DEV_SERVER = undefined
34+
process.env.WEBPACK_SERVE = undefined
3535
const { webpackConfig } = require('../index')
3636

3737
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))

0 commit comments

Comments
 (0)