mvdan / github-actions-golang

GitHub Actions as CI for Go
BSD 3-Clause "New" or "Revised" License
1.04k stars 74 forks source link

Warn about Pwsh quoting of Go commands arguments on Windows #24

Open dolmen opened 2 years ago

dolmen commented 2 years ago

I had the bad experience that this doesn't work on Windows:

      - name: Run coverage
        run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...

Output:

no required module provides package .out; to add it:
    go get .out
Error: Process completed with exit code 1.

But this works:

      - name: Run coverage
        run: go test -v -race -coverprofile coverage.out -covermode atomic ./...

The only difference is that = is replaced with space.

I suspect this is a PowerShell quoting issue.

mvdan commented 2 years ago

That is... interesting. When we add the warning, it would be good to also link to some docs explaining how the Powershell syntax conflicts with very simple POSIX shell without expansions or quoting.

dolmen commented 2 years ago

So far I found no document to confirm my hypothesis.

I only have experimental results:

dolmen commented 2 years ago

Those two pages from the PowerShell documentation don't mention something special about - args.

(the second one tells about --% that allows to block processing of the rest of the command line, but I don' see how it could be used to have portable commands shared between Unix and Windows).

dolmen commented 2 years ago

Nothing mentioned about = in the About parameters page either.

dolmen commented 2 years ago

In fact the default shell on Windows is Pwsh (Powershell Core).

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

dolmen commented 2 years ago

--% works (on Windows):

      - name: Run coverage
        run: go --% test -v -race -coverprofile=coverage.out -covermode=atomic ./...