Skip to content

Commit 1d52482

Browse files
alexeyr-ci2alexeyr
andauthored
Fix yarn/bundle install in CI (#1735)
* Apply hashFiles in GH Actions to lock files * Run yarn install and bundle install in frozen lockfile mode * Cache Node packages in setup-node --------- Co-authored-by: Alexey Romanov <alexey.v.romanov@gmail.com>
1 parent 3161d91 commit 1d52482

File tree

5 files changed

+33
-58
lines changed

5 files changed

+33
-58
lines changed

.github/workflows/examples.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ on:
88

99
jobs:
1010
examples:
11-
env:
12-
SKIP_YARN_COREPACK_CHECK: 0
1311
strategy:
1412
fail-fast: false
1513
matrix:
1614
versions: ['oldest', 'newest']
15+
env:
16+
SKIP_YARN_COREPACK_CHECK: 0
17+
BUNDLE_FROZEN: ${{ matrix.versions == 'oldest' && 'false' || 'true' }}
1718
runs-on: ubuntu-22.04
1819
steps:
1920
- uses: actions/checkout@v4
@@ -45,6 +46,8 @@ jobs:
4546
uses: actions/setup-node@v4
4647
with:
4748
node-version: 20
49+
cache: yarn
50+
cache-dependency-path: '**/yarn.lock'
4851
- name: Print system information
4952
run: |
5053
echo "Linux release: "; cat /etc/issue
@@ -57,21 +60,16 @@ jobs:
5760
- name: run conversion script to support shakapacker v6
5861
if: matrix.versions == 'oldest'
5962
run: script/convert
60-
- name: Save root node_modules to cache
61-
uses: actions/cache@v4
62-
with:
63-
path: node_modules
64-
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
6563
- name: Save root ruby gems to cache
6664
uses: actions/cache@v4
6765
with:
6866
path: vendor/bundle
69-
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
67+
key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-${{ matrix.versions }}
7068
- id: get-sha
7169
run: echo "sha=\"$(git rev-parse HEAD)\"" >> "$GITHUB_OUTPUT"
7270
- name: Install Node modules with Yarn for renderer package
7371
run: |
74-
yarn install --no-progress --no-emoji
72+
yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
7573
sudo yarn global add yalc
7674
- name: yalc publish for react-on-rails
7775
run: yalc publish

.github/workflows/lint-js-and-ruby.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88

99
jobs:
1010
build:
11+
env:
12+
BUNDLE_FROZEN: true
1113
runs-on: ubuntu-22.04
1214
steps:
1315
- uses: actions/checkout@v4
@@ -22,6 +24,8 @@ jobs:
2224
uses: actions/setup-node@v4
2325
with:
2426
node-version: 20
27+
cache: yarn
28+
cache-dependency-path: '**/yarn.lock'
2529
- name: Print system information
2630
run: |
2731
echo "Linux release: "; cat /etc/issue
@@ -31,42 +35,32 @@ jobs:
3135
echo "Node version: "; node -v
3236
echo "Yarn version: "; yarn --version
3337
echo "Bundler version: "; bundle --version
34-
- name: Save root node_modules to cache
35-
uses: actions/cache@v4
36-
with:
37-
path: node_modules
38-
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
3938
- name: Save root ruby gems to cache
4039
uses: actions/cache@v4
4140
with:
4241
path: vendor/bundle
43-
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest
42+
key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-oldest
4443
- name: Install Node modules with Yarn for renderer package
4544
run: |
46-
yarn install --no-progress --no-emoji
45+
yarn install --no-progress --no-emoji --frozen-lockfile
4746
sudo yarn global add yalc
4847
- name: yalc publish for react-on-rails
4948
run: yalc publish
50-
- name: Save spec/dummy/node_modules to cache
51-
uses: actions/cache@v4
52-
with:
53-
path: spec/dummy/node_modules
54-
key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-newest
5549
- name: yalc add react-on-rails
5650
run: cd spec/dummy && yalc add react-on-rails
5751
- name: Install Node modules with Yarn for dummy app
58-
run: cd spec/dummy && yarn install --no-progress --no-emoji
52+
run: cd spec/dummy && yarn install --no-progress --no-emoji --frozen-lockfile
5953
- name: Install Ruby Gems for package
6054
run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
6155
- name: Lint Ruby
6256
run: bundle exec rubocop
6357
- name: Install Node modules with Yarn for dummy app
64-
run: cd spec/dummy && yarn install --ignore-scripts --no-progress --no-emoji
58+
run: cd spec/dummy && yarn install --no-progress --no-emoji --frozen-lockfile
6559
- name: Save dummy app ruby gems to cache
6660
uses: actions/cache@v4
6761
with:
6862
path: spec/dummy/vendor/bundle
69-
key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest
63+
key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-oldest
7064
- name: Install Ruby Gems for dummy app
7165
run: |
7266
cd spec/dummy

.github/workflows/main.yml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
uses: actions/setup-node@v4
3030
with:
3131
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
32+
cache: yarn
33+
cache-dependency-path: '**/yarn.lock'
3234
- name: Print system information
3335
run: |
3436
echo "Linux release: "; cat /etc/issue
@@ -41,31 +43,21 @@ jobs:
4143
- name: run conversion script to support shakapacker v6
4244
if: matrix.versions == 'oldest'
4345
run: script/convert
44-
- name: Save root node_modules to cache
45-
uses: actions/cache@v4
46-
with:
47-
path: node_modules
48-
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
4946
- name: Install Node modules with Yarn for renderer package
5047
run: |
51-
yarn install --no-progress --no-emoji
48+
yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
5249
sudo yarn global add yalc
5350
- name: yalc publish for react-on-rails
5451
run: yalc publish
55-
- name: Save spec/dummy/node_modules to cache
56-
uses: actions/cache@v4
57-
with:
58-
path: spec/dummy/node_modules
59-
key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }}
6052
- name: yalc add react-on-rails
6153
run: cd spec/dummy && yalc add react-on-rails
6254
- name: Install Node modules with Yarn for dummy app
63-
run: cd spec/dummy && yarn install --no-progress --no-emoji
55+
run: cd spec/dummy && yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
6456
- name: Save dummy app ruby gems to cache
6557
uses: actions/cache@v4
6658
with:
6759
path: spec/dummy/vendor/bundle
68-
key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
60+
key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-${{ matrix.versions }}
6961
- name: Install Ruby Gems for dummy app
7062
run: |
7163
cd spec/dummy
@@ -105,6 +97,8 @@ jobs:
10597
uses: actions/setup-node@v4
10698
with:
10799
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
100+
cache: yarn
101+
cache-dependency-path: '**/yarn.lock'
108102
- name: Print system information
109103
run: |
110104
echo "Linux release: "; cat /etc/issue
@@ -117,26 +111,16 @@ jobs:
117111
- name: run conversion script to support shakapacker v6
118112
if: matrix.versions == 'oldest'
119113
run: script/convert
120-
- name: Save root node_modules to cache
121-
uses: actions/cache@v4
122-
with:
123-
path: node_modules
124-
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
125114
- name: Save root ruby gems to cache
126115
uses: actions/cache@v4
127116
with:
128117
path: vendor/bundle
129-
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
118+
key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-${{ matrix.versions }}
130119
- name: Save dummy app ruby gems to cache
131120
uses: actions/cache@v4
132121
with:
133122
path: spec/dummy/vendor/bundle
134-
key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
135-
- name: Save spec/dummy/node_modules to cache
136-
uses: actions/cache@v4
137-
with:
138-
path: spec/dummy/node_modules
139-
key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }}
123+
key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-${{ matrix.versions }}
140124
- id: get-sha
141125
run: echo "sha=\"$(git rev-parse HEAD)\"" >> "$GITHUB_OUTPUT"
142126
- name: Save test Webpack bundles to cache (for build number checksum used by RSpec job)
@@ -146,14 +130,14 @@ jobs:
146130
key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }}
147131
- name: Install Node modules with Yarn
148132
run: |
149-
yarn install --no-progress --no-emoji
133+
yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
150134
sudo yarn global add yalc
151135
- name: yalc publish for react-on-rails
152136
run: yalc publish
153137
- name: yalc add react-on-rails
154138
run: cd spec/dummy && yalc add react-on-rails
155139
- name: Install Node modules with Yarn for dummy app
156-
run: cd spec/dummy && yarn install --no-progress --no-emoji
140+
run: cd spec/dummy && yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
157141
- name: Dummy JS tests
158142
run: |
159143
cd spec/dummy

.github/workflows/package-js-tests.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,21 @@ jobs:
2020
uses: actions/setup-node@v4
2121
with:
2222
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
23+
cache: yarn
24+
cache-dependency-path: '**/yarn.lock'
2325
- name: Print system information
2426
run: |
2527
echo "Linux release: "; cat /etc/issue
2628
echo "Current user: "; whoami
2729
echo "Current directory: "; pwd
2830
echo "Node version: "; node -v
2931
echo "Yarn version: "; yarn --version
30-
- name: Save root node_modules to cache
31-
uses: actions/cache@v4
32-
with:
33-
path: node_modules
34-
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
3532
- name: run conversion script
3633
if: matrix.versions == 'oldest'
3734
run: script/convert
3835
- name: Install Node modules with Yarn for renderer package
3936
run: |
40-
yarn install --no-progress --no-emoji
37+
yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
4138
sudo yarn global add yalc
4239
- name: Run JS unit tests for Renderer package
4340
run: yarn test

.github/workflows/rspec-package-specs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
versions: ['oldest', 'newest']
15+
env:
16+
BUNDLE_FROZEN: ${{ matrix.versions == 'oldest' && 'false' || 'true' }}
1517
runs-on: ubuntu-22.04
1618
steps:
1719
- uses: actions/checkout@v4
@@ -38,7 +40,7 @@ jobs:
3840
uses: actions/cache@v4
3941
with:
4042
path: vendor/bundle
41-
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }}
43+
key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-${{ matrix.versions }}
4244
- name: Install Ruby Gems for package
4345
run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
4446
- name: Git Stuff

0 commit comments

Comments
 (0)