@@ -123,48 +123,113 @@ end
123
123
install_via_homebrew(reporter_info; force=false)
124
124
125
125
Install Coveralls reporter via Homebrew (macOS).
126
+ First installs a local Homebrew if needed, then installs coveralls locally.
126
127
"""
127
128
function install_via_homebrew (reporter_info; force= false )
128
- # Check if Homebrew is available
129
- brew_path = Sys. which (" brew" )
130
- if brew_path === nothing
131
- error (" Homebrew is not installed. Please install Homebrew first: https://brew.sh" )
129
+ # Set up local Homebrew installation directory using scratch space
130
+ local_homebrew_dir = @get_scratch! (" local_homebrew" )
131
+ local_brew_path = joinpath (local_homebrew_dir, " bin" , " brew" )
132
+
133
+ # Use the local Homebrew installation
134
+ brew_cmd = local_brew_path
135
+
136
+ # Check if local Homebrew is available, install if not
137
+ if ! isfile (local_brew_path)
138
+ @info " Installing local Homebrew to: $local_homebrew_dir "
139
+ try
140
+ # Create the directory
141
+ mkpath (local_homebrew_dir)
142
+
143
+ # Download and extract Homebrew tarball directly
144
+ @info " Downloading latest Homebrew release..."
145
+
146
+ # Get the latest release info
147
+ latest_release_url = " https://api.github.com/repos/Homebrew/brew/releases/latest"
148
+ response = HTTP. get (latest_release_url)
149
+ release_data = JSON. parse (String (response. body))
150
+ latest_tag = release_data[" tag_name" ]
151
+ tarball_url = release_data[" tarball_url" ]
152
+
153
+ @info " Found latest Homebrew release: $latest_tag "
154
+ tarball_path = joinpath (local_homebrew_dir, " homebrew-$latest_tag .tar.gz" )
155
+
156
+ # Download the tarball
157
+ Downloads. download (tarball_url, tarball_path)
158
+
159
+ # Extract the tarball to our directory
160
+ @info " Extracting Homebrew..."
161
+ run (` tar -xzf $tarball_path -C $local_homebrew_dir --strip-components=1` ; wait= true )
162
+
163
+ # Remove the tarball
164
+ rm (tarball_path)
165
+
166
+ # Verify the brew executable exists
167
+ if ! isfile (local_brew_path)
168
+ error (" Homebrew extraction failed - brew executable not found at: $local_brew_path " )
169
+ end
170
+
171
+ # Post-install setup
172
+ @info " Running Homebrew post-install setup..."
173
+ run (` $brew_cmd update --force --quiet` ; wait= true )
174
+
175
+ # Fix zsh permissions
176
+ brew_prefix = chomp (read (` $brew_cmd --prefix` , String))
177
+ zsh_share_dir = joinpath (brew_prefix, " share" , " zsh" )
178
+ if isdir (zsh_share_dir)
179
+ run (` chmod -R go-w $zsh_share_dir ` ; wait= true )
180
+ end
181
+
182
+ @info " Local Homebrew installed successfully"
183
+ catch e
184
+ error (" Failed to install local Homebrew: $e " )
185
+ end
186
+ else
187
+ @info " Local Homebrew found at: $local_brew_path "
132
188
end
133
189
134
- # Check if coveralls is already installed
190
+ # Check if coveralls is already installed locally
135
191
if ! force
136
- coveralls_path = Sys. which (" coveralls" )
137
- if coveralls_path != = nothing && isfile (coveralls_path)
138
- @info " Coveralls reporter already installed via Homebrew at: $coveralls_path "
139
- return coveralls_path
192
+ # Check for coveralls in the local Homebrew bin directory
193
+ local_coveralls_path = joinpath (local_homebrew_dir, " bin" , " coveralls" )
194
+ if isfile (local_coveralls_path)
195
+ @info " Coveralls reporter already installed via local Homebrew at: $local_coveralls_path "
196
+ return local_coveralls_path
140
197
end
141
198
end
142
199
143
- @info " Installing Coveralls reporter via Homebrew..."
200
+ @info " Installing Coveralls reporter via local Homebrew..."
144
201
145
202
try
146
- # Add the tap if it doesn't exist
203
+ # Add the tap if it doesn't exist (ignore failures)
147
204
@info " Adding Homebrew tap: $(reporter_info. tap) "
148
- run (` brew tap $(reporter_info. tap) ` ; wait= true )
205
+ try
206
+ run (` $brew_cmd tap $(reporter_info. tap) ` ; wait= true )
207
+ catch e
208
+ @debug " Tap command failed (possibly already exists): $e "
209
+ end
149
210
150
- # Install coveralls
211
+ # Install coveralls (ignore exit status)
151
212
@info " Installing Coveralls reporter..."
152
- if force
153
- run (` brew reinstall $(reporter_info. package) ` ; wait= true )
154
- else
155
- run (` brew install $(reporter_info. package) ` ; wait= true )
213
+ try
214
+ if force
215
+ run (` $brew_cmd reinstall $(reporter_info. package) ` ; wait= true )
216
+ else
217
+ run (` $brew_cmd install $(reporter_info. package) ` ; wait= true )
218
+ end
219
+ catch e
220
+ @debug " Install command failed (possibly already installed): $e "
156
221
end
157
222
158
- # Get the installed path
159
- coveralls_path = Sys . which ( " coveralls" )
160
- if coveralls_path === nothing
161
- error (" Coveralls installation failed - command not found in PATH " )
223
+ # Check if the binary exists regardless of install command status
224
+ local_coveralls_path = joinpath (local_homebrew_dir, " bin " , " coveralls" )
225
+ if ! isfile (local_coveralls_path)
226
+ error (" Coveralls installation failed - not found at expected path: $local_coveralls_path " )
162
227
end
163
- @info " Coveralls reporter installed at: $coveralls_path "
164
- return coveralls_path
228
+ @info " Coveralls reporter installed locally at: $local_coveralls_path "
229
+ return local_coveralls_path
165
230
166
231
catch e
167
- error (" Failed to install Coveralls reporter via Homebrew: $e " )
232
+ error (" Failed to install Coveralls reporter via local Homebrew: $e " )
168
233
end
169
234
end
170
235
@@ -176,7 +241,8 @@ Install Coveralls reporter via direct download (Linux/Windows).
176
241
function install_via_download (reporter_info, platform; force= false , install_dir= nothing )
177
242
# Determine installation directory
178
243
if install_dir === nothing
179
- install_dir = mktempdir (; prefix= " coveralls_reporter_" , cleanup= false )
244
+ # Use scratch space for persistent storage across sessions
245
+ install_dir = @get_scratch! (" coveralls_reporter" )
180
246
else
181
247
mkpath (install_dir)
182
248
end
0 commit comments