-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
ENV setup, Windows tar, Windows bash shell #64
Conversation
Re CI:
I need to look into this more. Since the stdout syntax is published, I may look at using a stdout.write to combine several Path and/or env variable statements. I believe the core methods both modify ENV variables in the node environment and write to stdout for the C# runner to process the command... |
Updated to write 'core commands' directly to the runner. This fixes the step env display, and also eliminates rare intermittent failures. |
Could you rather fix it upstream in https://github.com/actions/toolkit? |
I believe it's an official API, see All that actions/core does is combine the above with doing the same in the current node process. |
Yes I know, but wouldn't it be good to fix it (i.e., make it a synchronous write) for all actions, not just this one? |
In theory, it is a sync write on Windows ( At present, we're using very few ENV calls for Ubuntu or macOS, but that could change.
actions/core is a 'helper' action. It may have not been tested against all possible uses. The API is the pipe text description, actions/core is a wrapper around that. JFYI, js |
Added a class to common.js that handles ENV operations. Replaces all calls to |
common.js
Outdated
this.ENV = process.env | ||
} | ||
|
||
addVari(k,v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to keep this action source code, so no abbreviations please.
Can you file a bug to that repo then? And do you have a log of a case(s) that failed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to duplicate code from https://github.com/actions/toolkit/tree/master/packages/core
We should try to figure out exactly what goes wrong, or fix it upstream, or at least file an issue to ask them to investigate.
What do you mean? It seems to work fine for me (except being a long list). |
Yes, I think that would be useful, and avoid so much commands in test.yml. |
If one is using one tab and trying to look at Windows logs, one is constantly scrolling the window. PITA. Bad UI, the primary pane (the job list) should srroll independently of the secondary, dependent pane, the log.
I think some should still be ran, but they can run within the script. It's helpful to check if the Windows Rubies have working bash scripts for all the bin files?
I'm working on it. The issue may just be the handling of 'Path', so I'm thinking the common.cmd class maybe should handle core.addPath, along with |
I got it working using nothing but the core functions. PITA. Most of it seems to be due to removing items from One odd thing is that the Anyway, all Windows Rubies are running in a bash shell, using their respective devkits. If PR #65 is okay, I'll revise this after that's merged? |
#65 is merged now, I am sorry about the delay. Regarding removing the system ruby from PATH I'm not sure if it's very important. Maybe we could drop that and only use addPath()? Indeed, the output the show seems like some kind of bug in actions, I think it would be worth reporting to them. The Ruby we setup should anyway have all executables the system ruby has + some extra, no? And on many development systems it's common to have a system ruby + RVM/rbenv/chruby and they don't remove anything from PATH, so it seems not so much an issue, and something Rubyists already have to deal with. |
No problem, as it only affects the 'automatic' bundle iinstall. I mentioned revising this, and it's been a couple of weeks. I can't recall. I believe it was stable with the removal. |
It would also fix using the correct Bash on Windows, right (MSYS2' and not Git' Bash)? |
Well, it's mostly finished, see https://github.com/MSP-Greg/ruby-setup-ruby/runs/837069369. I currently have some Bash/PowerShell code contained in it for CI. Since that code is really about the Windows Ruby builds, there isn't a need in the CI here, at least not on an 'every commit' basis. The bash rake binstub in 2.3 has a bad shebang line, and there maybe something missing in the ruby-head build (bundler?). The issue is that the Windows Ruby's bin folders need files for both cmd/bat usage, and bash usage, and the bash files haven't been used by a lot of people... Re Path issues, I changed the code back to a single |
https://github.com/MSP-Greg/ruby-setup-ruby/runs/837069345 seems to run in the Git Bash shell (and not the MSYS2 shell). Or is that just a UI bug? |
I hate this. Apologies, you're correct, it is the Git shell. You will note that the log is showing PATH as is set in the code, but it's using the wrong shell. Conversely, in the older code, the Path was shown incorrectly, but the MSYS2 bash shell was used. I may try to work the casing of Path. The link above shows 'PATH', but as shown at https://github.com/MSP-Greg/ruby-setup-ruby/runs/777119210?check_suite_focus=true#step:4:7, the Path is incorrect, but it is shown as 'Path', and the MSYS2 is used. So the issue is either the casing, in which case we may be able to get the path shown correctly and the right shell, or the issue is that the C# runner only recognizes path changes via Sorry for mixing things, but Ruby ABI is a contract/promise. What we're doing here seems to be a grey area where the Actions API doesn't really promise anything. Let me see if the casing has any affect... |
The only way I could get it working causes the logged path to be incorrect. See: One change is that the MSYS2 paths are added to every Windows build, allowing JRuby CI to run with Bash. For older RI/MSYS builds (2.2 & 2.3), the MSYS paths are added before the MSYS2 paths. I need to dice & chop it into more commits... |
Sounds good. Would using only Probably we should report a bug to https://github.com/actions/runner that |
Actually, I think I mixed things up. I haven't looked at the code for a bit, I did change a few things, mostly to collect all the PATH manipulation into one function, so if the API is changed/updated, it's all in one place. See actions/runner#576, I just added a comment about adding a function like |
envPreInstall - sets ENV values for runners common.setupPath - collects all Path operations into one function, runs before Ruby install Add MSYS2 paths to all Windows builds for MSYS2 Bash use
Updated. All Windows Rubies now have MSYS2 added to path, so the JRuby issue is fixed, and the MSYS2 bash shell is the Windows default. |
Just to make it clear: this PR will change PowerShell to Bash for any workflow that uses |
Sorry I wasn't a bit more clear. The default shell in Windows should remain as PowerShell, as changing that would break a lot of CI scripts/workflows. If you run an Action step in a bash shell by changing the default or with the The Git bash shell is an MSYS2 bash shell, but may have a few less commands than the MSYS2 shell currently installed in the Actions Windows runners. The Git shell is probably missing some of the more dev oriented commands. See: vs the current behavior: EDIT: Re the above links, Actions logs are flushed, unlike Travis and AppVeyor. So, six months from now, they won't be available. The new behavior shows the following in the hidden portion of a Windows bash step:
The old behavior shows:
Note: MSYS2 provides git packages, but they are not installed on Actions. Hence, regardless of which shell is used, |
Understood, thanks. |
Since this PR changes the bash shell, and Bundler's Windows CI is ran from a bash shell, I ran its CI using this PR. All CI passed. See: |
This looks great, I'll try to review soon. |
@@ -26,7 +28,7 @@ export async function run() { | |||
export async function setupRuby(options = {}) { | |||
const inputs = { ...options } | |||
for (const key in inputDefaults) { | |||
if (!inputs.hasOwnProperty(key)) { | |||
if (!Object.prototype.hasOwnProperty.call(inputs, key)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? What does it do differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an ESLint thing. I still use it locally to (hopefully) catch typo's etc. I need a new keyboard, as my old one required a lot less travel.
} else { | ||
newPath = newPathEntries | ||
} | ||
core.addPath(newPath.join(path.delimiter)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A loop over paths with a core.addPath()
seems nicer (but would need to be done in reverse order).
Since this work though it seems fine.
[path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')] : | ||
[path.join(rubyPrefix, 'bin')] | ||
|
||
common.setupPath(newPathEntries) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems done rather early, even before the rubyPrefix
exists. I guess we can move it at the end of this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah but for Windows it's useful to add MSYS2 in Path for extraction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems done rather early
I can't recall the timeline of this. It involves the afterSetupPathHook
, and the issue of installing packages before bundle install
. I don't think I've modified setup-ruby-pkgs
for that, but I'm not sure. I'm looking at it shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it there, it seems useful notably to get tar
from MSYS2 on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JFYI, as I recall, that was needed only because the Win2016 image didn't have a native tar, which Win2019 did. For instance, locally (Windows 10), I have a native Windows tar
if (k === 'Path') { | ||
newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter) | ||
if (/^Path$/i.test(k)) { | ||
const newPathStr = v.replace(`$(path.delimiter)${process.env['Path']}`, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(path.delimiter)
=> ${path.delimiter}
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked, that Path was doubled with that, before:
https://github.com/ruby/setup-ruby/runs/1066490911?check_suite_focus=true
(e.g., mysql
is twice in Path)
after:
https://github.com/ruby/setup-ruby/pull/83/checks?check_run_id=1066493565
@MSP-Greg Great work, thanks! I'll make a PR with small cleanups. |
Three Commits:
A. ENV setup, Windows tar, Windows bash shell
B. Add envPreInstall, common.setupPath, use MSYS2 bash for Windows bash
index.js - envPreInstall - sets ENV values for runners
common.js - setupPath - collects all Path operations into one function, runs before Ruby install
Add MSYS2 paths to all Windows builds for MSYS2 Bash use
C. Add Actions 'bash test' and 'Windows JRuby' (gem install sassc) steps
Closes #81