Open bartekpacia opened 1 year ago
Apparently the difference in behavior is caused by the shell used. bash
is used on GitHub Action
My project is named
Quiz
bash-5.2$ dotnet tool run xstyler --recursive --file Quiz/**/*.xaml
Processing: Quiz/**/*.xaml
Unhandled exception. System.IO.DirectoryNotFoundException: Could not find a part of the path '/Users/bartek/dev/bartekpacia/Quiz/Quiz/**/*.xaml'.
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at Xavalon.XamlStyler.Console.XamlStylerConsole.TryProcessFile(String file) in /home/vsts/work/1/s/src/XamlStyler.Console/XamlStylerConsole.cs:line 239
at Xavalon.XamlStyler.Console.XamlStylerConsole.Process(ProcessType processType) in /home/vsts/work/1/s/src/XamlStyler.Console/XamlStylerConsole.cs:line 194
at Xavalon.XamlStyler.Console.Program.<>c.<Main>b__0_2(CommandLineOptions options) in /home/vsts/work/1/s/src/XamlStyler.Console/Program.cs:line 37
at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
at Xavalon.XamlStyler.Console.Program.Main(String[] args) in /home/vsts/work/1/s/src/XamlStyler.Console/Program.cs:line 17
bash-5.2$
Yet it works when I don't specify Quiz
explicitly:
bash-5.2$ dotnet tool run xstyler --recursive --file **/*.xaml
Processing: Quiz/App.xaml
Processing: Quiz/AppShell.xaml
Processing: Quiz/CreatePage.xaml
Processing: Quiz/MainPage.xaml
Processing: Quiz/PlayPage.xaml
Processed 5 of 5 files.
But it only processed 5 files (not what I want), whereas zsh
processed 8 (which is what I want):
zsh-5.9$ dotnet tool run xstyler --recursive --file **/*.xaml
Processing: Quiz/App.xaml
Processing: Quiz/AppShell.xaml
Processing: Quiz/CreatePage.xaml
Processing: Quiz/MainPage.xaml
Processing: Quiz/Platforms/Windows/App.xaml
Processing: Quiz/PlayPage.xaml
Processing: Quiz/Resources/Styles/Colors.xaml
Processing: Quiz/Resources/Styles/Styles.xaml
Processed 8 of 8 files.
Edit
Looks like bash
doesn't perform recursive wildcard expansion by default (SO link).
bash-5.2$ shopt -s globstar
bash-5.2$ dotnet tool run xstyler --recursive --file Quiz/**/*.xaml
Processing: Quiz/App.xaml
Processing: Quiz/AppShell.xaml
Processing: Quiz/CreatePage.xaml
Processing: Quiz/MainPage.xaml
Processing: Quiz/Platforms/Windows/App.xaml
Processing: Quiz/PlayPage.xaml
Processing: Quiz/Resources/Styles/Colors.xaml
Processing: Quiz/Resources/Styles/Styles.xaml
Processed 8 of 8 files.
Works fine after enabling it :) Bear in mind that the globstar
shell option is supported since Bash v4. The default Bash on macOS is v3.2, and it doesn't have globstar
. To install a non-ancient Bash, you can do brew install bash
.
So, for the future wanderers, if you want to use XamlStyler.Console
in your GitHub Actions, you can do the following:
- name: Install non-ancient Bash
run: brew install bash
- name: Verify XAML code formatting
shell: bash
run: |
shopt -s globstar
dotnet tool run xstyler --recursive --file Quiz/**/*.xaml --passive
There's probably a way to do a recursive glob in PowerShell v7 but I didn't bother finding it.
I'll reopen in case someone finds for PowerShell v7 :)
Describe the bug
I can't run XamlStyler on GitHub Actions.
To Reproduce
Steps to reproduce the behavior:
$ dotnet tool install XamlStyler.Console
Run on GitHub Actions (
macos-latest
runner) with the following step:Observe the failure:
At first I was running on
windows-latest
and thought the bug was because PowerShell 7 (the default shell onwindows-latest
runner) doesn't have globs likebash
-like shells do. That's why I switched tomacos-latest
. Unfortunately the error persists.What's strange is that the same exact command work just fine on my MacBook Air M1 (macOS 13 Ventura).
Screenshots
Expected behavior
I expect the tool to work on GitHub Actions'
macos-latest
runner.External Configuration
Version Info (please complete the following information):
macos-latest
GitHub Action runner (which is macOS 12 Monterey currently)Additional context
Example GitHub Action run that failed.