Skip to content
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

Custom shell wrapper doesn't work with powershell #78

Open
melund opened this issue Feb 15, 2024 · 14 comments · Fixed by #79
Open

Custom shell wrapper doesn't work with powershell #78

melund opened this issue Feb 15, 2024 · 14 comments · Fixed by #79

Comments

@melund
Copy link

melund commented Feb 15, 2024

When using the custom shell wrapper with powershell I get an error from github actions:

I am doing something like this on Windows runner.

- run:
    pytest 
  shell: pixi run pwsh -e test {0}

image

@ruben-arts
Copy link
Contributor

ruben-arts commented Feb 15, 2024

The pixi run command sends all info after the initial command to the task.
I think something like this could work:

- name: Run test with powershell
  run: pytest
  shell: pixi run -e test pwsh -File {0}

Note the run pwsh -e test -> run -e test pwsh

@pavelzw
Copy link
Collaborator

pavelzw commented Feb 15, 2024

This should be updated in the readme (and we should add a test for it as well)

@pavelzw
Copy link
Collaborator

pavelzw commented Feb 15, 2024

maybe also add a test for cmd.exe

@melund
Copy link
Author

melund commented Feb 17, 2024

@ruben-arts

I think something like this could work:
shell: pixi run -e test pwsh -File {0}

It doesn't seem to work.

image

It is odd, because GitHub Actions Docs does seem to indicate that is possible. Maybe they do something special if they detect the first argument is "pwsh" or "powershell".

@ruben-arts
Copy link
Contributor

Yeah I experienced the same, that's why we added this to the documentation and tests in #79

- run: |
    python --version | Select-String "3.11"
  shell: pixi run pwsh -Command {0}

You can use the environment with:

- run: pytest
  shell: pixi run -e test pwsh -Command {0}

@melund
Copy link
Author

melund commented Feb 17, 2024

Powershell can't run scripts without the right extension. So GitHub Actions does something special when they detect the first command is "pwsh". This seem to work for me though:

shell: pwsh -command "pixi run -e test pwsh '{0}'"

But now as nice to look at :(

@melund
Copy link
Author

melund commented Feb 17, 2024

Ahh. Ok. I hadn't tried your way

shell: pixi run -e test pwsh -Command {0}

I will give that a try.

@ruben-arts
Copy link
Contributor

Powershell can't run scripts without the right extension. So GitHub Actions does something special when they detect the first command is "pwsh". This seem to work for me though:

shell: pwsh -command "pixi run -e test pwsh '{0}'"

But now as nice to look at :(

Was this a reaction to my latest comment or did we comment at the same time?

@melund
Copy link
Author

melund commented Feb 17, 2024

They cross path I think :)

@melund
Copy link
Author

melund commented Feb 19, 2024

@ruben-arts, I am not sure your suggestion (pixi run -e test pwsh -Command {0}) works.

It doesn't produce any errors, but it doesn't run my code either. Or maybe it only runs the first line of run section. I have not tested that.

If I use my workaround:

shell: pwsh -command "pixi run -e test pwsh '{0}'"

Then the code actually runs.

See these screenshots from my pipeline:

With your suggestion nothing runs:

image

With: pwsh -command "pixi run -e test pwsh '{0}'" it runs:

image

@melund
Copy link
Author

melund commented Feb 21, 2024

@pavelzw did you guys see my last post? Easy to overlook in closed issue 😅 I dont mind creating a new issue if you think it is needed.

@pavelzw pavelzw reopened this Feb 21, 2024
@pavelzw
Copy link
Collaborator

pavelzw commented Feb 21, 2024

Yeah, I didn't try to reproduce this yet... Is the issue maybe that it's multiple files?

Does this work for your use case?

- run: |
python --version | Select-String "3.11"
shell: pixi run pwsh -Command {0}

@pavelzw
Copy link
Collaborator

pavelzw commented Sep 28, 2024

Does this work for your use case?

@melund did you get around to try this?

@melund
Copy link
Author

melund commented Sep 29, 2024

@pavelzw: Yes that doesn't work:

https://github.com/melund/test-pixi/actions/runs/11090308043/job/30812485079#step:5:5

Only: shell: pwsh -command "pixi run -e test pwsh '{0}'" seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants