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

Multi-line 'run' commands #8

Closed
eine opened this issue Oct 21, 2019 · 5 comments
Closed

Multi-line 'run' commands #8

eine opened this issue Oct 21, 2019 · 5 comments

Comments

@eine
Copy link
Contributor

eine commented Oct 21, 2019

Currently, it is not possible to provide multi-line 'run' commands as arguments to msys2do:

  - run: |
      msys2do <command_a>
      <command_b>
      <command_c>

Alternatives are to prepend each row with msys2do, or to put all the commands in a helper run.sh file and run msys2do ./run.sh.

It would be interesting to investigate alternatives, such as (untested):

    - shell: msys2do "{0}"
      run: |
        <command_a>
        <command_b>
        <command_c>
@Ecco
Copy link
Contributor

Ecco commented Oct 21, 2019

Yeah, actually I think it'd be great to completely bypass the msys2do command and make use of a proper shell.

Now that I think about this, shouldn't setup-msys2 simply overwrite the default shell?

I think when a user adds a - uses: numworks/setup-msys2@v1 step, they will most likely want to issue msys2 commands afterwards. So I think it would make sense for setup-msys2 to set the default shell to msys2's bash (like msys2do currently does). This way people could simply write things such as:

  steps:
     - uses: numworks/setup-msys2@v1
     - uses: actions/checkout@v1
     - run: pacman -S --noconfirm whatever
     - run: make my_target

@eine
Copy link
Contributor Author

eine commented Oct 22, 2019

I think that you mean the same I wrote in the example above (shell: msys2do "{0}"), which is based on https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#custom-shell. AFAIU, there is no mechanism to set the default shell for subsequent steps. What we can do is optionally use shell field only.

So I think it would make sense for setup-msys2 to set the default shell to msys2's bash (like msys2do currently does).

The default shell in windows is cmd. To use any other, shell field needs to be set. Therefore, there is no real advantage between:

    - shell: bash
      run: |
        msys2do <command_a>
        <command_b>

or

    - shell: bash --noprofile --norc -eo pipefail "msys2do {0}"
      run: |
        <command_a>
        <command_b>

and the example above.

As a matter of fact, before using this extension, I was installing MSYS2 through chocolatey and then using: shell: C:\tools\msys64\usr\bin\bash -lc "source /usr/bin/shell MINGW64; ./dist/msys2-mingw/run.sh -t". Hence, I have replaced a custom shell field with msys2do to reduce verbosity. I think that any enhancement should not involve going back to that syntax.

On the one hand, I think that we can add --noprofile --norc -eo pipefail to the bash call in msys2do, because that's recommended: https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference

On the other hand, shell: msys2do {0} should already work. I opened this issue mostly as a remainder that this needs to be tested.

Of course, if I am misunderstanding anything and it is already possible to set a default for shell, we should go for it. If this is the case, we should bypass msys2do, as you suggest.

@danyeaw
Copy link

danyeaw commented Nov 26, 2019

Here is an example of my use case of wanting to closely integrate CI builds in MSYS2:

    runs-on: windows-latest
    env:
      MSYS2_ARCH: x86_64
    steps:
      - uses: actions/checkout@v1
      - uses: numworks/setup-msys2@v1
        with:
          update: true
      - name: Install MSYS2 Dependencies
        run: >
          pacman --noconfirm -S --needed mingw-w64-x86_64-gcc
          mingw-w64-x86_64-gtk3 mingw-w64-x86_64-pkg-config
          mingw-w64-x86_64-cairo mingw-w64-x86_64-gobject-introspection
          mingw-w64-x86_64-python3 mingw-w64-x86_64-python3-gobject
          mingw-w64-x86_64-python3-cairo mingw-w64-x86_64-python3-pip
      - uses: dschep/install-poetry-action@v1.2
      - run: poetry install
      - run: poetry run pytest

Most of the examples of the action being used that I could find were running a bash script using msys2do. The example I gave above mirrors how I would test a Python app in Linux, and it would be really nice to make it this straightforward in MSYS2.

Do others have this use case as well and would you be interested in supporting this with your action? Is it possible for us to setup the PATH and shell so that we can just directly run commands?

@eine
Copy link
Contributor Author

eine commented Nov 27, 2019

@danyeaw, see #21.

@eine
Copy link
Contributor Author

eine commented May 28, 2020

I'm closing this because #21 (which is part of eine/setup-msys2) has been tested for some months and it works as expected.

@eine eine closed this as completed May 28, 2020
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