Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5374d6a

Browse files
committed
ci: test against the different package managers
1 parent d6bdc57 commit 5374d6a

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

‎.github/workflows/ruby.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ jobs:
5858
strategy:
5959
fail-fast: false
6060
matrix:
61+
js_package_manager:
62+
- name: npm
63+
installer: npm
64+
- name: yarn_classic
65+
installer: yarn
66+
- name: pnpm
67+
installer: pnpm
6168
ruby: [2.7]
6269
gemfile:
6370
# These have shakapacker:
@@ -73,12 +80,13 @@ jobs:
7380
# Workaround b/c upgrading Minitest broke some mocking expectations
7481
# having to do with automatic kwarg splatting
7582
MT_KWARGS_HACK: 1
83+
PACKAGE_JSON_FALLBACK_MANAGER: ${{ matrix.js_package_manager.name }}
7684
steps:
7785
- uses: actions/checkout@v4
7886
with:
7987
persist-credentials: false
8088
- uses: actions/setup-node@v3
81-
- run: npm -g install yalc
89+
- run: npm -g install yalc ${{ matrix.js_package_manager.installer }}
8290
- run: yalc publish
8391
- name: Save root node_modules to cache
8492
uses: actions/cache@v3
@@ -94,14 +102,15 @@ jobs:
94102
with:
95103
bundler: 2.4.9
96104
ruby-version: ${{ matrix.ruby }}
105+
- run: ./test/bin/create-fake-js-package-managers ${{ matrix.js_package_manager.installer }}
97106
- name: Save dummy app ruby gems to cache
98107
uses: actions/cache@v3
99108
with:
100109
path: test/dummy/vendor/bundle
101110
key: dummy-app-gem-cache-${{ hashFiles('${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile.lock') }}
102111
- name: Install Ruby Gems for dummy app
103112
run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=test/dummy/vendor/bundle || bundle _2.4.9_ install --frozen --path=test/dummy/vendor/bundle --jobs=4 --retry=3
104-
- run: cd test/dummy && yalc add react_ujs && yarn
113+
- run: cd test/dummy && yalc add react_ujs && ${{ matrix.js_package_manager.installer }} install
105114
- run: bundle exec rake test
106115
env:
107116
NODE_OPTIONS: --openssl-legacy-provider
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
# creates a set of fake JavaScript package managers in a temporary bin
5+
# directory for GitHub Actions, _excluding_ the one passed in as an
6+
# argument in order to assert that only that package manager is used
7+
8+
require "tmpdir"
9+
10+
# setup the bin directory we want to use
11+
bin_dir = Dir.mktmpdir("react-rails-")
12+
13+
if ENV["GITHUB_ACTIONS"]
14+
puts "adding #{bin_dir} to GITHUB_PATH..."
15+
File.write(ENV.fetch("GITHUB_PATH"), "#{bin_dir}\n", mode: "a+")
16+
end
17+
18+
managers = %w[npm yarn pnpm]
19+
manager_in_use = ARGV[0]
20+
21+
Dir.chdir(bin_dir) do
22+
managers.each do |manager|
23+
next if manager == manager_in_use
24+
25+
puts "creating #{bin_dir}/#{manager}..."
26+
File.write(
27+
manager,
28+
<<~CONTENTS
29+
#!/usr/bin/env node
30+
31+
throw new Error("(#{manager}) this is not the package manager you're looking...");
32+
CONTENTS
33+
)
34+
File.chmod(0o755, manager)
35+
end
36+
end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /