Skip to content

Fix yarn/bundle install in CI #1735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ on:

jobs:
examples:
env:
SKIP_YARN_COREPACK_CHECK: 0
strategy:
fail-fast: false
matrix:
versions: ['oldest', 'newest']
env:
SKIP_YARN_COREPACK_CHECK: 0
BUNDLE_FROZEN: ${{ matrix.versions == 'oldest' && 'false' || 'true' }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -45,6 +46,8 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
cache-dependency-path: '**/yarn.lock'
Comment on lines +49 to +50
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data and https://github.com/actions/cache/blob/main/examples.md#node---npm for why this is preferred over caching node_modules. In our case it also avoids duplication between node_modules and spec/dummy/node_modules.

- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
Expand All @@ -57,21 +60,16 @@ jobs:
- name: run conversion script to support shakapacker v6
if: matrix.versions == 'oldest'
run: script/convert
- name: Save root node_modules to cache
uses: actions/cache@v4
with:
path: node_modules
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
- name: Save root ruby gems to cache
uses: actions/cache@v4
with:
path: vendor/bundle
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-${{ matrix.versions }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup-ruby documentation says action/cache isn't enough and action/cache docs link to it.

But I am awaiting their reply for what to do for multiple Gemfile.locks in a single repo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruby-setup with bundle-cache: true and a BUNDLE_GEMFILE set to a specific Gemfile set should work, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUNDLE_GEMFILE can only be set to a single Gemfile, right? Not to both root and spec/dummy Gemfiles at once. Their recommendation is actually to run setup-ruby twice with different Gemfiles, but I decided to avoid this change for now.

- id: get-sha
run: echo "sha=\"$(git rev-parse HEAD)\"" >> "$GITHUB_OUTPUT"
- name: Install Node modules with Yarn for renderer package
run: |
yarn install --no-progress --no-emoji
yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
sudo yarn global add yalc
- name: yalc publish for react-on-rails
run: yalc publish
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/lint-js-and-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:

jobs:
build:
env:
BUNDLE_FROZEN: true
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -22,6 +24,8 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
cache-dependency-path: '**/yarn.lock'
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
Expand All @@ -31,42 +35,32 @@ jobs:
echo "Node version: "; node -v
echo "Yarn version: "; yarn --version
echo "Bundler version: "; bundle --version
- name: Save root node_modules to cache
uses: actions/cache@v4
with:
path: node_modules
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
- name: Save root ruby gems to cache
uses: actions/cache@v4
with:
path: vendor/bundle
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest
key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-oldest
- name: Install Node modules with Yarn for renderer package
run: |
yarn install --no-progress --no-emoji
yarn install --no-progress --no-emoji --frozen-lockfile
sudo yarn global add yalc
- name: yalc publish for react-on-rails
run: yalc publish
- name: Save spec/dummy/node_modules to cache
uses: actions/cache@v4
with:
path: spec/dummy/node_modules
key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-newest
- name: yalc add react-on-rails
run: cd spec/dummy && yalc add react-on-rails
- name: Install Node modules with Yarn for dummy app
run: cd spec/dummy && yarn install --no-progress --no-emoji
run: cd spec/dummy && yarn install --no-progress --no-emoji --frozen-lockfile
- name: Install Ruby Gems for package
run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
- name: Lint Ruby
run: bundle exec rubocop
- name: Install Node modules with Yarn for dummy app
run: cd spec/dummy && yarn install --ignore-scripts --no-progress --no-emoji
run: cd spec/dummy && yarn install --no-progress --no-emoji --frozen-lockfile
- name: Save dummy app ruby gems to cache
uses: actions/cache@v4
with:
path: spec/dummy/vendor/bundle
key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest
key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-oldest
- name: Install Ruby Gems for dummy app
run: |
cd spec/dummy
Expand Down
38 changes: 11 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
cache: yarn
cache-dependency-path: '**/yarn.lock'
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
Expand All @@ -41,31 +43,21 @@ jobs:
- name: run conversion script to support shakapacker v6
if: matrix.versions == 'oldest'
run: script/convert
- name: Save root node_modules to cache
uses: actions/cache@v4
with:
path: node_modules
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
- name: Install Node modules with Yarn for renderer package
run: |
yarn install --no-progress --no-emoji
yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
sudo yarn global add yalc
- name: yalc publish for react-on-rails
run: yalc publish
- name: Save spec/dummy/node_modules to cache
uses: actions/cache@v4
with:
path: spec/dummy/node_modules
key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }}
- name: yalc add react-on-rails
run: cd spec/dummy && yalc add react-on-rails
- name: Install Node modules with Yarn for dummy app
run: cd spec/dummy && yarn install --no-progress --no-emoji
run: cd spec/dummy && yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
- name: Save dummy app ruby gems to cache
uses: actions/cache@v4
with:
path: spec/dummy/vendor/bundle
key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-${{ matrix.versions }}
- name: Install Ruby Gems for dummy app
run: |
cd spec/dummy
Expand Down Expand Up @@ -105,6 +97,8 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
cache: yarn
cache-dependency-path: '**/yarn.lock'
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
Expand All @@ -117,26 +111,16 @@ jobs:
- name: run conversion script to support shakapacker v6
if: matrix.versions == 'oldest'
run: script/convert
- name: Save root node_modules to cache
uses: actions/cache@v4
with:
path: node_modules
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
- name: Save root ruby gems to cache
uses: actions/cache@v4
with:
path: vendor/bundle
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-${{ matrix.versions }}
- name: Save dummy app ruby gems to cache
uses: actions/cache@v4
with:
path: spec/dummy/vendor/bundle
key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }}
- name: Save spec/dummy/node_modules to cache
uses: actions/cache@v4
with:
path: spec/dummy/node_modules
key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }}
key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-${{ matrix.versions }}
- id: get-sha
run: echo "sha=\"$(git rev-parse HEAD)\"" >> "$GITHUB_OUTPUT"
- name: Save test Webpack bundles to cache (for build number checksum used by RSpec job)
Expand All @@ -146,14 +130,14 @@ jobs:
key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }}
- name: Install Node modules with Yarn
run: |
yarn install --no-progress --no-emoji
yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
sudo yarn global add yalc
- name: yalc publish for react-on-rails
run: yalc publish
- name: yalc add react-on-rails
run: cd spec/dummy && yalc add react-on-rails
- name: Install Node modules with Yarn for dummy app
run: cd spec/dummy && yarn install --no-progress --no-emoji
run: cd spec/dummy && yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
- name: Dummy JS tests
run: |
cd spec/dummy
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/package-js-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,21 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }}
cache: yarn
cache-dependency-path: '**/yarn.lock'
- name: Print system information
run: |
echo "Linux release: "; cat /etc/issue
echo "Current user: "; whoami
echo "Current directory: "; pwd
echo "Node version: "; node -v
echo "Yarn version: "; yarn --version
- name: Save root node_modules to cache
uses: actions/cache@v4
with:
path: node_modules
key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
- name: run conversion script
if: matrix.versions == 'oldest'
run: script/convert
- name: Install Node modules with Yarn for renderer package
run: |
yarn install --no-progress --no-emoji
yarn install --no-progress --no-emoji ${{ matrix.versions == 'newest' && '--frozen-lockfile' || '' }}
sudo yarn global add yalc
- name: Run JS unit tests for Renderer package
run: yarn test
4 changes: 3 additions & 1 deletion .github/workflows/rspec-package-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
fail-fast: false
matrix:
versions: ['oldest', 'newest']
env:
BUNDLE_FROZEN: ${{ matrix.versions == 'oldest' && 'false' || 'true' }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -38,7 +40,7 @@ jobs:
uses: actions/cache@v4
with:
path: vendor/bundle
key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }}
key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-${{ matrix.versions }}
- name: Install Ruby Gems for package
run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
- name: Git Stuff
Expand Down
Loading