Skip to content

Commit 8bb5a2f

Browse files
larskanisEdouard-chin
authored andcommitted
Add a test run on Windows with non-admin user and disabled developer mode
This way we can ensure that rubygems runs on a normal user account with symlinks disabled. That is the default on an interactive Windows.
1 parent 2dea8e3 commit 8bb5a2f

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

.github/workflows/rubygems.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ jobs:
4141
os: { name: Ubuntu, value: ubuntu-24.04 }
4242
use_psych: true
4343

44+
- ruby: { name: no symlinks, value: 4.0.0 }
45+
os: { name: Windows, value: windows-2025 }
46+
symlink: off
4447
env:
4548
RUBYGEMS_USE_PSYCH: ${{ matrix.use_psych || 'false' }}
4649

4750
steps:
51+
- name: disable development mode on Windows
52+
run: powershell -c "Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowDevelopmentWithoutDevLicense -Value 0"
53+
if: matrix.symlink == 'off'
4854
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4955
with:
5056
persist-credentials: false
@@ -55,9 +61,14 @@ jobs:
5561
bundler: none
5662
- name: Install Dependencies
5763
run: bin/rake setup
64+
- name: Run Test with non-Admin user
65+
run: |
66+
gem inst win32-process --no-doc --conservative
67+
ruby bin/windows_run_as_user ruby -S rake test
68+
if: matrix.symlink == 'off'
5869
- name: Run Test
5970
run: bin/rake test
60-
if: matrix.ruby.name != 'truffleruby' && matrix.ruby.name != 'jruby'
71+
if: matrix.ruby.name != 'truffleruby' && matrix.ruby.name != 'jruby' && matrix.symlink != 'off'
6172
- name: Run Test isolatedly
6273
run: bin/rake test:isolated
6374
if: matrix.ruby.name == '3.4' && matrix.os.name != 'Windows'

bin/windows_run_as_user

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require "win32/process"
2+
require "rbconfig"
3+
4+
TESTUSER = "testuser"
5+
6+
system("net user #{TESTUSER} /del 2>NUL")
7+
system("net user #{TESTUSER} \"Password123+\" /add") || raise
8+
system("icacls . /grant #{TESTUSER}:(OI)(CI)(IO)(F)")
9+
10+
stdout_read, stdout_write = IO.pipe
11+
cmd = ARGV.join(" ")
12+
env = {
13+
"TMP" => "#{Dir.pwd}/tmp",
14+
"TEMP" => "#{Dir.pwd}/tmp"
15+
}
16+
pinfo = Process.create command_line: cmd,
17+
with_logon: TESTUSER,
18+
password: "Password123+",
19+
cwd: Dir.pwd,
20+
environment: ENV.to_h.merge(env).map{|k,v| "#{k}=#{v}" },
21+
startup_info: { stdout: stdout_write, stderr: stdout_write }
22+
23+
stdout_write.close
24+
out = stdout_read.read
25+
puts out
26+
27+
# Wait for process to terminate
28+
sleep 0.1 while !(ecode=Process.get_exitcode(pinfo.process_id))
29+
30+
exit ecode

0 commit comments

Comments
 (0)