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

make the shell configurable (default to bash) #8

Merged
merged 2 commits into from
Nov 12, 2021

Conversation

marten-seemann
Copy link
Contributor

@marten-seemann
Copy link
Contributor Author

This PR doesn't work. It looks like we can't specify the shell here using variables. It seems like only strings are allowed (although this isn't properly documented).
Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.shell

action.yml Outdated

runs:
using: "composite"
steps:
- shell: bash
- shell: ${{ inputs.shell }}
Copy link

@aschmahmann aschmahmann Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a composite action restriction actions/runner#835. There's a hack/workaround in the issue we might be able to leverage (e.g. creating a file or symlink on the OS which proxies to our shell)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's annoying. multiple-go-modules was supposed to be a fairly independent action, I'd hate to couple it that tightly to the rest of our shell logic.

Copy link
Contributor Author

@marten-seemann marten-seemann Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that alternatively, we could duplicate the step here and add an if: ${{ inputs.shell == 'bash' }} to if: ${{ inputs.shell == 'msys2' }} to each step, respectively, but that doesn't work either. Apparently, you can't use if in an Action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking about this for a bit, maybe the hack that issue is not that terrible.
I modified the PR, and we're now checking not for the OS, but for ${{ inputs.shell }}. That makes this action (at least a little bit) more general purpose.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make it more general purpose if we need to by making a bash script that forwards the command along. Essentially making the yaml point at custom-shell {0} and making a script called custom-shell that just takes its arguments and forwards them to whatever the shell name in inputs.shell is.

@marten-seemann
Copy link
Contributor Author

marten-seemann commented Nov 12, 2021

I simplified the setup a bit by using ifs (which GitHub now finally allows).
The alternative to this would be to just duplicate the step:

    - shell: bash
      if: inputs.shell == 'bash'
      working-directory: ${{ inputs.working-directory }}
      run: |
        <code>

once for bash and once for msys2 {0} (unfortunately, GH Actions doesn't support YAML anchors, so we can't use that to avoid the duplication). Not sure which one is less ugly.

@mvdan @aschmahmann Can you take another look?

Copy link

@mvdan mvdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a minute to understand what the symlink code is doing, but I agree with the approach :)

What's with the {0} by the way? Ideally we'd strip that, especially given the weird characters and the space.

@marten-seemann
Copy link
Contributor Author

What's with the {0} by the way? Ideally we'd strip that, especially given the weird characters and the space.

That would be nice, but I think I tried this at some point, and it didn't work. Also, it seems to be the standard way of doing this, see for example https://github.com/msys2/setup-msys2 or https://ariya.io/2020/07/on-github-actions-with-msys2.

@marten-seemann marten-seemann merged commit 9d28aab into master Nov 12, 2021
@marten-seemann marten-seemann deleted the configure-shell branch November 12, 2021 09:41
galargh added a commit that referenced this pull request Dec 2, 2021
This reverts commit 9d28aab, reversing
changes made to a932405.
galargh added a commit that referenced this pull request Mar 15, 2022
Revert "Merge pull request #8 from protocol/configure-shell"
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 this pull request may close these issues.

3 participants