-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Enable GitHub-Actions CI and deployment #1023
Conversation
8aa4cd3
to
c30d7d0
Compare
@sharkdp , I found some time to work on this ... The CICD file is essentially the same as the one used for I don't have a build/pkg for the '..._i386.deb' package. I'm not sure how to build it, and I don't see a target platform on the rust platform list to build toward for that package. I found two problems (and included solutions):
As the test time seemed unchanged, I left the instrumentation in the tests (future value?).
#[cfg(not(windows))]
fn build_command<'a, 'b>(prog_name: &'b str, args: &'a mut Vec<&'b str>) -> (std::borrow::Cow<'b, str>, &'a [&'b str]) {
(prog_name, &args[..])
}
#[cfg(windows)]
fn build_command<'a, 'b>(prog_name: &'b str, args: &'a mut Vec<&'b str>) -> (std::borrow::Cow<'b, str>, &'a [&'b str]) {
args.insert(0, prog_name);
args.insert(0, "/d/c");
let prog_name = std::env::var("ComSpec")
.map(std::borrow::Cow::from)
.unwrap_or_else(|_| std::borrow::Cow::from("cmd"));
(prog_name, &args[..])
} I created a simpler (maybe slightly hacky 🤷 ) solution for the pager process logic. #[cfg(windows)]
let (pager_path, args) = {
let p = std::env::var("ComSpec").unwrap_or_else(|_| "cmd".to_string());
let mut a = args.to_vec();
a.insert(0, pager_path.to_str().unwrap().to_string());
a.insert(0, "/d/c".to_string());
(p, a)
}; Of course, with this, and reverting to using Ultimately, all tests are passing and auto-deployment is working. I should be able to muck with this more later this weekend if you'd like any changes. Cheers! |
@rivy Thank you so much for working on this! I haven't looked into the details, but a short comment regarding the pager issue: Instead of always using an intermediate
|
Yes, that's a solution, but I think it's not ideal. The included solution (or a future variation) let's users of Asking just windows users to specify the pager in an unusual, somewhat arcane, way seems counter-productive to wider use of the tool and creates more "user friction". (If it's not obvious, I'm a cross-platform developer, using Windows primarily and linux of various stripes quite commonly. And I really like to have all of my tools on both platforms. And, as much as possible, I expect them to work in the same manner, minimizing platform-specific quirks.) As an example that will bite windows users... And, concretely, you'd have to special case several of your tests and the As written here, So, I've pushed a variation of this solution into |
I absolutely get your points. In principle, I'm all for getting users the best experience. Three counter arguments:
* Benchmarks via: hyperfine \
--warmup 5 \
'bat --paging=always --pager=less test.txt' \
'bat --paging=always --pager="bash -c less" test.txt' \
--export-markdown test.md |
These tests seem to be running just fine on AppVeyor: https://ci.appveyor.com/project/sharkdp/bat/builds/33205057 - any idea what is different on the GHA machines? |
True, but, reiterating the point, if I, as a user, use a paging program which operates via a BAT/CMD entry point, and it "just works" as say
Sure, I'd like to see an analysis of that as well. I do think it's generally irrelevant here as a premature optimization, because when you're using a pager, you're planning to look at the results. And the console display + actual reading of the content should far outweigh the time spent starting an extra process.
This, I agree with... but "injection bugs" really only occur with permission differentials. On windows, I don't see how the pager would ever have any different permissions than
I've not see a way to do this with the CMD shell, as of yet, although I'd like to be able to do timings such as this... Just my cross-platform centric opinion... I'm happy to help investigate and implement a "best" strategy for you. Let me know what I can do to help. ... later ... And now I've found |
Hmm, well, I'm sure that is a line ending difference. So, my suspicion is that AppVeyor and GHA have different baseline I generally use a .gitattributes file in the main directory when I'm concerned about this issue. Something like...
|
Well, ok then, I didn’t realize you wrote |
After testing a few command variations, it appears that there is about a 13.3 ms penalty (or about 12% overhead) for using the C:\>env BAT_PAGER="more.com" hyperfine --warmup 5 "bat.exe --paging=always test.txt"
Benchmark #1: bat.exe --paging=always test.txt
Time (mean ± σ): 108.6 ms ± 2.2 ms [User: 4.4 ms, System: 6.8 ms]
Range (min … max): 106.6 ms … 116.7 ms 23 runs
C:\>env BAT_PAGER="cmd.exe /c more.com" hyperfine --warmup 5 "bat.exe --paging=always test.txt"
Benchmark #1: bat.exe --paging=always test.txt
Time (mean ± σ): 121.9 ms ± 2.0 ms [User: 2.9 ms, System: 5.4 ms]
Range (min … max): 118.6 ms … 126.6 ms 21 runs I had to use the C:\> hyperfine --warmup 5 "bat.exe --paging=always --pager=more.com test.txt" "bat.exe --paging=always --pager=\"cmd.exe /c more.com\" test.txt"
Benchmark #1: bat.exe --paging=always --pager=more.com test.txt 0
Time (mean ± σ): 109.2 ms ± 2.4 ms [User: 4.2 ms, System: 9.1 ms] 0
Range (min … max): 106.5 ms … 116.0 ms 23 runs
Benchmark #2: bat.exe --paging=always --pager="cmd.exe /c more.com" test.txt
Error: Command terminated with non-zero exit code. Use the '-i'/'--ignore-failure' option if you want to ignore this. Alternatively, use the '--show-output' option to debug what went wrong. |
That's true AppVeyor has sane |
It does not, no. Only if the output goes to a TTY.
The actual reading time outweighs the 13 ms by far, sure. However, what I'm more concerned about is latency / startup speed. I really like programs that feel fast. This is why
I didn't really know that CR/LF issues could be handled via a |
Alright, I can see I'm not going to prevail here, but, for the record, you officially have one windows user reporting this as a problem (me 👋 😄) and thinks a slightly slower pager startup would not be a problem. And it likely affects the default pager path for windows users as well. I'll drop the code, but it will break testing on windows platforms.
Alternatively, I just saw another .gitattributes variant to solve the same problem...
|
Thanks for the clarification. |
…r errors - `undefined reference to `_imp____acrt_iob_func'` - ref: <rust-lang/rust#68887 (comment)> - ref: <https://users.rust-lang.org/t/linking-with-gcc-failed-exit-code-1/34124> - ref: <https://www.gitmemory.com/issue/rust-lang/rust/47048/530376978> - ref: <https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/?limit=250&page=7>
- using `echo` on 'windows' platforms requires process execution indirectly via the shell - `printf` is available on all GHA CI platforms - `printf` is *not* available on usual 'windows' platforms; so this is just temporizing, awaiting a true fix
- fixes windows test failures - avoids `git` platform-dependent conversion of line endings for checkout of test fixtures (*tests/examples/...*)
## [why] For 'windows' platforms, directly spawning a process (eg, called PATHNAME) bypasses the usual windows shell machinery for determining which process to execute. Specifically, the extensions in PATHEXT will not be used to determine the final executable. So, `PATHNAME.bat`, `PATHNAME.cmd`, ... will *not* be executed even if on they exist on the PATH; and this is counter to the usual expectation of a Windows user. Additionally, built-in commands, such as `echo` and `dir`, will never be accessible as they do not have a PATH to execute and, so, will never be found. To use the usual machinery, giving access to PATHNAME.bat and `echo`, execute the PATHNAME using the windows shell, eg `cmd /d/c PATHNAME`. Note this may expose the constructed command line to the windows shell quoting vagaries (sadly, that may be part of the price). Following Windows standards, the ComSpec environment variable is used to determine which shell to use, with a fallback to the "modern", built-in `cmd` shell.
3997cde
to
8b70bbd
Compare
Reversions added and rebased to master. |
93a43c0
to
b77c4c0
Compare
…ests) per PR feedback/owner request - reverts commit f8ed8aa
@rivy: Thank you very much! I'm going to merge this as-is and leave it running in parallel to TravisCI / AppVeyor for now. One thing that would be really valuable for
The Quite a lot of tests depend on the builtin set of syntaxes, so this special run would be very valuable in catching bugs/inconsistencies in the syntax additions early. |
Fixes #978